diff options
Diffstat (limited to 'test/all-in-place.test')
-rwxr-xr-x | test/all-in-place.test | 113 |
1 files changed, 88 insertions, 25 deletions
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 $? |