about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2017-03-30 01:36:42 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2017-03-30 01:36:42 +0000
commit7d3ec71c7aa5ba5ee4aec5a0abd62a4f64e131b6 (patch)
treeec4b35c867906871eb224337a0320b667910ccb2 /test
parent61d34764c63a99b42b4a6100e00d6c642c677a96 (diff)
downloadnetpbm-mirror-7d3ec71c7aa5ba5ee4aec5a0abd62a4f64e131b6.tar.gz
netpbm-mirror-7d3ec71c7aa5ba5ee4aec5a0abd62a4f64e131b6.tar.xz
netpbm-mirror-7d3ec71c7aa5ba5ee4aec5a0abd62a4f64e131b6.zip
Add tiffcmyk test, improve ppmpat, tiff roundtrip test
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2935 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rwxr-xr-xtest/Execute-Tests3
-rw-r--r--test/Test-Order4
-rwxr-xr-xtest/all-in-place.test33
-rwxr-xr-xtest/legacy-names.test21
-rw-r--r--test/ppmpat-random.ok3
-rwxr-xr-xtest/ppmpat-random.test30
-rw-r--r--test/ppmpat.ok6
-rwxr-xr-xtest/ppmpat.test38
-rw-r--r--test/tiff-flate-lzw-roundtrip.ok12
-rwxr-xr-xtest/tiff-flate-lzw-roundtrip.test23
-rw-r--r--test/tiff-roundtrip.ok30
-rwxr-xr-xtest/tiff-roundtrip.test85
-rw-r--r--test/tiffcmyk-roundtrip.ok5
-rwxr-xr-xtest/tiffcmyk-roundtrip.test46
14 files changed, 275 insertions, 64 deletions
diff --git a/test/Execute-Tests b/test/Execute-Tests
index 39d6a5d1..bf8ecb56 100755
--- a/test/Execute-Tests
+++ b/test/Execute-Tests
@@ -180,7 +180,8 @@ elif [ $VALGRIND_TESTS = "on" ]
   vg_command_base="valgrind --trace-children=yes";
 
   for i in awk cat cksum cmp cp cut date dirname egrep fgrep file grep gs \
-    head mkdir mktemp perl rm sed seq sh tee testrandom tr uniq
+    head mkdir mktemp perl rm sed seq sh tee testrandom tr uniq \
+    Available-Testprog
 
     # Tell valgrind not to probe execution of the above programs.
 
diff --git a/test/Test-Order b/test/Test-Order
index 8c5a7aae..767d7f76 100644
--- a/test/Test-Order
+++ b/test/Test-Order
@@ -18,11 +18,12 @@ ppmgauss.test
 ppmcie.test
 ppmwheel.test
 pamcrater.test
+ppmpat.test
 
 # Generators with random components
 
 pgmnoise.test
-ppmpat.test
+ppmpat-random.test
 ppmforge.test
 ppmrough.test
 
@@ -159,4 +160,5 @@ xwd-roundtrip.test
 
 fiasco-roundtrip.test
 jpeg-roundtrip.test
+tiffcmyk-roundtrip.test
 yuv-roundtrip.test
diff --git a/test/all-in-place.test b/test/all-in-place.test
index 1cdae7f6..7c17efc7 100755
--- a/test/all-in-place.test
+++ b/test/all-in-place.test
@@ -368,9 +368,17 @@ ordinary_testprogs="\
 "
 
 
-# The string "fiascotopnm" has to be filtered out by egrep for fiascotopnm
+# The string "fiascotopnm" has to be filtered out by fgrep for fiascotopnm
 # has a slightly different version report format.
 
+# Switch to control output from "program --version"
+#
+grepSwitch=1        # Initial value
+                    # Always 1 for check-install,
+                    # otherwise changes to 0 once a command succeeds.
+grepOption[0]="-v"  # Suppress output
+grepOption[1]=""    # Output --version message
+
 for i in $ordinary_testprogs
   do
     # Stub out programs that aren't built.
