about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-06-28 23:54:29 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2019-06-28 23:54:29 +0000
commitbe0a23cddaf0182d1fda4f623a3b23f67db91d73 (patch)
tree5d46db6bd85005728f7821965e66e3e5f0018d62 /test
parentb13ba8b9b606c916e0bda39348ee009e920df22e (diff)
downloadnetpbm-mirror-be0a23cddaf0182d1fda4f623a3b23f67db91d73.tar.gz
netpbm-mirror-be0a23cddaf0182d1fda4f623a3b23f67db91d73.tar.xz
netpbm-mirror-be0a23cddaf0182d1fda4f623a3b23f67db91d73.zip
Promote Development to Advanced
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@3647 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rwxr-xr-xtest/Execute-Tests7
-rw-r--r--test/Test-Order8
-rwxr-xr-xtest/bmp-quant-roundtrip.test2
-rwxr-xr-xtest/g3-roundtrip.test2
-rw-r--r--test/pad-crop-roundtrip.ok2
-rwxr-xr-xtest/pad-crop-roundtrip.test15
-rw-r--r--test/pamditherbw.ok24
-rwxr-xr-xtest/pamditherbw.test52
-rw-r--r--test/pamfile.ok7
-rwxr-xr-xtest/pamfile.test16
-rw-r--r--test/pamfind.ok178
-rwxr-xr-xtest/pamfind.test11
-rw-r--r--test/pamgauss.ok10
-rwxr-xr-xtest/pamgauss.test21
-rw-r--r--test/pamhue-roundtrip.ok10
-rwxr-xr-xtest/pamhue-roundtrip.test19
-rw-r--r--test/pamhue.ok25
-rwxr-xr-xtest/pamhue.test10
-rw-r--r--test/pamscale-filters3.ok1
-rwxr-xr-xtest/pamscale-filters3.test3
-rw-r--r--test/pamseq.ok6
-rwxr-xr-xtest/pamseq.test19
-rw-r--r--test/pamsumm.ok7
-rwxr-xr-xtest/pamsumm.test16
-rwxr-xr-xtest/pamtable.test2
-rwxr-xr-xtest/pbm-misc-converters.test2
-rw-r--r--test/pbmclean.ok13
-rwxr-xr-xtest/pbmclean.test25
-rw-r--r--test/pbmmake.ok21
-rwxr-xr-xtest/pbmmake.test23
-rw-r--r--test/pbmpage.ok6
-rwxr-xr-xtest/pbmpage.test19
-rw-r--r--test/pbmupc.ok11
-rwxr-xr-xtest/pbmupc.test18
-rwxr-xr-xtest/pdb-roundtrip.test2
-rw-r--r--test/pgmhist.ok22
-rwxr-xr-xtest/pgmhist.test25
-rw-r--r--test/pgmmake.ok10
-rwxr-xr-xtest/pgmmake.test19
-rw-r--r--test/pgmramp.ok9
-rwxr-xr-xtest/pgmramp.test19
-rw-r--r--test/pnmcrop-blank.ok130
-rwxr-xr-xtest/pnmcrop-blank.test55
-rw-r--r--test/pnmcrop1.ok103
-rwxr-xr-xtest/pnmcrop1.test75
-rw-r--r--test/pnmcrop2.ok29
-rwxr-xr-xtest/pnmcrop2.test55
-rw-r--r--test/pnmcrop3.ok90
-rwxr-xr-xtest/pnmcrop3.test71
-rw-r--r--test/pnmpsnr.ok7
-rwxr-xr-xtest/pnmpsnr.test21
-rwxr-xr-xtest/pnmquantall.test2
-rw-r--r--test/ppmforge-parameters.ok10
-rwxr-xr-xtest/ppmforge-parameters.test29
-rw-r--r--test/ppmhist.ok6
-rwxr-xr-xtest/ppmhist.test18
-rw-r--r--test/ppmmake.ok13
-rwxr-xr-xtest/ppmmake.test20
-rw-r--r--test/ppmpat.ok33
-rwxr-xr-xtest/ppmpat.test55
-rwxr-xr-xtest/sgi-roundtrip.test2
61 files changed, 1501 insertions, 40 deletions
diff --git a/test/Execute-Tests b/test/Execute-Tests
index 7a65d51f..3530d978 100755
--- a/test/Execute-Tests
+++ b/test/Execute-Tests
@@ -179,9 +179,10 @@ 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 iconv mkdir mktemp perl rm sed seq sh tee testrandom tr uniq \
-    Available-Testprog
+  for i in awk basename cat cksum cmp comm cp cut date dirname \
+           egrep fgrep file grep gs head iconv mkdir mktemp perl rm \
+           sed seq sh sort tee tr uniq wc \
+           testrandom Available-Testprog
 
     # Tell valgrind not to probe execution of the above programs.
 
diff --git a/test/Test-Order b/test/Test-Order
index 49eaeff2..e9ea1b55 100644
--- a/test/Test-Order
+++ b/test/Test-Order
@@ -22,6 +22,7 @@ ppmcie.test
 ppmwheel.test
 pamcrater.test
 ppmpat.test
+ppmforge-parameters.test
 
 # Generators with random components
 
@@ -53,6 +54,7 @@ pnmtopnm-plain.test
 # Editor tests
 
 pamditherbw.test
+pamhue.test
 
 pbmclean.test
 pamcut.test
@@ -89,6 +91,11 @@ pamenlarge-pamscale-point.test
 
 pamstretch.test
 
+pnmcrop1.test
+pnmcrop2.test
+pnmcrop3.test
+pnmcrop-blank.test
+
 ppmmix.test
 pammixmulti-identity.test
 
@@ -125,6 +132,7 @@ pamslice-roundtrip.test
 lookup-roundtrip.test
 enlarge-reduce-roundtrip.test
 cut-cat-roundtrip.test
+pamhue-roundtrip.test
 
 # Round-trip tests : lossless converters
 
diff --git a/test/bmp-quant-roundtrip.test b/test/bmp-quant-roundtrip.test
index 2c223b7c..9f1036d0 100755
--- a/test/bmp-quant-roundtrip.test
+++ b/test/bmp-quant-roundtrip.test
@@ -1,6 +1,6 @@
 #! /bin/bash
 # This script tests: bmptopnm ppmtobmp pnmquant
-# Also requires: ppmhist
+# Also requires:
 
 tmpdir=${tmpdir:-/tmp}
 quant_ppm=${tmpdir}/quant.ppm
diff --git a/test/g3-roundtrip.test b/test/g3-roundtrip.test
index 6e31c587..d18e4466 100755
--- a/test/g3-roundtrip.test
+++ b/test/g3-roundtrip.test
@@ -1,6 +1,6 @@
 #! /bin/bash
 # This script tests: g3topbm pbmtog3
-# Also requires: pnmcrop
+# Also requires: pnmcrop pbmmake
 
 tmpdir=${tmpdir:-/tmp}
 complete256_pbm=${tmpdir}/complete256.pbm
diff --git a/test/pad-crop-roundtrip.ok b/test/pad-crop-roundtrip.ok
index 67f7a1fe..0e712ce7 100644
--- a/test/pad-crop-roundtrip.ok
+++ b/test/pad-crop-roundtrip.ok
@@ -1,2 +1,4 @@
 1926073387 101484
+1926073387 101484
+2425386270 41
 2425386270 41
diff --git a/test/pad-crop-roundtrip.test b/test/pad-crop-roundtrip.test
index c7780d68..75979901 100755
--- a/test/pad-crop-roundtrip.test
+++ b/test/pad-crop-roundtrip.test
@@ -1,9 +1,18 @@
 #! /bin/bash
-# This script tests: pnmcrop pnmmargin
-# Also requires: pnmpad
-
+# This script tests: pnmcrop pnmmargin pnmpad
+# Also requires:
 
 pnmmargin -white 10 testimg.ppm | \
   pnmcrop | cksum
+
+pnmpad -white -left 10 -top 10 testimg.ppm | \
+  pnmpad -white -right 10 -bottom 10 | \
+  pnmcrop -right -bottom | pnmcrop -left -top | cksum
+
 pnmmargin -white 10 testgrid.pbm | \
   pnmcrop | cksum
+
+pnmpad -white -left 10 -top 10 testgrid.pbm | \
+  pnmpad -white -right 10 -bottom 10 | \
+  pnmcrop -left -right | pnmcrop -top -bottom | cksum
+
diff --git a/test/pamditherbw.ok b/test/pamditherbw.ok
index e8186c24..eba3c44c 100644
--- a/test/pamditherbw.ok
+++ b/test/pamditherbw.ok
@@ -1,4 +1,28 @@
+Test: simple threshold
 1316122660 33894
+Test: Hilbert
 3342429190 33894
+2905156049 33894
+4294967295 0
+339841328 33894
+1633267750 33894
+Test: Dither-8
 3325147568 33894
+Test: Cluster-3
 4124728025 33894
+Test: Cluster-4
+4124728025 33894
+Test: Cluster-8
+3493215477 33894
+Test: Invalid
+Expected failure 1
+Expected failure 2
+Expected failure 3
+Expected failure 4
+Expected failure 5
+Expected failure 6
+Expected failure 7
+Expected failure 8
+Expected failure 9
+Expected failure 10
+Expected failure 11
diff --git a/test/pamditherbw.test b/test/pamditherbw.test
index 3f377f81..7b646a88 100755
--- a/test/pamditherbw.test
+++ b/test/pamditherbw.test
@@ -2,31 +2,59 @@
 # This script tests: pamditherbw
 # Also requires: pamchannel pamtopnm
 
