Skip to content

Commit 7fb2568

Browse files
author
giraffedata
committed
avoid false negatives in tests where input generation fails; add tests for -os2, -windows, -mapfile to BMP roundtrip test
git-svn-id: https://svn.code.sf.net/p/netpbm/code/trunk@3441 9d0c8265-081b-0410-96cb-a4ca84ce46f8
1 parent 39931e2 commit 7fb2568

23 files changed

+180
-84
lines changed

test/Test-Order

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ atari-roundtrip.test
119119
atk-roundtrip.test
120120
avs-roundtrip.test
121121
bmp-roundtrip.test
122+
bmp-quant-roundtrip.test
122123
cis-roundtrip.test
123124
cmuw-roundtrip.test
124125
facesaver-roundtrip.test

test/bmp-quant-roundtrip.ok

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
colors=256, bpp=8
2+
0 0 0 : 0
3+
0 0 0 : 0
4+
colors=16, bpp=4
5+
0 0 0 : 0
6+
0 0 0 : 0

test/bmp-quant-roundtrip.test

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#! /bin/bash
2+
# This script tests: bmptopnm ppmtobmp pnmquant
3+
# Also requires: ppmhist
4+
5+
tmpdir=${tmpdir:-/tmp}
6+
quant_ppm=${tmpdir}/quant.ppm
7+
8+
colors=256 # any value between 2 - 256 works
9+
bpp=8
10+
echo colors=${colors}, bpp=${bpp}
11+
12+
pnmquant ${colors} testimg.ppm > ${quant_ppm}
13+
14+
for mode in "-windows" "-os2"
15+
do
16+
ppmtobmp $mode -bpp=${bpp} ${quant_ppm} | bmptopnm | \
17+
cmp -s - ${quant_ppm} > /dev/null
18+
echo ${PIPESTATUS[@]} ":" $?
19+
done
20+
21+
rm ${quant_ppm}
22+
23+
colors=16 # any value between 2 - 16 works
24+
bpp=4
25+
echo colors=${colors}, bpp=${bpp}
26+
27+
pnmquant ${colors} testimg.ppm > ${quant_ppm}
28+
29+
for mode in "-windows" "-os2"
30+
do
31+
ppmtobmp -bpp=${bpp} ${quant_ppm} | bmptopnm | \
32+
cmp -s - ${quant_ppm} > /dev/null
33+
echo ${PIPESTATUS[@]} ":" $?
34+
done
35+
36+
rm ${quant_ppm}

test/bmp-roundtrip.ok

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
1-
1926073387 101484
1+
PBM
2+
2425386270 41
3+
2425386270 41
4+
2425386270 41
25
2425386270 41
6+
PPM
7+
1926073387 101484
8+
1926073387 101484
9+
1926073387 101484
10+
1926073387 101484
11+
PGM
12+
1571496937 33838
13+
1571496937 33838
14+
1571496937 33838
15+
1571496937 33838
16+
1571496937 33838
17+
1571496937 33838
18+
1571496937 33838
19+
1571496937 33838
20+
1571496937 33838

test/bmp-roundtrip.test

+38-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,42 @@
11
#! /bin/bash
22
# This script tests: bmptopnm ppmtobmp
3-
# Also requires:
3+
# Also requires: pamchannel pamtopnm pamseq
44

5+
tmpdir=${tmpdir:-/tmp}
56

6-
ppmtobmp testimg.ppm | bmptopnm | cksum
7-
ppmtobmp testgrid.pbm | bmptopnm | cksum
7+
# Test 1. Should print 2425386270 41 four times
8+
9+
echo PBM
10+
11+
for mode in "" "-bpp=1" "-windows" "-os2"
12+
do
13+
ppmtobmp ${mode} testgrid.pbm | bmptopnm | cksum
14+
done
15+
16+
# Test 2. Should print 1926073387 101484 four times
17+
18+
echo PPM
19+
20+
for mode in "" "-bpp=24" "-windows" "-os2"
21+
do
22+
ppmtobmp ${mode} testimg.ppm | bmptopnm | cksum
23+
done
24+
25+
# Test 3. Should print 1571496937 33838 nine times
26+
27+
echo PGM
28+
29+
red_pgm=${tmpdir}/red.pgm
30+
mapfile_pgm=${tmpdir}/mapfile.pgm
31+
pamseq -tupletype="GRAYSCALE" 1 255 > ${mapfile_pgm}
32+
33+
pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | \
34+
pamtopnm | tee ${red_pgm} | cksum
35+
36+
for mode in "" "-bpp=8" "-windows" "-os2"
37+
do
38+
ppmtobmp ${mode} ${red_pgm} | bmptopnm | cksum
39+
ppmtobmp ${mode} -mapfile=${mapfile_pgm} ${red_pgm} | bmptopnm | cksum
40+
done
41+
42+
rm ${mapfile_pgm} ${red_pgm}