@@ -381,11 +389,24 @@ for i in $ordinary_testprogs
       continue
       fi
 
-    $i --version  2>&1 | \
-    egrep -v -e fiascotopnm -e \
-    "(Using libnetpbm|Compiled|(BSD|SYSV|MSDOS|AMIGA) defined|RGB_?ENV=)" \
-      1>&2;
-    testExitStatus $i 0 ${PIPESTATUS[0]}
+
+    $i --version < /dev/null 2>&1 | \
+    # Older versions of pamstretch-gen and ppmshadow (encountered when
+    # one does "make check-install") get stuck when there is no input.
+    # Supply /dev/null as input to placate these programs.
+    
+    egrep -v -e "fiascotopnm" -e \
+    ": ((BSD|SYSV|MSDOS|AMIGA) defined|RGB_?ENV=)" | \
+    egrep ${grepOption[$grepSwitch]} -e \
+    ": (Using lib(net)?pbm|(Built (by|at)|Compiled ))" 1>&2;
+    # See showVersion() in lib/libpm.c for the above regular expressions.
+  
+    exitStatus=${PIPESTATUS[0]}
+    testExitStatus $i 0 ${exitStatus}
+
+    if [ ${CHECK_TYPE} != "install" ]
+      then grepSwitch=$((${grepSwitch} * ${exitStatus})) ;
+    fi
   done
 
 
diff --git a/test/legacy-names.test b/test/legacy-names.test
index 46bc9ee4..5a65615f 100755
--- a/test/legacy-names.test
+++ b/test/legacy-names.test
@@ -94,6 +94,13 @@ ordinary_testprogs="\
   ppmtouil \
 "
 
+# Switch to control output from "program --version"
+# See comments in all-in-place.test
+
+if [ ${CHECK_TYPE} = "install" ]
+  then grepOption[1]="" ;   # Output --version message
+  else grepOption[0]="-v" ; # Suppress output
+fi
 
 for i in $ordinary_testprogs
   do
@@ -105,11 +112,15 @@ for i in $ordinary_testprogs
       continue
       fi
 
-    $i --version  2>&1 | \
-    egrep -v \
-    "(Using libnetpbm|Compiled|(BSD|SYSV|MSDOS|AMIGA) defined|RGB_?ENV=)" \
-      1>&2;
-    testExitStatus $i 0 ${PIPESTATUS[0]}
+    $i --version < /dev/null 2>&1 | \
+    egrep -v -e "fiascotopnm" -e \
+    ": ((BSD|SYSV|MSDOS|AMIGA) defined|RGB_?ENV=)" | \
+    egrep ${grepOption[$grepSwitch]} -e \
+    ": (Using lib(net)?pbm|(Built (by|at)|Compiled ))" 1>&2;
+    # See showVersion() in lib/libpm.c for the above regular expressions.
+  
+    exitStatus=${PIPESTATUS[0]}
+    testExitStatus $i 0 ${exitStatus}
   done
 
 
diff --git a/test/ppmpat-random.ok b/test/ppmpat-random.ok
new file mode 100644
index 00000000..4d298cec
--- /dev/null
+++ b/test/ppmpat-random.ok
@@ -0,0 +1,3 @@
+2219119109 36015
+3436846137 16813
+908097729 16813
diff --git a/test/ppmpat-random.test b/test/ppmpat-random.test
new file mode 100755
index 00000000..d9f69c18
--- /dev/null
+++ b/test/ppmpat-random.test
@@ -0,0 +1,30 @@
+#! /bin/bash
+# This script tests: ppmpat
+# Also requires:
+
+# TODO: Write tests for squig and poles.  It appears that they are
+# sensitive to differences in floating point math.
+
+# These tests require random numbers.
+
+testrandom -q
+case $? in
+   81)
+   # Test 1. Should print: 2219119109 36015
+   ppmpat --randomseed=0 -camo 100 120 | cksum
+
+   # Test 2. Should print: 3436846137 16813
+   ppmpat --randomseed=0 -anticamo 80 70 | cksum
+
+   # Test 3. Should print: 908097729 16813
+   ppmpat --randomseed=0 --color \
+     rgb:55/c0/34,rgb:0/ff/0,rgb:0/ee/0,rgb:0/cd/0,rgb:0/8b/0,rgb:4f/4f/2f \
+     -camo 80 70 | cksum
+   ;;
+
+   8[02-9] | 90)
+       echo "Skipping: random number generator is not glibc." 1>&2
+       exit 80;;
+
+   *)  exit 1;;  # testrandom failed
+esac
diff --git a/test/ppmpat.ok b/test/ppmpat.ok
index c5b71909..bb940aee 100644
--- a/test/ppmpat.ok
+++ b/test/ppmpat.ok
@@ -1,6 +1,6 @@
 4008533639 781
