diff options
42 files changed, 508 insertions, 417 deletions
diff --git a/test/cut-cat-roundtrip.test b/test/cut-cat-roundtrip.test index 970c3e17..f9928b30 100755 --- a/test/cut-cat-roundtrip.test +++ b/test/cut-cat-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamcut # Also requires: pamfile pnmcat pnmpad pnmcrop @@ -16,30 +16,30 @@ testimg_ppm_sum=`cat testimg.ppm | cksum` echo ${testimg_ppm_sum} imgsize=$(pamfile -size testimg.ppm) - iw=$(echo ${imgsize} | cut -d" " -f1) - ih=$(echo ${imgsize} | cut -d" " -f2) + width=$(echo ${imgsize} | cut -d " " -f 1) + height=$(echo ${imgsize} | cut -d " " -f 2) for i in 0 1 128 224 225 do pamcut -left=$((i+1)) testimg.ppm > ${right_ppm} pamcut -right=$i testimg.ppm > ${left_ppm} pnmcat -lr ${left_ppm} ${right_ppm} | \ - pamcut -left=0 -width=${iw} | cksum + pamcut -left=0 -width=${width} | cksum rm ${left_ppm} ${right_ppm} done echo "Test 2. Should print 3891261972 202953 1926073387 101484 six times" # Padding added to right. -pnmpad -right=${iw} -black testimg.ppm | cksum | tr '\n' ' ' +pnmpad -right=${width} -black testimg.ppm | cksum | tr '\n' ' ' echo ${testimg_ppm_sum} for border in 0 1 128 224 225 do - pamcut -left=$((${border}+1)) -width=${iw} -pad testimg.ppm > ${right_ppm} - pamcut -right=${border} -width=${iw} -pad testimg.ppm > ${left_ppm} + pamcut -left=$((${border}+1)) -width=${width} -pad testimg.ppm > ${right_ppm} + pamcut -right=${border} -width=${width} -pad testimg.ppm > ${left_ppm} pnmcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \ - pamcut -left=$((${iw}-${border}-1)) -width=$((${iw}*2)) | \ + pamcut -left=$((${width}-${border}-1)) -width=$((${width}*2)) | \ tee ${padded_ppm} | cksum | tr '\n' ' ' pnmcrop -black -right ${padded_ppm} | cksum rm ${left_ppm} ${right_ppm} ${padded_ppm} @@ -54,21 +54,22 @@ for border in 0 1 70 147 pamcut -top=$((${border}+1)) testimg.ppm > ${bottom_ppm} pamcut -bottom=${border} testimg.ppm > ${top_ppm} pnmcat -tb ${top_ppm} ${bottom_ppm} | \ - pamcut -top=0 -height=${ih} | cksum + pamcut -top=0 -height=${height} | cksum rm ${top_ppm} ${bottom_ppm} done echo "Test 4. Should print 26789469 202953 1926073387 101484 five times" # Padding added to bottom. -pnmpad -bottom=${ih} -black testimg.ppm | cksum | tr '\n' ' ' +pnmpad -bottom=${height} -black testimg.ppm | cksum | tr '\n' ' ' echo ${testimg_ppm_sum} for border in 0 1 70 147 do - pamcut -top=$((${border}+1)) -height=${ih} -pad testimg.ppm > ${bottom_ppm} - pamcut -bottom=${border} -height=${ih} -pad testimg.ppm > ${top_ppm} + pamcut -top=$((${border}+1)) -height=${height} -pad testimg.ppm \ + > ${bottom_ppm} + pamcut -bottom=${border} -height=${height} -pad testimg.ppm > ${top_ppm} pnmcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \ - pamcut -top=$((${ih}-${border}-1)) -height=$((${ih}*2)) | \ + pamcut -top=$((${height}-${border}-1)) -height=$((${height}*2)) | \ tee ${padded_ppm} | cksum | tr '\n' ' 'cksum pnmcrop -black -bottom ${padded_ppm} | cksum rm ${top_ppm} ${bottom_ppm} ${padded_ppm} @@ -86,15 +87,15 @@ maze_pbm_sum=`cat maze.pbm | cksum` echo ${maze_pbm_sum} imgsize=$(pamfile -size maze.pbm) -iw=$(echo ${imgsize} | cut -d" " -f1) -ih=$(echo ${imgsize} | cut -d" " -f2) +width=$(echo ${imgsize} | cut -d " " -f 1) +height=$(echo ${imgsize} | cut -d " " -f 2) for i in 0 1 10 30 50 do pamcut -left=$((i+1)) maze.pbm > ${right_ppm} pamcut -right=$i maze.pbm > ${left_ppm} pnmcat -lr ${left_ppm} ${right_ppm} | \ - pamcut -left=0 -width=${iw} | cksum + pamcut -left=0 -width=${width} | cksum rm ${left_ppm} ${right_ppm} done @@ -102,15 +103,15 @@ for i in 0 1 10 30 50 echo "Test 6. Should print 1748767123 895 281226646 481 six times" # Padding added to right. -pnmpad -right=${iw} -black maze.pbm | cksum | tr '\n' ' ' +pnmpad -right=${width} -black maze.pbm | cksum | tr '\n' ' ' echo ${maze_pbm_sum} for border in 0 1 10 30 50 do - pamcut -left=$((${border}+1)) -width=${iw} -pad maze.pbm > ${right_ppm} - pamcut -right=${border} -width=${iw} -pad maze.pbm > ${left_ppm} + pamcut -left=$((${border}+1)) -width=${width} -pad maze.pbm > ${right_ppm} + pamcut -right=${border} -width=${width} -pad maze.pbm > ${left_ppm} pnmcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \ - pamcut -left=$((${iw}-${border}-1)) -width=$((${iw}*2)) | \ + pamcut -left=$((${width}-${border}-1)) -width=$((${width}*2)) | \ tee ${padded_ppm} | cksum | tr '\n' ' ' pnmcrop -black -right ${padded_ppm} | cksum rm ${left_ppm} ${right_ppm} ${padded_ppm} @@ -125,21 +126,21 @@ for border in 0 1 12 21 31 44 pamcut -top=$((${border}+1)) maze.pbm > ${bottom_ppm} pamcut -bottom=${border} maze.pbm > ${top_ppm} pnmcat -tb ${top_ppm} ${bottom_ppm} | \ - pamcut -top=0 -height=${ih} | cksum + pamcut -top=0 -height=${height} | cksum rm ${top_ppm} ${bottom_ppm} done echo "Test 8. Should print 1346655680 954 281226646 481 five times" # Padding added to bottom. -pnmpad -bottom=${ih} -black maze.pbm | cksum | tr '\n' ' ' +pnmpad -bottom=${height} -black maze.pbm | cksum | tr '\n' ' ' echo ${maze_pbm_sum} for border in 0 1 10 50 do - pamcut -top=$((${border}+1)) -height=${ih} -pad maze.pbm > ${bottom_ppm} - pamcut -bottom=${border} -height=${ih} -pad maze.pbm > ${top_ppm} + pamcut -top=$((${border}+1)) -height=${height} -pad maze.pbm > ${bottom_ppm} + pamcut -bottom=${border} -height=${height} -pad maze.pbm > ${top_ppm} pnmcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \ - pamcut -top=$((${ih}-${border}-1)) -height=$((${ih}*2)) | \ + pamcut -top=$((${height}-${border}-1)) -height=$((${height}*2)) | \ tee ${padded_ppm} | cksum | tr '\n' ' 'cksum pnmcrop -black -bottom ${padded_ppm} | cksum rm ${top_ppm} ${bottom_ppm} ${padded_ppm} diff --git a/test/g3-roundtrip.test b/test/g3-roundtrip.test index f35c4935..2736c09a 100755 --- a/test/g3-roundtrip.test +++ b/test/g3-roundtrip.test @@ -11,7 +11,7 @@ pagemax_pbm=${tmpdir}/pagemax.pbm echo "Test 1. Should print 0 0 0 : 0 or 0 0 0 0 : 0 total three times" -width=$(pamfile -size maze.pbm | cut -d" " -f1) +width=$(pamfile -size maze.pbm | cut -d " " -f 1) pbmtog3 -nofixedwidth maze.pbm | \ g3topbm -width=${width} | cmp -s - maze.pbm diff --git a/test/pamarith-multiple-input.test b/test/pamarith-multiple-input.test index 7df08817..b9c09662 100755 --- a/test/pamarith-multiple-input.test +++ b/test/pamarith-multiple-input.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamarith # Also requires: pgmmake ppmpat pamfunc @@ -14,7 +14,7 @@ pgmmake -maxval=99 0.01 16 11 > ${input1_pgm} add_command="pamarith -add "${input1_pgm} -for ((i=1 ; i<10 ; i++ )) +for i in 1 2 3 4 5 6 7 8 9 # for i in `seq 9` do echo ${i}":" add_command=${add_command}" "${input1_pgm} @@ -58,4 +58,4 @@ for function in "-add" "-and" "-or" "-xor" "-nand" "-nor" pamarith ${function} ${g2_ppm} ${g3_ppm} ${g2_ppm} | cksum done -rm ${g2_ppm} ${g3_ppm} \ No newline at end of file +rm ${g2_ppm} ${g3_ppm} diff --git a/test/pamcut.test b/test/pamcut.test index e18c3cf2..2299b4bc 100755 --- a/test/pamcut.test +++ b/test/pamcut.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamcut pbmmake # Also requires: pamfile @@ -27,8 +27,9 @@ pamcut -top 10 -left 10 -width 207 -height 129 testimg.ppm | cksum echo "Test 5. Should print 281226646 481 five times" -width=$(pamfile -size maze.pbm | awk '{print $1}') -height=$(pamfile -size maze.pbm | awk '{print $2}') +mazesize=$(pamfile -size maze.pbm) +width=$(echo ${mazesize} | cut -d " " -f 1) +height=$(echo ${mazesize} | cut -d " " -f 2) pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 maze.pbm | \ cksum diff --git a/test/pamdice-roundtrip.test b/test/pamdice-roundtrip.test index 741615f5..4d3fba19 100755 --- a/test/pamdice-roundtrip.test +++ b/test/pamdice-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamdice pamundice # Also requires: pamfile @@ -6,8 +6,8 @@ tmpdir=${tmpdir:-/tmp} fname_stem=${tmpdir}/pamdice_part mazesize=$(pamfile -size maze.pbm) -mw=$(echo ${mazesize} | cut -d" " -f1) -mh=$(echo ${mazesize} | cut -d" " -f2) +mw=$(echo ${mazesize} | cut -d " " -f 1) +mh=$(echo ${mazesize} | cut -d " " -f 2) echo "Test 1. Should print 281226646 481" diff --git a/test/pamendian-roundtrip.ok b/test/pamendian-roundtrip.ok index 50450617..6245abb9 100644 --- a/test/pamendian-roundtrip.ok +++ b/test/pamendian-roundtrip.ok @@ -1,4 +1,5 @@ -Test 1: Should print '0 0 0 : 0' +Test 1. Should print '0 0 0 : 0' 0 0 0 : 0 -Test 2 should print echo '0 0 0 0 0 : 0' +Test 2. Should print '0 0 0 0 0 : 0' twice +0 0 0 0 0 : 0 0 0 0 0 0 : 0 diff --git a/test/pamendian-roundtrip.test b/test/pamendian-roundtrip.test index aed03c76..b060b704 100755 --- a/test/pamendian-roundtrip.test +++ b/test/pamendian-roundtrip.test @@ -2,7 +2,7 @@ # This script tests: pamendian # Also requires: pamdepth pgmtopbm pamseq -echo "Test 1: Should print '0 0 0 : 0'" +echo "Test 1. Should print '0 0 0 : 0'" tmpdir=${tmpdir:-/tmp} test0_pam=${tmpdir}/test0.pam @@ -15,8 +15,12 @@ pamendian < ${test0_pam} | pamendian |\ rm ${test0_pam} -echo "Test 2 should print echo '0 0 0 0 0 : 0'" +echo "Test 2. Should print '0 0 0 0 0 : 0' twice" pamdepth 65535 testgrid.pbm | pamendian | pamendian | \ pgmtopbm -th -val=0.5 | cmp -s - testgrid.pbm + echo ${PIPESTATUS[@]} ":" $? + +pamdepth 4095 maze.pbm | pamendian | pamendian | \ + pgmtopbm -th -val=0.5 | cmp -s - maze.pbm echo ${PIPESTATUS[@]} ":" $? \ No newline at end of file diff --git a/test/pamenlarge-pbm.test b/test/pamenlarge-pbm.test index 87493516..fbb2eced 100755 --- a/test/pamenlarge-pbm.test +++ b/test/pamenlarge-pbm.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamenlarge # Also requires: pbmmake pnmpad @@ -18,22 +18,24 @@ LC_ALL=C awk 'BEGIN { print "P4"; # header # Test 1. echo "test 1" -for xs in `seq 23` +for xs in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 # for xs in `seq 23` do - pamenlarge -xscale=$xs ${complete256_pbm} | cksum + pamenlarge -xscale=${xs} ${complete256_pbm} | cksum done # Test 2. echo "test 2" -for xs1 in `seq 15` +for xs1 in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # for xs in `seq 15` do - xs2=$((30-$xs1)) - pamenlarge -xscale=$xs1 ${complete256_pbm} | pamenlarge -xscale=$xs2 | cksum - if [ $xs1 != $xs2 ]; then - pamenlarge -xscale=$xs2 ${complete256_pbm} | pamenlarge -xscale=$xs1 | cksum + xs2=$((30-${xs1})) + pamenlarge -xscale=${xs1} ${complete256_pbm} | \ + pamenlarge -xscale=${xs2} | cksum + if [ ${xs1} != ${xs2} ]; then + pamenlarge -xscale=${xs2} ${complete256_pbm} | \ + pamenlarge -xscale=${xs1} | cksum fi - pamenlarge -xscale=$(($xs1 * $xs2)) ${complete256_pbm} | cksum + pamenlarge -xscale=$((${xs1} * ${xs2})) ${complete256_pbm} | cksum done rm ${complete256_pbm} @@ -43,19 +45,19 @@ echo "test 3" test3_pbm=${tmpdir}/test3.pbm -for width in `seq 16` +for width in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # for width in `seq 16` do pbmmake -g ${width} 1 | pnmpad -top=1 -white | \ pnmpad -bottom=1 -black > ${test3_pbm}.${width} done - for xscale in `seq 16` + for xscale in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # for xscale in `seq 16` do echo -n ${xscale} " " - for width in `seq 16` + for width in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # for width in `seq 16` do pamenlarge -xscale=${xscale} ${test3_pbm}.${width} ; done | cksum # # unlike most other tests we take the cksum of a composite PBM file # done -rm ${test3_pbm}.[1-9] ${test3_pbm}.1[0-6] \ No newline at end of file +rm ${test3_pbm}.[1-9] ${test3_pbm}.1[0-6] diff --git a/test/pamexec.test b/test/pamexec.test index ec57f4ae..7c2bf054 100755 --- a/test/pamexec.test +++ b/test/pamexec.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamexec # Also requires: pbmtext pamfile pbmminkowski pbmtog3 g3topbm @@ -6,7 +6,9 @@ tmpdir=${tmpdir:-/tmp} test_pbm=${tmpdir}/test.pbm combined_pbm=${tmpdir}/combined.pbm -for i in `seq 0 9`; do echo $i | pbmtext -builtin=fixed > ${test_pbm}$i; done +for i in 0 1 2 3 4 5 6 7 8 9 # for i in `seq 0 9` + do echo ${i} | pbmtext -builtin=fixed > ${test_pbm}${i} + done cat ${test_pbm}[0123456789] > ${combined_pbm} echo "Test 1 : Should print 10 stdin: PBM RAW 21 24 1 1 BLACKANDWHITE twice" @@ -16,7 +18,8 @@ pamexec "pamfile -mach" ${combined_pbm} | uniq -c | sed 's/^ *//' echo "Test 2: Should print 1791121103 989 twice" -for i in `seq 0 9`; do pbmminkowski ${test_pbm}$i ; done | cksum +for i in 0 1 2 3 4 5 6 7 8 9 # for i in `seq 0 9` + do pbmminkowski ${test_pbm}${i}; done | cksum pamexec "pbmminkowski" ${combined_pbm} | cksum rm ${test_pbm}[0123456789] diff --git a/test/pamgauss.test b/test/pamgauss.test index 87e172a8..6c3eff78 100755 --- a/test/pamgauss.test +++ b/test/pamgauss.test @@ -1,16 +1,16 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamgauss # Also requires: pamfile echo "Test 1" -for i in `seq 3 11` -do -for s in `seq 1 9` -do -pamgauss $i $i -oversample=1 -sigma=.$s | cksum -done -done +for i in 3 4 5 6 7 8 9 10 11 # for i in `seq 3 11` + do + for s in 1 2 3 4 5 6 7 8 9 # for s in `seq 9` + do + pamgauss ${i} ${i} -oversample=1 -sigma=.${s} | cksum + done + done echo "Test 2" diff --git a/test/pamscale-filters1.test b/test/pamscale-filters1.test index 63e0d012..575355c6 100755 --- a/test/pamscale-filters1.test +++ b/test/pamscale-filters1.test @@ -5,8 +5,8 @@ tmpdir=${tmpdir:-/tmp} enlarge_ppm=${tmpdir}/enlarge.ppm -width_height=`pamfile -size testimg.ppm | \ - awk '{print "-width="$1, "-height="$2}'` +width_height=$(pamfile -size testimg.ppm | \ + awk '{print "-width="$1, "-height="$2}') # The target values here were determined by running the test on a # 32-bit GNU/Linux system and subtracting 2.5 (dB) from observed diff --git a/test/pamscale-filters2.test b/test/pamscale-filters2.test index f7370020..764488c5 100755 --- a/test/pamscale-filters2.test +++ b/test/pamscale-filters2.test @@ -5,8 +5,8 @@ tmpdir=${tmpdir:-/tmp} stretch_ppm=${tmpdir}/stretch.ppm -width_height=`pamfile -size testimg.ppm | \ - awk '{print "-width="$1, "-height="$2}'` +width_height=$(pamfile -size testimg.ppm | \ + awk '{print "-width="$1, "-height="$2}') pamstretch -xscale=4 -yscale=3 testimg.ppm | pamvalidate > ${stretch_ppm} echo -xscale=4 -yscale=3 mitchell: diff --git a/test/pamscale-filters3.test b/test/pamscale-filters3.test index 5a865508..23e79373 100755 --- a/test/pamscale-filters3.test +++ b/test/pamscale-filters3.test @@ -5,8 +5,8 @@ tmpdir=${tmpdir:-/tmp} stretch_ppm=${tmpdir}/stretch.ppm -width_height=`pamfile -size testimg.ppm | \ - awk '{print "-width="$1, "-height="$2}'` +width_height=$(pamfile -size testimg.ppm | \ + awk '{print "-width="$1, "-height="$2}') pamstretch-gen 3.96 testimg.ppm | pamvalidate > ${stretch_ppm} echo 3.96 hermite: diff --git a/test/pamslice-roundtrip.test b/test/pamslice-roundtrip.test index d1a8a72c..2b7929cf 100755 --- a/test/pamslice-roundtrip.test +++ b/test/pamslice-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamslice pamdeinterlace # Also requires: pamfile pamcut pamtopnm pamflip @@ -7,14 +7,14 @@ echo "Test 1. Should print 139976034 137 twice" # Add header and reconstruct pbm image. # Note that in pamslice output 0 is white and 1 is black: opposite of PBM -mwidth=$(pamfile -size maze.pbm | cut -d" " -f1) +mwidth=$(pamfile -size maze.pbm | cut -d " " -f 1) height=16 pamcut -top=0 -left=0 -height=${height} maze.pbm | cksum (echo "P1" echo "${mwidth} ${height}" - for ((i = 0; i < ${height}; ++i)) + for i in `seq 0 $((${height}-1))` do pamslice -row=$i maze.pbm done | cut -d" " -f2- | sed 'y/01/10/' ) \ @@ -27,7 +27,6 @@ echo "Test 2. Should print 1624460505 574 three times" # whole image takes much time. # Add header and reconstruct ppm image. - tmpdir=${tmpdir:-/tmp} test1711_ppm=${tmpdir}/test1711.ppm @@ -37,21 +36,20 @@ pamcut -left=50 -top=50 -width=17 -height=11 testimg.ppm | \ (echo "P3" echo "17 11" echo "255" - for ((i = 0; i < 11; ++i)) + for i in 0 1 2 3 4 5 6 7 8 9 10 # for i in `seq 0 10` do - pamslice -row=$i ${test1711_ppm} + pamslice -row=${i} ${test1711_ppm} done | cut -d" " -f2- ) \ | pamtopnm | cksum # Same as above test 2, but take cols instead of rows. -# Should print 914327477 4864 (echo "P3" echo "11 17" echo "255" - for ((i = 0; i < 17; ++i)) + for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # for i in `seq 0 16` do - pamslice -col=$i ${test1711_ppm} + pamslice -col=${i} ${test1711_ppm} done | cut -d " " -f2- ) | pamflip -xy | cksum echo "Test 3. Should print 1624460505 574" @@ -66,10 +64,10 @@ pamdeinterlace -takeeven ${test1711_ppm} > ${testeven_ppm} ( echo "P3" echo "17 11" echo "255" - ( for ((i = 0; i < 5; ++i)) + ( for i in 0 1 2 3 4 do - pamslice -row=$i ${testeven_ppm} - pamslice -row=$i ${testodd_ppm} + pamslice -row=${i} ${testeven_ppm} + pamslice -row=${i} ${testodd_ppm} done pamslice -row=5 ${testeven_ppm}; ) | cut -d" " -f2- ) | pamtopnm | cksum diff --git a/test/pamtable.test b/test/pamtable.test index 335d45c4..037d3b07 100755 --- a/test/pamtable.test +++ b/test/pamtable.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtable # Also requires: pamseq pamdepth pbmmake ppmrainbow @@ -9,12 +9,13 @@ echo pamseq 4 1 -tupletype=RGBA | pamtable echo for maxval in 9 10 9999 10000 65535 - do pbmmake -g 2 2 | pamdepth $maxval | pamtable - echo - ppmrainbow -width=3 -height=2 -norepeat black white | \ - pamdepth $maxval | pamtable - echo - ppmrainbow -width=4 -height=2 -norepeat red blue green | \ - pamdepth $maxval | pamtable - echo + do + pbmmake -g 2 2 | pamdepth ${maxval} | pamtable + echo + ppmrainbow -width=3 -height=2 -norepeat black white | \ + pamdepth ${maxval} | pamtable + echo + ppmrainbow -width=4 -height=2 -norepeat red blue green | \ + pamdepth ${maxval} | pamtable + echo done diff --git a/test/pbm-misc-converters.ok b/test/pbm-misc-converters.ok index a137102f..4a511d35 100644 --- a/test/pbm-misc-converters.ok +++ b/test/pbm-misc-converters.ok @@ -1,27 +1,27 @@ -1638343024 43 -2141128209 77 -2542756600 120 -3102495729 32 -2414506375 47 -3241517214 145 -1454090165 46 -1436169407 46 -1454090165 46 -2912484298 46 -3576177652 52 -1478164284 52 -3213223606 141 -3213223606 141 -3213223606 141 -1463148415 108 -203901789 30 -3732005859 92 -2459345477 86 -424535246 92 -609530223 252 -4195053594 248 -2602382240 43 -129620534 361 -2256096096 80 -1349121911 149 +3017587389 501 +2529120683 622 +2361485126 1740 +4017331268 450 +3481527833 672 +2707446245 1744 +2100180787 510 +2963515498 510 +2100180787 510 +1513122412 510 +34750317 804 +1731023722 546 +1540204160 762 +908699854 763 +908699854 763 +1554612498 636 +1574732995 458 +3813814418 972 +1385394245 966 +3924854157 972 +3970098281 3388 +167529797 3384 +2260274013 483 +2120102625 5318 +541430122 708 +2297581967 1725 3955750161 284701 diff --git a/test/pbm-misc-converters.test b/test/pbm-misc-converters.test index ad96f13c..93773e48 100755 --- a/test/pbm-misc-converters.test +++ b/test/pbm-misc-converters.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmto10x pbmto4425 pbmtoascii pbmtobbnbg # This script tests: pbmtodjvurle pbmtoepson pbmtogo pbmtoibm23xx # This script tests: pbmtolj pbmtoln03 pbmtomatrixorbital pbmtonokia @@ -10,31 +10,31 @@ # direction. We check whether the output is unchanged from older # versions. -pbmto10x testgrid.pbm | cksum -pbmto4425 testgrid.pbm | cksum -pbmtoascii testgrid.pbm | cksum -pbmtoascii -2x4 testgrid.pbm | cksum -pbmtobbnbg < testgrid.pbm | cksum -pbmtodjvurle testgrid.pbm | cksum -pbmtoepson testgrid.pbm | cksum -pbmtoepson -protocol=escp testgrid.pbm | cksum -pbmtoepson -protocol=escp9 testgrid.pbm | cksum -pbmtoepson -nonadjacent testgrid.pbm | cksum -pbmtogo testgrid.pbm | cksum -pbmtoibm23xx -xres=60 -yres=60 testgrid.pbm | cksum -pbmtolj testgrid.pbm | cksum -pbmtolj -packbits testgrid.pbm | cksum -pbmtolj -compress testgrid.pbm | cksum -pbmtoln03 testgrid.pbm | cksum -pbmtomatrixorbital < testgrid.pbm | cksum -pbmtonokia -fmt HEX_NOL testgrid.pbm | cksum -pbmtonokia -fmt HEX_NGG testgrid.pbm | cksum -pbmtonokia -fmt HEX_NPM testgrid.pbm | cksum -pbmtonokia -fmt NOL testgrid.pbm | cksum -pbmtonokia -fmt NGG testgrid.pbm | cksum -pbmtonokia -fmt NPM testgrid.pbm | cksum -pbmtoplot testgrid.pbm | cksum -pbmtoptx testgrid.pbm | cksum -pbmtozinc testgrid.pbm | cksum +pbmto10x maze.pbm | cksum +pbmto4425 maze.pbm | cksum +pbmtoascii maze.pbm | cksum +pbmtoascii -2x4 maze.pbm | cksum +pbmtobbnbg < maze.pbm | cksum +pbmtodjvurle maze.pbm | cksum +pbmtoepson maze.pbm | cksum +pbmtoepson -protocol=escp maze.pbm | cksum +pbmtoepson -protocol=escp9 maze.pbm | cksum +pbmtoepson -nonadjacent maze.pbm | cksum +pbmtogo maze.pbm | cksum +pbmtoibm23xx -xres=60 -yres=60 maze.pbm | cksum +pbmtolj maze.pbm | cksum +pbmtolj -packbits maze.pbm | cksum +pbmtolj -compress maze.pbm | cksum +pbmtoln03 maze.pbm | cksum +pbmtomatrixorbital < maze.pbm | cksum +pbmtonokia -fmt HEX_NOL maze.pbm | cksum +pbmtonokia -fmt HEX_NGG maze.pbm | cksum +pbmtonokia -fmt HEX_NPM maze.pbm | cksum +pbmtonokia -fmt NOL maze.pbm | cksum +pbmtonokia -fmt NGG maze.pbm | cksum +pbmtonokia -fmt NPM maze.pbm | cksum +pbmtoplot maze.pbm | cksum +pbmtoptx maze.pbm | cksum +pbmtozinc maze.pbm | cksum (pbmpage 1; pbmpage 2; pbmpage 3) | pbmtoppa | cksum diff --git a/test/pbmmake.test b/test/pbmmake.test index eef4e0da..c3691b80 100755 --- a/test/pbmmake.test +++ b/test/pbmmake.test @@ -1,25 +1,26 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmmake # Also requires: echo "Test 1" -for i in `seq 1 8` -do -for color in -white -black -gray -do -pbmmake -plain $color $i $i | tr -d '\n'; echo -done -done +for size in 1 2 3 4 5 6 7 8 # for size in `seq 8` + do + for color in -white -black -gray + do + pbmmake -plain ${color} ${size} ${size} | tr -d '\n'; echo + done + done echo "Test 2" -for i in `seq 8 5 98` -do - ( pbmmake -w $i $i ; - pbmmake -b $i $i ; - pbmmake -g $i $i ) | cksum -done +for size in 8 13 18 23 28 33 38 43 48 53 58 63 68 73 78 83 88 93 98 + # for size in `seq 8 5 98` + do + ( pbmmake -w ${size} ${size} ; + pbmmake -b ${size} ${size} ; + pbmmake -g ${size} ${size} ) | cksum + done echo "Test Invalid" diff --git a/test/pbmnoise1.test b/test/pbmnoise1.test index 1b8fc241..855a5629 100755 --- a/test/pbmnoise1.test +++ b/test/pbmnoise1.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmnoise # @@ -13,7 +13,9 @@ done echo "Test 2." -for ((i=0 ; i<=32; i++)) +for i in 0 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 + # for i in `seq 0 32` do pbmnoise -endian=little -randomseed=11 -ratio=$i/32 -plain 32 1 | \ tr '\n' ' '; echo diff --git a/test/pbmtext.test b/test/pbmtext.test index a7c75c23..b82b0771 100755 --- a/test/pbmtext.test +++ b/test/pbmtext.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtext # Also requires: pamfile @@ -41,7 +41,7 @@ for flags in "" "-builtin fixed" do pbmtext ${flags} ${text} | tee ${temp_pbm} | cksum width1=`pamfile ${temp_pbm} | awk '$2=="PBM" && NR==1 {w=$4}; END {print w}' ` -width2=`pbmtext ${flags} ${text} --dry-run | awk '{print $1}' ` +width2=`pbmtext ${flags} ${text} --dry-run | cut -d " " -f 1` if [ ${width1} -eq ${width2} ]; then pbmtext ${flags} -width=${width1} ${text} | cksum diff --git a/test/pcx-roundtrip.ok b/test/pcx-roundtrip.ok index 968f46b9..0f5ac87d 100644 --- a/test/pcx-roundtrip.ok +++ b/test/pcx-roundtrip.ok @@ -1,5 +1,9 @@ +Test 1. Should print 1926073387 101484 1926073387 101484 +Test 2. Should print 369063776 101484 three times 369063776 101484 369063776 101484 369063776 101484 -829921912 685 +Test 3. Should print 669206373 10102 twice +669206373 10102 +669206373 10102 diff --git a/test/pcx-roundtrip.test b/test/pcx-roundtrip.test index 3dba42b9..3a78faba 100755 --- a/test/pcx-roundtrip.test +++ b/test/pcx-roundtrip.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmtopcx pcxtoppm # Also requires: pnmremap @@ -29,17 +29,16 @@ P3 255 255 255 EOF -# Test 1. Should print 1926073387 101484 +echo "Test 1. Should print 1926073387 101484" ppmtopcx testimg.ppm | pcxtoppm | cksum -# Test 2. Should print 369063776 101484 three times +echo "Test 2. Should print 369063776 101484 three times" pnmremap testimg.ppm -mapfile=${pcxstd_ppm} | tee ${testpcx_ppm} | cksum ppmtopcx -stdpalette -packed ${testpcx_ppm} | pcxtoppm | cksum ppmtopcx -stdpalette -packed -8bit ${testpcx_ppm} | pcxtoppm | cksum rm ${testpcx_ppm} ${pcxstd_ppm} -# Test 3. Should print 829921912 685 which is the -# result of: -# pgmtoppm < testgrid.pbm | cksum -ppmtopcx -stdpalette -packed testgrid.pbm | pcxtoppm | cksum +echo "Test 3. Should print 669206373 10102 twice" +pgmtoppm < maze.pbm | cksum +ppmtopcx -stdpalette -packed maze.pbm | pcxtoppm | cksum diff --git a/test/pdb-roundtrip.ok b/test/pdb-roundtrip.ok index b903da8d..fbc897fe 100644 --- a/test/pdb-roundtrip.ok +++ b/test/pdb-roundtrip.ok @@ -1,18 +1,18 @@ -pbm grid +Test 1: pbm grid : Should print 2224198737 25671 three times 2224198737 25671 2224198737 25671 2224198737 25671 -pbm tiled +Test 2: pbmnoise : Should print 0 0 0 0 : 0 four times 0 0 0 0 : 0 0 0 0 0 : 0 0 0 0 0 : 0 0 0 0 0 : 0 -pgm ellipse +Test 3: pgm ellipse : Should print 0 0 0 0 0 : 0 four times 0 0 0 0 0 : 0 0 0 0 0 0 : 0 0 0 0 0 0 : 0 0 0 0 0 0 : 0 -pgm ellipse -4depth +Test 4: pgm ellipse -4depth : Should print 0 0 0 0 0 : 0 three times 0 0 0 0 0 : 0 0 0 0 0 0 : 0 0 0 0 0 0 : 0 diff --git a/test/pdb-roundtrip.test b/test/pdb-roundtrip.test index 32d7aa87..c31a63e1 100755 --- a/test/pdb-roundtrip.test +++ b/test/pdb-roundtrip.test @@ -3,35 +3,29 @@ # Also requires: pnmtile pgmramp pamtopnm pamdepth tmpdir=${tmpdir:-/tmp} -tiled_pbm=${tmpdir}/tiled.pbm +noise_pbm=${tmpdir}/noise.pbm ellipse_pgm=${tmpdir}/ellipse.pgm -# Test 1. Should produce 2224198737 25671 -# 3 times -echo pbm grid +echo "Test 1: pbm grid : Should print 2224198737 25671 three times" 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} +echo "Test 2: pbmnoise : Should print 0 0 0 0 : 0 four times" +pbmnoise -randomseed=1 160 160 > ${noise_pbm} for flag in "" "-compressed" "-maybecompressed" "-uncompressed" do - pamtopdbimg ${flag} ${tiled_pbm} | pdbimgtopam | pamtopnm | \ - cmp -s - ${tiled_pbm} + pamtopdbimg ${flag} ${noise_pbm} | pdbimgtopam | pamtopnm | \ + cmp -s - ${noise_pbm} echo ${PIPESTATUS[@]} ":" $? done -rm ${tiled_pbm} +rm ${noise_pbm} -# Test 3. Should produce 0 0 0 -# 4 times -echo pgm ellipse +echo "Test 3: pgm ellipse : Should print 0 0 0 0 0 : 0 four times" pgmramp -ellipse 160 160 -maxval=3 > ${ellipse_pgm} for flag in "" "-compressed" "-maybecompressed" "-uncompressed" do @@ -42,9 +36,7 @@ for flag in "" "-compressed" "-maybecompressed" "-uncompressed" rm ${ellipse_pgm} -# Test 3. Should produce 0 0 0 -# 3 times -echo pgm ellipse -4depth +echo "Test 4: pgm ellipse -4depth : Should print 0 0 0 0 0 : 0 three times" pgmramp -ellipse 160 160 -maxval=15 > ${ellipse_pgm} for flag in "-compressed" "-maybecompressed" "-uncompressed" do @@ -52,4 +44,4 @@ for flag in "-compressed" "-maybecompressed" "-uncompressed" pamtopnm | pamdepth 15 | cmp -s - ${ellipse_pgm} echo ${PIPESTATUS[@]} ":" $? done -rm ${ellipse_pgm} \ No newline at end of file +rm ${ellipse_pgm} diff --git a/test/pgmnoise.ok b/test/pgmnoise.ok index 80376c78..d98ee053 100644 --- a/test/pgmnoise.ok +++ b/test/pgmnoise.ok @@ -77,7 +77,7 @@ Should print four identical lines 969759084 1682 969759084 1682 Test 6. -First column should be 2^n - 1 +First column should be 2^n - 1. Last column should be 'pool'. 1 pgmnoise: method: pool 3 pgmnoise: method: pool 7 pgmnoise: method: pool @@ -86,6 +86,9 @@ First column should be 2^n - 1 63 pgmnoise: method: pool 127 pgmnoise: method: pool 255 pgmnoise: method: pool +511 pgmnoise: method: pool +1023 pgmnoise: method: pool +65535 pgmnoise: method: pool Test Invalid Expected failure 1 1 Expected failure 2 1 diff --git a/test/pgmnoise.test b/test/pgmnoise.test index 4a6e21dd..45374793 100755 --- a/test/pgmnoise.test +++ b/test/pgmnoise.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmnoise # Also requires: pgmhist pamvalidate pamfile @@ -17,7 +17,7 @@ pgmnoise --randomseed=5489 -maxval=9999 -plain 5 20 echo "Test 3." -for maxval in `seq 16` 255 65535 +for maxval in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 255 65535 do echo ${maxval} pgmnoise -maxval=${maxval} -randomseed=1 -plain 16 1 | tr '\n' ' ' @@ -26,7 +26,8 @@ echo echo "Test 4." # Check for maxval violation -for maxval in `seq 16` 30 31 32 254 255 256 65534 65535 +for maxval in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 \ + 30 31 32 254 255 256 65534 65535 do echo -n ${maxval} " " pgmnoise -maxval=${maxval} -randomseed=1 -plain ${maxval} 10 | \ @@ -42,20 +43,29 @@ for xysize in "1 10000" "100 100" "250 40" "1000 10" tmpdir=${tmpdir:-/tmp} -messages=${tmpdir}/messages +outfile=${tmpdir}/out echo "Test 6." -echo "First column should be 2^n - 1" +echo "First column should be 2^n - 1. Last column should be 'pool'." # The "pool" method of generating pixvals is used iff maxval is # a power of 2 minus 1: 1, 3, 7, 15, 31 ... -for maxval in `seq 35; seq 60 69; seq 120 129; seq 250 259` - do - pgmnoise -maxval=${maxval} -randomseed=1 -verbose 1 1 > /dev/null \ - 2> ${messages} - awk -v mval=${maxval} '/method/ && /pool/ { print mval, $0 }' ${messages} - done - rm ${messages} + +for maxval in \ + 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 60 61 62 63 64 65 \ + 127 255 511 1023 65535 \ + 129 142 186 219 677 1068 1788 1820 2067 2154 2301 2317 \ + 5180 5321 5596 6304 7565 9525 \ + 10501 14178 25797 27451 28653 + do + pgmnoise -maxval=${maxval} -plain -randomseed=1 -verbose 1 1 \ + > /dev/null 2> ${outfile} + awk -v mval=${maxval} '/method/ && /pool/ { print mval, $0 }' ${outfile} + rm ${outfile} + done echo "Test Invalid" diff --git a/test/pgmtopgm.ok b/test/pgmtopgm.ok index 53c25a44..38cfd268 100644 --- a/test/pgmtopgm.ok +++ b/test/pgmtopgm.ok @@ -1 +1,11 @@ -729348909 237 +Test 1. Should print two identical PGM images +P2 +10 1 +255 +0 0 0 0 0 0 0 0 0 0 +P2 +10 1 +255 +0 0 0 0 0 0 0 0 0 0 +Test 2. Should print 2582999797 3376 +2582999797 3376 diff --git a/test/pgmtopgm.test b/test/pgmtopgm.test index e919fdac..d81260d8 100755 --- a/test/pgmtopgm.test +++ b/test/pgmtopgm.test @@ -1,6 +1,12 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmtopgm -# Also requires: +# Also requires: pgmmake +echo "Test 1. Should print two identical PGM images" -pgmtopgm < testgrid.pbm | cksum +pgmmake -plain 0 10 1 +pgmmake 0 10 1 | pgmtopgm -plain + +echo "Test 2. Should print 2582999797 3376" + +pgmtopgm < maze.pbm | cksum diff --git a/test/pnmcrop1.ok b/test/pnmcrop1.ok index d02d14b3..d979d2db 100644 --- a/test/pnmcrop1.ok +++ b/test/pnmcrop1.ok @@ -1,103 +1,82 @@ Test 1 -test.pbm - -0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 --white -0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 --black -0 0 0 -2 28 30 rgb-1:0/0/0 0.000000 --sides -0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 --top -0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 --bottom -0 0 0 0 28 32 rgb-1:1/1/1 0.000000 --left -0 0 0 0 28 32 rgb-1:1/1/1 0.000000 --right -0 0 0 0 28 32 rgb-1:1/1/1 0.000000 --top -bottom -0 0 -7 0 28 25 rgb-1:1/1/1 0.000000 --bottom -bg-corner=bottomright -0 0 0 -2 28 30 rgb-1:0/0/0 0.000000 --right -bg-corner=bottomright -0 0 0 0 28 32 rgb-1:0/0/0 0.000000 --bg-color=white -0 0 0 0 28 32 rgb-1:1/1/1 0.000000 --bg-color=black -0 0 0 -2 28 30 rgb-1:0/0/0 0.000000 --bg-color=red -0 0 0 0 28 32 rgb-1:0/0/0 0.000000 -test.ppm - +file: maze.pbm option: +0 0 -7 0 71 68 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -white +0 0 -7 0 71 68 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -black +0 0 0 -2 71 73 rgb-1:0/0/0 0.000000 +file: maze.pbm option: -sides +0 0 -7 0 71 68 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -top +0 0 -7 0 71 68 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -bottom +0 0 0 0 71 75 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -left +0 0 0 0 71 75 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -right +0 0 0 0 71 75 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -top -bottom +0 0 -7 0 71 68 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -bottom -bg-corner=bottomright +0 0 0 -2 71 73 rgb-1:0/0/0 0.000000 +file: maze.pbm option: -right -bg-corner=bottomright +0 0 0 0 71 75 rgb-1:0/0/0 0.000000 +file: maze.pbm option: -bg-color=white +0 0 0 0 71 75 rgb-1:1/1/1 0.000000 +file: maze.pbm option: -bg-color=black +0 0 0 -2 71 73 rgb-1:0/0/0 0.000000 +file: maze.pbm option: -bg-color=red +0 0 0 0 71 75 rgb-1:0/0/0 0.000000 +file: rose.ppm option: 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --white +file: rose.ppm option: -white -6 0 0 0 244 161 rgb-255:255/255/255 0.000000 --black +file: rose.ppm option: -black 0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 --sides +file: rose.ppm option: -sides -6 0 0 0 244 161 rgb-255:255/255/255 0.000000 --top +file: rose.ppm option: -top 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --bottom +file: rose.ppm option: -bottom 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --left +file: rose.ppm option: -left 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --right +file: rose.ppm option: -right 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --top -bottom +file: rose.ppm option: -top -bottom 0 0 0 0 250 161 rgb-255:127/127/127 0.000000 --bottom -bg-corner=bottomright +file: rose.ppm option: -bottom -bg-corner=bottomright 0 0 0 0 250 161 rgb-255:0/0/0 0.000000 --right -bg-corner=bottomright +file: rose.ppm option: -right -bg-corner=bottomright 0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 --bg-color=white +file: rose.ppm option: -bg-color=white -6 0 0 0 244 161 rgb-255:255/255/255 0.000000 --bg-color=black +file: rose.ppm option: -bg-color=black 0 -11 0 0 239 161 rgb-255:0/0/0 0.000000 --bg-color=red +file: rose.ppm option: -bg-color=red 0 0 0 0 250 161 rgb-255:255/0/0 0.000000 -Test 2 -test.pbm - -3130931737 109 -3130931737 109 --white -3130931737 109 -3130931737 109 --top -3130931737 109 -3130931737 109 -test.ppm - -1435955776 120765 -1435955776 120765 --white -638507845 117867 -638507845 117867 --top -1435955776 120765 -1435955776 120765 +Test 2. Should print 0 six times +file: maze.pbm option: +0 +file: maze.pbm option: -white +0 +file: maze.pbm option: -top +0 +file: rose.ppm option: +0 +file: rose.ppm option: -white +0 +file: rose.ppm option: -top +0 Test Invalid --reportfull -reportsize Expected failure: -reportfull -reportsize 1 --reportfull -borderfile=testgrid.pbm Expected failure: -reportfull -borderfile=testgrid.pbm 1 --reportsize -borderfile=testgrid.pbm Expected failure: -reportsize -borderfile=testgrid.pbm 1 --black -white Expected failure: -black -white 1 --black -sides Expected failure: -black -sides 1 --white -bg-color=red Expected failure: -white -bg-color=red 1 --white -bg-corner=topleft Expected failure: -white -bg-corner=topleft 1 --white -bg-corner=top Expected failure: -white -bg-corner=top 1 --blank-image=pasturize Expected failure: -blank-image=pasturize 1 --bg-color=black -closeness=-1 Expected failure: -bg-color=black -closeness=-1 1 --bg-color=black -closeness=101 Expected failure: -bg-color=black -closeness=101 1 diff --git a/test/pnmcrop1.test b/test/pnmcrop1.test index 936cbd95..00d5ee80 100755 --- a/test/pnmcrop1.test +++ b/test/pnmcrop1.test @@ -1,13 +1,13 @@ -#! /bin/bash + #! /bin/sh # This script tests: pnmcrop # Also requires: pnmpad pnmmargin pamcut tmpdir=${tmpdir:-/tmp} -test_pbm=${tmpdir}/test.pbm -test_ppm=${tmpdir}/test.ppm +test_pbm=${tmpdir}/maze.pbm +test_ppm=${tmpdir}/rose.ppm -pnmmargin -white 7 testgrid.pbm | pnmpad -black -bottom=2 > ${test_pbm} +pnmmargin -white 7 maze.pbm | pnmpad -black -bottom=2 > ${test_pbm} pnmmargin -white 6 testimg.ppm | pnmpad -black -right=11 > ${test_ppm} #Test 1 @@ -15,36 +15,41 @@ echo Test 1 for input_file in ${test_pbm} ${test_ppm} do - echo `basename ${input_file}` + bfile=`basename ${input_file}` for option in "" "-white" "-black" "-sides" \ "-top" "-bottom" "-left" "-right" "-top -bottom" \ "-bottom -bg-corner=bottomright" \ "-right -bg-corner=bottomright" \ "-bg-color=white" "-bg-color=black" "-bg-color=red" do - echo ${option} + echo "file: ${bfile} option: ${option}" pnmcrop -reportfull ${option} ${input_file} || echo fail done done #Test 2 -echo Test 2 +echo "Test 2. Should print 0 six times" + +out_pnm=${tmpdir}/out.pnm for input_file in ${test_pbm} ${test_ppm} do - echo `basename ${input_file}` + bfile=`basename ${input_file}` for option in "" "-white" "-top" do - echo ${option} + echo file: ${bfile} option: ${option} # Normal crop operation - pnmcrop ${option} ${input_file} | cksum + pnmcrop ${option} ${input_file} > ${out_pnm} # Compute edge extents with pnmcrop; let pamcut do the actual cropping pamcut ${input_file} `pnmcrop -reportsize ${option} ${input_file} | \ awk 'NF==6 && NR==1 && \ $1<=0 && $2<=0 && $3<=0 && $4<=0 && $5>=0 && $6>=0 \ - { printf("-cropleft=%d -cropright=%d ", -$1, -$2); - printf("-croptop=%d -cropbottom=%d", -$3, -$4) }' ` | cksum + { printf("-cropleft=%d -cropright=%d ", -$1, -$2); + printf("-croptop=%d -cropbottom=%d ", -$3, -$4) }' ` | \ + cmp -s - ${out_pnm} + echo $? + rm ${out_pnm} done done @@ -72,7 +77,6 @@ for option in "-reportfull -reportsize" \ "-bg-color=black -closeness=-1" \ "-bg-color=black -closeness=101" do - echo ${option} pnmcrop -reportfull ${option} testgrid.pbm > ${test_out} || \ echo -n "Expected failure: " ${option} test -s ${test_out}; echo " "$? diff --git a/test/pnmcrop2.test b/test/pnmcrop2.test index d6c83c73..3d402a57 100755 --- a/test/pnmcrop2.test +++ b/test/pnmcrop2.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmcrop # Also requires: @@ -44,7 +44,7 @@ for corner in topleft topright bottomleft bottomright echo Test 3 -for closeness in `seq 0 6` +for closeness in 0 1 2 3 4 5 6 # for closeness in `seq 0 6` do echo ${closeness} pnmcrop -reportfull -bg-corner=topleft -closeness=${closeness} ${test_pgm} \ diff --git a/test/pnmcrop3.ok b/test/pnmcrop3.ok index 6824143a..5a86139c 100644 --- a/test/pnmcrop3.ok +++ b/test/pnmcrop3.ok @@ -86,5 +86,5 @@ P1 1111111111111 -3 -1 -1 -1 9 13 544280424 101484 -4294967295 0 -4294967295 0 +Expected failure 1 1 +Expected failure 2 1 diff --git a/test/pnmcrop3.test b/test/pnmcrop3.test index c46fd7ea..04cf6f52 100755 --- a/test/pnmcrop3.test +++ b/test/pnmcrop3.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pnmcrop # Also requires: pnmpad pamfile pgmmake @@ -16,7 +16,7 @@ pnmpad -top=11 -bottom=1 -left=21 -right=9 testimg.ppm > ${test_ppm} pnmpad -top=4 -bottom=4 -left=8 -right=5 testgrid.pbm > ${border_pbm} pnmpad -top=7 -bottom=5 -left=30 -right=0 testimg.ppm > ${border_ppm} -pgmmake 0.5 `pamfile -size ${test_pbm}` > ${gray_pgm} +pgmmake 0.5 $(pamfile -size ${test_pbm}) > ${gray_pgm} # Test 1 echo Test 1 @@ -38,7 +38,7 @@ echo Test 2 for input_file in ${test_pbm} ${test_ppm} do echo `basename ${input_file}` - for margin in `seq 0 5` + for margin in 0 1 2 3 4 5 # for margin in `seq 0 5` do pnmcrop -reportsize -margin=${margin} ${input_file} || echo fail2 done @@ -59,13 +59,22 @@ pnmcrop -borderfile=${border_pbm} ${test_pbm} | pnmcrop -black -reportsize pnmcrop -borderfile=${border_ppm} ${test_ppm} | cksum -# The following two cases are expected to fai +test_out=${tmpdir}/test_out +# The following two cases are expected to fail + +echo "Border file size mismatch" 1>&2 echo "Error messages should appear below the line." 1>&2 echo "--------------------------------------------" 1>&2 -pnmcrop -borderfile=${border_ppm} ${test_pbm} | cksum -pnmcrop -borderfile=${border_pbm} ${test_ppm} | cksum +pnmcrop -borderfile=${border_ppm} ${test_pbm} > ${test_out} || \ + echo -n "Expected failure 1"; + test -s ${test_out}; echo " "$? + rm ${test_out} +pnmcrop -borderfile=${border_pbm} ${test_ppm} > ${test_out} || \ + echo -n "Expected failure 2"; + test -s ${test_out}; echo " "$? + rm ${test_out} -rm ${test_pbm} ${test_ppm} ${border_pbm} ${border_ppm} ${gray_pgm} \ No newline at end of file +rm ${test_pbm} ${test_ppm} ${border_pbm} ${border_ppm} ${gray_pgm} diff --git a/test/pnmtopnm-plain.ok b/test/pnmtopnm-plain.ok index 02d99f1e..640f0964 100644 --- a/test/pnmtopnm-plain.ok +++ b/test/pnmtopnm-plain.ok @@ -1,48 +1,51 @@ +Test. Should print three identical images in plain format, twice each P1 -14 16 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 -10101010101010 -11111111111111 +5 5 +01010 +10101 +01010 +10101 +01010 +P1 +5 5 +01010 +10101 +01010 +10101 +01010 +P2 +8 8 +7 +0 0 1 1 2 2 3 3 +0 1 1 2 2 3 3 4 +1 1 2 2 3 3 4 4 +1 2 2 3 3 4 4 5 +2 2 3 3 4 4 5 5 +2 3 3 4 4 5 5 6 +3 3 4 4 5 5 6 6 +3 4 4 5 5 6 6 7 P2 -14 16 +8 8 +7 +0 0 1 1 2 2 3 3 +0 1 1 2 2 3 3 4 +1 1 2 2 3 3 4 4 +1 2 2 3 3 4 4 5 +2 2 3 3 4 4 5 5 +2 3 3 4 4 5 5 6 +3 3 4 4 5 5 6 6 +3 4 4 5 5 6 6 7 +P3 +4 4 255 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 255 0 255 0 255 0 255 0 255 0 255 0 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 31 255 0 31 255 63 0 0 0 31 255 +0 31 255 0 31 255 0 31 255 63 0 0 +0 31 255 63 0 0 63 0 0 63 0 0 +63 0 0 0 31 255 63 0 0 63 0 0 P3 -14 16 +4 4 255 -0 0 0 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 -0 0 0 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 -0 0 0 255 255 255 0 0 0 255 255 255 0 0 0 255 255 255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 31 255 0 31 255 63 0 0 0 31 255 +0 31 255 0 31 255 0 31 255 63 0 0 +0 31 255 63 0 0 63 0 0 63 0 0 +63 0 0 0 31 255 63 0 0 63 0 0 diff --git a/test/pnmtopnm-plain.test b/test/pnmtopnm-plain.test index 5b7e4b48..87b74064 100755 --- a/test/pnmtopnm-plain.test +++ b/test/pnmtopnm-plain.test @@ -1,10 +1,14 @@ -#! /bin/bash +#! /bin/sh # This script tests: pamtopnm -# Also requires: pgmtopgm ppmtoppm +# Also requires: pbmmake pgmramp ppmpat -pamtopnm -plain testgrid.pbm +echo "Test. Should print three identical images in plain format, twice each" -pgmtopgm < testgrid.pbm | pamtopnm -plain +pbmmake -g 5 5 -plain +pbmmake -g 5 5 | pamtopnm -plain -ppmtoppm < testgrid.pbm | pamtopnm -plain | \ - head -n11 +pgmramp -maxval 7 -diag 8 8 -plain +pgmramp -maxval 7 -diag 8 8 | pamtopnm -plain + +ppmpat -g2 -color=rgb:00/1f/ff,rgb:3f/00/00 -mesh 4 4 -plain +ppmpat -g2 -color=rgb:00/1f/ff,rgb:3f/00/00 -mesh 4 4 | pamtopnm -plain diff --git a/test/ppmshift.ok b/test/ppmshift.ok index e18de8f0..735ac445 100755 --- a/test/ppmshift.ok +++ b/test/ppmshift.ok @@ -2,13 +2,22 @@ Test 1. Should print: 3705777303 101484 3705777303 101484 Test 2. Should print: 202790723 685 202790723 685 -Test 3. Should print: 0 : 0 -0 : 0 -Test 4. (15) Should print: 0 : 0 -0 : 0 -Test 4. (16) Should print: 0 : 0 -0 : 0 -Test 4. (20) Should print: 0 : 0 -0 : 0 -Test 4. (1000) Should print: 0 : 0 -0 : 0 +Test 3. Should print: 0 0 : 0 +0 0 : 0 +Test 4. Should print: 0 0 : 0 +0 0 : 0 +Test 5. (1) Should print: 1 twice +1 +1 +Test 5. (15) Should print: 1 twice +1 +1 +Test 5. (16) Should print: 1 twice +1 +1 +Test 5. (20) Should print: 1 twice +1 +1 +Test 5. (1000) Should print: 1 twice +1 +1 diff --git a/test/ppmshift.test b/test/ppmshift.test index cd086d68..fff193b3 100755 --- a/test/ppmshift.test +++ b/test/ppmshift.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: ppmshift -# Also requires: +# Also requires: pgmtoppm echo "Test 1. Should print: 3705777303 101484" ppmshift -seed=1 10 testimg.ppm | cksum @@ -8,20 +8,35 @@ ppmshift -seed=1 10 testimg.ppm | cksum echo "Test 2. Should print: 202790723 685" ppmshift -seed=1 1 testgrid.pbm | cksum -echo "Test 3. Should print: 0 : 0" -ppmshift -seed=1 0 testimg.ppm | cmp -s - testimg.ppm | \ +echo "Test 3. Should print: 0 0 : 0" +ppmshift -seed=1 0 testimg.ppm | cmp -s - testimg.ppm echo ${PIPESTATUS[@]} ":" $? tmpdir=${tmpdir:-/tmp} -test_pbm=${tmpdir}/test.pbm +test0_ppm=${tmpdir}/test0.ppm +test14_ppm=${tmpdir}/test14.ppm -ppmshift -seed=2 14 testgrid.pbm > ${test_pbm} +pgmtoppm < maze.pbm > ${test0_ppm} -for i in 15 16 20 1000 - do - echo "Test 4. ("$i") Should print: 0 : 0" - ppmshift -seed=2 $i testgrid.pbm > ${test_pbm} | cmp -s - testgrid.ppm | \ +echo "Test 4. Should print: 0 0 : 0" + ppmshift -seed=2 0 maze.pbm | cmp -s - ${test0_ppm} echo ${PIPESTATUS[@]} ":" $? + +ppmshift -seed=2 14 maze.pbm > ${test14_ppm} + +for i in 1 15 16 20 1000 + do + echo "Test 5. ("$i") Should print: 1 twice" + ppmshift -seed=2 $i maze.pbm | cmp -s - ${test0_ppm} + echo $? + ppmshift -seed=2 $i maze.pbm | cmp -s - ${test14_ppm} + echo $? done -rm ${test_pbm} \ No newline at end of file +# In Test 5 the image files are not supposed to match. +# When cmp finds a difference, it may terminate and stop reading input from +# the pipe at that point. This may cause a "broken pipe" exception; however +# this does not always happen. The broken pipe shows up as a non-zero value +# for ${PIPESTATUS[0]}. + +rm ${test0_ppm} ${test14_ppm} diff --git a/test/ppmspread.ok b/test/ppmspread.ok index 7d44ab8e..40f44465 100755 --- a/test/ppmspread.ok +++ b/test/ppmspread.ok @@ -1,6 +1,12 @@ -Test 1. Should print 639729144 101484 +Test 1. +stdin: PPM RAW 227 149 3 255 RGB +stdin: PPM RAW 227 149 3 255 RGB +Test 2. +57 59 +57 59 +Test 3. Should print 281226646 481 +281226646 481 +Test 4. Should print 639729144 101484 639729144 101484 -Test 2. Should print 3278353642 685 +Test 5. Should print 3278353642 685 3278353642 685 -Test 3. Should print 2425386270 41 -2425386270 41 diff --git a/test/ppmspread.test b/test/ppmspread.test index 871f7438..d7e0fb37 100755 --- a/test/ppmspread.test +++ b/test/ppmspread.test @@ -1,12 +1,28 @@ -#! /bin/bash +#! /bin/sh # This script tests: ppmspread -# Also requires: ppmtopgm pgmtopbm +# Also requires: pamfile ppmtopgm pgmtopbm -echo "Test 1. Should print 639729144 101484" +# Input/output size does not change + +echo "Test 1." +cat testimg.ppm | pamfile -machine +ppmspread -randomseed=100 20 testimg.ppm | pamfile -machine + +echo "Test 2." +pamfile -size maze.pbm +ppmspread -randomseed=100 20 maze.pbm | pamfile -size + +# No change when spread distance value is 0 + +echo "Test 3. Should print 281226646 481" +ppmspread -randomseed=1 0 maze.pbm | ppmtopgm | pgmtopbm | cksum + +# The following tests will fail when changes are made to the random +# number generator + +echo "Test 4. Should print 639729144 101484" ppmspread -randomseed=1 10 testimg.ppm | cksum -echo "Test 2. Should print 3278353642 685" +echo "Test 5. Should print 3278353642 685" ppmspread -randomseed=1 1 testgrid.pbm | cksum -echo "Test 3. Should print 2425386270 41" -ppmspread -randomseed=1 0 testgrid.pbm | ppmtopgm | pgmtopbm | cksum diff --git a/test/sunicon-roundtrip.test b/test/sunicon-roundtrip.test index c5b85909..38513ea8 100755 --- a/test/sunicon-roundtrip.test +++ b/test/sunicon-roundtrip.test @@ -1,27 +1,26 @@ -#! /bin/bash +#! /bin/sh # This script tests: pbmtosunicon sunicontopnm -# Also requires: pamcut pnmpad +# Also requires: pbmnoise -# Width of Sun icons are multiples of 8. - -#imgsize=$(pamfile -size maze.pbm | awk '{print "-width="$1, "-height="$2}') +# Width of a Sun icon is always a multiple of 8. tmpdir=${tmpdir:-/tmp} -maze16_pbm=${tmpdir}/maze16.pbm -maze32_pbm=${tmpdir}/maze32.pbm -maze64_pbm=${tmpdir}/maze64.pbm - -pamcut -top=0 -left=0 -width=16 -height=16 maze.pbm > ${maze16_pbm} -pamcut -top=0 -left=0 -width=32 -height=32 maze.pbm > ${maze32_pbm} -pnmpad -width=64 -height=64 maze.pbm > ${maze64_pbm} +noise16_pbm=${tmpdir}/noise16.pbm +noise32_pbm=${tmpdir}/noise32.pbm +noise64_pbm=${tmpdir}/noise64.pbm echo "Test. Should print 0 three times" -pbmtosunicon ${maze16_pbm} | sunicontopnm | cmp -s - ${maze16_pbm} -echo $? -pbmtosunicon ${maze32_pbm} | sunicontopnm | cmp -s - ${maze32_pbm} -echo $? -pbmtosunicon ${maze64_pbm} | sunicontopnm | cmp -s - ${maze64_pbm} -echo $? +pbmnoise -randomseed=1 16 16 > ${noise16_pbm} && \ + pbmtosunicon ${noise16_pbm} | sunicontopnm | cmp -s - ${noise16_pbm} + echo $? + +pbmnoise -randomseed=1 32 32 > ${noise32_pbm} && \ + pbmtosunicon ${noise32_pbm} | sunicontopnm | cmp -s - ${noise32_pbm} + echo $? + +pbmnoise -randomseed=1 64 64 > ${noise64_pbm} && \ + pbmtosunicon ${noise64_pbm} | sunicontopnm | cmp -s - ${noise64_pbm} + echo $? -rm ${maze16_pbm} ${maze32_pbm} ${maze64_pbm} \ No newline at end of file +rm ${noise16_pbm} ${noise32_pbm} ${noise64_pbm} \ No newline at end of file diff --git a/test/symmetry.ok b/test/symmetry.ok index a5945014..111f09cf 100644 --- a/test/symmetry.ok +++ b/test/symmetry.ok @@ -1,5 +1,8 @@ +Test 1. ok +Test 2. ok +Test 3. Should print ok 7 times ok ok ok @@ -7,7 +10,9 @@ ok ok ok ok +Test 4. ok +Test 5. Should print ok 7 times. ok ok ok @@ -15,4 +20,5 @@ ok ok ok ok +Test 6. ok diff --git a/test/symmetry.test b/test/symmetry.test index 52ba6388..3c495778 100755 --- a/test/symmetry.test +++ b/test/symmetry.test @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/sh # This script tests: pgmramp pamgauss pgmkernel pbmmake pbmpscale # Also requires: pamflip @@ -25,7 +25,7 @@ tmpdir=${tmpdir:-/tmp} -# Test 1. +echo "Test 1." rect_pgm=${tmpdir}/rect.pgm pgmramp -rect 31 31 > ${rect_pgm} @@ -37,7 +37,8 @@ pgmramp -rect 31 31 > ${rect_pgm} rm ${rect_pgm} -# Test 2. + +echo "Test 2." circle_pgm=${tmpdir}/circle.pgm pgmramp -ell 63 63 > ${circle_pgm} @@ -48,7 +49,8 @@ pgmramp -ell 63 63 > ${circle_pgm} rm ${circle_pgm} -# Test 3. Should print "ok" 7 times + +echo "Test 3. Should print ok 7 times" gauss_pgm=${tmpdir}/gauss.pgm for size in 3 4 5 8 13 21 25 do @@ -63,7 +65,7 @@ rm ${gauss_pgm} done -# Test 4. +echo "Test 4." kernel_pgm=${tmpdir}/kernel.pgm pgmkernel 15 15 > ${kernel_pgm} @@ -74,12 +76,12 @@ pgmkernel 15 15 > ${kernel_pgm} rm ${kernel_pgm} -# Test 5. -# Should print "ok" 7 times. + +echo "Test 5. Should print ok 7 times." pscale_pbm=${tmpdir}/pscale.pbm -for size in `seq 1 7` -do -pbmmake -g 5 5 | pbmpscale $size > ${pscale_pbm} +for size in 1 2 3 4 5 6 7 # for size in `seq 7` + do + pbmmake -g 5 5 | pbmpscale ${size} > ${pscale_pbm} ( for op in -null -tb -lr -r90 do pamflip $op ${pscale_pbm} | cksum @@ -89,7 +91,8 @@ pbmmake -g 5 5 | pbmpscale $size > ${pscale_pbm} rm ${pscale_pbm} done -# Test 6. + +echo "Test 6." ell_pgm=${tmpdir}/ell.pgm pgmramp -ell 101 33 > ${ell_pgm} |