test/g3-roundtrip.ok

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
0
2-
0
3-
0
4-
0
5-
0
6-
0
7-
0
8-
0
9-
0
10-
0
1+
0 0 0 : 0
2+
0 0 0 : 0
3+
0 0 0 0 : 0
4+
0 0 0 : 0
5+
0 0 0 : 0
6+
0 0 0 0 : 0
7+
0 0 0 0 : 0
8+
0 0 0 : 0
9+
0 0 0 : 0
10+
0 0 0 : 0
1111
1777627284 265
1212
2985378006 3135
1313
3651878552 3135

test/g3-roundtrip.test

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ wideb_pbm=${tmpdir}/wideb.pbm
99

1010
pbmtog3 -nofixedwidth testgrid.pbm | \
1111
g3topbm -width=14 | cmp -s - testgrid.pbm
12-
echo $?
12+
echo ${PIPESTATUS[@]} ":" $?
1313

1414
pbmtog3 -nofixedwidth -reversebits testgrid.pbm | \
1515
g3topbm -width=14 -reversebits | cmp -s - testgrid.pbm
16-
echo $?
16+
echo ${PIPESTATUS[@]} ":" $?
1717

1818
pbmtog3 testgrid.pbm | \
1919
g3topbm | pnmcrop -white -right -bottom | \
20-
cmp -s - testgrid.pbm ; echo $?
20+
cmp -s - testgrid.pbm ; echo ${PIPESTATUS[@]} ":" $?
2121

2222
# works with gawk and mawk
2323
# produce all possible 8-bit patterns
@@ -28,31 +28,31 @@ LC_ALL=C awk 'BEGIN { print "P4"; # header
2828
printf("%c",i) }' > ${complete256_pbm}
2929

3030
pbmtog3 -nofixedwidth ${complete256_pbm} | g3topbm -width=8 | \
31-
cmp -s - ${complete256_pbm} ; echo $?
31+
cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $?
3232

3333
pbmtog3 -reverse -nofixedwidth ${complete256_pbm} | \
3434
g3topbm -reversebits -width=8 | \
35-
cmp -s - ${complete256_pbm} ; echo $?
35+
cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $?
3636

3737
pbmtog3 -align8 ${complete256_pbm} | \
3838
g3topbm -width=1728 | pnmcrop -white -right | \
39-
cmp -s - ${complete256_pbm} ; echo $?
39+
cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $?
4040

4141
pbmtog3 -align16 ${complete256_pbm} | \
4242
g3topbm -width=1728 | pnmcrop -white -right | \
43-
cmp -s - ${complete256_pbm} ; echo $?
43+
cmp -s - ${complete256_pbm} ; echo ${PIPESTATUS[@]} ":" $?
4444

4545
pbmmake -w 5000 5 > ${widew_pbm}
4646
pbmtog3 -nofixedwidth ${widew_pbm} | g3topbm | \
47-
cmp -s - ${widew_pbm} ; echo $?
47+
cmp -s - ${widew_pbm} ; echo ${PIPESTATUS[@]} ":" $?
4848

4949
pbmtog3 -nofixedwidth ${widew_pbm} | \
5050
g3topbm -width=5000 | \
51-
cmp -s - ${widew_pbm} ; echo $?
51+
cmp -s - ${widew_pbm} ; echo ${PIPESTATUS[@]} ":" $?
5252

5353
pbmmake -b 5000 5 > ${wideb_pbm}
5454
pbmtog3 -nofixedwidth ${wideb_pbm} | g3topbm | \
55-
cmp -s - ${wideb_pbm} ; echo $?
55+
cmp -s - ${wideb_pbm} ; echo ${PIPESTATUS[@]} ":" $?
5656

5757
cat ${complete256_pbm} | cksum
5858
cat ${wideb_pbm} | cksum

