about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-03-25 17:14:57 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2018-03-25 17:14:57 +0000
commitcd86a2c8d798c98b2f5d7656971fc4553b4ed172 (patch)
tree6218a52f6e09f0cb0ff15c0a0b130da920328e8e /test
parente488b82f0f446576138084a1bd57b7b4406e8db0 (diff)
downloadnetpbm-mirror-cd86a2c8d798c98b2f5d7656971fc4553b4ed172.tar.gz
netpbm-mirror-cd86a2c8d798c98b2f5d7656971fc4553b4ed172.tar.xz
netpbm-mirror-cd86a2c8d798c98b2f5d7656971fc4553b4ed172.zip
Copy Development as new Advanced
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3186 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rwxr-xr-xtest/all-in-place.test2
-rw-r--r--test/gif-roundtrip.ok13
-rwxr-xr-xtest/gif-roundtrip.test105
-rw-r--r--test/jpeg-roundtrip.ok6
-rwxr-xr-xtest/jpeg-roundtrip.test23
-rw-r--r--test/pnmpsnr.ok3
-rwxr-xr-xtest/pnmpsnr.test3
-rw-r--r--test/ppmhist.ok14
-rwxr-xr-xtest/ppmhist.test21
-rw-r--r--test/tiffcmyk-roundtrip.ok10
-rwxr-xr-xtest/tiffcmyk-roundtrip.test33
11 files changed, 169 insertions, 64 deletions
diff --git a/test/all-in-place.test b/test/all-in-place.test
index 52d38bcf..a52739ed 100755
--- a/test/all-in-place.test
+++ b/test/all-in-place.test
@@ -406,7 +406,7 @@ for i in $ordinary_testprogs
     testExitStatus $i 0 ${exitStatus}
 
     if [ ${CHECK_TYPE} != "install" ]
-      then grepSwitch=$((${grepSwitch} * ${exitStatus})) ;
+      then grepSwitch=$((${grepSwitch} * ${exitStatus}==0 ? 0 : 1)) ;
     fi
   done
 
diff --git a/test/gif-roundtrip.ok b/test/gif-roundtrip.ok
index 552bf90c..1704ba03 100644
--- a/test/gif-roundtrip.ok
+++ b/test/gif-roundtrip.ok
@@ -3,9 +3,20 @@
 1571496937 33838
 1571496937 33838
 1571496937 33838
+1571496937 33838
 2425386270 41
 2425386270 41
 2425386270 41
 2425386270 41
 2425386270 41
-P1 4 1 0101 
\ No newline at end of file
+P1 4 1 0101 
+4030 0 , 4030 0
+4031 0 , 4031 0
+4097 0 , 4097 0
+238 0 , 238 0
+239 0 , 239 0
+240 0 , 240 0
+241 0 , 241 0
+255 0 , 255 0
+256 0 , 256 0
+257 0 , 257 0
diff --git a/test/gif-roundtrip.test b/test/gif-roundtrip.test
index a6d0ec4c..b49cc6d2 100755
--- a/test/gif-roundtrip.test
+++ b/test/gif-roundtrip.test
@@ -1,7 +1,6 @@
 #! /bin/bash
 # This script tests: giftopnm pamtogif
-# Also requires: ppmtorgb3 rgb3toppm pbmmake pnminvert
-
+# Also requires: ppmtorgb3 rgb3toppm pbmmake pnminvert pamcut pamdepth
 
 tmpdir=${tmpdir:-/tmp}
 
@@ -33,12 +32,13 @@ rm ${test_ppm} ${test_grn} ${test_blu} ${out_red} ${out_grn}
 
 # Test 2. Should produce 1571496937 33838
 # which is the result of cksum testimg.red
-# four times
+# five times
 
 test_gif=${tmpdir}/testimg.gif
 
 pamtogif ${test_red} | giftopnm | cksum
 pamtogif -interlace ${test_red} | giftopnm | cksum
+pamtogif -noclear ${test_red} | giftopnm | cksum
 pamtogif -sort ${test_red} | tee ${test_gif} | \
   giftopnm | cksum
 echo "junk" >> ${test_gif} && \
@@ -48,6 +48,7 @@ rm  ${test_gif} ${test_red}
 
 
 # Test 3. Should produce 2425386270 41 five times.
+# testgrid.pbm is too small for -noclear to take effect 
 
 pamtogif testgrid.pbm | giftopnm | cksum
 pamtogif -nolzw testgrid.pbm | giftopnm | cksum
@@ -56,11 +57,107 @@ 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.
 # Image data: 3 bits, end code 4 bits.
 # Should produce P1 4 1 0 1 0 1
 
 pbmmake -g 4 1 | \