-
 tmpdir=${tmpdir:-/tmp}
 test_red=${tmpdir}/testimg.red
 
 # Test 1.  Simple threshold
+echo "Test: simple threshold"
+
 pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
   tee ${test_red} | \
   pamditherbw -threshold -val=0.5 | cksum
 
-# Test 2.  Floyd-Steinberg
-#pamditherbw -floyd -val=0.5 ${test_red} | cksum
-
-# Test 3. Atkinson
-#pamditherbw -atkinson -val=0.5 ${test_red} | cksum
 
-# Test 4. Hilbert
+# Test 2. Hilbert
+echo "Test: Hilbert"
 pamditherbw -hilbert ${test_red} | cksum
+pamditherbw -hilbert -clump=4   ${test_red} | cksum
+pamditherbw -hilbert -clump=4 -threshold -value=0.5  ${test_red} | cksum
+pamditherbw -hilbert -clump=16  ${test_red} | cksum
+pamditherbw -hilbert -clump=100 ${test_red} | cksum
 
-# Test 5. Dither-8
+# Test 3. Dither-8
+echo "Test: Dither-8"
 pamditherbw -dither8 ${test_red} | cksum
 
-# Test 6. Cluster4
+# Test 4. Cluster-3
+echo "Test: Cluster-3"
+pamditherbw -cluster4 ${test_red} | cksum
+
+# Test 5. Cluster-4
+echo "Test: Cluster-4"
 pamditherbw -cluster4 ${test_red} | cksum
 
-# Test 7. Atkinson
-#pamditherbw -atkinson -val=0.5 ${test_red} | cksum
+# Test 6. Cluster-8
+echo "Test: Cluster-8"
+pamditherbw -cluster8 ${test_red} | cksum
+
+
+echo "Test: Invalid"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pamditherbw -fs -atkinson       ${test_red} || echo "Expected failure 1"
+pamditherbw -floyd -atkinson    ${test_red} || echo "Expected failure 2"
+pamditherbw -dither8  -cluster3 ${test_red} || echo "Expected failure 3"
+pamditherbw -cluster3 -cluster4 ${test_red} || echo "Expected failure 4"
+pamditherbw -cluster3 -cluster8 ${test_red} || echo "Expected failure 5"
+pamditherbw -cluster4 -cluster8 ${test_red} || echo "Expected failure 6"
+pamditherbw -clump=8            ${test_red} || echo "Expected failure 7"
+pamditherbw -fs -clump=8        ${test_red} || echo "Expected failure 8"
+pamditherbw -hilbert -clump=1   ${test_red} || echo "Expected failure 9"
+pamditherbw -th -value=-1       ${test_red} || echo "Expected failure 10"
+pamditherbw -th -value=1.1      ${test_red} || echo "Expected failure 11"
 
-rm ${test_red}
+rm ${test_red}
\ No newline at end of file
diff --git a/test/pamfile.ok b/test/pamfile.ok
index c0d80c28..b1d68ae1 100644
--- a/test/pamfile.ok
+++ b/test/pamfile.ok
@@ -1,12 +1,19 @@
+Test 1
 testimg.ppm:	PPM raw, 227 by 149  maxval 255
 testgrid.pbm:	PBM raw, 14 by 16
 stdin:	PGM raw, 227 by 149  maxval 255
 stdin:	PAM, 227 by 149 by 1 maxval 255
     Tuple type: GRAYSCALE
+Test 2
 stdin:	3 images
 stdin:	Image 0:	PBM raw, 14 by 16
 stdin:	Image 1:	PBM raw, 14 by 16
 stdin:	Image 2:	PBM raw, 14 by 16
+Test 3
 227 149
 testimg.ppm: PPM RAW 227 149 3 255 RGB
 stdin: PBM RAW 14 16 1 1 BLACKANDWHITE
+Test 4
+Expected failure 1
+Expected failure 2
+Expected failure 3
diff --git a/test/pamfile.test b/test/pamfile.test
index 545a2289..32771bfe 100755
--- a/test/pamfile.test
+++ b/test/pamfile.test
@@ -2,15 +2,31 @@
 # This script tests: pamfile
 # Also requires: pamchannel pamtopnm
 
+echo "Test 1"
 
 pamfile testimg.ppm
 pamfile testgrid.pbm
 pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | pamfile
 pamchannel -tupletype="GRAYSCALE" -infile=testimg.ppm 0 | pamfile
 
+echo "Test 2"
+
 cat testgrid.pbm testgrid.pbm testgrid.pbm | pamfile -count
 cat testgrid.pbm testgrid.pbm testgrid.pbm | pamfile -allimages
 
+echo "Test 3"
+
 pamfile -size testimg.ppm
 pamfile -machine testimg.ppm
 cat testgrid.pbm testimg.ppm testgrid.pbm | pamfile -machine
+
+echo "Test 4"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pamfile -size -machine  testimg.ppm || echo "Expected failure 1"
+pamfile -count -machine testimg.ppm || echo "Expected failure 2"
+head -n1 testimg.ppm | pamfile || echo "Expected failure 3"
\ No newline at end of file
diff --git a/test/pamfind.ok b/test/pamfind.ok
index dc0f95ed..9ddddced 100644
--- a/test/pamfind.ok
+++ b/test/pamfind.ok
@@ -20,6 +20,14 @@ Locations containing tuple (210/57/41)/255:
 (101, 77)
 (101, 78)
 (102, 72)
+118 195
+137 176
+137 177
+137 178
+138 183
+139 205
+140 188
+144 199
 Test 2
 Locations containing tuple (1)/1:
 (0, 1)
@@ -78,6 +86,176 @@ Locations containing tuple (1)/1:
 (14, 9)
 (14, 11)
 (14, 13)
+00 00
+00 02
+00 04
+00 06
+00 08
+00 10
+00 12
+01 00
+01 01
+01 02
+01 03
+01 04
+01 05
+01 06
+01 07
+01 08
+01 09
+01 10
+01 11
+01 12
+01 13
+02 00
+02 02
+02 04
+02 06
+02 08
+02 10
+02 12
+03 00
+03 01
+03 02
+03 03
+03 04
+03 05
+03 06
+03 07
+03 08
+03 09
+03 10
+03 11
+03 12
+03 13
+04 00
+04 02
+04 04
+04 06
+04 08
+04 10
+04 12
+05 00
+05 01
+05 02
+05 03
+05 04
+05 05
+05 06
+05 07
+05 08
+05 09
+05 10
+05 11
+05 12
+05 13
+06 00
+06 02
+06 04
+06 06
+06 08
+06 10
+06 12
+07 00
+07 01
+07 02
+07 03
+07 04
+07 05
+07 06
+07 07
+07 08
+07 09
+07 10
+07 11
+07 12
+07 13
+08 00
+08 02
+08 04
+08 06
+08 08
+08 10
+08 12
+09 00
+09 01
+09 02
+09 03
+09 04
+09 05
+09 06
+09 07
+09 08
+09 09
+09 10
+09 11
+09 12
+09 13
+10 00
+10 02
+10 04
+10 06
+10 08
+10 10
+10 12
+11 00
+11 01
+11 02
+11 03
+11 04
+11 05
+11 06
+11 07
+11 08
+11 09
+11 10
+11 11
+11 12
+11 13
+12 00
+12 02
+12 04
+12 06
+12 08
+12 10
+12 12
+13 00
+13 01
+13 02
+13 03
+13 04
+13 05
+13 06
+13 07
+13 08
+13 09
+13 10
+13 11
+13 12
+13 13
+14 00
+14 02
+14 04
+14 06
+14 08
+14 10
+14 12
+15 00
+15 01
+15 02
+15 03
+15 04
+15 05
+15 06
+15 07
+15 08
+15 09
+15 10
+15 11
+15 12
+15 13
 Test 3
 okay
 okay
+Test 4
+expected error
diff --git a/test/pamfind.test b/test/pamfind.test
index 39cb1437..e55f290c 100755
--- a/test/pamfind.test
+++ b/test/pamfind.test
@@ -10,10 +10,12 @@ sorted1_res=${tmpdir}/pamfind_sorted1.res
 echo Test 1
 pamfind -color=grey17     testimg.ppm 
 pamfind -target=210,57,41 testimg.ppm
+pamfind -target=50,55,49 -machine testimg.ppm
 
 # Test 2
 echo Test 2
 pamfind -target=1 testgrid.pbm
+pamfind -target=0 -machine testgrid.pbm
 
 # Test 3
 # The two outputs should be disjoint
@@ -29,4 +31,13 @@ comm -12 ${sorted0_res}  ${sorted1_res} |
 
 rm ${sorted0_res} ${sorted1_res}
 
+# Test 4
 
+echo 1>&2
+echo "Invalid command-line argument combination." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+echo Test 4
+pamfind -color=black -target=1 testimg.ppm || \
+  echo expected error
diff --git a/test/pamgauss.ok b/test/pamgauss.ok
index 153d4f6e..eaef2570 100644
--- a/test/pamgauss.ok
+++ b/test/pamgauss.ok
@@ -1,3 +1,4 @@
+Test 1
 3712518499 55
 3712518499 55
 1147844094 55