-2448908863 9613
+3805937800 9613
 2698433077 1549
 3705929501 781
-2219119109 36015
-3436846137 16813
+3057513592 661
+1861389287 661
diff --git a/test/ppmpat.test b/test/ppmpat.test
index 89f86f67..cd00c0f1 100755
--- a/test/ppmpat.test
+++ b/test/ppmpat.test
@@ -2,34 +2,20 @@
 # This script tests: ppmpat
 # Also requires:
 
-# TODO: Write tests for squig and poles.  It appears that they are
-# sensitive to differences in floating point math.
+# Test 1. Should print: 4008533639 781
+ppmpat -g2 --color=rgb:32/0d/b7,rgb:31/58/a3 16 16 | cksum
 
-testrandom -q
-case $? in
-   81)
-       # Test 1. Should print: 4008533639 781
-       ppmpat --randomseed=0 -g2 16 16 | cksum
+# Test 2. Should print: 3805937800 9613
+ppmpat -g3 --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 64 50 | cksum
 
-       # Test 2. Should print: 2448908863 9613
-       ppmpat --randomseed=0 -g2 64 50 | cksum
+# Test 3. Should print: 2698433077 1549
+ppmpat -madras --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 32 16 | cksum
 
-       # Test 3. Should print: 2698433077 1549
-       ppmpat --randomseed=0 -madras 32 16 | cksum
+# Test 4. Should print: 3705929501 781
+ppmpat -tartan --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 16 16 | cksum
 
-       # Test 4. Should print: 3705929501 781
-       ppmpat --randomseed=0 -tartan 16 16 | cksum
+# Test 5. Should print: 3057513592 661
+ppmpat -argyle1 --color=rgb:ff/ff/ff,rgb:ff/0/0 12 18 | cksum
 
-       # Test 5. Should print: 2219119109 36015
-       ppmpat --randomseed=0 -camo 100 120 | cksum
-
-       # Test 6. Should print: 3436846137 16813
-       ppmpat --randomseed=0 -anticamo 80 70 | cksum
-       ;;
-
-   8[02-9] | 90)
-       echo "Skipping: random number generator is not glibc." 1>&2
-       exit 80;;
-
-   *)  exit 1;;  # testrandom failed
-esac
+# Test 6. Should print: 1861389287 661
+ppmpat -argyle2 --color=rgb:00/00/00,rgb:ff/80/80,rgb:e0/e0/e0 12 18 | cksum
diff --git a/test/tiff-flate-lzw-roundtrip.ok b/test/tiff-flate-lzw-roundtrip.ok
index 0ee3e083..4d5597cc 100644
--- a/test/tiff-flate-lzw-roundtrip.ok
+++ b/test/tiff-flate-lzw-roundtrip.ok
@@ -1,7 +1,7 @@
-764594701 101484
-764594701 101484
-764594701 101484
-764594701 101484
-764594701 101484
-764594701 101484
+1079668603 10237
+1079668603 10237
+1079668603 10237
+1079668603 10237
+1079668603 10237
+1079668603 10237
 2425386270 41
