diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-06-30 19:38:50 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-06-30 19:38:50 +0000 |
commit | ffa495eb1f02bfc0e5f83a17e917e8709ec41356 (patch) | |
tree | 509aee1a7696e401ad791c39f9a4fab440b180c9 /test/pamarith.test | |
parent | aa813fa24371ead6a50fed6080fe82f8ccc7f491 (diff) | |
download | netpbm-mirror-ffa495eb1f02bfc0e5f83a17e917e8709ec41356.tar.gz netpbm-mirror-ffa495eb1f02bfc0e5f83a17e917e8709ec41356.tar.xz netpbm-mirror-ffa495eb1f02bfc0e5f83a17e917e8709ec41356.zip |
Release 10.95.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4119 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/pamarith.test')
-rwxr-xr-x | test/pamarith.test | 254 |
1 files changed, 159 insertions, 95 deletions
diff --git a/test/pamarith.test b/test/pamarith.test index a4c98859..b7fe3212 100755 --- a/test/pamarith.test +++ b/test/pamarith.test @@ -1,7 +1,7 @@ #! /bin/bash # This script tests: pamarith -# Also requires: pamtopnm rgb3toppm pamenlarge pnmcat pamseq pbmmake pgmmake -# Also requires: ppmpat pamchannel +# Also requires: pamtopnm rgb3toppm pamenlarge pnmcat pamseq pbmmake pgmmake +# Also requires: ppmpat pamchannel tmpdir=${tmpdir:-/tmp} input1_pgm=${tmpdir}/input1.pgm @@ -15,8 +15,8 @@ echo "Test 1" pamseq 1 15 | pamtopnm -assume > ${input1_pgm} pgmmake -maxval 15 0.15 16 1 > ${input2_pgm} -rgb3toppm ${input1_pgm} ${input1_pgm} ${input1_pgm} > ${input1_ppm} -rgb3toppm ${input2_pgm} ${input2_pgm} ${input2_pgm} > ${input2_ppm} +rgb3toppm ${input1_pgm} ${input1_pgm} ${input1_pgm} > ${input1_ppm} +rgb3toppm ${input2_pgm} ${input2_pgm} ${input2_pgm} > ${input2_ppm} pnmcat -tb -plain ${input1_pgm} ${input2_pgm} @@ -93,7 +93,7 @@ echo "cksum is 2425386270 41 or 2921940274 59" for image in testgrid.pbm ${input1_ppm} do echo "input image" - cat ${image} | cksum + cat ${image} | cksum for fn in "-minimum" "-maximum" "-mean" "-and" "-or" do echo ${fn} @@ -123,105 +123,136 @@ echo "-----------------------------------------------------------" 1>&2 echo "Test Invalid" -output_ppm=${tmpdir}/output.ppm +test_out=${tmpdir}/test_out # multiple functions -pamarith -add -subtract testimg.ppm testimg.ppm > ${output_ppm} || \ +pamarith -add -subtract testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 1" - test -s ${output_ppm}; echo " "$? -pamarith -multiply -divide testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -multiply -divide testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 2" - test -s ${output_ppm}; echo " "$? -pamarith -difference -minimum testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -difference -minimum testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 3" - test -s ${output_ppm}; echo " "$? -pamarith -maximum -mean testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -maximum -mean testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 4" - test -s ${output_ppm}; echo " "$? -pamarith -compare -and testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -compare -and testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 5" - test -s ${output_ppm}; echo " "$? -pamarith -compare -equal testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -compare -equal testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 6" - test -s ${output_ppm}; echo " "$? -pamarith -or -nand testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -or -nand testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 7" - test -s ${output_ppm}; echo " "$? -pamarith -nor -xor testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -nor -xor testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 8" - test -s ${output_ppm}; echo " "$? -pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 9" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} # -add does not take a value -pamarith -add=1 testimg.ppm testimg.ppm > ${output_ppm} || \ +pamarith -add=1 testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 10" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} # No function -pamarith -plain testimg.ppm testimg.ppm > ${output_ppm} || \ +pamarith -plain testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 11" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} -pamarith testimg.ppm testimg.ppm > ${output_ppm} || \ +pamarith testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 12" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} # Just one input image file -pamarith -add testimg.ppm > ${output_ppm} || \ +pamarith -add testimg.ppm > ${test_out} || \ echo -n "Expected failure 13" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} # No input image file -pamarith -add > ${output_ppm} || \ +pamarith -add > ${test_out} || \ echo -n "Expected failure 14" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} # Input images with different depth (number of planes) pamchannel -infile testimg.ppm 0 1 | \ - pamarith -add testimg.ppm - > ${output_ppm} || \ + pamarith -add testimg.ppm - > ${test_out} || \ echo -n "Expected failure 15" - test -s ${output_ppm}; echo " "$? - + test -s ${test_out}; echo " "$? + rm -f ${test_out} # Input images with different x/y dimensions -pamarith -add testimg.ppm testgrid.pbm > ${output_ppm} || \ +pamarith -add testimg.ppm testgrid.pbm > ${test_out} || \ echo -n "Expected failure 16" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} pamenlarge -xscale=2 testgrid.pbm | \ - pamarith -add testgrid.pbm - > ${output_ppm} || \ + pamarith -add testgrid.pbm - > ${test_out} || \ echo -n "Expected failure 17" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} pamenlarge -yscale=3 testgrid.pbm | \ - pamarith -add testgrid.pbm - > ${output_ppm} || \ + pamarith -add testgrid.pbm - > ${test_out} || \ echo -n "Expected failure 18" - test -s ${output_ppm}; echo " "$? - + test -s ${test_out}; echo " "$? + rm -f ${test_out} # Invalid usage of -closeness -pamarith -equal -closeness=100.1 testgrid.pbm > ${output_ppm} || \ +pamarith -equal -closeness=100.1 testgrid.pbm > ${test_out} || \ echo -n "Expected failure 19" - test -s ${output_ppm}; echo " "$? -pamarith -equal -closeness=-10 testgrid.pbm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -equal -closeness=-10 testgrid.pbm > ${test_out} || \ echo -n "Expected failure 20" - test -s ${output_ppm}; echo " "$? -pamarith -closeness -equal testgrid.pbm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -closeness -equal testgrid.pbm > ${test_out} || \ echo -n "Expected failure 21" - test -s ${output_ppm}; echo " "$? -pamarith -compare -closeness=10 testgrid.pbm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -compare -closeness=10 testgrid.pbm > ${test_out} || \ echo -n "Expected failure 22" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} # Bit string functions # Create PGM test input @@ -230,52 +261,73 @@ input3_pgm=${tmpdir}/input3.pgm input4_pgm=${tmpdir}/input4.pgm input5_pgm=${tmpdir}/input5.pgm -pgmmake -maxval=4095 1.0 3 1 > ${input3_pgm} +pgmmake -maxval=4095 1.0 3 1 > ${input3_pgm} pgmmake -maxval=4096 1.0 3 1 > ${input4_pgm} pgmmake -maxval=8191 1.0 3 1 > ${input5_pgm} # Bit string functions - Maxval must match -pamarith -and ${input3_pgm} ${input5_pgm} > ${output_ppm} || \ +pamarith -and ${input3_pgm} ${input5_pgm} > ${test_out} || \ echo -n "Expected failure 23" - test -s ${output_ppm}; echo " "$? -pamarith -or ${input3_pgm} ${input5_pgm} > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -or ${input3_pgm} ${input5_pgm} > ${test_out} || \ echo -n "Expected failure 24" - test -s ${output_ppm}; echo " "$? -pamarith -nand ${input3_pgm} ${input5_pgm} > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -nand ${input3_pgm} ${input5_pgm} > ${test_out} || \ echo -n "Expected failure 25" - test -s ${output_ppm}; echo " "$? -pamarith -nor ${input3_pgm} ${input5_pgm} > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -nor ${input3_pgm} ${input5_pgm} > ${test_out} || \ echo -n "Expected failure 26" - test -s ${output_ppm}; echo " "$? -pamarith -xor ${input3_pgm} ${input5_pgm} > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -xor ${input3_pgm} ${input5_pgm} > ${test_out} || \ echo -n "Expected failure 27" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} # Bit string functions - Maxval must be 2^n -1 -pamarith -and ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ +pamarith -and ${input4_pgm} ${input4_pgm} > ${test_out} || \ echo -n "Expected failure 28" - test -s ${output_ppm}; echo " "$? -pamarith -or ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -or ${input4_pgm} ${input4_pgm} > ${test_out} || \ echo -n "Expected failure 29" - test -s ${output_ppm}; echo " "$? -pamarith -nand ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -nand ${input4_pgm} ${input4_pgm} > ${test_out} || \ echo -n "Expected failure 30" - test -s ${output_ppm}; echo " "$? -pamarith -nor ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -nor ${input4_pgm} ${input4_pgm} > ${test_out} || \ echo -n "Expected failure 31" - test -s ${output_ppm}; echo " "$? -pamarith -xor ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -xor ${input4_pgm} ${input4_pgm} > ${test_out} || \ echo -n "Expected failure 32" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} -pamarith -shiftleft ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ +pamarith -shiftleft ${input4_pgm} ${input4_pgm} > ${test_out} || \ echo -n "Expected failure 33" - test -s ${output_ppm}; echo " "$? -pamarith -shiftright ${input4_pgm} ${input4_pgm} > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -shiftright ${input4_pgm} ${input4_pgm} > ${test_out} || \ echo -n "Expected failure 34" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} rm ${input3_pgm} ${input4_pgm} ${input5_pgm} @@ -283,33 +335,45 @@ rm ${input3_pgm} ${input4_pgm} ${input5_pgm} # Only the functions that are commutative and associative allow # three or more inputs. -pamarith -subtract testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ +pamarith -subtract testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 35" - test -s ${output_ppm}; echo " "$? -pamarith -divide testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -divide testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 36" - test -s ${output_ppm}; echo " "$? -pamarith -compare testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -compare testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 37" - test -s ${output_ppm}; echo " "$? -pamarith -difference testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -difference testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 38" - test -s ${output_ppm}; echo " "$? -pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 39" - test -s ${output_ppm}; echo " "$? -pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \ + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm > ${test_out} || \ echo -n "Expected failure 40" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} # Currently -equal and -mean do not allow more than two input images. # These two cases should be removed once improvements are made. -pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm > ${output_ppm} || \ +pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm > ${test_out} || \ echo -n "Expected failure 41" - test -s ${output_ppm}; echo " "$? -pamarith -mean testgrid.pbm testgrid.pbm testgrid.pbm > ${output_ppm} || \ - echo -n "Expected failure 42" - test -s ${output_ppm}; echo " "$? + test -s ${test_out}; echo " "$? + rm -f ${test_out} -rm ${output_ppm} +pamarith -mean testgrid.pbm testgrid.pbm testgrid.pbm > ${test_out} || \ + echo -n "Expected failure 42" + test -s ${test_out}; echo " "$? + rm -f ${test_out} |