@@ -79,3 +80,12 @@
 4102007360 169
 3022719594 169
 1769176609 169
+Test 2
+stdin:	PAM, 3 by 3 by 1 maxval 255
+    Tuple type: GRAYSCALE
+Test 3.
+Expected error 1
+Expected error 2
+Expected error 3
+Expected error 4
+Expected error 5
diff --git a/test/pamgauss.test b/test/pamgauss.test
index b48517c4..392b5179 100755
--- a/test/pamgauss.test
+++ b/test/pamgauss.test
@@ -1,7 +1,8 @@
 #! /bin/bash
 # This script tests: pamgauss
-# Also requires:
+# Also requires: pamfile
 
+echo "Test 1"
 
 for i in `seq 3 11`
 do
@@ -10,3 +11,21 @@ do
 pamgauss $i $i -oversample=1 -sigma=.$s | cksum
 done
 done
+
+echo "Test 2"
+
+pamgauss 3 3 -sigma=0.5 -tupletype="GRAYSCALE" | pamfile
+
+
+echo "Test 3."
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pamgauss 3 3               | echo "Expected error 1"
+pamgauss 3 3   -sigma=0    | echo "Expected error 2"
+pamgauss 3 3   -sigma=-1.5 | echo "Expected error 3"
+pamgauss 3     -sigma=0.5  | echo "Expected error 4"
+pamgauss 3 3 3 -sigma=0.5  | echo "Expected error 5"
diff --git a/test/pamhue-roundtrip.ok b/test/pamhue-roundtrip.ok
new file mode 100644
index 00000000..b341398c
--- /dev/null
+++ b/test/pamhue-roundtrip.ok
@@ -0,0 +1,10 @@
+input image
+1926073387 101484
+360
+1926073387 101484
+180
+1926073387 101484
+120
+1926073387 101484
+60
+1926073387 101484
diff --git a/test/pamhue-roundtrip.test b/test/pamhue-roundtrip.test
new file mode 100755
index 00000000..643ac99a
--- /dev/null
+++ b/test/pamhue-roundtrip.test
@@ -0,0 +1,19 @@
+#! /bin/bash
+# This script tests: pamhue
+# Also requires:
+
+echo input image
+cat testimg.ppm | cksum
+
+echo 360
+pamhue -huechange=360 testimg.ppm | cksum
+echo 180
+pamhue -huechange=180 testimg.ppm | pamhue -huechange=180 | cksum
+echo 120
+pamhue -huechange=120 testimg.ppm | pamhue -huechange=120 | \
+  pamhue -huechange=120 | cksum
+echo 60
+pamhue -huechange=60 testimg.ppm | pamhue -huechange=60 | \
+  pamhue -huechange=60 | pamhue -huechange=60 | \
+  pamhue -huechange=60 | pamhue -huechange=60 | cksum
+
diff --git a/test/pamhue.ok b/test/pamhue.ok
new file mode 100644
index 00000000..447759ba
--- /dev/null
+++ b/test/pamhue.ok
@@ -0,0 +1,25 @@
+1213482165 83
+ Summary: 8 colors: 1 black, 1 white, 0 gray, 6 color
+
+   r     g     b   	 lum 	 count  
+ ----- ----- ----- 	-----	------- 
+     0     0     0	    0	      1 
+     0     0   255	   29	      1 
+   255   255     0	  226	      1 
+   255   255   255	  255	      1 
+     0   255     0	  150	      1 
+     0   255   255	  179	      1 
+   255     0     0	   76	      1 
+   255     0   255	  105	      1 
+ Summary: 8 colors: 1 black, 1 white, 0 gray, 6 color
+
+   r     g     b   	 lum 	 count  
+ ----- ----- ----- 	-----	------- 
+     0     0     0	    0	      1 
+     0     0   255	   29	      1 
+   255   255     0	  226	      1 
+   255   255   255	  255	      1 
+     0   255     0	  150	      1 
+     0   255   255	  179	      1 
+   255     0     0	   76	      1 
+   255     0   255	  105	      1 
diff --git a/test/pamhue.test b/test/pamhue.test
new file mode 100755
index 00000000..544b1d32
--- /dev/null
+++ b/test/pamhue.test
@@ -0,0 +1,10 @@
+#! /bin/bash
+# This script tests: pamhue
+# Also requires: pamseq ppmhist pamdepth
+
+pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=60 | cksum
+
+pamseq -tupletype=RGB 3 1 | pamdepth 255 | ppmhist
+pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=60 | ppmhist
+
+
diff --git a/test/pamscale-filters3.ok b/test/pamscale-filters3.ok
index 94d4ae96..182700cd 100644
--- a/test/pamscale-filters3.ok
+++ b/test/pamscale-filters3.ok
@@ -1,4 +1,3 @@
-failure : 0
 3.96 hermite:
 match
 match
diff --git a/test/pamscale-filters3.test b/test/pamscale-filters3.test
index 83198e2b..5a865508 100755
--- a/test/pamscale-filters3.test
+++ b/test/pamscale-filters3.test
@@ -1,7 +1,6 @@
 #! /bin/bash
 # This script tests: pamscale pamstretch pamstretch-gen 
- # Also requires: pamvalidate pnmpsnr || \
-  echo failure ${PIPESTATUS[@]} ":" $?
+# Also requires: pamvalidate pnmpsnr
 
 tmpdir=${tmpdir:-/tmp}
 stretch_ppm=${tmpdir}/stretch.ppm
diff --git a/test/pamseq.ok b/test/pamseq.ok
index 52bb3dd8..b0455449 100644
--- a/test/pamseq.ok
+++ b/test/pamseq.ok
@@ -1 +1,7 @@
+Test 1
 3929266994 304
+Test 2
+Expected error 1
+Expected error 2
+Expected error 3
+Expected error 4
diff --git a/test/pamseq.test b/test/pamseq.test
index e7b8060d..ea19013b 100755
--- a/test/pamseq.test
+++ b/test/pamseq.test
@@ -2,5 +2,24 @@
 # This script tests: pamseq
 # Also requires:
 
+echo "Test 1"
 
 pamseq 1 255 | cksum
+
+echo "Test 2"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pamseq 1 || echo "Expected error 1"
+pamseq 0 255 || echo "Expected error 2"
+pamseq 3 0   || echo "Expected error 3"
+
+c64="0123456789012345678901234567890123456789012345678901234567890123"
+c256=${c64}${c64}${c64}${c64}
+
+# Tupletype string length=256
+
+pamseq -tupletype="${c256}" 3 15 || echo "Expected error 4"
diff --git a/test/pamsumm.ok b/test/pamsumm.ok
index 0643081b..24ae23d2 100644
--- a/test/pamsumm.ok
+++ b/test/pamsumm.ok
@@ -1,8 +1,15 @@
+Test 1
 56
 0
 1
 0.250000
+Test 2
 10772432
 15
 255
 106.164760
+Test 3
+Expected failure 1
+Expected failure 2
+the mean of all samples is 106.164760
+Expected failure 4
diff --git a/test/pamsumm.test b/test/pamsumm.test
index a99dea0e..882b1b14 100755
--- a/test/pamsumm.test
+++ b/test/pamsumm.test
@@ -2,13 +2,29 @@
 # This script tests: pamsumm
 # Also requires:
 
+echo "Test 1"
 
 for type in -sum -min -max -mean
   do
   pamsumm -brief $type testgrid.pbm
   done
 
+echo "Test 2"
+
 for type in -sum -min -max -mean
   do
   pamsumm -brief $type testimg.ppm
   done
+
+
+echo "Test 3"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pamsumm -sum -min  testimg.ppm || echo "Expected failure 1"
+pamsumm -sum -max  testimg.ppm || echo "Expected failure 2"
+pamsumm -mean -max testimg.ppm || echo "Expected failure 3"
+pamsumm            testimg.ppm || echo "Expected failure 4"
diff --git a/test/pamtable.test b/test/pamtable.test
index 5c66b7ae..335d45c4 100755
--- a/test/pamtable.test
+++ b/test/pamtable.test
@@ -1,6 +1,6 @@
 #! /bin/bash
 # This script tests: pamtable
-# Also requires: pamgradient pamseq pamdepth
+# Also requires: pamseq pamdepth pbmmake ppmrainbow
 
 pamtable testgrid.pbm
 echo
diff --git a/test/pbm-misc-converters.test b/test/pbm-misc-converters.test
index aa71489b..ad96f13c 100755
--- a/test/pbm-misc-converters.test
+++ b/test/pbm-misc-converters.test
@@ -3,7 +3,7 @@
 # This script tests: pbmtodjvurle pbmtoepson pbmtogo pbmtoibm23xx
 # This script tests: pbmtolj pbmtoln03 pbmtomatrixorbital pbmtonokia
 # This script tests: pbmtoplot pbmtoptx pbmtozinc
-# Also requires: pbmpage
+# Also requires: pbmpage pbmtoppa
 
 # Note: one-way test.
 # These converters do not have counterparts that work in the opposite
diff --git a/test/pbmclean.ok b/test/pbmclean.ok
index 71b622d0..47d6c07d 100644
--- a/test/pbmclean.ok
+++ b/test/pbmclean.ok
@@ -1,3 +1,4 @@
+Test 1
 P1
 7 7
 1111111
@@ -70,4 +71,16 @@ P1
 0000000
 0000000
 0000000
+Test 2
 760076056 4210813
