From a70405848cb06782036364a88e27f452fb0a0b32 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 31 Dec 2022 00:32:37 +0000 Subject: promote Development to Advanced git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4489 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- test/pamcat3.test | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100755 test/pamcat3.test (limited to 'test/pamcat3.test') diff --git a/test/pamcat3.test b/test/pamcat3.test new file mode 100755 index 00000000..3aed0131 --- /dev/null +++ b/test/pamcat3.test @@ -0,0 +1,97 @@ +#! /bin/sh +# This script tests: pamcat +# Also requires: + +tmpdir=${tmpdir:-/tmp} +list=${tmpdir}/list +list2=${tmpdir}/list2 +list3=${tmpdir}/list3 +liste1=${tmpdir}/liste1 +liste2=${tmpdir}/liste2 +liste3=${tmpdir}/liste3 +files="maze.pbm testgrid.pbm testimg.ppm" + +ls ${files} | tee ${list} | awk '{print ""; print $0; print ""}' > ${list3} +sed 's/maze.pbm/-/' ${list} > ${list2} + +echo "Test 1. Should print 585134073 133221 four times" +pamcat -lr -jt ${files} | cksum +pamcat -lr -jt -listfile=${list} | cksum +cat maze.pbm | pamcat -lr -jt -listfile=${list2} | cksum +pamcat -lr -jt -listfile=${list3} | cksum + +echo "Test 2. Should print 1331083756 152559 three times" +pamcat -tb -jl ${files} | cksum +pamcat -tb -jl -listfile=${list} | cksum +cat ${list} | pamcat -tb -jl -listfile=- | cksum + +echo "Test Invalid" + +test_out=${tmpdir}/test_out + +echo 1>&2 +echo "Invalid command-line argument combinations & listfile content." 1>&2 +echo "Error messages should appear below the line." 1>&2 +echo "-----------------------------------------------------------" 1>&2 + +# listfile not specified +pamcat -lr -listfile > ${test_out} || \ + printf "Expected failure 1" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# listfile does not exist +pamcat -lr -listfile=`mktemp -u` > ${test_out} || \ + printf "Expected failure 2" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# listfile empty +pamcat -lr -listfile=/dev/null > ${test_out} || \ + printf "Expected failure 3" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# listfile from stdin, empty +cat /dev/null | pamcat -lr -listfile=- > ${test_out} || \ + printf "Expected failure 4" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# Files provided from command line in addition to listfile +pamcat -lr -listfile=${list} testgrid.pbm testgrid.pbm > ${test_out} || \ + printf "Expected failure 5" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# "-" (stdin) provided from command line in addition to listfile +pamcat -lr -listfile=${list} - > ${test_out} || \ + printf "Expected failure 6" + test -s ${test_out}; echo " "$? + rm -f ${test_out} + +# listfile has nothing but blank lines +sed 's/^.*$//' ${list3} > ${liste1} +pamcat -lr -listfile=${liste1} > ${test_out} || \ + printf "Expected failure 7" + test -s ${test_out}; echo " "$? + rm -f ${test_out} ${liste1} + +# Non-existing file in listfile +( cat ${list} ; mktemp -u ) > ${liste2} +pamcat -lr -listfile=${liste2} > ${test_out} || \ + printf "Expected failure 8" + test -s ${test_out}; echo " "$? + rm -f ${test_out} ${liste2} + +# Multiple instances of "-" in listfile +( echo "-"; cat ${list}; echo "-"; echo "-" ) > ${liste3} +pamcat -lr -listfile=${liste3} > ${test_out} || \ + printf "Expected failure 9" + test -s ${test_out}; echo " "$? + rm -f ${test_out} ${liste3} + + +rm ${list} ${list2} ${list3} + + -- cgit 1.4.1