diff --git a/test/tiff-flate-lzw-roundtrip.test b/test/tiff-flate-lzw-roundtrip.test
index 7e28a899..59d4c483 100755
--- a/test/tiff-flate-lzw-roundtrip.test
+++ b/test/tiff-flate-lzw-roundtrip.test
@@ -1,6 +1,6 @@
 #! /bin/bash
 # This script tests: pamtotiff tifftopnm
-# Also requires: pnmquant
+# Also requires: ppmpat
 
 # Failure message
 ## If tiff-rountrip.test succeeds and this test fails, the likely
@@ -9,25 +9,26 @@
 
 tmpdir=${tmpdir:-/tmp}
 
-test40_ppm=${tmpdir}/testimg40.ppm
+tartan_ppm=${tmpdir}/testimg40.ppm
 
 # Make a test image with reduced colors which compresses better
-# cksum is 764594701 101484
- 
-pnmquant 40 testimg.ppm | tee ${test40_ppm} | cksum
-pamtotiff ${test40_ppm} | tifftopnm | cksum
+# cksum is 1079668603 10237
+
+ppmpat -tartan --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 71 48 | \
+  tee ${tartan_ppm} | cksum
+pamtotiff ${tartan_ppm} | tifftopnm | cksum
 
 # test flate compression
-pamtotiff -flate ${test40_ppm} | tifftopnm | cksum
+pamtotiff -flate ${tartan_ppm} | tifftopnm | cksum
 
 # test adobeflate compression
-pamtotiff -adobeflate ${test40_ppm} | tifftopnm | cksum
+pamtotiff -adobeflate ${tartan_ppm} | tifftopnm | cksum
 
 # test LZW compression
-pamtotiff -lzw ${test40_ppm} | tifftopnm | cksum
-pamtotiff -lzw -predictor=1 ${test40_ppm} | tifftopnm | cksum
+pamtotiff -lzw ${tartan_ppm} | tifftopnm | cksum
+pamtotiff -lzw -predictor=1 ${tartan_ppm} | tifftopnm | cksum
 
 # PBM image: test flate compression
 pamtotiff -flate testgrid.pbm | tifftopnm | cksum
 
-rm ${test40_ppm}
+rm ${tartan_ppm}
diff --git a/test/tiff-roundtrip.ok b/test/tiff-roundtrip.ok
index f6f04103..14258de2 100644
--- a/test/tiff-roundtrip.ok
+++ b/test/tiff-roundtrip.ok
@@ -1,8 +1,38 @@
+PPM-rose
 1926073387 101484
 1926073387 101484
 1926073387 101484
 1926073387 101484
 1926073387 101484
+PPM-6
+1646869394 29498
+1646869394 29498
+1646869394 29498
+1646869394 29498
+PPM-2
+3743909631 14836
+3743909631 14836
+3743909631 14836
+3743909631 14836
+PPM-gray
+603974118 4954
+603974118 4954
+603974118 4954
+603974118 4954
+603974118 4954
+603974118 4954
+PPM-bilevel-black-white
+1001018459 4954
+1001018459 4954
+1001018459 4954
+1001018459 4954
+PBM
 2425386270 41
 2425386270 41
 2425386270 41
+Extract from multi-image TIFF
+1926073387 101484
+1646869394 29498
+3743909631 14836
+603974118 4954
+1001018459 4954
diff --git a/test/tiff-roundtrip.test b/test/tiff-roundtrip.test
index 747006b3..55aba278 100755
--- a/test/tiff-roundtrip.test
+++ b/test/tiff-roundtrip.test
@@ -1,24 +1,99 @@
 #! /bin/bash
 # This script tests: pamtotiff tifftopnm
-# Also requires:
+# Also requires: ppmpat pampick ppmtopgm
 
 # Failure message
 ## If this test fails, the cause may be a problem in the TIFF library.
 
+tmpdir=${tmpdir:-/tmp}
+tartan_ppm=${tmpdir}/tartan.ppm
+gingham_ppm=${tmpdir}/gingham.ppm
+argylecolor_ppm=${tmpdir}/argyle1.ppm
+argylegray_ppm=${tmpdir}/argyle2.ppm
+multiimage_tiff=${tmpdir}/multiimage.ppm
+
 # PPM image
 # Should print 1926073387 101484 five times
 