+Test 3
+2096087149 5051
+2096087149 5051
+3762787431 5051
+1966718 5051
+544084261 5051
+2970762900 5051
+2571756059 5051
+2571756059 5051
+436062787 5051
+4188415575 5051
diff --git a/test/pbmclean.test b/test/pbmclean.test
index a8e469b1..b9ea0937 100755
--- a/test/pbmclean.test
+++ b/test/pbmclean.test
@@ -1,19 +1,36 @@
 #! /bin/bash
 # This script tests: pbmclean
-# Also requires: pbmmake pbmpage pnmmargin pnmpad
+# Also requires: pbmmake pbmpage pbmtext pnmmargin pnmpad
 
 
 tmpdir=${tmpdir:-/tmp}
 test_pbm=${tmpdir}/test.pbm
+sheet_pbm=${tmpdir}/sheet.pbm
+
+echo "Test 1"
 
 pbmmake -g 3 3 | pnmmargin -black 2 > ${test_pbm}
 
 for n in 1 2 3 4 5 6 7 8
-do
-pbmclean -min=$n -black -plain ${test_pbm}
-done
+  do
+  pbmclean -min=${n} -black -plain ${test_pbm}
+  done
 
 rm ${test_pbm}
 
+
+echo "Test 2"
+
 # Should print 760076056 4210813
 pbmpage 1 | pbmclean -black | cksum
+
+
+echo "Test 3"
+
+pbmtext -dump-sheet > ${sheet_pbm}
+for n in 1 2 3 4 5 6 7 8 9 10
+  do
+  pbmclean -min=${n} -extended  ${sheet_pbm} | cksum
+  done
+
+rm ${sheet_pbm}
diff --git a/test/pbmmake.ok b/test/pbmmake.ok
index 754eefdf..354106f0 100644
--- a/test/pbmmake.ok
+++ b/test/pbmmake.ok
@@ -1,27 +1,36 @@
+Test 1.
 P11 10
 P11 11
 P11 10
+Test 2.
 P12 20000
 P12 21111
 P12 20110
+Test 2.
 P13 3000000000
 P13 3111111111
 P13 3010101010
+Test 2.
 P14 40000000000000000
 P14 41111111111111111
 P14 40101101001011010
+Test 2.
 P15 50000000000000000000000000
 P15 51111111111111111111111111
 P15 50101010101010101010101010
+Test 2.
 P16 6000000000000000000000000000000000000
 P16 6111111111111111111111111111111111111
 P16 6010101101010010101101010010101101010
+Test 2.
 P17 70000000000000000000000000000000000000000000000000
 P17 71111111111111111111111111111111111111111111111111
 P17 70101010101010101010101010101010101010101010101010
+Test 2.
 P18 80000000000000000000000000000000000000000000000000000000000000000
 P18 81111111111111111111111111111111111111111111111111111111111111111
 P18 80101010110101010010101011010101001010101101010100101010110101010
+Test 2.
 4058563256 45
 3969089344 105
 702117756 189
@@ -41,3 +50,15 @@ P18 80101010110101010010101011010101001010101101010100101010110101010
 1824232358 2931
 3651864954 3375
 3302595397 3849
+Test 3.
+Expected error 1
+Expected error 2
+Expected error 3
+Expected error 4
+Expected error 5
+Expected error 6
+Expected error 7
+Expected error 8
+P1
+1 1
+0
diff --git a/test/pbmmake.test b/test/pbmmake.test
index 4b18e3ea..eb4be6ea 100755
--- a/test/pbmmake.test
+++ b/test/pbmmake.test
@@ -2,13 +2,17 @@
 # This script tests: pbmmake
 # Also requires:
 
+echo "Test 1."
 
 for i in `seq 1 8`
 do
-for color in -w -b -g
+for color in -white -black -gray
 do
 pbmmake -plain $color $i $i | tr -d '\n'; echo
 done
+
+echo "Test 2."
+
 done
 for i in `seq 8 5 98`
 do
@@ -16,3 +20,20 @@ do
   pbmmake -b $i $i ;
   pbmmake  -g $i $i ) | cksum
 done
+
+echo "Test 3."
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pbmmake -b -w -plain 1 1 || echo "Expected error 1"
+pbmmake -b -g -plain 1 1 || echo "Expected error 2"
+pbmmake -white -gray -plain 1 1 || echo "Expected error 3"
+pbmmake -white -plain   || echo "Expected error 4"
+pbmmake -white -plain 1 || echo "Expected error 5"
+pbmmake -white -plain 1 0 || echo "Expected error 6"
+pbmmake -white -plain 0 1 || echo "Expected error 7"
+pbmmake -white -plain 1 1 1 || echo "Expected error 8"
+pbmmake -plain 1 1 ||  echo "Expected error 9"
diff --git a/test/pbmpage.ok b/test/pbmpage.ok
index 7f68da74..b41d7cf3 100644
--- a/test/pbmpage.ok
+++ b/test/pbmpage.ok
@@ -1,3 +1,9 @@
+Test 1
 550172004 4210813
 4142746975 4210813
 2347597649 4210813
+3453559794 4349933
+Test 2
+Expected error 1
+Expected error 2
+Expected error 3
diff --git a/test/pbmpage.test b/test/pbmpage.test
index e9bfe352..7cabcc7f 100755
--- a/test/pbmpage.test
+++ b/test/pbmpage.test
@@ -2,7 +2,20 @@
 # This script tests: pbmpage
 # Also requires:
 
+echo "Test 1"
 
-pbmpage 1 | cksum
-pbmpage 2 | cksum
-pbmpage 3 | cksum
+pbmpage 1     | cksum
+pbmpage 2     | cksum
+pbmpage 3     | cksum
+pbmpage -a4 2 | cksum
+
+echo "Test 2"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pbmpage -a3 1 || echo "Expected error 1"
+pbmpage 0 || echo "Expected error 2"
+pbmpage 4 || echo "Expected error 3"
diff --git a/test/pbmupc.ok b/test/pbmupc.ok
index 3e58f409..c5753609 100644
--- a/test/pbmupc.ok
+++ b/test/pbmupc.ok
@@ -1 +1,12 @@
+Test 1
 2619309127 10172
+Test 2
+Exptected error 1
+Exptected error 2
+Exptected error 3
+Exptected error 4
+Exptected error 5
+Exptected error 6
+Exptected error 7
+Exptected error 8
+Exptected error 9
diff --git a/test/pbmupc.test b/test/pbmupc.test
index 275117d5..aee380b0 100755
--- a/test/pbmupc.test
+++ b/test/pbmupc.test
@@ -2,8 +2,26 @@
 # This script tests: pbmupc
 # Also requires:
 
+echo "Test 1"
 
 for type in -s1 -s2
 do
 pbmupc $type 0 72890 00011
 done | cksum
+
+echo "Test 2"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pbmupc -s3 0 72890 00011     || echo "Exptected error 1"
+pbmupc -s1   72890 00011     || echo "Exptected error 2"
+pbmupc -s1 0 72890           || echo "Exptected error 3"
+pbmupc -s1 10 72890 00011    || echo "Exptected error 4"
+pbmupc -s1 0 172890 00011    || echo "Exptected error 5"
+pbmupc -s1 0   2890 00011    || echo "Exptected error 6"
+pbmupc -s1 0 72890 100011    || echo "Exptected error 7"
+pbmupc -s1 0 72890   0011    || echo "Exptected error 8"
+pbmupc -s1 0 72890 100011 1  || echo "Exptected error 9"
diff --git a/test/pdb-roundtrip.test b/test/pdb-roundtrip.test
index 6b4e152c..32d7aa87 100755
--- a/test/pdb-roundtrip.test
+++ b/test/pdb-roundtrip.test
@@ -1,6 +1,6 @@
 #! /bin/bash
 # This script tests: pamtopdbimg pdbimgtopam
-# Also requires: pnmtile pgmramp pamtopnm
+# Also requires: pnmtile pgmramp pamtopnm pamdepth
 
 tmpdir=${tmpdir:-/tmp}
 tiled_pbm=${tmpdir}/tiled.pbm
diff --git a/test/pgmhist.ok b/test/pgmhist.ok
index 7d89bb33..6d9dfbe5 100644
--- a/test/pgmhist.ok
+++ b/test/pgmhist.ok
@@ -1,3 +1,4 @@
+Test 1
 value count b% w%
 ----- ----- ------ ------
  0 2 12.5% 100%
@@ -12,3 +13,24 @@ value count b% w%
 ----- ----- ------ ------
  0 168 75% 100%
  255 56 100% 25%
+Test 2
+127
+63
+127
+191
+255
+25
+51
+76
+102
+127
+153
+179
+204
+230
+255
+Test 3
+Expected failure 1
+Expected failure 2
+Expected failure 3
+Expected failure 4
diff --git a/test/pgmhist.test b/test/pgmhist.test
index 42666fbf..c566c5cb 100755
--- a/test/pgmhist.test
+++ b/test/pgmhist.test
@@ -5,8 +5,33 @@
 
 # Ignore differences in spaces.
 
+echo "Test 1"
+
 pgmramp -maxval=8 -lr 8 2 | pgmhist | \
   sed -e 's/  */ /g' -e 's/ *$//'
 
 pgmhist testgrid.pbm | \
   sed -e 's/  */ /g' -e 's/ *$//'