-  pamtogif | giftopnm -plain | \
+  pamtogif -verbose | giftopnm -plain | \
   tr '\n' ' '
+echo ""
+
+
+# Test 5.
+# Test whether saturated code tables are handled correctly.
+# Test input images which most use up the string code table or
+# come close to doing so.
+
+# Should produce:
+# 4030 0 , 4030 0
+# 4031 0 , 4031 0
+# 4097 0 , 4097 0
+# 238 0 , 238 0
+# 239 0 , 239 0
+# 240 0 , 240 0
+# 241 0 , 241 0
+# 255 0 , 255 0
+# 256 0 , 256 0
+# 257 0 , 257 0
+
+test4097_pgm=${tmpdir}/testimg4097.pgm
+test_pgm=${tmpdir}/testimg.pgm
+
+# The following awk script produces a PGM file with no repeated sequences.
+# Here is a smaller example with the same property:
+# P2
+# 8 8
+# 7
+# 0 0 1 1 0 2 2 0
+# 3 3 0 4 4 0 5 5
+# 0 6 6 0 7 7 1 2
+# 1 3 1 4 1 5 1 6
+# 1 7 2 3 2 4 2 5
+# 2 6 2 7 3 4 3 5
+# 3 6 3 7 4 5 4 6
+# 4 7 5 6 5 7 6 7
+
+maxval=63
+awk -v maxval=${maxval} 'BEGIN \
+{ print "P2"
+         print "1 "(maxval+1) * (maxval+1) +1
+         print maxval
+         print 0 
+         for (j=i+1; j<=maxval; ++j)
+	    {print 0; print j; print j }
+         for (i=1; i<=maxval; ++i)
+             for (j=i+1; j<=maxval; ++j)
+                 {print i; print j }
+         print 0
+}' > ${test4097_pgm}
+
+for size in 4030 4031 4097
+  do
+  pamcut -height ${size} ${test4097_pgm} > ${test_pgm} &&
+  pamtogif -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
+    cmp - ${test_pgm}
+  # pamdepth ${maxval} is necessary because
+  # giftopnm output is maxval 255
+  echo -n ${size} $? ", "
+  pamtogif -nolzw ${test_pgm} | giftopnm | pamdepth ${maxval} | \
+    cmp - ${test_pgm}
+  echo ${size} $?
+  rm ${test_pgm}
+  done 
+
+rm ${test4097_pgm}
+test257_pgm=${tmpdir}/testimg257.pgm
+
+maxval=15
+awk -v maxval=${maxval} 'BEGIN \
+{ print "P2"
+         print "1 "(maxval+1) * (maxval+1) +1
+         print maxval
+         print 0 
+         for (j=i+1; j<=maxval; ++j)
+	    {print 0; print j; print j }
+         for (i=1; i<=maxval; ++i)
+             for (j=i+1; j<=maxval; ++j)
+                 {print i; print j }
+         print 0
+}' >  ${test257_pgm}
+
+for size in 238 239 240 241 255 256 257
+  do
+  pamcut -height=${size} ${test257_pgm} > ${test_pgm} &&
+  pamtogif -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
+    cmp - ${test_pgm}
+  echo -n ${size} $? ", "
+  pamtogif -nolzw -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
+    cmp - ${test_pgm}
+  echo ${size} $?
+  rm ${test_pgm}
+  done 
+
+rm ${test257_pgm}
diff --git a/test/jpeg-roundtrip.ok b/test/jpeg-roundtrip.ok
index 9a93f216..5551f78e 100644
--- a/test/jpeg-roundtrip.ok
+++ b/test/jpeg-roundtrip.ok
@@ -1,3 +1,3 @@
-  3 1000.00 1000.00 1000.00
-  3 1000.00 1000.00 1000.00
-  3 1000.00 1000.00 1000.00
+match
+match
+match
diff --git a/test/jpeg-roundtrip.test b/test/jpeg-roundtrip.test
index 23df6341..7cc0fc20 100755
--- a/test/jpeg-roundtrip.test
+++ b/test/jpeg-roundtrip.test
@@ -4,29 +4,16 @@
 
 # TODO: threshold has been determined without much thought.
 # Observed pnmpsnr output: 56.20 58.26 49.38
+# On another system:       54.73 49.41 44.52
 # A small margin has been added to the above numbers.
 
-# Should print 3 1 1 1 three times
+# Should print "match" three times
 
 pnmtojpeg testimg.ppm | jpegtopnm | \
