diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2014-02-02 01:48:57 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2014-02-02 01:48:57 +0000 |
commit | 2f0b278d8156fb9c829f1ac97db5b8f2aab58717 (patch) | |
tree | 2bbc810809a84ca46758859ab167e060b3f6d7bc | |
parent | babc41a25094d444c75c6345a3958d16293f85c1 (diff) | |
download | netpbm-mirror-2f0b278d8156fb9c829f1ac97db5b8f2aab58717.tar.gz netpbm-mirror-2f0b278d8156fb9c829f1ac97db5b8f2aab58717.tar.xz netpbm-mirror-2f0b278d8156fb9c829f1ac97db5b8f2aab58717.zip |
Add ability to run tests for a specific program; add ability to print messages when tests fail; new tests
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2119 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rwxr-xr-x | test/Execute-Tests | 20 | ||||
-rw-r--r-- | test/Test-Order | 5 | ||||
-rw-r--r-- | test/gif-roundtrip.ok | 7 | ||||
-rwxr-xr-x | test/gif-roundtrip.test | 21 | ||||
-rw-r--r-- | test/jbig-roundtrip.ok | 2 | ||||
-rwxr-xr-x | test/jbig-roundtrip.test | 14 | ||||
-rw-r--r-- | test/pamslice-roundtrip.ok | 4 | ||||
-rwxr-xr-x | test/pamslice-roundtrip.test | 59 | ||||
-rw-r--r-- | test/png-roundtrip.ok | 34 | ||||
-rwxr-xr-x | test/png-roundtrip.test | 46 | ||||
-rwxr-xr-x | test/ps-roundtrip.test | 5 | ||||
-rw-r--r-- | test/symmetry.ok | 12 | ||||
-rwxr-xr-x | test/symmetry.test | 95 | ||||
-rwxr-xr-x | test/tiff-roundtrip.test | 4 |
14 files changed, 308 insertions, 20 deletions
diff --git a/test/Execute-Tests b/test/Execute-Tests index 7a1a3793..68dd5581 100755 --- a/test/Execute-Tests +++ b/test/Execute-Tests @@ -118,12 +118,25 @@ export PATH=${srcdir}:$PATH # By default the tests are executed in the order described in the # file Test-Order. Copy this file from the source directory # to the work directory. +# +# The string "target" is a comma-separated list of target programs. +# When set only tests for programs in the list will be run. # # The --no-clobber version comes useful when the user wants a modified # (pared-down) version of Test-Order. -cp ${srcdir}/Test-Order ./Test-Order -#cp --no-clobber ${srcdir}/Test-Order ./Test-Order +if [ ! -z $target ] + then echo $target | sed 's/,/\n/g' | \ + sed 's/^/\${PBM_TESTPREFIX}/' | \ + grep -f - ${srcdir}/*.test -l | \ + while read i ; do echo ${i##*/} ; done | + grep -f - ${srcdir}/Test-Order > ./Test-Order ; + else + cp ${srcdir}/Test-Order ./Test-Order ; + #cp --no-clobber ${srcdir}/Test-Order ./Test-Order ; +fi + +#let array[5]=0 for t in `grep -v "^#" ./Test-Order | fgrep ".test"` do @@ -134,6 +147,7 @@ case $result in if [ $? -eq 0 ] then let result=0; rm ${t%.test}.out ; else let result=1; + grep "^##" ${srcdir}/$t # Print failure message. fi let testable=1 ;; 80) let result=4 ; let testable=0;; @@ -173,7 +187,7 @@ echo ================== for s in 0 1 2 3 4 5 do - if [[ ${array[${s}]} -gt 0 || s -eq 1 ]] + if [[ ${array[${s}]} -gt 0 || s -eq 1 || s -eq 5 ]] then echo ${status[${s}]} ${array[${s}]} fi done diff --git a/test/Test-Order b/test/Test-Order index 31cd5324..1444f814 100644 --- a/test/Test-Order +++ b/test/Test-Order @@ -67,6 +67,10 @@ pnmshear.test ppmmix.test +# Symmetry test + +symmetry.test + # Format converter tests pbmtog3.test @@ -104,6 +108,7 @@ gem-roundtrip.test gif-roundtrip.test gif-quant-roundtrip.test hdiff-roundtrip.test +jbig-roundtrip.test leaf-roundtrip.test mgr-roundtrip.test mrf-roundtrip.test diff --git a/test/gif-roundtrip.ok b/test/gif-roundtrip.ok index cf95bb37..ece7593c 100644 --- a/test/gif-roundtrip.ok +++ b/test/gif-roundtrip.ok @@ -1,4 +1,11 @@ 2871603838 33838 +2871603838 33838 +2871603838 33838 +2871603838 33838 1926073387 101484 2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 P1 4 1 0101 \ No newline at end of file diff --git a/test/gif-roundtrip.test b/test/gif-roundtrip.test index 709edbb6..574638ac 100755 --- a/test/gif-roundtrip.test +++ b/test/gif-roundtrip.test @@ -8,13 +8,22 @@ alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm" alias ppmtorgb3="${PBM_BINPREFIX}ppmtorgb3" alias rgb3toppm="${PBM_BINPREFIX}rgb3toppm" + alias pnminvert="${PBM_BINPREFIX}pnminvert" shopt -s expand_aliases # Test 1. Should produce 2871603838 33838 # which is the result of ppmtopgm testimg.ppm | cksum +# four times -ppmtopgm testimg.ppm | \ - pamtogif | giftopnm | cksum +ppmtopgm testimg.ppm | tee ${tmpdir}/testimg.pgm | pamtogif | giftopnm | cksum +pamtogif -interlace ${tmpdir}/testimg.pgm | giftopnm | cksum +pamtogif -sort ${tmpdir}/testimg.pgm | tee ${tmpdir}/testimg.gif | \ + giftopnm | cksum +echo "junk" >> ${tmpdir}/testimg.gif && \ + giftopnm -image=1 -quitearly ${tmpdir}/testimg.gif | cksum + +rm ${tmpdir}/testimg.pgm +rm ${tmpdir}/testimg.gif # Test 2. Break up input image into three monochrome planes, # maxval 255. Transform each plane to gif and back to pgm. @@ -34,8 +43,14 @@ pamtogif ${tmpdir}/testimg.blu | \ rm ${tmpdir}/testimg.{ppm,red,grn,blu} ${tmpdir}/out.{red,grn} -# Test 3. Should produce 2425386270 41 +# Test 3. Should produce 2425386270 41 five times. + pamtogif testgrid.pbm | giftopnm | cksum +pamtogif -nolzw testgrid.pbm | giftopnm | cksum +pamtogif -transparent=black testgrid.pbm | giftopnm | cksum +pamtogif -alpha=testgrid.pbm testgrid.pbm | giftopnm | cksum +pamtogif -transparent=white testgrid.pbm | giftopnm -alpha=- | \ + pnminvert | cksum # Test 4. # In this gif file the code length changes after the last image data. diff --git a/test/jbig-roundtrip.ok b/test/jbig-roundtrip.ok new file mode 100644 index 00000000..a951db19 --- /dev/null +++ b/test/jbig-roundtrip.ok @@ -0,0 +1,2 @@ +2425386270 41 +2871603838 33838 diff --git a/test/jbig-roundtrip.test b/test/jbig-roundtrip.test new file mode 100755 index 00000000..766148c6 --- /dev/null +++ b/test/jbig-roundtrip.test @@ -0,0 +1,14 @@ +#! /bin/bash +# This script tests: pnmtojbig jbigtopnm +# Also requires: ppmtopgm + + alias pnmtojbig="${PBM_TESTPREFIX}pnmtojbig" + alias jbigtopnm="${PBM_TESTPREFIX}jbigtopnm" + alias ppmtopgm="${PBM_BINPREFIX}ppmtopgm" + shopt -s expand_aliases + +# Test 1. Should print 2425386270 41 +pnmtojbig testgrid.pbm | jbigtopnm | cksum + +# Test 2. Should print 2871603838 33838 +ppmtopgm testimg.ppm | pnmtojbig | jbigtopnm | cksum \ No newline at end of file diff --git a/test/pamslice-roundtrip.ok b/test/pamslice-roundtrip.ok index f9fe0bb4..eae64745 100644 --- a/test/pamslice-roundtrip.ok +++ b/test/pamslice-roundtrip.ok @@ -1,2 +1,4 @@ 2425386270 41 -1926073387 101484 +914327477 4864 +914327477 4864 +914327477 4864 diff --git a/test/pamslice-roundtrip.test b/test/pamslice-roundtrip.test index 5dc74d4d..edec0d26 100755 --- a/test/pamslice-roundtrip.test +++ b/test/pamslice-roundtrip.test @@ -1,11 +1,15 @@ #! /bin/bash -# This script tests: pamslice -# Also requires: pnmtopnm pamtopnm +# This script tests: pamslice pamdeinterlace +# Also requires: pamcut pnmtopnm pamflip alias pamslice="${PBM_TESTPREFIX}pamslice" + alias pamdeinterlace="${PBM_TESTPREFIX}pamdeinterlace" + alias pamcut="${PBM_BINPREFIX}pamcut" alias pnmtopnm="${PBM_BINPREFIX}pnmtopnm" + alias pamflip="${PBM_BINPREFIX}pamflip" shopt -s expand_aliases +# Test 1. # Slice rows, one by one, out of testgrid.pbm. # Add header and reconstruct pbm image. # Note that in pamslice output 0 is white and 1 is black: opposite of PBM @@ -13,21 +17,56 @@ (echo "P1" echo "14 16" - seq 0 15 | while read i; + seq 0 15 | while read i; do pamslice -row=$i testgrid.pbm | \ - awk '{print $2}' | sed 'y/01/10/'; + awk '{print $2}' | sed 'y/01/10/'; done ) | pnmtopnm | cksum -# Slice rows, one by one, out of testimg.ppm. +# Test 2. +# Slice rows, one by one, out of ppm test image +# We take a part out of testimg.ppm with pamcut for processing the +# whole image takes much time. # Add header and reconstruct ppm image. -# Should print 1926073387 101484 +# Should print 914327477 4864 + +pamcut 50 50 49 33 testimg.ppm > ${tmpdir}/test4933.ppm (echo "P3" - echo "227 149" + echo "49 33" echo "255" - seq 0 148 | while read i; + seq 0 32 | while read i; do - pamslice -row=$i testimg.ppm | awk '{print $2, $3, $4}'; - done ) | pnmtopnm | cksum + pamslice -row=$i ${tmpdir}/test4933.ppm | awk '{print $2, $3, $4}'; + done ) | pnmtopnm | cksum + +# Same as above test 2, but take cols instead of rows. +# Should print 914327477 4864 + +(echo "P3" + echo "33 49" + echo "255" + seq 0 48 | while read i; + do + pamslice -col=$i ${tmpdir}/test4933.ppm | awk '{print $2, $3, $4}'; + done ) | pamflip -xy | cksum + +# Test 4. +# Divide input image into two with pamdeinterlace and recombine. + +pamdeinterlace -takeodd ${tmpdir}/test4933.ppm > ${tmpdir}/testodd.ppm +pamdeinterlace -takeeven ${tmpdir}/test4933.ppm > ${tmpdir}/testevn.ppm + +(echo "P3" + echo "49 33" + echo "255" + seq 0 15 | while read i; + do + pamslice -row=$i ${tmpdir}/testevn.ppm | awk '{print $2, $3, $4}'; + pamslice -row=$i ${tmpdir}/testodd.ppm | awk '{print $2, $3, $4}'; + done + pamslice -row=16 ${tmpdir}/testevn.ppm | awk '{print $2, $3, $4}'; + ) | pnmtopnm | tee /tmp/z | cksum + +rm ${tmpdir}/test4933.ppm ${tmpdir}/testodd.ppm ${tmpdir}/testevn.ppm diff --git a/test/png-roundtrip.ok b/test/png-roundtrip.ok index 67f7a1fe..28b8c057 100644 --- a/test/png-roundtrip.ok +++ b/test/png-roundtrip.ok @@ -1,2 +1,36 @@ 1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +1926073387 101484 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 +2425386270 41 2425386270 41 diff --git a/test/png-roundtrip.test b/test/png-roundtrip.test index 75b0d808..223103c8 100755 --- a/test/png-roundtrip.test +++ b/test/png-roundtrip.test @@ -6,6 +6,48 @@ alias pnmtopng="${PBM_TESTPREFIX}pnmtopng" shopt -s expand_aliases -pnmtopng testimg.ppm | pngtopnm | cksum -pnmtopng testgrid.pbm | pngtopnm | cksum +## Fails because .ok not set yet. +# Test 1. Should print 1926073387 101484 18 times +for flags in "" -interlace \ + -gamma=.45 \ + -hist \ + -nofilter \ + -sub \ + -up \ + -avg \ + -paeth \ + -compression=9 \ + "-compression=0 -comp_mem=1 -comp_window=8 -comp_buffer=512" \ + "-compression=9 -comp_mem=1 -comp_window=15 -comp_buffer=512" \ + "-compression=9 -comp_mem=1 -comp_window=8 -comp_buffer=512" \ + "-compression=0 -comp_mem=9 -comp_window=8 -comp_buffer=512" \ + "-compression=9 -comp_mem=9 -comp_window=15 -comp_buffer=8096" \ + -comp_strategy=huffman_only \ + -comp_strategy=filtered \ + -force + do +pnmtopng testimg.ppm $flags | pngtopnm | cksum +done + +# Test 2. Should print 2425386270 41 18 times +for flags in "" -interlace \ + -gamma=.45 \ + -hist \ + -nofilter \ + -sub \ + -up \ + -avg \ + -paeth \ + -compression=9 \ + "-compression=0 -comp_mem=1 -comp_window=8 -comp_buffer=512" \ + "-compression=9 -comp_mem=1 -comp_window=15 -comp_buffer=512" \ + "-compression=9 -comp_mem=1 -comp_window=8 -comp_buffer=512" \ + "-compression=0 -comp_mem=9 -comp_window=8 -comp_buffer=512" \ + "-compression=9 -comp_mem=9 -comp_window=15 -comp_buffer=8096" \ + -comp_strategy=huffman_only \ + -comp_strategy=filtered \ + -force + do + pnmtopng testgrid.pbm $flags | pngtopnm | cksum + done diff --git a/test/ps-roundtrip.test b/test/ps-roundtrip.test index 9ca811ab..1877724d 100755 --- a/test/ps-roundtrip.test +++ b/test/ps-roundtrip.test @@ -11,6 +11,11 @@ alias pnmtopnm="${PBM_BINPREFIX}pnmtopnm" shopt -s expand_aliases +# Failure message +## This test fails when: +## (1) zlib was not linked. +## (2) ghostscript is not available. + # pstopnm does not use libnetpbm functions for output. # Output is filtered through pnmtopnm. diff --git a/test/symmetry.ok b/test/symmetry.ok new file mode 100644 index 00000000..23129684 --- /dev/null +++ b/test/symmetry.ok @@ -0,0 +1,12 @@ +ok +ok +ok +ok +ok +ok +ok +ok +ok +ok +ok +ok diff --git a/test/symmetry.test b/test/symmetry.test new file mode 100755 index 00000000..5fdb3918 --- /dev/null +++ b/test/symmetry.test @@ -0,0 +1,95 @@ +#! /bin/bash +# This script tests: pgmramp pamgauss pgmkernel pbmpscale +# Also requires: pamflip + + alias pgmramp="${PBM_TESTPREFIX}pgmramp" + alias pamgauss="${PBM_TESTPREFIX}pamgauss" + alias pgmkernel="${PBM_TESTPREFIX}pgmkernel" + alias pbmpscale="${PBM_TESTPREFIX}pbmpscale" + alias pamflip="${PBM_BINPREFIX}pamflip" + shopt -s expand_aliases + +# All tests print "ok" upon success, cksum results otherwise. +# The "$3>0" is a kludge for preventing false positives with empty files. + +# All test images are square and have the symmetries of the square (Dih4). +# The sole exception is ell.pgm which is a rectangle (Dih2, also called +# "Klein four-group".) + +# Example symmetric square PGM image: +# P2 +# 5 5 +# 6 +# 1 2 3 2 1 +# 2 4 5 4 2 +# 3 5 6 5 3 +# 2 4 5 4 2 +# 1 2 3 2 1 + +## Failure with this test indicates that a generator or editor which +## should produce symmetric output images isn't doing so. + +# Test 1. +pgmramp -rect 31 31 > ${tmpdir}/rect.pgm + +( for op in -null -tb -lr -r90 + do pamflip $op ${tmpdir}/rect.pgm | cksum + done ) | uniq -c | \ + awk '$1==4 && $3>0 { print "ok"; exit }; { print }' + +rm ${tmpdir}/rect.pgm + +# Test 2. +pgmramp -ell 63 63 > ${tmpdir}/circle.pgm + +( for op in -null -tb -lr -r90 + do pamflip $op ${tmpdir}/circle.pgm | cksum + done ) | uniq -c | \ + awk '$1==4 && $3>0 { print "ok"; exit }; { print }' + +rm ${tmpdir}/circle.pgm + +# Test 3. +pamgauss -sigma=0.1 -tupletype=GRAYSCALE 25 25 > ${tmpdir}/gauss.pam + +( for op in -null -tb -lr -r90 + do pamflip $op ${tmpdir}/gauss.pam | cksum + done ) | uniq -c | \ + awk '$1==4 && $3>0 { print "ok"; exit }; { print }' + +rm ${tmpdir}/gauss.pam + +# Test 4. +pgmkernel 15 15 > ${tmpdir}/kernel.pgm + +( for op in -null -tb -lr -r90 + do pamflip $op ${tmpdir}/kernel.pgm | cksum + done ) | uniq -c | \ + awk '$1==4 && $3>0 { print "ok"; exit }; { print }' + +rm ${tmpdir}/kernel.pgm + +# Test 5. +# Should print "ok" 7 times. +for size in `seq 1 7` +do +pbmmake -g 5 5 | pbmpscale $size > ${tmpdir}/pscale.pbm + +( for op in -null -tb -lr -r90 + do pamflip $op ${tmpdir}/pscale.pbm | cksum + done ) | uniq -c | \ + awk '$1==4 && $3>0 { print "ok"; exit }; { print }' + +rm ${tmpdir}/pscale.pbm +done + +# Test 6. +pgmramp -ell 101 33 > ${tmpdir}/ell.pgm + +( for op in -null -tb -lr + do pamflip $op ${tmpdir}/ell.pgm | cksum + done ) | uniq -c | \ + awk '$1==3 && $3>0 { print "ok"; exit }; { print }' + +rm ${tmpdir}/ell.pgm + diff --git a/test/tiff-roundtrip.test b/test/tiff-roundtrip.test index 09520f14..410148a5 100755 --- a/test/tiff-roundtrip.test +++ b/test/tiff-roundtrip.test @@ -6,11 +6,13 @@ alias tifftopnm="${PBM_TESTPREFIX}tifftopnm" shopt -s expand_aliases +# Failure message +## Second test fails if Netpbm was built without the flate library + pamtotiff testimg.ppm 1<>${tmpdir}/test1.tiff && tifftopnm ${tmpdir}/test1.tiff | cksum # test flate compression -# Will fail if Netpbm was built without the flate library pamtotiff -flate testimg.ppm 1<>${tmpdir}/test2.tiff && tifftopnm ${tmpdir}/test2.tiff | cksum |