+
+echo "Test 2"
+
+pgmramp -lr 256 1 | pgmhist -machine -median   | \
+  sed -e 's/  */ /g' -e 's/ *$//'
+
+pgmramp -lr 256 1 | pgmhist -machine -quartile | \
+  sed -e 's/  */ /g' -e 's/ *$//'
+
+pgmramp -lr 256 1 | pgmhist -machine -decile   | \
+  sed -e 's/  */ /g' -e 's/ *$//'
+
+echo "Test 3"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pgmhist -median   -quartile testgrid.pbm || echo "Expected failure 1"
+pgmhist -median   -decile   testgrid.pbm || echo "Expected failure 2"
+pgmhist -quartile -decile   testgrid.pbm || echo "Expected failure 3"
+pgmhist testimg.ppm || echo "Expected failure 4"
diff --git a/test/pgmmake.ok b/test/pgmmake.ok
index b9a03af2..9a88b9a6 100644
--- a/test/pgmmake.ok
+++ b/test/pgmmake.ok
@@ -1,2 +1,12 @@
+Test 1.
 3662611538 2513
 3109612402 5012
+Test 2.
+Expected error 1
+Expected error 2
+Expected error 3
+Expected error 4
+Expected error 5
+Expected error 6
+Expected error 7
+Expected error 8
diff --git a/test/pgmmake.test b/test/pgmmake.test
index 4a3c4842..3823e36f 100755
--- a/test/pgmmake.test
+++ b/test/pgmmake.test
@@ -2,6 +2,25 @@
 # This script tests: pgmmake
 # Also requires:
 
+echo "Test 1."
 
 pgmmake 1 50 50 | cksum
 pgmmake .2 50 100 -maxval=5 | cksum
+
+
+echo "Test 2."
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pgmmake 100  5 5 || echo "Expected error 1"
+pgmmake 1.01 5 5 || echo "Expected error 2"
+pgmmake .5   5   || echo "Expected error 3"
+pgmmake .5       || echo "Expected error 4"
+pgmmake -maxval=5        5 5 || echo "Expected error 5"
+pgmmake -maxval=0     .5 5 5 || echo "Expected error 6"
+pgmmake -maxval=-1    .5 5 5 || echo "Expected error 7"
+pgmmake -maxval=65536 .5 5 5 || echo "Expected error 8"
+
diff --git a/test/pgmramp.ok b/test/pgmramp.ok
index 989ef7d4..309f5773 100644
--- a/test/pgmramp.ok
+++ b/test/pgmramp.ok
@@ -1,3 +1,4 @@
+Test 1
 P2
 4 4
 6
@@ -33,8 +34,16 @@ P2
 1 2 3 4
 2 3 4 5
 3 4 5 6
+Test 2
 1777787286 65551
 2046889993 65551
 1975520432 65551
 807973067 65551
+Test 3
 886972785 131087
+Test 4
+Expected error: -lr -tb
+Expected error: -lr -rectangle
+Expected error: -rectangle -ellipse
+Expected error: insufficient parameters
+Expected error: excessive parameters
diff --git a/test/pgmramp.test b/test/pgmramp.test
index f6f770fe..bd63e10d 100755
--- a/test/pgmramp.test
+++ b/test/pgmramp.test
@@ -2,14 +2,33 @@
 # This script tests: pgmramp
 # Also requires:
 
+echo "Test 1"
 
 for type in -lr -tb -rectangle -ellipse -diagonal
 do
 pgmramp -maxval=6 $type 4 4 -plain
 done
 
+echo "Test 2"
+
 for type in -lr -tb -rectangle -ellipse
 do pgmramp $type 256 256 | cksum
 done
 
+echo "Test 3"
+
 pgmramp -diagonal -maxval=510 256 256 | cksum