test/gif-quant-roundtrip.ok

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0
1+
0 0 0 : 0

test/gif-quant-roundtrip.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ quant_ppm=${tmpdir}/quant.ppm
1313
pnmquant ${colors} testimg.ppm > ${quant_ppm} &&
1414
pamtogif ${quant_ppm} | giftopnm | \
1515
cmp -s - ${quant_ppm} > /dev/null
16-
echo $?
16+
echo ${PIPESTATUS[@]} ":" $?
1717

1818
rm ${quant_ppm}

test/gif-roundtrip.ok

+10-10
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
2425386270 41
1111
2425386270 41
1212
P1 4 1 0101
13-
4030 0 , 4030 0
14-
4031 0 , 4031 0
15-
4097 0 , 4097 0
16-
238 0 , 238 0
17-
239 0 , 239 0
18-
240 0 , 240 0
19-
241 0 , 241 0
20-
255 0 , 255 0
21-
256 0 , 256 0
22-
257 0 , 257 0
13+
4030 : 0 0 0 0 : 0 , 4030 : 0 0 0 0 : 0
14+
4031 : 0 0 0 0 : 0 , 4031 : 0 0 0 0 : 0
15+
4097 : 0 0 0 0 : 0 , 4097 : 0 0 0 0 : 0
16+
238 : 0 0 0 0 : 0 , 238 : 0 0 0 0 : 0
17+
239 : 0 0 0 0 : 0 , 239 : 0 0 0 0 : 0
18+
240 : 0 0 0 0 : 0 , 240 : 0 0 0 0 : 0
19+
241 : 0 0 0 0 : 0 , 241 : 0 0 0 0 : 0
20+
255 : 0 0 0 0 : 0 , 255 : 0 0 0 0 : 0
21+
256 : 0 0 0 0 : 0 , 256 : 0 0 0 0 : 0
22+
257 : 0 0 0 0 : 0 , 257 : 0 0 0 0 : 0

test/gif-roundtrip.test

+4-4
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ for size in 4030 4031 4097
124124
cmp - ${test_pgm}
125125
# pamdepth ${maxval} is necessary because
126126
# giftopnm output is maxval 255
127-
echo -n ${size} $? ", "
127+
echo -n ${size} ":" ${PIPESTATUS[@]} ":" $? ", "
128128
pamtogif -nolzw ${test_pgm} | giftopnm | pamdepth ${maxval} | \
129129
cmp - ${test_pgm}
130-
echo ${size} $?
130+
echo ${size} ":" ${PIPESTATUS[@]} ":" $?
131131
rm ${test_pgm}
132132
done
133133

@@ -153,10 +153,10 @@ for size in 238 239 240 241 255 256 257
153153
pamcut -height=${size} ${test257_pgm} > ${test_pgm} &&
154154
pamtogif -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
155155
cmp - ${test_pgm}
156-
echo -n ${size} $? ", "
156+
echo -n ${size} ":" ${PIPESTATUS[@]} ":" $? ", "
157157
pamtogif -nolzw -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
158158
cmp - ${test_pgm}
159-
echo ${size} $?
159+
echo ${size} ":" ${PIPESTATUS[@]} ":" $?
160160
rm ${test_pgm}
161161
done
162162

test/palm-roundtrip.ok

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Test 1
55
584219238 236
66
584219238 236
77
Test 2
8-
0
9-
0
10-
0
11-
0
8+
0 0 0 : 0
9+
0 0 0 : 0
10+
0 0 0 : 0
11+
0 0 0 : 0

test/palm-roundtrip.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ for flags in "" \
3333
"-packbits_compression"
3434
do pnmtopalm -colormap $flags ${test256color_ppm} | palmtopnm | \
3535
cmp -s - ${test256color_ppm} > /dev/null
36-
echo $?
36+
echo ${PIPESTATUS[@]} ":" $?
3737
done
3838

3939
rm ${test256color_ppm}

test/pbmtext-utf8.ok

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
2066913605 5110
33
2920616515 2301
44
2920616515 2301
5-
0
5+
0 0 0 0 : 0
66
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
77
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
8-
1
8+
0 1 : 1

test/pbmtext-utf8.test

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ awk 'BEGIN { for (i=32; i<=126;++i) printf("%c",i); print ""; \
6666
LC_ALL=en_US.utf8 pbmtext -builtin bdf -wchar -text-dump | \
6767
cmp --quiet - ${output}
6868

