diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Test-Order | 4 | ||||
-rw-r--r-- | test/g3-roundtrip.ok | 3 | ||||
-rwxr-xr-x | test/g3-roundtrip.test | 25 | ||||
-rw-r--r-- | test/palm-roundtrip.ok | 10 | ||||
-rwxr-xr-x | test/palm-roundtrip.test | 32 | ||||
-rw-r--r-- | test/palm-roundtrip2.ok | 5 | ||||
-rwxr-xr-x | test/palm-roundtrip2.test | 31 | ||||
-rw-r--r-- | test/pamtopdbimg.ok | 20 | ||||
-rwxr-xr-x | test/pamtopdbimg.test | 86 | ||||
-rw-r--r-- | test/pdb-roundtrip.ok | 18 | ||||
-rwxr-xr-x | test/pdb-roundtrip.test | 55 | ||||
-rw-r--r-- | test/pnmquantall.ok | 6 | ||||
-rwxr-xr-x | test/pnmquantall.test | 20 | ||||
-rw-r--r-- | test/ppmbrighten.ok | 6 |
14 files changed, 301 insertions, 20 deletions
diff --git a/test/Test-Order b/test/Test-Order index d67c7f29..9b280d12 100644 --- a/test/Test-Order +++ b/test/Test-Order @@ -82,6 +82,7 @@ symmetry.test # Format converter tests +pamtopdbimg.test pbmtog3.test 411toppm.test eyuvtoppm.test @@ -132,7 +133,10 @@ macp-roundtrip.test mda-roundtrip.test mgr-roundtrip.test mrf-roundtrip.test +palm-roundtrip.test +palm-roundtrip2.test pcx-roundtrip.test +pdb-roundtrip.test pfm-roundtrip.test pi3-roundtrip.test pict-roundtrip.test diff --git a/test/g3-roundtrip.ok b/test/g3-roundtrip.ok index 4521d575..853d06d2 100644 --- a/test/g3-roundtrip.ok +++ b/test/g3-roundtrip.ok @@ -8,3 +8,6 @@ 0 0 0 +1777627284 265 +2985378006 3135 +3651878552 3135 diff --git a/test/g3-roundtrip.test b/test/g3-roundtrip.test index baa6ac31..10174733 100755 --- a/test/g3-roundtrip.test +++ b/test/g3-roundtrip.test @@ -19,12 +19,15 @@ pbmtog3 testgrid.pbm | \ g3topbm | pnmcrop -white -right -bottom | \ cmp -s - testgrid.pbm ; echo $? -awk 'BEGIN { print "P4"; # header - print "8 256"; - for (i=0;i<256;++i) # raster - printf("%c",i) }' > ${complete256_pbm} +# works with gawk and mawk +# produce all possible 8-bit patterns -pbmtog3 -nofixedwidth ${complete256_pbm} | g3topbm -width=8 | tee /tmp/z1 | \ +LC_ALL=C awk 'BEGIN { print "P4"; # header + print "8 256"; + for (i=0;i<256;++i) # raster + printf("%c",i) }' > ${complete256_pbm} + +pbmtog3 -nofixedwidth ${complete256_pbm} | g3topbm -width=8 | \ cmp -s - ${complete256_pbm} ; echo $? pbmtog3 -reverse -nofixedwidth ${complete256_pbm} | \ @@ -39,16 +42,20 @@ pbmtog3 -align16 ${complete256_pbm} | \ g3topbm -width=1728 | pnmcrop -white -right | \ cmp -s - ${complete256_pbm} ; echo $? -pbmmake -w 5000 5 | tee ${widew_pbm} | pbmtog3 -nofixedwidth | \ -g3topbm | \ +pbmmake -w 5000 5 > ${widew_pbm} +pbmtog3 -nofixedwidth ${widew_pbm} | g3topbm | \ cmp -s - ${widew_pbm} ; echo $? pbmtog3 -nofixedwidth ${widew_pbm} | \ g3topbm -width=5000 | \ cmp -s - ${widew_pbm} ; echo $? -pbmmake -b 5000 5 | tee ${wideb_pbm} | pbmtog3 -nofixedwidth | \ -g3topbm | \ +pbmmake -b 5000 5 > ${wideb_pbm} +pbmtog3 -nofixedwidth ${wideb_pbm} | g3topbm | \ cmp -s - ${wideb_pbm} ; echo $? +cat ${complete256_pbm} | cksum +cat ${wideb_pbm} | cksum +cat ${widew_pbm} | cksum + rm ${complete256_pbm} ${wideb_pbm} ${widew_pbm} diff --git a/test/palm-roundtrip.ok b/test/palm-roundtrip.ok new file mode 100644 index 00000000..6c9114a4 --- /dev/null +++ b/test/palm-roundtrip.ok @@ -0,0 +1,10 @@ +584219238 236 +584219238 236 +584219238 236 +584219238 236 +584219238 236 +600373046 101484 +600373046 101484 +600373046 101484 +600373046 101484 +600373046 101484 diff --git a/test/palm-roundtrip.test b/test/palm-roundtrip.test new file mode 100755 index 00000000..5570e968 --- /dev/null +++ b/test/palm-roundtrip.test @@ -0,0 +1,32 @@ +#! /bin/bash +# This script tests: pnmtopalm palmtopnm +# Also requires: pamdepth pnmquant + +tmpdir=${tmpdir:-/tmp} +test4bit_pgm=${tmpdir}/test4bit.pgm +test256color_ppm=${tmpdir}/test256color.ppm + +# Test 1. Should print 584219238 236 5 times + +pamdepth 15 testgrid.pbm | tee ${test4bit_pgm} | cksum + +for flags in "" \ + "-scanline_compression" \ + "-rle_compression" \ + "-packbits_compression" + do pnmtopalm $flags ${test4bit_pgm} | palmtopnm | cksum; done + +rm ${test4bit_pgm} + + +# Test 2. Should print 600373046 101484 5 times + +pnmquant 256 testimg.ppm | tee ${test256color_ppm} | cksum + +for flags in "" \ + "-scanline_compression" \ + "-rle_compression" \ + "-packbits_compression" + do pnmtopalm -colormap $flags ${test256color_ppm} | palmtopnm | cksum; done + +rm ${test256color_ppm} diff --git a/test/palm-roundtrip2.ok b/test/palm-roundtrip2.ok new file mode 100644 index 00000000..0060d7b6 --- /dev/null +++ b/test/palm-roundtrip2.ok @@ -0,0 +1,5 @@ +438301914 101484 +438301914 101484 +438301914 101484 +438301914 101484 +438301914 101484 diff --git a/test/palm-roundtrip2.test b/test/palm-roundtrip2.test new file mode 100755 index 00000000..4c94df8c --- /dev/null +++ b/test/palm-roundtrip2.test @@ -0,0 +1,31 @@ +#! /bin/bash +# This script tests: pnmtopalm palmtopnm +# Also requires: pnmremap + +tmpdir=${tmpdir:-/tmp} +test256color_ppm=${tmpdir}/test256color.ppm + +if [ ${CHECK_TYPE} = install ] + then mapfile=$(netpbm-config --datadir)/palmcolor8.map + else mapfile=${PALMMAPDIR}/palmcolor8.map +fi + +if [ ! -f ${mapfile} ] + then + echo "Cannot find palmcolor8.map. Skipping." 1>&2 + exit 80; +fi + + +# Test. Should print 438301914 101484 +# 5 times + +pnmremap -mapfile=${mapfile} testimg.ppm | tee ${test256color_ppm} | cksum + +for flags in "" \ + "-scanline_compression" \ + "-rle_compression" \ + "-packbits_compression" + do pnmtopalm -colormap $flags ${test256color_ppm} | palmtopnm | cksum; done + +rm ${test256color_ppm} diff --git a/test/pamtopdbimg.ok b/test/pamtopdbimg.ok new file mode 100644 index 00000000..57258940 --- /dev/null +++ b/test/pamtopdbimg.ok @@ -0,0 +1,20 @@ +high compression +2 +1 +poor compression +1 +2 +long titles +268 +0 +268 +0 +0 +1 +large notefile +3344 +0 +68885 +0 +0 +1 diff --git a/test/pamtopdbimg.test b/test/pamtopdbimg.test new file mode 100755 index 00000000..267f6bc8 --- /dev/null +++ b/test/pamtopdbimg.test @@ -0,0 +1,86 @@ +#! /bin/bash +# This script tests: pamtopdbimg +# Also requires: pgmmake pgmnoise + +tmpdir=${tmpdir:-/tmp} +mono_pgm=${tmpdir}/graymono.pgm +noise_pgm=${tmpdir}/graynoise.pgm +text65533=${tmpdir}/ascii65533.txt +text65534=${tmpdir}/ascii65534.txt +text65597=${tmpdir}/ascii65597.txt + +# The PDB image format has a time stamp. This causes pamtopdbimg +# to produce slightly different output files with each invocation. + +# Test 1. High compression +# -maybecompressed should produce a compressed file +# Should print: +# 2 +# 1 +echo high compression +pgmmake 0.5 -maxval=15 160 160 > ${mono_pgm} +for flag in "-compressed" "-maybecompressed" "-uncompressed" + do + pamtopdbimg $flag ${mono_pgm} | wc -c + done | uniq -c | awk '{print $1}' +rm ${mono_pgm} + + +# Test 2. Poor compression +# -maybecompressed should produce a uncompressed file +# Should print: +# 1 +# 2 +echo poor compression +pgmnoise -maxval=15 -randomseed=0 160 160 > ${noise_pgm} +for flag in "-compressed" "-maybecompressed" "-uncompressed" + do + pamtopdbimg $flag ${noise_pgm} | wc -c + done | uniq -c | awk '{print $1}' +rm ${noise_pgm} + + +# Test 3. long titles +# Should succeed twice and fail once, producing: +# 268 +# 0 +# 268 +# 0 +# 1 +# 0 +echo long titles +for flag in "" "-title=0123456789012345678901234567890" \ + "-title=01234567890123456789012345678901" + do + pamtopdbimg $flag testgrid.pbm | wc -c ; echo ${PIPESTATUS[0]} + done + + +# Test 4. large notefile +# Should succeed twice and fail once, producing: +# 3344 +# 0 +# 68886 +# 0 +# 1 +# 0 +echo large notefile +awk 'BEGIN { ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + abc="abcdefghijklmnopqrstuvwxyz"; + digits="0123456789"; string =""; + + while ( length(string) < 65597 ) + string = string ABC abc digits; + + print string }' > ${text65597} + +head -c 65533 ${text65597} > ${text65533} +head -c 65534 ${text65597} > ${text65534} +pamtopdbimg -uncompressed testgrid.pbm | wc -c + echo ${PIPESTATUS[0]} +pamtopdbimg -uncompressed -notefile=${text65533} testgrid.pbm | wc -c + echo ${PIPESTATUS[0]} +pamtopdbimg -uncompressed -notefile=${text65534} testgrid.pbm | wc -c + echo ${PIPESTATUS[0]} + +rm ${text65533} ${text65534} ${text65597} \ No newline at end of file diff --git a/test/pdb-roundtrip.ok b/test/pdb-roundtrip.ok new file mode 100644 index 00000000..cb920669 --- /dev/null +++ b/test/pdb-roundtrip.ok @@ -0,0 +1,18 @@ +pbm grid +2224198737 25671 +2224198737 25671 +2224198737 25671 +pbm tiled +0 0 0 +0 0 0 +0 0 0 +0 0 0 +pgm ellipse +0 0 0 +0 0 0 +0 0 0 +0 0 0 +pgm ellipse -4depth +0 0 0 +0 0 0 +0 0 0 diff --git a/test/pdb-roundtrip.test b/test/pdb-roundtrip.test new file mode 100755 index 00000000..a6de93d2 --- /dev/null +++ b/test/pdb-roundtrip.test @@ -0,0 +1,55 @@ +#! /bin/bash +# This script tests: pamtopdbimg pdbimgtopam +# Also requires: pnmtile pgmramp pamtopnm + +tmpdir=${tmpdir:-/tmp} +tiled_pbm=${tmpdir}/tiled.pbm +ellipse_pgm=${tmpdir}/ellipse.pgm + + +# Test 1. Should produce 2224198737 25671 +# 3 times +echo pbm grid +for flag in "-compressed" "-maybecompressed" "-uncompressed" + do + pamtopdbimg ${flag} testgrid.pbm | pdbimgtopam | cksum + done + + +# Test 2. Should produce 0 0 0 +# 4 times +echo pbm tiled +pnmtile 160 160 testgrid.pbm > ${tiled_pbm} +for flag in "" "-compressed" "-maybecompressed" "-uncompressed" + do + pamtopdbimg ${flag} ${tiled_pbm} | pdbimgtopam | pamtopnm | \ + cmp -s - ${tiled_pbm} + echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} $? + done +rm ${tiled_pbm} + + +# Test 3. Should produce 0 0 0 +# 4 times +echo pgm ellipse +pgmramp -ellipse 160 160 -maxval=3 > ${ellipse_pgm} +for flag in "" "-compressed" "-maybecompressed" "-uncompressed" + do + pamtopdbimg ${flag} ${ellipse_pgm} | pdbimgtopam | \ + pamtopnm | pamdepth 3 | cmp -s - ${ellipse_pgm} + echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} $? + done +rm ${ellipse_pgm} + + +# Test 3. Should produce 0 0 0 +# 3 times +echo pgm ellipse -4depth +pgmramp -ellipse 160 160 -maxval=15 > ${ellipse_pgm} +for flag in "-compressed" "-maybecompressed" "-uncompressed" + do + pamtopdbimg -4depth ${flag} ${ellipse_pgm} | pdbimgtopam | \ + pamtopnm | pamdepth 15 | cmp -s - ${ellipse_pgm} + echo ${PIPESTATUS[0]} ${PIPESTATUS[1]} $? + done +rm ${ellipse_pgm} \ No newline at end of file diff --git a/test/pnmquantall.ok b/test/pnmquantall.ok index bd5bbc05..172eb0aa 100644 --- a/test/pnmquantall.ok +++ b/test/pnmquantall.ok @@ -1,5 +1,5 @@ got color map -2373957371 33838 testimg.red -3892560659 33838 testimg.grn -1383839923 33838 testimg.blu +2373957371 33838 +3892560659 33838 +1383839923 33838 1 diff --git a/test/pnmquantall.test b/test/pnmquantall.test index 7d9ddf82..cd01bb8d 100755 --- a/test/pnmquantall.test +++ b/test/pnmquantall.test @@ -2,16 +2,26 @@ # This script tests: pnmquantall # Also requires: ppmtorgb3 pgmhist -ppmtorgb3 testimg.ppm +tmpdir=${tmpdir:-/tmp} +test_ppm=${tmpdir}/testimg.ppm -pnmquantall 20 testimg.red testimg.grn testimg.blu +cp testimg.ppm ${tmpdir} && +ppmtorgb3 ${test_ppm} -for i in testimg.red testimg.grn testimg.blu +test_red=${tmpdir}/testimg.red +test_grn=${tmpdir}/testimg.grn +test_blu=${tmpdir}/testimg.blu + +pnmquantall 20 ${test_red} ${test_grn} ${test_blu} + +for i in ${test_red} ${test_grn} ${test_blu} do -cksum $i +cat $i | cksum done # Should print 1 -pnmcat testimg.red testimg.grn testimg.blu -tb | \ +pnmcat ${test_red} ${test_grn} ${test_blu} -tb | \ pgmhist -m | awk '$2>0 {s++}; END { print (s<=20) }' + +rm ${test_red} ${test_grn} ${test_blu} ${test_ppm} \ No newline at end of file diff --git a/test/ppmbrighten.ok b/test/ppmbrighten.ok index 65feb812..0ce9f722 100644 --- a/test/ppmbrighten.ok +++ b/test/ppmbrighten.ok @@ -1,3 +1,3 @@ -2737989845 101484 -1059247992 101484 -32344911 101484 +2634278866 101484 +2791274519 101484 +2464564658 101484 |