-  pnmpsnr -machine - testimg.ppm |\
-  awk '{printf("%3d %.2f %.2f %.2f\n", NF,
-                $1>55.0 ? 1000.00 : $1,
-                $2>57.0 ? 1000.00 : $2,
-                $3>48.0 ? 1000.00 : $3) }'
-
+  pnmpsnr -target1=54 -target2=49 -target3=44 - testimg.ppm
 
 pnmtojpeg testimg.ppm -opt | jpegtopnm | \
-  pnmpsnr -machine - testimg.ppm |\
-  awk '{printf("%3d %.2f %.2f %.2f\n", NF,
-                $1>55.0 ? 1000.00 : $1,
-                $2>57.0 ? 1000.00 : $2,
-                $3>48.0 ? 1000.00 : $3) }'
-
+  pnmpsnr -target1=54 -target2=49 -target3=44 - testimg.ppm
 
 pnmtojpeg testimg.ppm -progressive | jpegtopnm | \
-  pnmpsnr -machine - testimg.ppm |\
-  awk '{printf("%3d %.2f %.2f %.2f\n", NF,
-                $1>55.0 ? 1000.00 : $1,
-                $2>57.0 ? 1000.00 : $2,
-                $3>48.0 ? 1000.00 : $3) }'
+  pnmpsnr -target1=54 -target2=49 -target3=44 - testimg.ppm
diff --git a/test/pnmpsnr.ok b/test/pnmpsnr.ok
index 4c7eccde..3469f836 100644
--- a/test/pnmpsnr.ok
+++ b/test/pnmpsnr.ok
@@ -1,4 +1,7 @@
 0.00
 inf
 1000.00
+match
 300.00 300.00 300.00
+match
+match
diff --git a/test/pnmpsnr.test b/test/pnmpsnr.test
index c7591983..f24c08aa 100755
--- a/test/pnmpsnr.test
+++ b/test/pnmpsnr.test
@@ -15,6 +15,9 @@ pbmmake -b 10 10 > ${b_pbm}
 pnmpsnr  ${w_pbm}  ${b_pbm} -machine
 pnmpsnr  ${w_pbm}  ${w_pbm} -machine
 pnmpsnr  ${w_pbm}  ${w_pbm} -machine -max=1000
+pnmpsnr  ${w_pbm}  ${w_pbm} -target=1000
 pnmpsnr  testimg.ppm  testimg.ppm -machine -max=300
+pnmpsnr  testimg.ppm  testimg.ppm -target=1000
+pnmpsnr  testimg.ppm  testimg.ppm -target1=1000 -target2=1000 -target3=1000
 
 rm ${b_pbm} ${w_pbm}
diff --git a/test/ppmhist.ok b/test/ppmhist.ok
index d7ecf07e..f2ba637b 100644
--- a/test/ppmhist.ok
+++ b/test/ppmhist.ok
@@ -1,5 +1,3 @@
-   r     g     b   	 lum 	 count  
- ----- ----- ----- 	-----	------- 
      0     0     0	    0	      2 
      1     1     1	    1	      2 
      2     2     2	    2	      2 
@@ -8,4 +6,14 @@
      5     5     5	    5	      2 
      6     6     6	    6	      2 
      8     8     8	    8	      2 
-3438989921 711087
+3081591280 60957
+ Summary: 1 colors: 1 black, 0 white, 0 gray, 0 color
+ Summary: 1 colors: 0 black, 1 white, 0 gray, 0 color
+ Summary: 2 colors: 1 black, 1 white, 0 gray, 0 color
+ Summary: 16 colors: 1 black, 1 white, 14 gray, 0 color
+ Summary: 8 colors: 1 black, 1 white, 6 gray, 0 color
+ Summary: 8 colors: 1 black, 1 white, 0 gray, 6 color
+ Summary: 27 colors: 1 black, 1 white, 1 gray, 24 color
+ Summary: 6 colors: 0 black, 0 white, 0 gray, 6 color
+ Summary: 6 colors: 1 black, 0 white, 0 gray, 5 color
+ Summary: 6 colors: 1 black, 1 white, 1 gray, 3 color
diff --git a/test/ppmhist.test b/test/ppmhist.test
index 97fbd79d..27d31562 100755
--- a/test/ppmhist.test
+++ b/test/ppmhist.test
@@ -1,7 +1,22 @@
 #! /bin/bash
 # This script tests: ppmhist
-# Also requires: pgmramp
+# Also requires: pgmramp pamtopnm pbmmake pamseq ppmpat
 
+pgmramp -maxval=8 -lr 8 2 | ppmhist -sort=rgb -noheader
+ppmhist -map -sort=rgb -noheader testimg.ppm | pamtopnm | cksum
 