+
+echo "Test 4"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+for combination in "-lr -tb" "-lr -rectangle" "-rectangle -ellipse"
+do pgmramp $combination 10 10 || echo "Expected error: $combination"
+done
+
+pgmramp -lr     1 || echo "Expected error: insufficient parameters"
+pgmramp -tb 1 1 1 || echo "Expected error: excessive parameters"
diff --git a/test/pnmcrop-blank.ok b/test/pnmcrop-blank.ok
new file mode 100644
index 00000000..55103acb
--- /dev/null
+++ b/test/pnmcrop-blank.ok
@@ -0,0 +1,130 @@
+Test 1
+-blank-image=pass
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+-blank-image=minimize
+-7 -7 -7 -6 1 1
+0 0 0 0 15 14
+-7 -7 -7 -6 1 1
+-7 -7 -7 -6 1 1
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+-7 -7 -7 -6 1 1
+-blank-image=minimize -top
+0 0 -13 0 15 1
+0 0 0 0 15 14
+0 0 -13 0 15 1
+0 0 -13 0 15 1
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 -13 0 15 1
+-blank-image=minimize -bottom
+0 0 0 -13 15 1
+0 0 0 0 15 14
+0 0 0 -13 15 1
+0 0 0 -13 15 1
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 -13 15 1
+-blank-image=minimize -left
+-14 0 0 0 1 14
+0 0 0 0 15 14
+-14 0 0 0 1 14
+-14 0 0 0 1 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+-14 0 0 0 1 14
+-blank-image=minimize -right
+0 -14 0 0 1 14
+0 0 0 0 15 14
+0 -14 0 0 1 14
+0 -14 0 0 1 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 -14 0 0 1 14
+-blank-image=minimize -left -right
+-7 -7 0 0 1 14
+0 0 0 0 15 14
+-7 -7 0 0 1 14
+-7 -7 0 0 1 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+-7 -7 0 0 1 14
+-blank-image=maxcrop
+-15 -15 -14 -14 15 14
+0 0 0 0 15 14
+-15 -15 -14 -14 15 14
+-15 -15 -14 -14 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+0 0 0 0 15 14
+-15 -15 -14 -14 15 14
+-blank-image=abort
+fail1
+fail2
+0 0 0 0 15 14
+0 0 0 0 15 14
+fail3
+
+fail1
+fail2
+0 0 0 0 15 14
+0 0 0 0 15 14
+fail3
+Test 2
+-blank-image=maxcrop -top
+0 0 -99 0 100 99
+0 0 -99 0 100 99
+0 0 0 0 100 99
+-blank-image=minimize
+-50 -49 -49 -49 1 1
+-50 -49 -49 -49 1 1
+0 0 0 0 100 99
+-blank-image=maxcrop
+-100 -100 -99 -99 100 99
+-100 -100 -99 -99 100 99
+0 0 0 0 100 99
+-blank-image=maxcrop -top
+0 0 -99 0 100 99
+0 0 -99 0 100 99
+0 0 0 0 100 99
+-blank-image=maxcrop -bottom
+0 0 0 -99 100 99
+0 0 0 -99 100 99
+0 0 0 0 100 99
+-blank-image=maxcrop -left
+-100 0 0 0 100 99
+-100 0 0 0 100 99
+0 0 0 0 100 99
+-blank-image=maxcrop -right
+0 -100 0 0 100 99
+0 -100 0 0 100 99
+0 0 0 0 100 99
+-blank-image=maxcrop -top -bottom -right
+0 -100 -99 -99 100 99
+0 -100 -99 -99 100 99
+0 0 0 0 100 99
+
+fail4
+fail5
+0 0 0 0 100 99
diff --git a/test/pnmcrop-blank.test b/test/pnmcrop-blank.test
new file mode 100755
index 00000000..087ad65e
--- /dev/null
+++ b/test/pnmcrop-blank.test
@@ -0,0 +1,55 @@
+#! /bin/bash
+# This script tests: pnmcrop
+# Also requires: pbmmake ppmmake
+
+tmpdir=${tmpdir:-/tmp}
+
+test_pbm=${tmpdir}/test.pbm
+test_ppm=${tmpdir}/test.ppm
+
+echo "Error messages should appear below the line." 1>&2
+echo "--------------------------------------------" 1>&2
+
+#Test 1
+echo Test 1
+
+( pbmmake -white 15 14; pbmmake -gray 15 14; pbmmake -black 15 14 ) > \
+  ${test_pbm}
+for type in    "-blank-image=pass" \
+               "-blank-image=minimize" \
+               "-blank-image=minimize -top" \
+               "-blank-image=minimize -bottom" \
+               "-blank-image=minimize -left" \
+               "-blank-image=minimize -right" \
+               "-blank-image=minimize -left -right" \
+               "-blank-image=maxcrop" \
+               "-blank-image=abort" ""
+  do
+  echo ${type}
+  pnmcrop -reportsize ${type} ${test_pbm} || echo "fail1"
+  pnmcrop -reportsize ${type} -white ${test_pbm} || echo "fail2"
+  pnmcrop -reportsize ${type} -black ${test_pbm} || echo "fail3"
+  done
+
+rm ${test_pbm}
+
+
+#Test 2
+
+ppmmake rgb:ff/ff/ff 100 99 > ${test_ppm}
+echo Test 2
+for type in    "-blank-image=maxcrop -top" \
+               "-blank-image=minimize" "-blank-image=maxcrop" \
+               "-blank-image=maxcrop -top" \
+               "-blank-image=maxcrop -bottom" \
+               "-blank-image=maxcrop -left" \
+               "-blank-image=maxcrop -right" \
+               "-blank-image=maxcrop -top -bottom -right" ""
+  do
+  echo ${type}
+  pnmcrop -reportsize ${type} ${test_ppm} || echo "fail4"
+  pnmcrop -reportsize ${type} -white ${test_ppm} || echo "fail5"
+  pnmcrop -reportsize ${type} -black ${test_ppm} || echo "fail6"
+  done
+
+rm ${test_ppm}
\ No newline at end of file
diff --git a/test/pnmcrop1.ok b/test/pnmcrop1.ok
new file mode 100644
index 00000000..25bc52ce
--- /dev/null
+++ b/test/pnmcrop1.ok
@@ -0,0 +1,103 @@
+Test 1
+test.pbm
+
+0 0 -7 0 28 25 rgb-1:1/1/1 0.000000
+-white
+0 0 -7 0 28 25 rgb-1:1/1/1 0.000000
+-black
+0 0 0 -2 28 30 rgb-1:0/0/0 0.000000
+-sides
+0 0 -7 0 28 25 rgb-1:1/1/1 0.000000
+-top
+0 0 -7 0 28 25 rgb-1:1/1/1 0.000000
+-bottom
+0 0 0 0 28 32 rgb-1:1/1/1 0.000000
+-left
+0 0 0 0 28 32 rgb-1:1/1/1 0.000000
+-right
+0 0 0 0 28 32 rgb-1:1/1/1 0.000000
+-top -bottom
+0 0 -7 0 28 25 rgb-1:1/1/1 0.000000
+-bottom -bg-corner=bottomright
+0 0 0 -2 28 30 rgb-1:0/0/0 0.000000
+-right -bg-corner=bottomright
+0 0 0 0 28 32 rgb-1:0/0/0 0.000000
+-bg-color=white
+0 0 0 0 28 32 rgb-1:1/1/1 0.000000
+-bg-color=black
+0 0 0 -2 28 30 rgb-1:0/0/0 0.000000
+-bg-color=red
+0 0 0 0 28 32 rgb-1:0/0/0 0.000000
+test.ppm
+
+0 0 0 0 250 161 rgb-255:127/127/127 0.000000
+-white
+-6 0 0 0 244 161 rgb-255:255/255/255 0.000000
+-black
+0 -11 0 0 239 161 rgb-255:0/0/0 0.000000
+-sides
+-6 0 0 0 244 161 rgb-255:255/255/255 0.000000
+-top
+0 0 0 0 250 161 rgb-255:127/127/127 0.000000
+-bottom
+0 0 0 0 250 161 rgb-255:127/127/127 0.000000
+-left
+0 0 0 0 250 161 rgb-255:127/127/127 0.000000
+-right
+0 0 0 0 250 161 rgb-255:127/127/127 0.000000
+-top -bottom
+0 0 0 0 250 161 rgb-255:127/127/127 0.000000
+-bottom -bg-corner=bottomright
+0 0 0 0 250 161 rgb-255:0/0/0 0.000000
+-right -bg-corner=bottomright
+0 -11 0 0 239 161 rgb-255:0/0/0 0.000000
+-bg-color=white
+-6 0 0 0 244 161 rgb-255:255/255/255 0.000000
+-bg-color=black
+0 -11 0 0 239 161 rgb-255:0/0/0 0.000000
+-bg-color=red
+0 0 0 0 250 161 rgb-255:255/0/0 0.000000
+Test 2
+test.pbm
+
+3130931737 109
+3130931737 109
+-white
+3130931737 109
+3130931737 109
+-top
+3130931737 109
+3130931737 109
+test.ppm
+
+1435955776 120765
+1435955776 120765
+-white
+638507845 117867
+638507845 117867
+-top
+1435955776 120765
+1435955776 120765
+Test 3
+-reportfull -reportsize
+expected failure
+-reportfull -borderfile=testgrid.pbm
+expected failure
+-reportsize -borderfile=testgrid.pbm
+expected failure
+-black -white
+expected failure
+-black -sides
+expected failure
+-white -bg-color=red
+expected failure
+-white -bg-corner=topleft
+expected failure
+-white -bg-corner=top
+expected failure
+-blank-image=pasturize
+expected failure
+-bg-color=black -closeness=-1
+expected failure
+-bg-color=black -closeness=101
+expected failure
diff --git a/test/pnmcrop1.test b/test/pnmcrop1.test
new file mode 100755
index 00000000..6b37da23
--- /dev/null
+++ b/test/pnmcrop1.test
@@ -0,0 +1,75 @@
+#! /bin/bash
+# This script tests: pnmcrop
+# Also requires: pnmpad pnmmargin pamcut
+
+tmpdir=${tmpdir:-/tmp}
+
+test_pbm=${tmpdir}/test.pbm
+test_ppm=${tmpdir}/test.ppm
+
+pnmmargin -white 7 testgrid.pbm | pnmpad -black -bottom=2  > ${test_pbm}
+pnmmargin -white 6 testimg.ppm  | pnmpad -black -right=11  > ${test_ppm}
+
+#Test 1
+echo Test 1
+
+for input_file in ${test_pbm} ${test_ppm}
+  do
+  echo `basename ${input_file}`
+  for option in "" "-white" "-black" "-sides" \
+              "-top" "-bottom" "-left" "-right" "-top -bottom" \
+              "-bottom -bg-corner=bottomright" \
+              "-right -bg-corner=bottomright" \
+              "-bg-color=white" "-bg-color=black" "-bg-color=red"
+    do
+    echo ${option}
+    pnmcrop -reportfull ${option} ${input_file} || echo fail
+    done
+  done
+
+#Test 2
+echo Test 2
+
+for input_file in ${test_pbm} ${test_ppm}
+  do
+  echo `basename ${input_file}`
+  for option in "" "-white" "-top"
+    do
+    echo ${option}
+    # Normal crop operation
+    pnmcrop ${option} ${input_file} | cksum
+
+    # Compute edge extents with pnmcrop; let pamcut do the actual cropping
+    pamcut ${input_file} `pnmcrop -reportsize ${option} ${input_file} | \
+        awk 'NF==6 && NR==1 && \
+             $1<=0 && $2<=0 && $3<=0 && $4<=0 && $5>=0 && $6>=0 \
+             { printf("-cropleft=%d -cropright=%d  ", -$1, -$2);
+               printf("-croptop=%d -cropbottom=%d", -$3, -$4) }' ` | cksum
+    done
+  done
+
+rm ${test_pbm} ${test_ppm}
+
+# Test 3
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+echo Test 3
+for option in "-reportfull -reportsize" \
+              "-reportfull -borderfile=testgrid.pbm" \
+              "-reportsize -borderfile=testgrid.pbm" \
+              "-black -white" \
+              "-black -sides" \
+              "-white -bg-color=red" \
+              "-white -bg-corner=topleft" \
+              "-white -bg-corner=top" \
+              "-blank-image=pasturize" \
+              "-bg-color=black -closeness=-1" \
+              "-bg-color=black -closeness=101"
+    do
+    echo ${option}
+    pnmcrop -reportfull ${option} testgrid.pbm || echo expected failure
+    done
diff --git a/test/pnmcrop2.ok b/test/pnmcrop2.ok
new file mode 100644
index 00000000..4eff830d
--- /dev/null
+++ b/test/pnmcrop2.ok
@@ -0,0 +1,29 @@
+Test 1
+
+0 0 0 0 5 5 rgb-200:2/2/2 0.000000
+-sides
+0 0 0 0 5 5 rgb-200:6/6/6 0.000000
+Test 2
+topleft
+0 0 0 0 5 5 rgb-200:0/0/0 0.000000
+topright
+0 0 0 0 5 5 rgb-200:4/4/4 0.000000
+bottomleft
+0 0 0 0 5 5 rgb-200:8/8/8 0.000000
+bottomright
+0 0 0 0 5 5 rgb-200:15/15/15 0.000000
+Test 3
+0
+0 0 0 0 5 5 rgb-200:0/0/0 0.000000
+1
+0 0 0 0 5 5 rgb-200:0/0/0 1.000000
+2
+0 0 -1 0 5 4 rgb-200:0/0/0 2.000000
+3
+-1 0 -1 0 4 4 rgb-200:0/0/0 3.000000
+4
+-1 0 -1 0 4 4 rgb-200:0/0/0 4.000000
+5
+-1 -1 -1 -1 3 3 rgb-200:0/0/0 5.000000
+6
+-1 -1 -1 -1 3 3 rgb-200:0/0/0 6.000000
diff --git a/test/pnmcrop2.test b/test/pnmcrop2.test
new file mode 100755
index 00000000..d6c83c73
--- /dev/null
+++ b/test/pnmcrop2.test
@@ -0,0 +1,55 @@
+#! /bin/bash
+# This script tests: pnmcrop
+# Also requires:
+
+tmpdir=${tmpdir:-/tmp}
+test_pgm=${tmpdir}/test.pgm
+
+cat > ${test_pgm} << EOF
+P2
+5 5
+200
+0 1 2 3 4
+5 199 199 199 9
+6 199 199 199 10
+7 199 199 199 11
+8 12 13 14 15
+EOF
+
+# Test 1
+# Test color detection; none of the sides are cropped
+
+echo Test 1
+
+for option in "" "-sides"
+  do
+  echo ${option}
+  pnmcrop -reportfull ${option} ${test_pgm} || echo fail1
+  done
+
+# Test 2
+# Test color detection; none of the sides are cropped
+echo Test 2
+
+for corner in topleft topright bottomleft bottomright
+  do
+  echo ${corner}
+  pnmcrop -reportfull -bg-corner=${corner} ${test_pgm} || echo fail2
+  done
+
+# Test 3
+# Left edge   is cropped at closeness 2% and above
+# Top  edge   is cropped at closeness 3% and above
+# All  edges are cropped at closeness 5% and above
+
+echo Test 3
+
+for closeness in `seq 0 6`
+  do
+  echo ${closeness}
+  pnmcrop -reportfull -bg-corner=topleft -closeness=${closeness} ${test_pgm} \
+    || echo fail3
+  done
+
+rm ${test_pgm}
+
diff --git a/test/pnmcrop3.ok b/test/pnmcrop3.ok
new file mode 100644
index 00000000..6824143a
--- /dev/null
+++ b/test/pnmcrop3.ok
@@ -0,0 +1,90 @@
+Test 1
+test.pbm
+-left
+-12 0 0 0 15 24
+-right
+0 -2 0 0 25 24
+-top
+0 0 -3 0 27 21
+-bottom
+0 0 0 -6 27 18
+-left -right
+-12 -2 0 0 13 24
+-left -bottom
+-12 0 0 -6 15 18
+-right -bottom
+0 -2 0 -6 25 18
+test.ppm
+-left
+-21 0 0 0 236 161
+-right
+0 -9 0 0 248 161
+-top
+0 0 -11 0 257 150
+-bottom
+0 0 0 -1 257 160
+-left -right
+-21 -9 0 0 227 161
+-left -bottom
+-21 0 0 -1 236 160
+-right -bottom
+0 -9 0 -1 248 160
+Test 2
+test.pbm
+-12 -2 -3 -6 13 15
+-11 -1 -2 -5 15 17
+-10 0 -1 -4 17 19
+-9 +1 0 -3 19 21
+-8 +2 +1 -2 21 23
+-7 +3 +2 -1 23 25
+test.ppm
+-21 -9 -11 -1 227 149
+-20 -8 -10 0 229 151
+-19 -7 -9 +1 231 153
+-18 -6 -8 +2 233 155
+-17 -5 -7 +3 235 157
+-16 -4 -6 +4 237 159
+Test 3
+13 15
+P2
+13 15
+255
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+128 128 128 128 128 128 128 128 128 128 128 128 128
+13 15
+0 0 0 0 13 15
+13 15
+P1
+13 15
+1111111111111
+1110101010101
+1111111111111
+1110101010101
+1111111111111
+1110101010101
+1111111111111
+1110101010101
+1111111111111
+1110101010101
+1111111111111
+1110101010101
+1111111111111
+1110101010101
+1111111111111
+-3 -1 -1 -1 9 13
+544280424 101484
+4294967295 0
+4294967295 0
diff --git a/test/pnmcrop3.test b/test/pnmcrop3.test
new file mode 100755
index 00000000..c46fd7ea
--- /dev/null
+++ b/test/pnmcrop3.test
@@ -0,0 +1,71 @@
+#! /bin/bash
+# This script tests: pnmcrop
+# Also requires: pnmpad pamfile pgmmake
+
+tmpdir=${tmpdir:-/tmp}
+
+test_pbm=${tmpdir}/test.pbm
+test_ppm=${tmpdir}/test.ppm
+border_pbm=${tmpdir}/border.pbm
+border_ppm=${tmpdir}/border.ppm
+gray_pgm=${tmpdir}/gray.pgm
+
+pnmpad -top=3 -bottom=5 -left=11 -right=2 testgrid.pbm > ${test_pbm}
+pnmpad -top=11 -bottom=1 -left=21 -right=9 testimg.ppm > ${test_ppm}
+
+pnmpad -top=4 -bottom=4 -left=8 -right=5 testgrid.pbm > ${border_pbm}
+pnmpad -top=7 -bottom=5 -left=30 -right=0 testimg.ppm > ${border_ppm}
+
+pgmmake 0.5 `pamfile -size ${test_pbm}` > ${gray_pgm}
+
+# Test 1
+echo Test 1
+
+for input_file in ${test_pbm} ${test_ppm}
+  do
+  echo `basename ${input_file}`
+  for option in "-left" "-right" "-top" "-bottom" \
+            "-left -right" "-left -bottom" "-right -bottom"
+    do
+    echo ${option}
+    pnmcrop -reportsize ${option} ${input_file} || echo fail1
+    done
+  done
+
+# Test 2
+echo Test 2
+
+for input_file in ${test_pbm} ${test_ppm}
+  do
+  echo `basename ${input_file}`
+  for margin in `seq 0 5`
+    do
+    pnmcrop -reportsize -margin=${margin} ${input_file} || echo fail2
+    done
+  done
+
+# Test 3
+echo Test 3
+
+pnmcrop -borderfile=${border_pbm} ${gray_pgm} | pamfile -size
+pnmcrop -borderfile=${border_pbm} ${gray_pgm} -plain 
+
+pnmcrop -borderfile=${test_pbm} ${test_pbm}   | pamfile -size
+pnmcrop -borderfile=${test_pbm} ${test_pbm}   | pnmcrop -black -reportsize
+
+pnmcrop -borderfile=${border_pbm} ${test_pbm} | pamfile -size
+pnmcrop -borderfile=${border_pbm} ${test_pbm} -plain
+pnmcrop -borderfile=${border_pbm} ${test_pbm} | pnmcrop -black -reportsize
+
+pnmcrop -borderfile=${border_ppm} ${test_ppm} | cksum 
+
+# The following two cases are expected to fai
+
+echo "Error messages should appear below the line." 1>&2
+echo "--------------------------------------------" 1>&2
+
+pnmcrop -borderfile=${border_ppm} ${test_pbm} | cksum 
+pnmcrop -borderfile=${border_pbm} ${test_ppm} | cksum 
+
+
+rm ${test_pbm} ${test_ppm} ${border_pbm} ${border_ppm} ${gray_pgm}
\ No newline at end of file
diff --git a/test/pnmpsnr.ok b/test/pnmpsnr.ok
index 3469f836..e8b5ebc2 100644
--- a/test/pnmpsnr.ok
+++ b/test/pnmpsnr.ok
@@ -1,7 +1,14 @@
+Test 1
 0.00
 inf
 1000.00
 match