-pamtotiff testimg.ppm | tifftopnm | cksum
-pamtotiff -truecolor testimg.ppm | tifftopnm | cksum
-
+echo PPM-rose
+pamtotiff testimg.ppm | tifftopnm -headerdump | cksum
+pamtotiff -truecolor testimg.ppm -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} -byrow | cksum
 pamtotiff -truecolor -packbits testimg.ppm | tifftopnm | cksum
 pamtotiff -truecolor -rowsperstrip=2 testimg.ppm | tifftopnm | cksum
 pamtotiff -truecolor -lsb2msb  testimg.ppm | \
   tifftopnm -respectfillorder | cksum
 
+# PPM image with six colors
+# Should print 1646869394 29498 four times
+
+echo PPM-6
+ppmpat -tartan -color=rgb:0/8/8,rgb:8/f/8,rgb:f/f/0 108 91 | \
+  tee ${tartan_ppm} | cksum
+pamtotiff -truecolor ${tartan_ppm} | tifftopnm | cksum
+pamtotiff ${tartan_ppm} | tifftopnm -respectfillorder | cksum
+pamtotiff ${tartan_ppm} -append -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} | pampick 1 | cksum
+
+
+# PPM image with two colors
+# Should print 3743909631 14836 four times
+
+echo PPM-2
+ppmpat -argyle2 -color=rgb:0/0/0,rgb:f/8/f,rgb:0/0/0 61 81 | \
+  tee ${argylecolor_ppm} | cksum
+pamtotiff -indexbits=2 ${argylecolor_ppm} -append -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} | pampick 2 | cksum
+pamtotiff -indexbits=1 ${argylecolor_ppm} | tifftopnm | cksum
+pamtotiff -indexbits=1 -g4 ${argylecolor_ppm} | tifftopnm | cksum
+
+# PPM image with six shades of gray
+# pamtotiff detects the absence of colors and produces a grayscale
+# tiff image unless -color is specified
+# Pipeline output is PGM unless -color is specified
+# Should print 603974118 4954 six times
+
+echo PPM-gray
+ppmpat -gingham3 -color=rgb:0/0/0,rgb:ff/ff/ff,rgb:0/0/0 61 81 | \
+  tee ${gingham_ppm} | ppmtopgm | cksum
+pamtotiff -color ${gingham_ppm} | tifftopnm | cksum
+pamtotiff -indexbits=1,2 -mb -fill ${gingham_ppm} | tifftopnm | cksum
+pamtotiff -indexbits=1,2 -mw ${gingham_ppm} | tifftopnm | cksum
+pamtotiff -indexbits=1,2,4,8 -mb ${gingham_ppm} | tifftopnm | cksum
+pamtotiff -mb ${gingham_ppm} -append -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} | pampick 3 | cksum
+
+# PPM image with two shades of gray (bilevel)
+# pamtotiff detects the absence of colors and produces a grayscale
+# tiff image unless -color is specified
+# Pipeline output is PGM unless -color is specified
+# Should print 1001018459 4954 four times
+
+echo PPM-bilevel-black-white
+ppmpat -argyle2 -color=rgb:0/0/0,rgb:ff/ff/ff,rgb:0/0/0 61 81 | \
+  tee ${argylegray_ppm} | ppmtopgm | cksum
+pamtotiff -color -fill ${argylegray_ppm} | tifftopnm | cksum
+pamtotiff -indexbits=1 -mw ${argylegray_ppm} | tifftopnm | cksum
+pamtotiff -mb ${argylegray_ppm} -append -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} | pampick 4 | cksum
+
 # PBM image
 # Should print 2425386270 41 three times
 
+echo PBM
 pamtotiff testgrid.pbm | tifftopnm | cksum
 pamtotiff -g3 -fill testgrid.pbm | tifftopnm | cksum
