about summary refs log tree commit diff
path: root/test/pamstack.test
blob: 6374c4bd1bda676ea7894f8a4e80b90b6172ed99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#! /bin/sh
# This script tests: pamstack
# Also requires: pamdepth pgmmake pamfile

tmpdir=${tmpdir:-/tmp}
i1_pgm=${tmpdir}/testimg_1.pnm
i2_pgm=${tmpdir}/testimg_2.pgm
i7_pgm=${tmpdir}/testimg_7.pgm
i31_pgm=${tmpdir}/testimg_31.pgm
std_pgm=${tmpdir}/testimg_255.pgm
max_pgm=${tmpdir}/testimg_max.pgm

maze2_pbm=${tmpdir}/testimg_maze2.pgm
maze3_pbm=${tmpdir}/testimg_maze3.pgm

pamdepth 1 testgrid.pbm > ${i1_pgm}
pgmmake -maxval=2 0 14 16 > ${i2_pgm}
pgmmake -maxval=7 0.5 14 16 > ${i7_pgm}
pgmmake -maxval=31 0.5 14 16 > ${i31_pgm}
pgmmake -maxval=255 0.5 14 16 > ${std_pgm}
pgmmake -maxval=65535 0.5 14 16 > ${max_pgm}
cat maze.pbm maze.pbm > ${maze2_pbm}
cat maze.pbm maze.pbm maze.pbm > ${maze3_pbm}

# test 0
echo test 0: Should print 1652911383 4046

# Test the integrity of the input files
cat ${i1_pgm} ${i2_pgm} ${i7_pgm} ${i31_pgm} ${std_pgm} ${max_pgm} \
    ${maze2_pbm} ${maze3_pbm}| cksum

# test 1
echo test 1: Should print 1398841785 13544 three times
pamstack ${maze2_pbm} ${maze2_pbm} | cksum
pamstack ${maze3_pbm} ${maze2_pbm} | cksum
pamstack ${maze2_pbm} ${maze3_pbm} | cksum

rm ${maze2_pbm} ${maze3_pbm}

# test 2
echo test 2: Should print 210239904 3186 five times
pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
                      ${i7_pgm} ${i2_pgm} ${i1_pgm} ${i1_pgm} | cksum
pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
	              ${i7_pgm} ${i2_pgm} ${i1_pgm} testgrid.pbm | cksum

pamstack -lcmmaxval   ${max_pgm} ${std_pgm} ${i31_pgm} \
	              ${i7_pgm} ${i2_pgm} ${i1_pgm} ${i1_pgm} | cksum
pamstack ${i1_pgm} ${i1_pgm} |\
  pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} ${i2_pgm} - | cksum
pamstack -firstmaxval ${i2_pgm} testgrid.pbm ${i1_pgm} |\
  pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} - | cksum


# test 3
echo test 3: maxval should be 65535
pamstack -firstmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
	              ${i7_pgm} ${i2_pgm} ${i1_pgm} | pamfile

pamstack -lcmmaxval ${max_pgm} ${std_pgm} ${i31_pgm} \
	            ${i7_pgm} ${i2_pgm} ${i1_pgm} | pamfile

pamstack -lcmmaxval ${max_pgm} ${std_pgm} ${i31_pgm} ${i7_pgm} ${i1_pgm} | pamfile

pamstack -firstmaxval ${max_pgm} ${i2_pgm} | pamfile


# test 4
echo test 4: maxval should be 255 then 767
pamstack -firstmaxval ${std_pgm} ${i2_pgm} | pamfile
pamstack -lcmmaxval ${std_pgm} ${i2_pgm} | pamfile

# test 5
echo test 5: Should print 2741208386 719 twice

pamstack -lcmmaxval   ${i31_pgm} ${i1_pgm} ${i7_pgm} | cksum
pamstack -firstmaxval ${i31_pgm} ${i1_pgm} ${i7_pgm}  | cksum

# test 6
echo test 6: Should print true four times

s0=$(pamstack ${i1_pgm} | pamfile)
s1=$(pamstack -lcmmaxval ${i1_pgm} | pamfile)
s2=$(pamstack -firstmaxval ${i1_pgm} | pamfile)

test "$s0" = "$s1" && echo "true" || echo "false"
test "$s0" = "$s2" && echo "true" || echo "false"


s0=$(pamstack ${std_pgm} | pamfile)
s1=$(pamstack -lcmmaxval ${std_pgm} | pamfile)
s2=$(pamstack -firstmaxval ${std_pgm} | pamfile)

test "$s0" = "$s1" && echo "true" || echo "false"
test "$s0" = "$s2" && echo "true" || echo "false"


# Test Invalid
echo "Test Invalid"

. ${srcdir}/test-invalid.inc

invCmd "pamstack testgrid.pbm testimg.ppm"
invCmd "pamstack ${i1_pgm} ${std_pgm}"
invCmd "pamstack -lcmmaxval -firstmaxval testgrid.pbm testgrid.pbm"

rm ${i1_pgm} ${i2_pgm} ${i7_pgm} ${i31_pgm} ${std_pgm} ${max_pgm}