+Test 2
 300.00 300.00 300.00
 match
 match
+Test 3
+Expected failure 1
+Expected failure 2
+Expected failure 3
+Expected failure 4
diff --git a/test/pnmpsnr.test b/test/pnmpsnr.test
index f24c08aa..c6520002 100755
--- a/test/pnmpsnr.test
+++ b/test/pnmpsnr.test
@@ -5,19 +5,36 @@
 
 tmpdir=${tmpdir:-/tmp}
 
-
 w_pbm=${tmpdir}/w.pbm
 b_pbm=${tmpdir}/b.pbm
 
 pbmmake -w 10 10 > ${w_pbm}
 pbmmake -b 10 10 > ${b_pbm}
 
+echo "Test 1"
+
 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
+
+echo "Test 2"
+
 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}
+
+echo "Test 3"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pnmpsnr ${b_pbm} ${w_pbm} ${b_pbm}     || echo "Expected failure 1"
+pnmpsnr ${b_pbm}                       || echo "Expected failure 2"
+pnmpsnr ${b_pbm} ${w_pbm} -target1=100 || echo "Expected failure 3"
+pnmpsnr                   -machine     || echo "Expected failure 4"
+
+rm ${b_pbm} ${w_pbm}
\ No newline at end of file
diff --git a/test/pnmquantall.test b/test/pnmquantall.test
index cd01bb8d..b735b623 100755
--- a/test/pnmquantall.test
+++ b/test/pnmquantall.test
@@ -1,6 +1,6 @@
 #! /bin/bash
 # This script tests: pnmquantall
-# Also requires: ppmtorgb3 pgmhist
+# Also requires: ppmtorgb3 pgmhist pnmcat
 
 tmpdir=${tmpdir:-/tmp}
 test_ppm=${tmpdir}/testimg.ppm
diff --git a/test/ppmforge-parameters.ok b/test/ppmforge-parameters.ok
new file mode 100644
index 00000000..50e68390
--- /dev/null
+++ b/test/ppmforge-parameters.ok
@@ -0,0 +1,10 @@
+Test 1
+256 256
+100 90
+90 90
+Test 2
+Expected failure 1
+Expected failure 2
+Expected failure 3
+Expected failure 4
+Expected failure 5
diff --git a/test/ppmforge-parameters.test b/test/ppmforge-parameters.test
new file mode 100755
index 00000000..48c4ae4c
--- /dev/null
+++ b/test/ppmforge-parameters.test
@@ -0,0 +1,29 @@
+#! /bin/bash
+# This script tests: ppmforge
+# Also requires: pamfile
+
+echo "Test 1"
+
+# Should print 256 256
+ppmforge -night | pamfile -size
+
+# Width is adjusted if not even
+# becomes 100 in this case
+ppmforge -night -width=99 -height=90 | pamfile -size
+
+# Width is adjusted if smaller than height
+# brought up to 100 in this case
+ppmforge -night -width=80 -height=90 | pamfile -size
+
+echo "Test 2"
+
+echo 1>&2
+echo "Invalid command-line arguments." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+ppmforge -night  -dimension=0  || echo "Expected failure 1"
+ppmforge -clouds -mesh=1.99    || echo "Expected failure 2"
+ppmforge -clouds -power=0      || echo "Expected failure 3"
+ppmforge         -ice=0        || echo "Expected failure 4"
+ppmforge         -glaciers=0   || echo "Expected failure 5"
diff --git a/test/ppmhist.ok b/test/ppmhist.ok
index f2ba637b..38b7770f 100644
--- a/test/ppmhist.ok
+++ b/test/ppmhist.ok
@@ -1,3 +1,4 @@
+Test 1
      0     0     0	    0	      2 
      1     1     1	    1	      2 
      2     2     2	    2	      2 
