diff options
53 files changed, 509 insertions, 108 deletions
diff --git a/GNUmakefile b/GNUmakefile index a302d309..9066f2a7 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -409,11 +409,12 @@ install.sharedlibstub: .PHONY: check check: # This works on typical Linux systems - cd $(SRCDIR)/test; \ + if [ ! -d $(RESULTDIR) ]; then mkdir -pv $(RESULTDIR); fi + cd $(RESULTDIR); \ PBM_TESTPREFIX=$(PKGDIR)/bin \ LD_LIBRARY_PATH=$(PKGDIR)/lib \ RGBDEF=$(SRCDIR)/lib/rgb.txt \ - ./Execute-Tests + $(SRCDIR)/test/Execute-Tests 2>&1 clean: localclean diff --git a/common.mk b/common.mk index f93c9e0f..5ac872fd 100644 --- a/common.mk +++ b/common.mk @@ -109,12 +109,24 @@ LDLIBS = $(LOADLIBES) $(LIBS) # disastrous if PKGDIR is a relative directory, and I don't know any # way to detect that case and fail, so I just add a '/' to the front # if it isn't already there. +# +# TODO: Convert 'pkgdir' to absolute path with # the $(abspath ...) +# built-in function, available from GNU Make v 3.81 onward. ifneq ($(pkgdir)x,x) - PKGDIR = $(patsubst //%, /%, /$(pkgdir)) + PKGDIR = $(patsubst //%,/%, /$(pkgdir)) else PKGDIR = $(PKGDIR_DEFAULT) endif + +# 'resultdir', like 'pkgdir' is meant to be supplied from the make +# command line. Unlike 'pkgdir' we allow relative paths. +ifneq ($(resultdir)x,x) + RESULTDIR = $(resultdir) +else + RESULTDIR = $(RESULTDIR_DEFAULT) +endif + #=========================================================================== # We build a directory full of symbolic links to the intra-Netpbm public # header files just so the compile commands don't have to be littered diff --git a/config.mk.in b/config.mk.in index 53950a5f..3873ba19 100644 --- a/config.mk.in +++ b/config.mk.in @@ -526,6 +526,10 @@ DONT_HAVE_PROCESS_MGMT = N # override it by setting 'pkgdir' on the Make command line. PKGDIR_DEFAULT = /tmp/netpbm +# This is where test results are written when you do 'make check', unless +# you override it by setting 'resultdir' on the Make command line. +RESULTDIR_DEFAULT = /tmp/netpbm-test + # Subdirectory of the package directory ($(pkgdir)) in which man pages # go. PKGMANDIR = man diff --git a/test/411toppm.ok b/test/411toppm.ok new file mode 100644 index 00000000..615d2b6d --- /dev/null +++ b/test/411toppm.ok @@ -0,0 +1 @@ +240376509 9229 diff --git a/test/411toppm.test b/test/411toppm.test new file mode 100755 index 00000000..ce374f29 --- /dev/null +++ b/test/411toppm.test @@ -0,0 +1,12 @@ +#! /bin/bash +# This script tests: 411toppm +# Also requires: + +# Test 1. should produce: 240376509 9229 +# The above value is what 411toppm has been always producing. +# 411toppm's author Steve Allen says he was not able to obtain accurate +# specifications for the .411 format. Technically, the above can change. +# +# See comment at head of source file 411toppm.c. + +head -c 4608 /dev/zero | ${PBM_TESTPREFIX}411toppm -quiet | cksum diff --git a/test/Execute-Tests b/test/Execute-Tests index 104853e5..9cbbe63f 100755 --- a/test/Execute-Tests +++ b/test/Execute-Tests @@ -2,11 +2,11 @@ # Confirm that PBM_TESTPREFIX is set. # PBM_TESTPREFIX is the directory with the Netpbm programs you want to -# test. This can be null, but this is not recommended. +# test. If set to null, executables will be sought from the default +# execution path ($PATH). Usually you should explicitly set this. # -# You can set it here by decommenting and modifying the next line: -# export PBM_TESTPREFIX="/usr/local/bin/" - +# You can set it here by de-commenting and modifying the next line: +#export PBM_TESTPREFIX="/usr/local/bin/" if [ -z $PBM_TESTPREFIX ] then @@ -20,7 +20,7 @@ elif [ ! -d $PBM_TESTPREFIX ] exit 1 else # append "/" to end of string if necessary - export PBM_TESTPREFIX=`echo $PBM_TESTPREFIX | sed '/\/$/!s@$@/@'` + export PBM_TESTPREFIX=$(echo $PBM_TESTPREFIX | sed '/\/$/!s@$@/@') fi # Set PBM_BINPREFIX. @@ -30,7 +30,8 @@ fi # # If testing a fresh install, this should be the same as PBM_TESTPREFIX. # If you are developing a single Netpbm program, you may want to -# set this to a directory with stable executables. +# set this to a directory with stable executables. (Final "/" is +# mandatory.) # If set to null, executables in the default execution path will # be used. @@ -47,19 +48,35 @@ if [ ! -z $PBM_BINPREFIX ] export PATH=${PBM_BINPREFIX}:$PATH fi -# Set tmpdir, which is used in some of the test scripts. -# This must be an existing directory. +# Set srcdir, which is the directory which contains Execute-Tests +# (this script), Test-Order *.test and *.ok files. + +srcdir=$(dirname $0) + +# Set tmpdir, which is used in some of the test scripts. By default +# this is created by mktemp. The user can override and specify tmpdir, +# but in this case it must be an existing directory and must not be +# either $srcdir or current work. if [ -z $tmpdir ] then - if [ -z $TMPDIR ] - then - export tmpdir=/tmp/ - else - export tmpdir=$TMPDIR + tmpdir_created=$(mktemp -p "" -d TestPBM-XXXXXXX) || exit 1; + export tmpdir=${tmpdir_created} + else + tmpdir_created=""; + if [ ! -d ${tmpdir} ] + then echo "Specified temporary directory $tmpdir does not exist." + exit 1; + elif [ ${tmpdir} -ef ${srcdir} ] + then echo "Temporary directory must not be $srcdir." + exit 1; + elif [ ${tmpdir} -ef $PWD ] + then echo "Temporary directory must not be current directory." + exit 1; fi fi + # If necessary set the RGBDEF environment variable. #export RGBDEF=/etc/rgb.txt #export RGBDEF=/usr/local/netpbm/lib/rgb.txt @@ -67,47 +84,96 @@ fi # Declare arrays used to count and report test results. # For now only "SUCCESS" and "FAILURE" are used. -declare -a array=(0 0 0 0 0) -declare -a status=("SUCCESS" "FAILURE" "UNEXPECTED SUCCESS" \ - "EXPECTED FAILURE" "NOT SUPPORTED") +declare -a array=(0 0 0 0 0 0) +declare -a status=("SUCCESS" "FAILURE" "UNEXPECTED SUCCESS" + "EXPECTED FAILURE" "NOT SUPPORTED" "TOTAL SUPPORTED") + +# Copy test files to the current work directory + +cp -n -t . ${srcdir}/testgrid.pbm ${srcdir}/testimg.ppm # Execute the tests, as described in the "Test-Order" file. # -# To execute just one test, or a few tests, replace the grep part -# within backquotes with names of tests you want to run like this: -# -# for t in pbmmake.test pgmmake.test ppmmake.test +# Each test outputs a ".out" file, which is compared against a +# corresponding ".ok" file. For example the output from "pbmmake.test" +# is "pbmmake.out" and when this matches "pbmmake.ok" we declare the +# test a success. +# In the error case the ".out" file is retained in the current work +# directory. +# +# All tests are self-contained. +# +# By defeault the tests are executed in the order described in the +# file Test-Order. Normally the Test-Order in the source directory +# will be used, but the user can override this with a file named +# Test-Order placed in the work directory. (This feature comes useful +# when you want to pare down the list.) + +if [ ! -f ./Test-Order ] +then cp ${srcdir}/Test-Order ./Test-Order +fi -for t in `grep -v "^#" Test-Order | grep "."` +for t in `grep -v "^#" ./Test-Order | fgrep ".test"` do echo == $t == -./$t > ${t%.test}.out ; let result=$? +${srcdir}/$t > ${t%.test}.out ; let result=$? case $result in -0) cmp --quiet ${t%.test}.out ${t%.test}.ok ; +0) cmp --quiet ${t%.test}.out ${srcdir}/${t%.test}.ok ; if [ $? -eq 0 ] then let result=0; rm ${t%.test}.out ; else let result=1; - fi ;; -1 | 2 | 3 ) ;; -*) let result=1 ;; + fi + let supported=1 ;; +*) let result=1 ; let supported=1;; esac -# Print out a summary report. + +# Report whether a single test succeeded or failed. +# Increment counters. echo $t: ${status[${result}]}; echo let array[${result}]=${array[${result}]}+1 +let array[5]=${array[5]}+$supported + done + +# Erase temporary directory and its contents, if it was created. + +if [ -n $tmpdir_created ] + then rm -rf $tmpdir_created +fi + + +# Erase test image files in the current (work) directory. +# (Do not erase them if we are working from the source directory.) + +if [ ! $PWD -ef ${srcdir} ] + then rm ./testimg.ppm ./testgrid.pbm +fi + + +# Calculate success / failure totals and print a summary report. +# Report date and time of completion. + echo "Test summary:" echo ================== -for s in 0 1 2 3 4 -do -if [[ ${array[${s}]} -gt 0 || s -eq 1 ]] -then -echo ${status[${s}]} ${array[${s}]} -fi -done +for s in 0 1 2 3 4 5 + do + if [[ ${array[${s}]} -gt 0 || s -eq 1 ]] + then echo ${status[${s}]} ${array[${s}]} + fi + done echo ================== echo "All tests done." +date --rfc-3339=seconds + + +# Exit with status 0 if all supported tests succeeded, 1 otherwise. + +if [[ ${array[0]} -eq ${array[5]} ]] +then exit 0 +else exit 1 +fi diff --git a/test/Test-Order b/test/Test-Order index 2801878a..a23bdd92 100644 --- a/test/Test-Order +++ b/test/Test-Order @@ -16,6 +16,7 @@ pgmramp.test ppmgauss.test ppmcie.test ppmwheel.test +ppmpat.test # Analyzer tests @@ -60,6 +61,12 @@ ppmmix.test # Format converter tests pbmtog3.test +411toppm.test +eyuvtoppm.test + +# Miscellaneous utility tests + +ppmdfont.test # Round-trip tests : editors @@ -77,13 +84,31 @@ pamslice-roundtrip.test # Round-trip tests : lossless converters -g3-roundtrip.test +atk-roundtrip.test +avs-roundtrip.test bmp-roundtrip.test +cmuw-roundtrip.test +facesaver-roundtrip.test +fits-roundtrip.test +g3-roundtrip.test +gem-roundtrip.test gif-roundtrip.test +hdiff-roundtrip.test +leaf-roundtrip.test +mgr-roundtrip.test +mrf-roundtrip.test +pfm-roundtrip.test png-roundtrip.test ps-roundtrip.test +sunrast-roundtrip.test +targa-roundtrip.test tiff-roundtrip.test +utahrle-roundtrip.test +wbmp-roundtrip.test xbm-roundtrip.test xpm-roundtrip.test xwd-roundtrip.test -hdiff-roundtrip.test + +# Round-trip tests : lossy converter + +yuv-roundtrip.test diff --git a/test/all-in-place.ok b/test/all-in-place.ok index 52334382..75e1e01a 100644 --- a/test/all-in-place.ok +++ b/test/all-in-place.ok @@ -262,7 +262,6 @@ ppmmix: ok ppmnorm: ok ppmntsc: ok ppmpat: ok -ppmquant: ok ppmrelief: ok ppmrough: ok ppmshift: ok @@ -335,17 +334,17 @@ yuvsplittoppm: ok yuvtoppm: ok zeisstopnm: ok fiascotopnm: ok -anytopnm: ok -hpcdtoppm: ok manweb: ok -pbmtox10bm: ok pnmmargin: ok +anytopnm: ok +pbmtox10bm: ok pnmnoraw: ok +pnmtoplainpnm: ok +ppmtomap: ok +ppmshadow: ok pnmquant: ok pnmquantall: ok -pnmtoplainpnm: ok -ppmfade: ok +ppmquant: ok ppmquantall: ok ppmrainbow: ok -ppmshadow: ok -ppmtomap: ok +ppmfade: ok diff --git a/test/all-in-place.test b/test/all-in-place.test index 1726337b..ae67e809 100755 --- a/test/all-in-place.test +++ b/test/all-in-place.test @@ -1,11 +1,36 @@ #! /bin/bash # Tests whether the executable files listed below are in place. +# We test by actually running all the executables. + # See Netpbm Library Prerequisites # http://netpbm.sourceforge.net/prereq.html # if make succeeds but this test fails. +function testExitStatus () { + +# This function takes 3 positional parameters: +# $1: filename +# $2: expected exit status (In some cases we expect error.) +# $3: actual exit status + + case $3 in + $2) echo $1": ok" ;; + 126) if [ ! -z ${PBM_TESTPREFIX} ] && [ ! -x ${PBM_TESTPREFIX}/$1 ] + then echo $1": NOT EXECUTABLE"; + else echo $1": ERROR: "$3; echo $1": error: "$3 1>&2 ; + fi ;; + 127) if [ ! -z ${PBM_TESTPREFIX} ] && [ ! -f ${PBM_TESTPREFIX}/$1 ] + then echo $1": NO SUCH FILE"; + else echo $1": ERROR: "$3; echo $1": error: "$3 1>&2 ; + fi ;; + *) echo $1": ERROR: "$3; echo $1": error: "$3 1>&2 ;; + esac +} + + # Test programs which support the --version flag. +# See showVersion() in lib/libpm.c for the standard version announcement. for i in \ 411toppm asciitopgm atktopbm avstopam bioradtopgm \ @@ -55,7 +80,7 @@ for i in \ ppmcie ppmcolormask ppmcolors ppmdcfont ppmddumpfont \ ppmdim ppmdist ppmdither ppmdmkfont ppmdraw ppmflash \ ppmforge ppmglobe ppmhist ppmlabel ppmmake ppmmix ppmnorm \ - ppmntsc ppmpat ppmquant ppmrelief ppmrough ppmshift \ + ppmntsc ppmpat ppmrelief ppmrough ppmshift \ ppmspread ppmtoacad ppmtoapplevol ppmtoarbtxt ppmtoascii \ ppmtobmp ppmtoeyuv ppmtogif ppmtoicr ppmtoilbm ppmtojpeg \ ppmtoleaf ppmtolj ppmtomitsu ppmtompeg ppmtoneo ppmtopcx \ @@ -69,36 +94,74 @@ for i in \ winicontoppm xbmtopbm ximtoppm xpmtoppm xvminitoppm \ xwdtopnm ybmtopbm yuvsplittoppm yuvtoppm zeisstopnm do - ${PBM_TESTPREFIX}$i --version 2> /dev/null; - case $? in - 0) echo $i": ok";; - 127) echo $i": no such file";; - *) echo $i": error" $?;; - esac + ${PBM_TESTPREFIX}$i --version 2>&1 | \ + egrep -v \ + "(Using libnetpbm|Compiled|(BSD|SYSV|MSDOS|AMIGA) defined|RGB_?ENV=)" \ + 1>&2; + testExitStatus $i 0 ${PIPESTATUS[0]} done -# Test fiascotopnm, which has a unique -v flag + +# Test fiascotopnm, which has a unique -v flag. ${PBM_TESTPREFIX}fiascotopnm -v 2> /dev/null - case $? in - 2) echo fiascotopnm": ok";; - 127) echo fiascotopnm": no such file";; - *) echo fiascotopnm": error" $?;; - esac + testExitStatus fiascotopnm 2 $? -# Test programs which do not have no --version flag. -for i in \ - anytopnm hpcdtoppm manweb pbmtox10bm pnmmargin \ - pnmnoraw pnmquant pnmquantall pnmtoplainpnm ppmfade ppmquantall \ - ppmrainbow ppmshadow ppmtomap +# Test manweb and pnmmargin, which support --help. + +${PBM_TESTPREFIX}manweb --help > /dev/null + testExitStatus manweb 0 $? + +${PBM_TESTPREFIX}pnmmargin --help 2> /dev/null + testExitStatus pnmmargin 1 $? + + + +# Test anytopnm, pbmtox10bm, pnmnoraw, pnmquant, pnmquantall, +# pnmtoplainpnm, ppmquantall, ppmrainbow, ppmshadow, ppmtomap +# with trivial input. + +cat > ${tmpdir}/test.pbm <<EOF +P1 +1 1 +1 +EOF + +for i in anytopnm pbmtox10bm pnmnoraw pnmtoplainpnm ppmtomap ppmshadow + do + ${PBM_TESTPREFIX}$i ${tmpdir}/test.pbm > /dev/null 2> /dev/null; + testExitStatus $i 0 $? + done + +for i in pnmquant pnmquantall ppmquant ppmquantall do - if [ -x ${PBM_TESTPREFIX}$i ] - then echo $i": ok" - elif [ -f ${PBM_TESTPREFIX}$i ] - then echo $i": not executable" - else echo $i": no such file" - fi - done + ${PBM_TESTPREFIX}$i 2 ${tmpdir}/test.pbm > /dev/null 2> /dev/null; + testExitStatus $i 0 $? + done + +rm ${tmpdir}/test.pbm + +${PBM_TESTPREFIX}ppmrainbow rgb:00/00/00 rgb:ff/ff/ff \ + -tmpdir=${tmpdir} -width=2 -height=2 > /dev/null + testExitStatus ppmrainbow 0 $? + + + +# Test ppmfade with corrupt input. +# Prevent the creation of output files by setting base to /dev/null. +# Exit status should be 50. + +${PBM_TESTPREFIX}ppmfade -f /dev/zero -base /dev/null > /dev/null 2> /dev/null + testExitStatus ppmfade 50 $? + + + +# We do not test hpcdtoppm. +# This is a stand-in which announces the absence of the real hpcdtoppm. +# TODO: Provide for the case in which the real hpcdtoppm is encountered. + +#${PBM_TESTPREFIX}hpcdtoppm 2> /dev/null +# testExitStatus hpcdtoppm 1 $? diff --git a/test/atk-roundtrip.ok b/test/atk-roundtrip.ok new file mode 100644 index 00000000..845be5fb --- /dev/null +++ b/test/atk-roundtrip.ok @@ -0,0 +1 @@ +2425386270 41 diff --git a/test/atk-roundtrip.test b/test/atk-roundtrip.test new file mode 100755 index 00000000..f64b0c3c --- /dev/null +++ b/test/atk-roundtrip.test @@ -0,0 +1,6 @@ +#! /bin/bash +# This script tests: pbmtoatk atktopbm +# Also requires: + +# Should print 2425386270 41, cksum of testgrid.pbm +${PBM_TESTPREFIX}pbmtoatk testgrid.pbm | ${PBM_TESTPREFIX}atktopbm | cksum diff --git a/test/avs-roundtrip.ok b/test/avs-roundtrip.ok new file mode 100644 index 00000000..82eac5a8 --- /dev/null +++ b/test/avs-roundtrip.ok @@ -0,0 +1 @@ +1926073387 101484 diff --git a/test/avs-roundtrip.test b/test/avs-roundtrip.test new file mode 100755 index 00000000..33f9e581 --- /dev/null +++ b/test/avs-roundtrip.test @@ -0,0 +1,7 @@ +#! /bin/bash +# This script tests: pamtoavs avstopam +# Also requires: pamtopnm + +# Should produce 1926073387 101484, cksum of testimg.ppm +${PBM_TESTPREFIX}pamtoavs testimg.ppm | \ + ${PBM_TESTPREFIX}avstopam | ${PBM_BINPREFIX}pamtopnm | cksum diff --git a/test/cmuw-roundtrip.ok b/test/cmuw-roundtrip.ok new file mode 100644 index 00000000..845be5fb --- /dev/null +++ b/test/cmuw-roundtrip.ok @@ -0,0 +1 @@ +2425386270 41 diff --git a/test/cmuw-roundtrip.test b/test/cmuw-roundtrip.test new file mode 100755 index 00000000..85de9706 --- /dev/null +++ b/test/cmuw-roundtrip.test @@ -0,0 +1,6 @@ +#! /bin/bash +# This script tests: pbmtocmuwm cmuwmtopbm +# Also requires: + +# Should print 2425386270 41, cksum of testgrid.pbm +${PBM_TESTPREFIX}pbmtocmuwm testgrid.pbm | ${PBM_TESTPREFIX}cmuwmtopbm | cksum diff --git a/test/cut-paste-roundtrip.test b/test/cut-paste-roundtrip.test index cd81a1c6..d5d5989f 100755 --- a/test/cut-paste-roundtrip.test +++ b/test/cut-paste-roundtrip.test @@ -2,5 +2,5 @@ # This script tests: pamcut pnmpaste # Also requires: -${PBM_TESTPREFIX}pamcut 50 40 100 70 ~/test-netpbm/testimg.ppm | \ -${PBM_TESTPREFIX}pnmpaste -replace - 50 40 ~/test-netpbm/testimg.ppm | cksum +${PBM_TESTPREFIX}pamcut 50 40 100 70 testimg.ppm | \ +${PBM_TESTPREFIX}pnmpaste -replace - 50 40 testimg.ppm | cksum diff --git a/test/eyuvtoppm.ok b/test/eyuvtoppm.ok new file mode 100644 index 00000000..90830f9f --- /dev/null +++ b/test/eyuvtoppm.ok @@ -0,0 +1 @@ +1719878124 253455 diff --git a/test/eyuvtoppm.test b/test/eyuvtoppm.test new file mode 100755 index 00000000..5009d3ba --- /dev/null +++ b/test/eyuvtoppm.test @@ -0,0 +1,7 @@ +#! /bin/bash +# This script tests: eyuvtoppm +# Also requires: + +# Should produce 1719878124 253455 + +head -c 126720 /dev/zero | ${PBM_TESTPREFIX}eyuvtoppm -quiet | cksum diff --git a/test/facesaver-roundtrip.ok b/test/facesaver-roundtrip.ok new file mode 100644 index 00000000..32a4743b --- /dev/null +++ b/test/facesaver-roundtrip.ok @@ -0,0 +1 @@ +2871603838 33838 diff --git a/test/facesaver-roundtrip.test b/test/facesaver-roundtrip.test new file mode 100755 index 00000000..410ba897 --- /dev/null +++ b/test/facesaver-roundtrip.test @@ -0,0 +1,8 @@ +#! /bin/bash +# This script tests: pgmtofs fstopgm +# Also requires: ppmtopgm + +# Should produce 2871603838 33838, cksum of testimg.pgm + +${PBM_BINPREFIX}ppmtopgm testimg.ppm | \ + ${PBM_TESTPREFIX}pgmtofs | ${PBM_TESTPREFIX}fstopgm | cksum \ No newline at end of file diff --git a/test/fits-roundtrip.ok b/test/fits-roundtrip.ok new file mode 100644 index 00000000..82eac5a8 --- /dev/null +++ b/test/fits-roundtrip.ok @@ -0,0 +1 @@ +1926073387 101484 diff --git a/test/fits-roundtrip.test b/test/fits-roundtrip.test new file mode 100755 index 00000000..0c244c5a --- /dev/null +++ b/test/fits-roundtrip.test @@ -0,0 +1,6 @@ +#! /bin/bash +# This script tests: pamtofits fitstopnm +# Also requires: + +# Should produce 1926073387 101484, cksum of testimg.ppm +${PBM_TESTPREFIX}pamtofits testimg.ppm | ${PBM_TESTPREFIX}fitstopnm | cksum diff --git a/test/gem-roundtrip.ok b/test/gem-roundtrip.ok new file mode 100644 index 00000000..845be5fb --- /dev/null +++ b/test/gem-roundtrip.ok @@ -0,0 +1 @@ +2425386270 41 diff --git a/test/gem-roundtrip.test b/test/gem-roundtrip.test new file mode 100755 index 00000000..9548637a --- /dev/null +++ b/test/gem-roundtrip.test @@ -0,0 +1,6 @@ +#! /bin/bash +# This script tests: pbmtogem gemtopbm +# Also requires: + +# Should print 2425386270 41, cksum of testgrid.pbm +${PBM_TESTPREFIX}pbmtogem testgrid.pbm | ${PBM_TESTPREFIX}gemtopbm | cksum diff --git a/test/leaf-roundtrip.ok b/test/leaf-roundtrip.ok new file mode 100644 index 00000000..82eac5a8 --- /dev/null +++ b/test/leaf-roundtrip.ok @@ -0,0 +1 @@ +1926073387 101484 diff --git a/test/leaf-roundtrip.test b/test/leaf-roundtrip.test new file mode 100755 index 00000000..6fb7547c --- /dev/null +++ b/test/leaf-roundtrip.test @@ -0,0 +1,6 @@ +#! /bin/bash +# This script tests: ppmtoleaf leaftoppm +# Also requires: + +# Should produce 1926073387 101484, cksum of testimg.ppm +${PBM_TESTPREFIX}ppmtoleaf testimg.ppm | ${PBM_TESTPREFIX}leaftoppm | cksum diff --git a/test/mgr-roundtrip.ok b/test/mgr-roundtrip.ok new file mode 100644 index 00000000..845be5fb --- /dev/null +++ b/test/mgr-roundtrip.ok @@ -0,0 +1 @@ +2425386270 41 diff --git a/test/mgr-roundtrip.test b/test/mgr-roundtrip.test new file mode 100755 index 00000000..2ca3d4b3 --- /dev/null +++ b/test/mgr-roundtrip.test @@ -0,0 +1,6 @@ +#! /bin/bash +# This script tests: pbmtomgr mgrtopbm +# Also requires: + +# Should print 2425386270 41, cksum of testgrid.pbm +${PBM_TESTPREFIX}pbmtomgr testgrid.pbm | ${PBM_TESTPREFIX}mgrtopbm | cksum diff --git a/test/mrf-roundtrip.ok b/test/mrf-roundtrip.ok new file mode 100644 index 00000000..845be5fb --- /dev/null +++ b/test/mrf-roundtrip.ok @@ -0,0 +1 @@ +2425386270 41 diff --git a/test/mrf-roundtrip.test b/test/mrf-roundtrip.test new file mode 100755 index 00000000..80dca546 --- /dev/null +++ b/test/mrf-roundtrip.test @@ -0,0 +1,6 @@ +#! /bin/bash +# This script tests: pbmtomrf mrftopbm +# Also requires: + +# Should print 2425386270 41, cksum of testgrid.pbm +${PBM_TESTPREFIX}pbmtomrf testgrid.pbm | ${PBM_TESTPREFIX}mrftopbm | cksum diff --git a/test/pfm-roundtrip.ok b/test/pfm-roundtrip.ok new file mode 100644 index 00000000..82eac5a8 --- /dev/null +++ b/test/pfm-roundtrip.ok @@ -0,0 +1 @@ +1926073387 101484 diff --git a/test/pfm-roundtrip.test b/test/pfm-roundtrip.test new file mode 100755 index 00000000..7cd2693c --- /dev/null +++ b/test/pfm-roundtrip.test @@ -0,0 +1,7 @@ +#! /bin/bash +# This script tests: pamtopfm pfmtopam +# Also requires: pamtopnm + +# Should print 1926073387 101484, cksum of testimg.ppm +${PBM_TESTPREFIX}pamtopfm testimg.ppm | ${PBM_TESTPREFIX}pfmtopam | \ + ${PBM_BINPREFIX}pamtopnm | cksum diff --git a/test/pgmhist.ok b/test/pgmhist.ok index d98c2244..7d89bb33 100644 --- a/test/pgmhist.ok +++ b/test/pgmhist.ok @@ -1,14 +1,14 @@ -value count b% w% ------ ----- ------ ------ - 0 2 12.5% 100% - 1 2 25% 87.5% - 2 2 37.5% 75% - 3 2 50% 62.5% - 4 2 62.5% 50% - 5 2 75% 37.5% - 6 2 87.5% 25% - 8 2 100% 12.5% -value count b% w% ------ ----- ------ ------ - 0 168 75% 100% - 255 56 100% 25% +value count b% w% +----- ----- ------ ------ + 0 2 12.5% 100% + 1 2 25% 87.5% + 2 2 37.5% 75% + 3 2 50% 62.5% + 4 2 62.5% 50% + 5 2 75% 37.5% + 6 2 87.5% 25% + 8 2 100% 12.5% +value count b% w% +----- ----- ------ ------ + 0 168 75% 100% + 255 56 100% 25% diff --git a/test/pgmhist.test b/test/pgmhist.test index b5e7ef7d..b3361dc4 100755 --- a/test/pgmhist.test +++ b/test/pgmhist.test @@ -2,5 +2,10 @@ # This script tests: pgmhist # Also requires: pgmramp -${PBM_BINPREFIX}pgmramp -maxval=8 -lr 8 2 | ${PBM_TESTPREFIX}pgmhist -${PBM_TESTPREFIX}pgmhist testgrid.pbm \ No newline at end of file +# Ignore differences in spaces. + +${PBM_BINPREFIX}pgmramp -maxval=8 -lr 8 2 | ${PBM_TESTPREFIX}pgmhist | \ + sed -e 's/ */ /g' -e 's/ *$//' + +${PBM_TESTPREFIX}pgmhist testgrid.pbm | \ + sed -e 's/ */ /g' -e 's/ *$//' \ No newline at end of file diff --git a/test/ppmcie.ok b/test/ppmcie.ok index 3398b2f7..79ebd086 100644 --- a/test/ppmcie.ok +++ b/test/ppmcie.ok @@ -1 +1,2 @@ -955840041 786447 +ok +ok diff --git a/test/ppmcie.test b/test/ppmcie.test index cd84536a..1e60c848 100755 --- a/test/ppmcie.test +++ b/test/ppmcie.test @@ -1,6 +1,6 @@ #! /bin/bash # This script tests: ppmcie -# Also requires: +# Also requires: pamsumm pamsharpness # Test 1. Should print 955840041 786447 # Without -nolabel -noaxes -nowpoint -noblack older versions of @@ -8,13 +8,35 @@ # Output from "ppmcie | cksum" : # v. 10.35.86: 288356530 786447 # v. 10.59.2 : 2292601420 786447 -# -# This test fails when ppmcie is compiled with SSE features are turned on. + +${PBM_TESTPREFIX}ppmcie -nolabel -noaxes -nowpoint -noblack \ + > ${tmpdir}/ppmcie.ppm + +# There is a slight difference in the output depending on whether ppmcie +# is compiled with SSE features are turned on or off. # Note that Gcc turns on SSE,SSE2 on by default for x86-64. +# Output from "cksum ppmcie.ppm": # v. 10.59.2 # x86 32 bit: 955840041 786447 # x86 64 bit: 4208660683 786447 -${PBM_TESTPREFIX}ppmcie -nolabel -noaxes -nowpoint -noblack | cksum +# Test 1. Measure mean value +# v. 10.59.2 +# x86 32 bit: 38.660173 +# x86 64 bit: 38.681432 + +${PBM_BINPREFIX}pamsumm --mean --brief ${tmpdir}/ppmcie.ppm | \ + awk '{ if(38.65 < $1 && $1 <38.69) print "ok"; else print $1}' + +# Test 2. Measure image sharpness +# v. 10.59.2 +# x86 32 bit: 0.002476 +# x86 64 bit: 0.002478 + +${PBM_BINPREFIX}pamsharpness ${tmpdir}/ppmcie.ppm 2>&1 | \ + awk 'NF==4 && $2=="Sharpness" \ + {if (0.002475 < $4 && $4 < 0.002479) print "ok"; else print $4} + NF>0 && NF!=4 {print "error"}' +rm ${tmpdir}/ppmcie.ppm diff --git a/test/ppmdfont.ok b/test/ppmdfont.ok new file mode 100644 index 00000000..c996a8f5 --- /dev/null +++ b/test/ppmdfont.ok @@ -0,0 +1,2 @@ +2726488777 48129 +2845495212 75033 diff --git a/test/ppmdfont.test b/test/ppmdfont.test new file mode 100755 index 00000000..e973297b --- /dev/null +++ b/test/ppmdfont.test @@ -0,0 +1,9 @@ +#! /bin/bash +# This script tests: ppmdmkfont ppmddumpfont ppmdcfont +# Also requires: + +# Test 1. Should produce: 2726488777 48129 +${PBM_TESTPREFIX}ppmdmkfont | ${PBM_TESTPREFIX}ppmddumpfont 2>&1 | cksum + +# Test 2. Should produce: 2845495212 75033 +${PBM_TESTPREFIX}ppmdmkfont | ${PBM_TESTPREFIX}ppmdcfont | cksum diff --git a/test/ppmdim.test b/test/ppmdim.test index 27bbc4e1..b8158d63 100755 --- a/test/ppmdim.test +++ b/test/ppmdim.test @@ -1,9 +1,9 @@ #! /bin/bash # This script tests: ppmdim -# Also requires: pamfunc pamarith pamsumm +# Also requires: pamfunc pnmarith pamsumm # Compare ppmdim and pamfunc with various dim factors -# Due to the difference rounding methods, pamfunc produces slightly +# Due to the difference in rounding methods, pamfunc produces slightly # brighter images, by about 0.5 per pixel. # If the mean difference is between 0 and 0.75 we consider the output # normal. This works for dim values up to 0.994 . diff --git a/test/ppmhist.ok b/test/ppmhist.ok index 91731d4b..d7ecf07e 100644 --- a/test/ppmhist.ok +++ b/test/ppmhist.ok @@ -1,11 +1,11 @@ -value count b% w% ------ ----- ------ ------ - 0 2 12.5% 100% - 1 2 25% 87.5% - 2 2 37.5% 75% - 3 2 50% 62.5% - 4 2 62.5% 50% - 5 2 75% 37.5% - 6 2 87.5% 25% - 8 2 100% 12.5% + r g b lum count + ----- ----- ----- ----- ------- + 0 0 0 0 2 + 1 1 1 1 2 + 2 2 2 2 2 + 3 3 3 3 2 + 4 4 4 4 2 + 5 5 5 5 2 + 6 6 6 6 2 + 8 8 8 8 2 3438989921 711087 diff --git a/test/ppmhist.test b/test/ppmhist.test index 29bba206..b849e72d 100755 --- a/test/ppmhist.test +++ b/test/ppmhist.test @@ -2,6 +2,6 @@ # This script tests: ppmhist # Also requires: pgmhist pgmramp -${PBM_BINPREFIX}pgmramp -maxval=8 -lr 8 2 | ${PBM_BINPREFIX}pgmhist +${PBM_BINPREFIX}pgmramp -maxval=8 -lr 8 2 | ${PBM_TESTPREFIX}ppmhist ${PBM_TESTPREFIX}ppmhist -map -sort=rgb testimg.ppm | cksum diff --git a/test/ppmpat.ok b/test/ppmpat.ok new file mode 100644 index 00000000..c5b71909 --- /dev/null +++ b/test/ppmpat.ok @@ -0,0 +1,6 @@ +4008533639 781 +2448908863 9613 +2698433077 1549 +3705929501 781 +2219119109 36015 +3436846137 16813 diff --git a/test/ppmpat.test b/test/ppmpat.test new file mode 100755 index 00000000..0fe9f25a --- /dev/null +++ b/test/ppmpat.test @@ -0,0 +1,28 @@ +#! /bin/bash +# This script tests: ppmpat +# Also requires: + +# TODO 1: Write tests for squig and poles. It appears that they are +# sensitive to differences in floating point math. + +# TODO 2: Skip this test if the pseudo-random number generator is +# not glibc's rand(). + + +# Test 1. Should print: 4008533639 781 +${PBM_TESTPREFIX}ppmpat --randomseed=0 -g2 16 16 | cksum + +# Test 2. Should print: 2448908863 9613 +${PBM_TESTPREFIX}ppmpat --randomseed=0 -g2 64 50 | cksum + +# Test 3. Should print: 2698433077 1549 +${PBM_TESTPREFIX}ppmpat --randomseed=0 -madras 32 16 | cksum + +# Test 4. Should print: 3705929501 781 +${PBM_TESTPREFIX}ppmpat --randomseed=0 -tartan 16 16 | cksum + +# Test 5. Should print: 2219119109 36015 +${PBM_TESTPREFIX}ppmpat --randomseed=0 -camo 100 120 | cksum + +# Test 6. Should print: 3436846137 16813 +${PBM_TESTPREFIX}ppmpat --randomseed=0 -anticamo 80 70 | cksum diff --git a/test/sunrast-roundtrip.ok b/test/sunrast-roundtrip.ok new file mode 100644 index 00000000..82eac5a8 --- /dev/null +++ b/test/sunrast-roundtrip.ok @@ -0,0 +1 @@ +1926073387 101484 diff --git a/test/sunrast-roundtrip.test b/test/sunrast-roundtrip.test new file mode 100755 index 00000000..ee5b25e3 --- /dev/null +++ b/test/sunrast-roundtrip.test @@ -0,0 +1,6 @@ +#! /bin/bash +# This script tests: pnmtorast rasttopnm +# Also requires: + +# Should produce 1926073387 101484, cksum of testimg.ppm +${PBM_TESTPREFIX}pnmtorast testimg.ppm | ${PBM_TESTPREFIX}rasttopnm | cksum diff --git a/test/targa-roundtrip.ok b/test/targa-roundtrip.ok new file mode 100644 index 00000000..2b4b6eb9 --- /dev/null +++ b/test/targa-roundtrip.ok @@ -0,0 +1,3 @@ +2425386270 41 +2871603838 33838 +1926073387 101484 diff --git a/test/targa-roundtrip.test b/test/targa-roundtrip.test new file mode 100755 index 00000000..3fac1630 --- /dev/null +++ b/test/targa-roundtrip.test @@ -0,0 +1,21 @@ +#! /bin/bash +# This script tests: pamtotga tgatoppm +# Also requires: ppmtopgm pgmtopbm + +#Test 1: Should print 2425386270 41, cksum of testgrid.pbm + +${PBM_TESTPREFIX}pamtotga -mono testgrid.pbm | \ + ${PBM_TESTPREFIX}tgatoppm | ${PBM_BINPREFIX}ppmtopgm | \ + ${PBM_BINPREFIX}pgmtopbm -threshold -val 0.5 | cksum + +#Test 2: Should print 2871603838 33838, cksum of testimg.pgm + +${PBM_BINPREFIX}ppmtopgm testimg.ppm > ${tmpdir}/testimg.pgm +${PBM_TESTPREFIX}pamtotga -cmap ${tmpdir}/testimg.pgm | \ + ${PBM_TESTPREFIX}tgatoppm | ${PBM_BINPREFIX}ppmtopgm | cksum + +rm ${tmpdir}/testimg.pgm + +#Test 3: Should print 1926073387 101484, cksum of testimg.ppm + +${PBM_TESTPREFIX}pamtotga -rgb testimg.ppm | ${PBM_TESTPREFIX}tgatoppm | cksum diff --git a/test/utahrle-roundtrip.ok b/test/utahrle-roundtrip.ok new file mode 100644 index 00000000..35fc434c --- /dev/null +++ b/test/utahrle-roundtrip.ok @@ -0,0 +1,2 @@ +2871603838 33838 +1926073387 101484 diff --git a/test/utahrle-roundtrip.test b/test/utahrle-roundtrip.test new file mode 100755 index 00000000..7113a2d5 --- /dev/null +++ b/test/utahrle-roundtrip.test @@ -0,0 +1,14 @@ +#! /bin/bash +# This script tests: pnmtorle rletopnm +# Also requires: ppmtopgm + +#Test 1. Should print 2871603838 33838, cksum of testimg.pgm +${PBM_BINPREFIX}ppmtopgm testimg.ppm > ${tmpdir}/testimg.pgm +${PBM_TESTPREFIX}pnmtorle ${tmpdir}/testimg.pgm | \ + ${PBM_TESTPREFIX}rletopnm | cksum + +rm ${tmpdir}/testimg.pgm + +#Test 2. Should print 1926073387 101484, cksum of testimg.ppm +${PBM_TESTPREFIX}pnmtorle testimg.ppm | \ + ${PBM_TESTPREFIX}rletopnm | cksum diff --git a/test/wbmp-roundtrip.ok b/test/wbmp-roundtrip.ok new file mode 100644 index 00000000..845be5fb --- /dev/null +++ b/test/wbmp-roundtrip.ok @@ -0,0 +1 @@ +2425386270 41 diff --git a/test/wbmp-roundtrip.test b/test/wbmp-roundtrip.test new file mode 100755 index 00000000..bab2b6a5 --- /dev/null +++ b/test/wbmp-roundtrip.test @@ -0,0 +1,6 @@ +#! /bin/bash +# This script tests: pbmtowbmp wbmptopbm +# Also requires: + +# Should print 2425386270 41, cksum of testgrid.pbm +${PBM_TESTPREFIX}pbmtowbmp testgrid.pbm | ${PBM_TESTPREFIX}wbmptopbm | cksum diff --git a/test/yuv-roundtrip.ok b/test/yuv-roundtrip.ok new file mode 100644 index 00000000..b4050681 --- /dev/null +++ b/test/yuv-roundtrip.ok @@ -0,0 +1 @@ +1904478375 253455 diff --git a/test/yuv-roundtrip.test b/test/yuv-roundtrip.test new file mode 100755 index 00000000..c160c480 --- /dev/null +++ b/test/yuv-roundtrip.test @@ -0,0 +1,8 @@ +#! /bin/bash +# This script tests: ppmtoyuv yuvtoppm +# Also requires: pamgradient + +# Should produce 1904478375 253455 + +${PBM_BINPREFIX}pamgradient cyan yellow red green 352 240 | \ + ${PBM_TESTPREFIX}ppmtoyuv | ${PBM_TESTPREFIX}yuvtoppm 352 240 | cksum |