-pamtotiff -g4 testgrid.pbm | tifftopnm | cksum
+pamtotiff -g4 -mb testgrid.pbm -append -output ${multiimage_tiff} && \
+  tifftopnm ${multiimage_tiff} | pampick 5 | cksum
+
+# Extract individual images from multi-image tiff file
+
+echo "Extract from multi-image TIFF"
+tifftopnm ${multiimage_tiff} | pampick 0 | cksum
+tifftopnm ${multiimage_tiff} | pampick 1 | cksum
+tifftopnm ${multiimage_tiff} | pampick 2 | cksum
+tifftopnm ${multiimage_tiff} | pampick 3 | cksum
+tifftopnm ${multiimage_tiff} | pampick 4 | cksum
+
+rm ${tartan_ppm} ${gingham_ppm} ${argylecolor_ppm} \
+   ${argylegray_ppm} ${multiimage_tiff}
\ No newline at end of file
diff --git a/test/tiffcmyk-roundtrip.ok b/test/tiffcmyk-roundtrip.ok
new file mode 100644
index 00000000..e152d0a7
--- /dev/null
+++ b/test/tiffcmyk-roundtrip.ok
@@ -0,0 +1,5 @@
+  3 1 1 1
+  3 1 1 1
+  3 1 1 1
+  3 1 1 1
+  3 1 1 1
diff --git a/test/tiffcmyk-roundtrip.test b/test/tiffcmyk-roundtrip.test
new file mode 100755
index 00000000..e123d807
--- /dev/null
+++ b/test/tiffcmyk-roundtrip.test
@@ -0,0 +1,46 @@
+#! /bin/bash
+# This script tests: pnmtotiffcmyk tifftopnm
+# Also requires: pnmpsnr
+
+# Failure message
+## If this test fails, the cause may be a problem in the TIFF library.
+
+tmpdir=${tmpdir:-/tmp}
+tartan_ppm=${tmpdir}/tartan.ppm
+output_ppm=${tmpdir}/output.ppm
+output_tiff=${tmpdir}/output.tiff
+
+# Note that color images cannot be tested by the roundtrip method
+# because of approximations incurred by converting from RGB to CMYK
+
+pnmtotiffcmyk testimg.ppm > ${output_tiff} && \
+  tifftopnm -headerdump -byrow ${output_tiff} | \
+  pnmpsnr -machine - testimg.ppm | \
+  awk '{printf("%3d %1d %1d %1d\n",NF,$1>45.0,$2>59.5,$3>56.5)}'
+
+
+# Note that "-rowsperstrip=1" does not work
+pnmtotiffcmyk -rowsperstrip 1 -lsb2msb testimg.ppm > ${output_tiff} && \
+  tifftopnm -respectfillorder -byrow  ${output_tiff} | \
+  pnmpsnr -machine - testimg.ppm | \
+  awk '{printf("%3d %1d %1d %1d\n",NF,$1>45.0,$2>59.5,$3>56.5)}'
+
+
+pnmtotiffcmyk -packbits testimg.ppm > ${output_tiff} && \
+  tifftopnm -byrow ${output_tiff} | \
+  pnmpsnr -machine - testimg.ppm | \
+  awk '{printf("%3d %1d %1d %1d\n",NF,$1>45.0,$2>59.5,$3>56.5)}'
+
+
+pnmtotiffcmyk -lzw testimg.ppm > ${output_tiff} && \
+  tifftopnm -byrow ${output_tiff} | \
+    pnmpsnr -machine - testimg.ppm | \
+  awk '{printf("%3d %1d %1d %1d\n",NF,$1>45.0,$2>59.5,$3>56.5)}'
+
+
+pnmtotiffcmyk -lzw -predictor 2 testimg.ppm > ${output_tiff} && \
+  tifftopnm -respectfillorder -byrow ${output_tiff} | \
+  pnmpsnr -machine - testimg.ppm | \
+  awk '{printf("%3d %1d %1d %1d\n",NF,$1>45.0,$2>59.5,$3>56.5)}'
+
+rm ${output_tiff}
\ No newline at end of file