69-
echo $?
69+
echo ${PIPESTATUS[@]} ":" $?
7070
rm ${output}
7171

7272

@@ -92,4 +92,4 @@ echo "-----------------------------------------------------------" 1>&2
9292
LC_ALL=C \
9393
awk 'BEGIN { for (i=128; i<=129;++i) printf("%c",i); print ""}' | \
9494
LC_ALL=en_US.utf8 pbmtext -builtin bdf -wchar -text-dump
95-
echo $?
95+
echo ${PIPESTATUS[@]} ":" $?

test/pdb-roundtrip.ok

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ pbm grid
33
2224198737 25671
44
2224198737 25671
55
pbm tiled
6-
0 0 0
7-
0 0 0
8-
0 0 0
9-
0 0 0
6+
0 0 0 0 : 0
7+
0 0 0 0 : 0
8+
0 0 0 0 : 0
9+
0 0 0 0 : 0
1010
pgm ellipse
11-
0 0 0
12-
0 0 0
13-
0 0 0
14-
0 0 0
11+
0 0 0 0 0 : 0
12+
0 0 0 0 0 : 0
13+
0 0 0 0 0 : 0
14+
0 0 0 0 0 : 0
1515
pgm ellipse -4depth
16-
0 0 0
17-
0 0 0
18-
0 0 0
16+
0 0 0 0 0 : 0
17+
0 0 0 0 0 : 0
18+
0 0 0 0 0 : 0

test/pdb-roundtrip.test

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ for flag in "" "-compressed" "-maybecompressed" "-uncompressed"
2424
do
2525
pamtopdbimg ${flag} ${tiled_pbm} | pdbimgtopam | pamtopnm | \
2626
cmp -s - ${tiled_pbm}
27-
echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} $?
27+
echo ${PIPESTATUS[@]} ":" $?
2828
done
2929
rm ${tiled_pbm}
3030

@@ -37,7 +37,7 @@ for flag in "" "-compressed" "-maybecompressed" "-uncompressed"
3737
do
3838
pamtopdbimg ${flag} ${ellipse_pgm} | pdbimgtopam | \
3939
pamtopnm | pamdepth 3 | cmp -s - ${ellipse_pgm}
40-
echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} $?
40+
echo ${PIPESTATUS[@]} ":" $?
4141
done
4242
rm ${ellipse_pgm}
4343

@@ -50,6 +50,6 @@ for flag in "-compressed" "-maybecompressed" "-uncompressed"
5050
do
5151
pamtopdbimg -4depth ${flag} ${ellipse_pgm} | pdbimgtopam | \
5252
pamtopnm | pamdepth 15 | cmp -s - ${ellipse_pgm}
53-
echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} $?
53+
echo ${PIPESTATUS[@]} ":" $?
5454
done
5555
rm ${ellipse_pgm}

test/pnmtile.ok

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
4228632379 259
2-
0
2+
0 0 : 0

test/pnmtile.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ pnmtile 454 298 testimg.ppm > ${testimg4_ppm} &&
1717
pnmcat -lr testimg.ppm testimg.ppm > ${testimg2_ppm} &&
1818
pnmcat -tb ${testimg2_ppm} ${testimg2_ppm} | \
1919
cmp -s - ${testimg4_ppm}
20-
echo $?
20+
echo ${PIPESTATUS[@]} ":" $?
2121

2222
rm ${testimg2_ppm} ${testimg4_ppm}

test/rgb3-roundtrip.ok

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
2425386270 41
44
0
55
0
6-
0
6+
0 0 : 0

test/rgb3-roundtrip.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ rgb3toppm ${testgrid_red} ${testgrid_grn} ${testgrid_blu} | \
4141
cmp -s ${testgrid_red} ${testgrid_grn} ; echo $?
4242
cmp -s ${testgrid_grn} ${testgrid_blu} ; echo $?
4343
pgmtopgm < testgrid.pbm | cmp -s - ${testgrid_red}
44-
echo $?
44+
echo ${PIPESTATUS[@]} ":" $?
4545

4646
rm ${testgrid_pbm} ${testgrid_red} ${testgrid_grn} ${testgrid_blu}

0 commit comments

Comments
 (0)