@@ -7,6 +8,7 @@
      6     6     6	    6	      2 
      8     8     8	    8	      2 
 3081591280 60957
+Test 2
  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
@@ -17,3 +19,7 @@
  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
+Test 3
+Expected failure 1
+Expected failure 2
+Expected failure 3
diff --git a/test/ppmhist.test b/test/ppmhist.test
index 27d31562..c17bab5a 100755
--- a/test/ppmhist.test
+++ b/test/ppmhist.test
@@ -2,11 +2,15 @@
 # This script tests: ppmhist
 # Also requires: pgmramp pamtopnm pbmmake pamseq ppmpat
 
+echo "Test 1"
+
 pgmramp -maxval=8 -lr 8 2 | ppmhist -sort=rgb -noheader
 ppmhist -map -sort=rgb -noheader testimg.ppm | pamtopnm | cksum
 
 # Test summary header
 
+echo "Test 2"
+
 pbmmake -b 2 1 | ppmhist   | head -n1
 pbmmake -w 2 1 | ppmhist   | head -n1
 pbmmake -g 2 1 | ppmhist   | head -n1
@@ -19,4 +23,16 @@ ppmpat -madras --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 25 25 | \
 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
+  ppmhist | head -n1
+
+echo "Test 3"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+ppmhist -hexcolor -float testimg.ppm || echo "Expected failure 1"
+ppmhist -hexcolor -map   testimg.ppm || echo "Expected failure 2"
+ppmhist -float    -map   testimg.ppm || echo "Expected failure 3"
+
diff --git a/test/ppmmake.ok b/test/ppmmake.ok
index 0e871732..8a2bedc7 100644
--- a/test/ppmmake.ok
+++ b/test/ppmmake.ok
@@ -1,2 +1,15 @@
+Test 1.
 2477651508 15012
+4294967295 0
 2378991101 7513
+Test 2.
+Expected error 1
+Expected error 2
+Expected error 3
+Expected error 4
+Expected error 5
+Expected error 6
+Expected error 7
+Expected error 8
+Expected error 9
+Expected error 10
diff --git a/test/ppmmake.test b/test/ppmmake.test
index 879a367e..edd6f251 100755
--- a/test/ppmmake.test
+++ b/test/ppmmake.test
@@ -2,6 +2,26 @@
 # This script tests: ppmmake
 # Also requires:
 
+echo "Test 1."
 
 ppmmake rgb:ff/80/80 50 100 -maxval=5 | cksum
+ppmmake rgbi:0.5/1.0/0 2   | cksum
 ppmmake red 50 50  | cksum
+
+echo "Test 2."
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+ppmmake rgb:gg/00/00  2 2  || echo "Expected error 1"
+ppmmake rgb:ff/ff/00  2    || echo "Expected error 2"
+ppmmake rgbi:1.1/0/0  2 2  || echo "Expected error 3"
+ppmmake rgbi:1.0/.5   2 2  || echo "Expected error 4"
+ppmmake rainbow       2 2  || echo "Expected error 5"
+ppmmake               2 2  || echo "Expected error 6"
+ppmmake blue -maxval=0 2 2  || echo "Expected error 7"
+ppmmake blue -maxval=-1 2 2  || echo "Expected error 8"
+ppmmake blue -maxval=65536 2 2  || echo "Expected error 9"
+RGBDEF=/dev/null ppmmake red 2 2 || echo "Expected error 10"
diff --git a/test/ppmpat.ok b/test/ppmpat.ok
index bb940aee..5493ba53 100644
--- a/test/ppmpat.ok
+++ b/test/ppmpat.ok
@@ -1,6 +1,39 @@
+Test 1
 4008533639 781
+Test 2
 3805937800 9613
+Test 3
 2698433077 1549
+Test 4
 3705929501 781
+Test 5
 3057513592 661
+Test 6
 1861389287 661
+Test 7
+Expected failure 1
+Expected failure 2
+Expected failure 3
+Expected failure 4
+Expected failure 5
+Expected failure 6
+Expected failure 7
+Expected failure 8
+Expected failure 9
+Expected failure 10
+Expected failure 11
+Expected failure 12
+Expected failure 13
+Expected failure 14
+Expected failure 15
+Expected failure 16
+Expected failure 17
+Expected failure 18
+Expected failure 19
+Expected failure 20
+Expected failure 21
+Expected failure 22
+Expected failure 23
+Expected failure 24
+Expected failure 25
+Expected failure 26
diff --git a/test/ppmpat.test b/test/ppmpat.test
index cd00c0f1..c6647328 100755
--- a/test/ppmpat.test
+++ b/test/ppmpat.test
@@ -3,19 +3,74 @@
 # Also requires:
 
 # Test 1. Should print: 4008533639 781
+echo "Test 1"
 ppmpat -g2 --color=rgb:32/0d/b7,rgb:31/58/a3 16 16 | cksum
 
 # Test 2. Should print: 3805937800 9613
+echo "Test 2"
 ppmpat -g3 --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 64 50 | cksum
 
 # Test 3. Should print: 2698433077 1549
+echo "Test 3"
 ppmpat -madras --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 32 16 | cksum
 
 # Test 4. Should print: 3705929501 781
+echo "Test 4"
 ppmpat -tartan --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 16 16 | cksum
 
 # Test 5. Should print: 3057513592 661
+echo "Test 5"
 ppmpat -argyle1 --color=rgb:ff/ff/ff,rgb:ff/0/0 12 18 | cksum
 
 # Test 6. Should print: 1861389287 661
+echo "Test 6"
 ppmpat -argyle2 --color=rgb:00/00/00,rgb:ff/80/80,rgb:e0/e0/e0 12 18 | cksum
+
+# Test 7.
+echo "Test 7"
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+ppmpat -g2 -g3 10 10 || echo "Expected failure 1"
+ppmpat -madras -tartan 10 10 || echo "Expected failure 2"
+ppmpat -poles -squig 10 10 || echo "Expected failure 3"
+ppmpat -camo -anticamo 10 10 || echo "Expected failure 4"
+ppmpat -argyle1 -argyle2 10 10 || echo "Expected failure 5"
+
+ppmpat 10 10 || echo "Expected failure 6"
+ppmpat -g2 10 || echo "Expected failure 7"
+ppmpat -g2 10 10 10 || echo "Expected failure 8"
+ppmpat -g2 10 || echo "Expected failure 9"
+
+clist1="-color=rgb:00/00/00"
+clist2="-color=rgb:00/00/00,rgb:00/00/ff"
+clist3="-color=rgb:00/00/00,rgb:00/00/ff,rgb:00/ff/ff"
+clist4="-color=rgb:00/00/00,rgb:00/00/ff,rgb:00/ff/ff,rgb:ff/ff/ff"
+
+# These patterns require exactly 2 colors 
+ppmpat -gingham2 ${clist1} 10 10 || echo "Expected failure 10"
+ppmpat -argyle1  ${clist1} 10 10 || echo "Expected failure 11"
+ppmpat -gingham2 ${clist3} 10 10 || echo "Expected failure 12"
+ppmpat -argyle1  ${clist3} 10 10 || echo "Expected failure 13"
+
+# These require exactly 3 colors 
+ppmpat -gingham3 ${clist2} 10 10 || echo "Expected failure 14"
+ppmpat -argyle2  ${clist2} 10 10 || echo "Expected failure 15"
+ppmpat -madras   ${clist2} 10 10 || echo "Expected failure 16"
+ppmpat -tartan   ${clist2} 10 10 || echo "Expected failure 17"
+ppmpat -gingham3 ${clist4} 10 10 || echo "Expected failure 18"
+ppmpat -argyle2  ${clist4} 10 10 || echo "Expected failure 19"
+ppmpat -madras   ${clist4} 10 10 || echo "Expected failure 20"
+ppmpat -tartan   ${clist4} 10 10 || echo "Expected failure 21"
+
+# These require at least 3 colors 
+ppmpat -squig    ${clist2} 10 10 || echo "Expected failure 22"
+ppmpat -camo     ${clist2} 10 10 || echo "Expected failure 23"
+ppmpat -anticamo ${clist2} 10 10 || echo "Expected failure 24"
+
+# The squig pattern has an aspect ratio restriction 
+ppmpat -squig ${clist3} 10 250  || echo "Expected failure 25"
+ppmpat -squig ${clist3} 500 20  || echo "Expected failure 26"
diff --git a/test/sgi-roundtrip.test b/test/sgi-roundtrip.test
index 88efb75e..5052bb81 100755
--- a/test/sgi-roundtrip.test
+++ b/test/sgi-roundtrip.test
@@ -1,6 +1,6 @@
 #! /bin/bash
 # This script tests: pnmtosgi sgitopnm
-# Also requires: rgb3toppm
+# Also requires: rgb3toppm pamdepth pamtopnm
 
 
 a_sgi=${tmpdir}/a.sgi