-pgmramp -maxval=8 -lr 8 2 | ppmhist -sort=rgb
-ppmhist -map -sort=rgb testimg.ppm | cksum
+# Test summary header
+
+pbmmake -b 2 1 | ppmhist   | head -n1
+pbmmake -w 2 1 | ppmhist   | head -n1
+pbmmake -g 2 1 | ppmhist   | head -n1
+pgmramp -lr 16 1 | ppmhist | head -n1
+pgmramp -lr -maxval=7 16 1 | ppmhist | head -n1
+pamseq  3 1 | ppmhist | head -n1
+pamseq  3 2 | ppmhist | head -n1
+ppmpat -madras --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 25 25 | \
+  ppmhist | head -n1
+ppmpat -madras --color=rgb:00/00/00,rgb:31/58/a3,rgb:e9/5e/d4 25 25 | \
+  ppmhist | head -n1
+ppmpat -madras --color=rgb:00/00/00,rgb:31/58/a3,rgb:ff/ff/ff 25 25 | \
+  ppmhist | head -n1
\ No newline at end of file
diff --git a/test/tiffcmyk-roundtrip.ok b/test/tiffcmyk-roundtrip.ok
index 5f4963cd..05c0b188 100644
--- a/test/tiffcmyk-roundtrip.ok
+++ b/test/tiffcmyk-roundtrip.ok
@@ -1,5 +1,5 @@
-  3 1000.00 1000.00 1000.00
-  3 1000.00 1000.00 1000.00
-  3 1000.00 1000.00 1000.00
-  3 1000.00 1000.00 1000.00
-  3 1000.00 1000.00 1000.00
+match
+match
+match
+match
+match
diff --git a/test/tiffcmyk-roundtrip.test b/test/tiffcmyk-roundtrip.test
index 99e02c48..133c81b7 100755
--- a/test/tiffcmyk-roundtrip.test
+++ b/test/tiffcmyk-roundtrip.test
@@ -15,47 +15,28 @@ output_tiff=${tmpdir}/output.tiff
 
 pnmtotiffcmyk testimg.ppm > ${output_tiff} && \
   tifftopnm -headerdump -byrow ${output_tiff} | \
-  pnmpsnr -machine - testimg.ppm | \
-  awk '{printf("%3d %.2f %.2f %.2f\n", NF,
-                $1>45.0 ? 1000.00 : $1,
-                $2>59.5 ? 1000.00 : $2,
-                $3>56.5 ? 1000.00 : $3) }'
+  pnmpsnr -target1=45.0 -target2=59.5 -target3=56.5 - testimg.ppm
 
 
 # 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 %.2f %.2f %.2f\n", NF,
-                $1>45.0 ? 1000.00 : $1,
-                $2>59.5 ? 1000.00 : $2,
-                $3>56.5 ? 1000.00 : $3) }'
+  pnmpsnr -target1=45.0 -target2=59.5 -target3=56.5 - testimg.ppm
 
 
 pnmtotiffcmyk -packbits testimg.ppm > ${output_tiff} && \
   tifftopnm -byrow ${output_tiff} | \
-  pnmpsnr -machine - testimg.ppm | \
-  awk '{printf("%3d %.2f %.2f %.2f\n", NF,
-                $1>45.0 ? 1000.00 : $1,
-                $2>59.5 ? 1000.00 : $2,
-                $3>56.5 ? 1000.00 : $3) }'
+  pnmpsnr -target1=45.0 -target2=59.5 -target3=56.5 - testimg.ppm
 
 
 pnmtotiffcmyk -lzw testimg.ppm > ${output_tiff} && \
   tifftopnm -byrow ${output_tiff} | \
-    pnmpsnr -machine - testimg.ppm | \
-  awk '{printf("%3d %.2f %.2f %.2f\n", NF,
-                $1>45.0 ? 1000.00 : $1,
-                $2>59.5 ? 1000.00 : $2,
-                $3>56.5 ? 1000.00 : $3) }'
+  pnmpsnr -target1=45.0 -target2=59.5 -target3=56.5 - testimg.ppm
 
 
 pnmtotiffcmyk -lzw -predictor 2 testimg.ppm > ${output_tiff} && \
   tifftopnm -respectfillorder -byrow ${output_tiff} | \
-  pnmpsnr -machine - testimg.ppm | \
-  awk '{printf("%3d %.2f %.2f %.2f\n", NF,
-                $1>45.0 ? 1000.00 : $1,
-                $2>59.5 ? 1000.00 : $2,
-                $3>56.5 ? 1000.00 : $3) }'
+  pnmpsnr -target1=45.0 -target2=59.5 -target=56.5 - testimg.ppm
 
-rm ${output_tiff}
\ No newline at end of file
+
+rm ${output_tiff}