about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2021-12-06 03:35:30 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2021-12-06 03:35:30 +0000
commitb62eff9e0c76dcdab094bf9fe32355c543ea909f (patch)
treed9fcb02c5a8830d088657885f5e55340b29ae767 /test
parent59bf40d2b1cfe85111b15ec05f8c124f657aefe2 (diff)
downloadnetpbm-mirror-b62eff9e0c76dcdab094bf9fe32355c543ea909f.tar.gz
netpbm-mirror-b62eff9e0c76dcdab094bf9fe32355c543ea909f.tar.xz
netpbm-mirror-b62eff9e0c76dcdab094bf9fe32355c543ea909f.zip
Add maze.pbm test image, update tests to use it
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4200 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rwxr-xr-xtest/Execute-Tests9
-rw-r--r--test/atk-roundtrip.ok4
-rwxr-xr-xtest/atk-roundtrip.test9
-rw-r--r--test/bmp-roundtrip.ok14
-rwxr-xr-xtest/bmp-roundtrip.test14
-rw-r--r--test/cis-roundtrip.ok5
-rwxr-xr-xtest/cis-roundtrip.test14
-rw-r--r--test/cmuw-roundtrip.ok3
-rwxr-xr-xtest/cmuw-roundtrip.test5
-rw-r--r--test/cut-cat-roundtrip.ok146
-rwxr-xr-xtest/cut-cat-roundtrip.test170
-rwxr-xr-xtest/g3-roundtrip.test19
-rw-r--r--test/gem-roundtrip.ok2
-rwxr-xr-xtest/gem-roundtrip.test4
-rw-r--r--test/gif-roundtrip.ok24
-rwxr-xr-xtest/gif-roundtrip.test82
-rw-r--r--test/ilbm-roundtrip.ok12
-rwxr-xr-xtest/ilbm-roundtrip.test19
-rw-r--r--test/jbig-roundtrip.ok2
-rwxr-xr-xtest/jbig-roundtrip.test4
-rw-r--r--test/lps-roundtrip.ok1
-rwxr-xr-xtest/lps-roundtrip.test17
-rw-r--r--test/macp-roundtrip.ok6
-rwxr-xr-xtest/macp-roundtrip.test19
-rw-r--r--test/maze.pbmbin0 -> 481 bytes
-rw-r--r--test/mda-roundtrip.ok5
-rwxr-xr-xtest/mda-roundtrip.test12
-rw-r--r--test/mgr-roundtrip.ok4
-rwxr-xr-xtest/mgr-roundtrip.test4
-rw-r--r--test/mrf-roundtrip.ok2
-rwxr-xr-xtest/mrf-roundtrip.test4
-rw-r--r--test/pad-crop-roundtrip.ok4
-rwxr-xr-xtest/pad-crop-roundtrip.test12
-rw-r--r--test/palm-roundtrip.ok14
-rwxr-xr-xtest/palm-roundtrip.test10
-rw-r--r--test/pamarith-compare-equal.ok30
-rwxr-xr-xtest/pamarith-compare-equal.test45
-rw-r--r--test/pamarith.ok22
-rwxr-xr-xtest/pamarith.test9
-rw-r--r--test/pamcut.ok22
-rwxr-xr-xtest/pamcut.test38
-rw-r--r--test/pamdepth-roundtrip.ok2
-rwxr-xr-xtest/pamdepth-roundtrip.test2
-rw-r--r--test/pamdice-roundtrip.ok22
-rwxr-xr-xtest/pamdice-roundtrip.test52
-rwxr-xr-xtest/pamenlarge-pamscale-point.test4
-rw-r--r--test/pamenlarge.ok8
-rwxr-xr-xtest/pamenlarge.test13
-rw-r--r--test/pamflip-roundtrip.ok81
-rwxr-xr-xtest/pamflip-roundtrip.test136
-rw-r--r--test/pamflip1.ok13
-rwxr-xr-xtest/pamflip1.test24
-rw-r--r--test/pamflip2.ok9
-rwxr-xr-xtest/pamflip2.test14
-rw-r--r--test/pamfunc.ok14
-rwxr-xr-xtest/pamfunc.test14
-rwxr-xr-xtest/pamhue.test6
-rw-r--r--test/pamslice-roundtrip.ok13
-rwxr-xr-xtest/pamslice-roundtrip.test78
-rw-r--r--test/pamsumm.ok9
-rwxr-xr-xtest/pamsumm.test11
-rw-r--r--test/pamtopam.ok40
-rwxr-xr-xtest/pamtopam.test21
-rwxr-xr-xtest/pamtopdbimg.test6
-rw-r--r--test/pamundice.ok16
-rwxr-xr-xtest/pamundice.test34
-rw-r--r--test/pbm-ppm-roundtrip.ok14
-rwxr-xr-xtest/pbm-ppm-roundtrip.test17
-rw-r--r--test/pbmminkowski.ok8
-rwxr-xr-xtest/pbmminkowski.test7
-rw-r--r--test/pbmpscale.ok223
-rwxr-xr-xtest/pbmpscale.test39
-rw-r--r--test/pbmtog3.ok18
-rwxr-xr-xtest/pbmtog3.test37
-rwxr-xr-xtest/pgmminkowski.test4
-rw-r--r--test/pi3-roundtrip.ok5
-rwxr-xr-xtest/pi3-roundtrip.test15
-rwxr-xr-xtest/pj-roundtrip.test4
-rw-r--r--test/png-roundtrip.ok36
-rwxr-xr-xtest/png-roundtrip.test4
-rw-r--r--test/png-roundtrip2.ok4
-rwxr-xr-xtest/png-roundtrip2.test4
-rw-r--r--test/pnm-pam-roundtrip.ok2
-rwxr-xr-xtest/pnm-pam-roundtrip.test2
-rw-r--r--test/pnm-plain-roundtrip.ok2
-rwxr-xr-xtest/pnm-plain-roundtrip.test2
-rwxr-xr-xtest/pnmcolormap.test6
-rw-r--r--test/pnminvert-roundtrip.ok2
-rwxr-xr-xtest/pnminvert-roundtrip.test2
-rw-r--r--test/ppmchange-roundtrip.ok4
-rwxr-xr-xtest/ppmchange-roundtrip.test4
-rw-r--r--test/ppmpat.ok20
-rwxr-xr-xtest/ppmpat.test44
-rw-r--r--test/sunicon-roundtrip.ok5
-rwxr-xr-xtest/sunicon-roundtrip.test25
-rw-r--r--test/targa-roundtrip.ok30
-rwxr-xr-xtest/targa-roundtrip.test27
-rw-r--r--test/tiff-flate-lzw-roundtrip.ok2
-rwxr-xr-xtest/tiff-flate-lzw-roundtrip.test2
-rw-r--r--test/tiff-roundtrip.ok6
-rwxr-xr-xtest/tiff-roundtrip.test8
-rw-r--r--test/wbmp-roundtrip.ok2
-rwxr-xr-xtest/wbmp-roundtrip.test4
-rw-r--r--test/winicon-roundtrip.ok14
-rwxr-xr-xtest/winicon-roundtrip.test9
-rwxr-xr-xtest/winicon-roundtrip2.test3
-rw-r--r--test/xbm-roundtrip.ok5
-rwxr-xr-xtest/xbm-roundtrip.test5
-rw-r--r--test/xpm-roundtrip.ok2
-rwxr-xr-xtest/xpm-roundtrip.test2
-rw-r--r--test/xwd-roundtrip.ok5
-rwxr-xr-xtest/xwd-roundtrip.test11
112 files changed, 1301 insertions, 878 deletions
diff --git a/test/Execute-Tests b/test/Execute-Tests
index 7a02fdef..da4504a4 100755
--- a/test/Execute-Tests
+++ b/test/Execute-Tests
@@ -103,6 +103,10 @@ if [ ! -f ./testgrid.pbm ]
   then cp -v ${srcdir}/testgrid.pbm ./testgrid.pbm
 fi
 
+if [ ! -f ./maze.pbm ]
+  then cp -v ${srcdir}/maze.pbm ./maze.pbm
+fi
+
 if [ ! -f ./testimg.ppm ]
   then cp -v ${srcdir}/testimg.ppm  ./testimg.ppm 
 fi
@@ -181,7 +185,7 @@ elif [ $VALGRIND_TESTS = "on" ]
   # You may want to add --track-origins=yes to the above.
 
   for i in awk basename cat cksum cmp comm cp cut date dirname \
-           egrep fgrep file grep gs head iconv mkdir mktemp perl rm \
+           egrep fgrep file grep gs head iconv ls mkdir mktemp perl rm \
            sed seq sh sort tee tr uniq wc \
            testrandom Available-Testprog
 
@@ -248,6 +252,7 @@ fi
 
 if [ ! -s ${srcdir}/${tname%.test}.ok ]
 then
+  echo "${tname%.test}.ok does not exist"
   let result=4;
 else
   ${srcdir}/Available-Testprog \
@@ -299,7 +304,7 @@ fi
 # (Do not erase them if we are working from the source directory.)
 
 if [ ! $PWD -ef ${srcdir} ]
-    then rm ./testimg.ppm ./testgrid.pbm
+    then rm ./testimg.ppm ./testgrid.pbm ./maze.pbm
 fi
 
 
diff --git a/test/atk-roundtrip.ok b/test/atk-roundtrip.ok
index c037f1b9..b9437e7d 100644
--- a/test/atk-roundtrip.ok
+++ b/test/atk-roundtrip.ok
@@ -1,5 +1,5 @@
-Test 1. Should print 2425386270 41
-2425386270 41
+Test 1. Should print 281226646 481
+281226646 481
 Test 2. Should print 1824220442 125013 twice, then 2146497872 1000013 twice
 241513515 125013
 241513515 125013
diff --git a/test/atk-roundtrip.test b/test/atk-roundtrip.test
index 856efa4f..f87c2e78 100755
--- a/test/atk-roundtrip.test
+++ b/test/atk-roundtrip.test
@@ -2,16 +2,17 @@
 # This script tests: pbmtoatk atktopbm
 # Also requires: pbmmake
 
-echo "Test 1. Should print 2425386270 41"
-# cksum of testgrid.pbm
+echo "Test 1. Should print 281226646 481"
+# cksum of maze.pbm
 
-pbmtoatk testgrid.pbm | atktopbm | cksum
+pbmtoatk maze.pbm | atktopbm | cksum
 
 tmpdir=${tmpdir:-/tmp}
 maxwidth_pbm=${tmpdir}/maxwidth.pbm
 maxheight_pbm=${tmpdir}/maxheight.pbm
 
-echo "Test 2. Should print 1824220442 125013 twice, then 2146497872 1000013 twice"
+echo \
+ "Test 2. Should print 1824220442 125013 twice, then 2146497872 1000013 twice"
 
 pbmmake -g 1000000 1 | tee ${maxwidth_pbm} | cksum
 pbmtoatk ${maxwidth_pbm} | atktopbm | cksum
diff --git a/test/bmp-roundtrip.ok b/test/bmp-roundtrip.ok
index 4f4f8367..217a54aa 100644
--- a/test/bmp-roundtrip.ok
+++ b/test/bmp-roundtrip.ok
@@ -1,14 +1,14 @@
-PBM
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-PPM
+Test 1 PBM.  Should print 281226646 481 four times
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+Test 2 PPM.  Should print 1926073387 101484 four times
 1926073387 101484
 1926073387 101484
 1926073387 101484
 1926073387 101484
-PGM
+Test 3 PGM.  Should print 1571496937 33838 nine times
 1571496937 33838
 1571496937 33838
 1571496937 33838
diff --git a/test/bmp-roundtrip.test b/test/bmp-roundtrip.test
index c9ef363a..df858a09 100755
--- a/test/bmp-roundtrip.test
+++ b/test/bmp-roundtrip.test
@@ -4,27 +4,21 @@
 
 tmpdir=${tmpdir:-/tmp}
 
-# Test 1.  Should print 2425386270 41 four times
-
-echo PBM
+echo "Test 1 PBM.  Should print 281226646 481 four times"
 
 for mode in "" "-bpp=1" "-windows" "-os2"
   do
-  ppmtobmp ${mode} testgrid.pbm | bmptopnm | cksum
+  ppmtobmp ${mode} maze.pbm | bmptopnm | cksum
   done
 
-# Test 2.  Should print 1926073387 101484 four times
-
-echo PPM
+echo "Test 2 PPM.  Should print 1926073387 101484 four times"
 
 for mode in "" "-bpp=24" "-windows" "-os2"
   do
   ppmtobmp ${mode} testimg.ppm | bmptopnm | cksum
   done
 
-# Test 3.  Should print 1571496937 33838 nine times
-
-echo PGM
+echo "Test 3 PGM.  Should print 1571496937 33838 nine times"
 
 red_pgm=${tmpdir}/red.pgm
 mapfile_pgm=${tmpdir}/mapfile.pgm
diff --git a/test/cis-roundtrip.ok b/test/cis-roundtrip.ok
index da90078b..1bb50cb7 100644
--- a/test/cis-roundtrip.ok
+++ b/test/cis-roundtrip.ok
@@ -1,2 +1,5 @@
+Test 1. Should print 2631579683 1546 twice
 2631579683 1546
-2425386270 41
+2631579683 1546
+Test 2. Should print 281226646 481, cksum of maze.pbm
+281226646 481
diff --git a/test/cis-roundtrip.test b/test/cis-roundtrip.test
index 62fcc3b9..35eb558a 100755
--- a/test/cis-roundtrip.test
+++ b/test/cis-roundtrip.test
@@ -1,14 +1,18 @@
 #! /bin/bash
 # This script tests: pbmtocis cistopbm
-# Also requires: pbmmake pamcut
+# Also requires: pbmmake pamcut pamfile
 
+tmpdir=${tmpdir:-/tmp}
+test_pbm=${tmpdir}/test.pbm
 
 # Output images produced by pbmtocis are of fixed size,
 # either 128x96 or 256x192.
 # Smaller input images are padded, larger ones are cropped.
 
-# Test 1. Should print 2631579683 1546
-pbmmake -g 128 96 | pbmtocis | cistopbm | cksum
+echo "Test 1. Should print 2631579683 1546 twice"
+pbmmake -g 128 96 | tee ${test_pbm} | cksum
+pbmtocis ${test_pbm} | cistopbm | cksum
 
-# Test 2. Should print 2425386270 41
-pbmtocis testgrid.pbm | cistopbm | pamcut 0 0 14 16 | cksum
+echo "Test 2. Should print 281226646 481, cksum of maze.pbm"
+size=$(pamfile -size maze.pbm | awk '{print "-width="$1,"-height="$2}')
+pbmtocis maze.pbm | cistopbm | pamcut -left=0 -top=0 ${size} | cksum
diff --git a/test/cmuw-roundtrip.ok b/test/cmuw-roundtrip.ok
index 845be5fb..4ec1a381 100644
--- a/test/cmuw-roundtrip.ok
+++ b/test/cmuw-roundtrip.ok
@@ -1 +1,2 @@
-2425386270 41
+Should print 281226646 481, cksum of maze.pbm
+281226646 481
diff --git a/test/cmuw-roundtrip.test b/test/cmuw-roundtrip.test
index e52adb70..725f9131 100755
--- a/test/cmuw-roundtrip.test
+++ b/test/cmuw-roundtrip.test
@@ -2,6 +2,5 @@
 # This script tests: pbmtocmuwm cmuwmtopbm
 # Also requires:
 
-
-# Should print 2425386270 41, cksum of testgrid.pbm
-pbmtocmuwm testgrid.pbm | cmuwmtopbm | cksum
+echo "Should print 281226646 481, cksum of maze.pbm"
+pbmtocmuwm maze.pbm | cmuwmtopbm | cksum
diff --git a/test/cut-cat-roundtrip.ok b/test/cut-cat-roundtrip.ok
index bc9b8cb4..edf1de67 100644
--- a/test/cut-cat-roundtrip.ok
+++ b/test/cut-cat-roundtrip.ok
@@ -1,92 +1,54 @@
-Test 1.
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-Test 2.
-3891261972 202953
-3891261972 202953
-3891261972 202953
-3891261972 202953
-3891261972 202953
-3891261972 202953
-Test 3.
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-Test 4.
-26789469 202953
-26789469 202953
-26789469 202953
-26789469 202953
-26789469 202953
-Test 5.
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-Test 6.
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-1887700557 73
-Test 7.
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-Test 8.
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
-3221289196 73
+Test 1.  Should print 1926073387 101484 six times
+1926073387 101484
+1926073387 101484
+1926073387 101484
+1926073387 101484
+1926073387 101484
+1926073387 101484
+Test 2.  Should print 3891261972 202953 1926073387 101484 six times
+3891261972 202953 1926073387 101484
+3891261972 202953 1926073387 101484
+3891261972 202953 1926073387 101484
+3891261972 202953 1926073387 101484
+3891261972 202953 1926073387 101484
+3891261972 202953 1926073387 101484
+Test 3.  Should print 1926073387 101484 five times
+1926073387 101484
+1926073387 101484
+1926073387 101484
+1926073387 101484
+1926073387 101484
+Test 4.  Should print 26789469 202953 1926073387 101484 five times
+26789469 202953 1926073387 101484
+26789469 202953 1926073387 101484
+26789469 202953 1926073387 101484
+26789469 202953 1926073387 101484
+26789469 202953 1926073387 101484
+Test 5.  Should print 281226646 481 six times
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+Test 6.  Should print 1748767123 895 281226646 481 six times
+1748767123 895 281226646 481
+1748767123 895 281226646 481
+1748767123 895 281226646 481
+1748767123 895 281226646 481
+1748767123 895 281226646 481
+1748767123 895 281226646 481
+Test 7.  Should print 281226646 481 seven times
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+Test 8.  Should print 1346655680 954 281226646 481 five times
+1346655680 954 281226646 481
+1346655680 954 281226646 481
+1346655680 954 281226646 481
+1346655680 954 281226646 481
+1346655680 954 281226646 481
diff --git a/test/cut-cat-roundtrip.test b/test/cut-cat-roundtrip.test
index 95ee5279..970c3e17 100755
--- a/test/cut-cat-roundtrip.test
+++ b/test/cut-cat-roundtrip.test
@@ -1,128 +1,146 @@
 #! /bin/bash
 # This script tests: pamcut
-# Also requires: pnmcat pnmpad
+# Also requires: pamfile pnmcat pnmpad pnmcrop
 
 tmpdir=${tmpdir:-/tmp}
-quant_ppm=${tmpdir}/quant.ppm
 
-right_pbm=${tmpdir}/right.pbm
-left_pbm=${tmpdir}/left.pbm
-right_ppm=${tmpdir}/right.ppm
 left_ppm=${tmpdir}/left.ppm
-bottom_pbm=${tmpdir}/bottom.pbm
-top_pbm=${tmpdir}/top.pbm
-bottom_ppm=${tmpdir}/bottom.ppm
+right_ppm=${tmpdir}/right.ppm
 top_ppm=${tmpdir}/top.ppm
+bottom_ppm=${tmpdir}/bottom.ppm
+padded_ppm=${tmpdir}/padded.ppm
+
+echo "Test 1.  Should print 1926073387 101484 six times"
 
+testimg_ppm_sum=`cat testimg.ppm | cksum`
+echo ${testimg_ppm_sum}
 
-# Test 1.  Should print 1926073387 101484 six times
-echo Test 1.
+ imgsize=$(pamfile -size testimg.ppm)
+ iw=$(echo ${imgsize} | cut -d" " -f1)
+ ih=$(echo ${imgsize} | cut -d" " -f2)
 
-cat testimg.ppm | cksum
 for i in 0 1 128 224 225
   do
   pamcut -left=$((i+1)) testimg.ppm > ${right_ppm}
   pamcut -right=$i      testimg.ppm > ${left_ppm}
   pnmcat -lr ${left_ppm} ${right_ppm} | \
-    pamcut -left=0 -width=227| cksum
+    pamcut -left=0 -width=${iw} | cksum
   rm ${left_ppm} ${right_ppm}
   done
 
+echo "Test 2.  Should print 3891261972 202953 1926073387 101484 six times"
+# Padding added to right.
 
-# Test 2.  Should print 3891261972 202953 six times
-# Not roundtrip.  Padding added to right.
-echo Test 2.
+pnmpad -right=${iw} -black testimg.ppm | cksum | tr '\n' ' '
+echo ${testimg_ppm_sum}
 
-pnmpad -right=227 -black testimg.ppm | cksum
-for i in  0 1 128 224 225
+for border in 0 1 128 224 225
   do
-  pamcut -left=$((i+1)) -width=227 -pad testimg.ppm > ${right_ppm}
-  pamcut -right=$i      -width=227 -pad testimg.ppm > ${left_ppm}
+  pamcut -left=$((${border}+1)) -width=${iw} -pad testimg.ppm > ${right_ppm}
+  pamcut -right=${border} -width=${iw} -pad testimg.ppm > ${left_ppm}
   pnmcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \
-    pamcut -left=$((227-i-1))  -width=$((227*2)) | cksum
-  rm ${left_ppm} ${right_ppm}
+    pamcut -left=$((${iw}-${border}-1))  -width=$((${iw}*2)) | \
+    tee ${padded_ppm} | cksum | tr '\n' ' '
+  pnmcrop -black -right ${padded_ppm} | cksum
+  rm ${left_ppm} ${right_ppm} ${padded_ppm}
   done
 
 
-# Test 3.  Should print 1926073387 101484 five times
-echo Test 3.
+echo "Test 3.  Should print 1926073387 101484 five times"
 
-cat testimg.ppm | cksum
-for i in 0 1 70 147
+echo ${testimg_ppm_sum}
+for border in 0 1 70 147
   do
-  pamcut -top=$((i+1)) testimg.ppm > ${bottom_ppm}
-  pamcut -bottom=$i    testimg.ppm > ${top_ppm}
+  pamcut -top=$((${border}+1)) testimg.ppm > ${bottom_ppm}
+  pamcut -bottom=${border}     testimg.ppm > ${top_ppm}
   pnmcat -tb ${top_ppm} ${bottom_ppm} | \
-    pamcut -top=0 -height=149 | cksum
+    pamcut -top=0 -height=${ih} | cksum
   rm ${top_ppm} ${bottom_ppm}
   done
 
-# Test 4.  Should print 26789469 202953 five times
-# Not roundtrip.  Padding added to bottom.
-echo Test 4.
+echo "Test 4.  Should print 26789469 202953 1926073387 101484 five times"
+# Padding added to bottom.
 
-pnmpad -bottom=149 -black testimg.ppm | cksum
-for i in 0 1 70 147
+pnmpad -bottom=${ih} -black testimg.ppm | cksum | tr '\n' ' '
+echo ${testimg_ppm_sum}
+for border in 0 1 70 147
   do
-  pamcut -top=$((i+1)) -height=149 -pad testimg.ppm > ${bottom_ppm}
-  pamcut -bottom=$i    -height=149 -pad testimg.ppm > ${top_ppm}
+  pamcut -top=$((${border}+1)) -height=${ih} -pad testimg.ppm > ${bottom_ppm}
+  pamcut -bottom=${border}     -height=${ih} -pad testimg.ppm > ${top_ppm}
   pnmcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \
-    pamcut -top=$((149-i-1))  -height=$((149*2)) | cksum
-  rm ${top_ppm} ${bottom_ppm}
+    pamcut -top=$((${ih}-${border}-1))  -height=$((${ih}*2)) | \
+    tee ${padded_ppm} | cksum | tr '\n' ' 'cksum
+  pnmcrop -black -bottom ${padded_ppm} | cksum
+  rm ${top_ppm} ${bottom_ppm} ${padded_ppm}
   done
 
-# Test 5.  Should print 2425386270 41 fourteen times
-echo Test 5.
+left_pbm=${tmpdir}/left.pbm
+right_pbm=${tmpdir}/right.pbm
+top_pbm=${tmpdir}/top.pbm
+bottom_pbm=${tmpdir}/bottom.pbm
+padded_pbm=${tmpdir}/padded.pbm
+
+echo "Test 5.  Should print 281226646 481 six times"
+
+maze_pbm_sum=`cat maze.pbm | cksum`
+echo ${maze_pbm_sum}
+
+imgsize=$(pamfile -size maze.pbm)
+iw=$(echo ${imgsize} | cut -d" " -f1)
+ih=$(echo ${imgsize} | cut -d" " -f2)
 
-cat testgrid.pbm | cksum
-for i in `seq 0 12`
+for i in 0 1 10 30 50
   do
-  pamcut -left=$((i+1)) testgrid.pbm > ${right_pbm}
-  pamcut -right=$i      testgrid.pbm > ${left_pbm}
-  pnmcat -lr ${left_pbm} ${right_pbm} | \
-    pamcut -left=0 -width=14 | cksum
-  rm ${left_pbm} ${right_pbm}
+  pamcut -left=$((i+1)) maze.pbm > ${right_ppm}
+  pamcut -right=$i      maze.pbm > ${left_ppm}
+  pnmcat -lr ${left_ppm} ${right_ppm} | \
+    pamcut -left=0 -width=${iw} | cksum
+  rm ${left_ppm} ${right_ppm}
   done
 
 
-# Test 6.  Should print 1887700557 73 fifteen times
-# Not roundtrip.  Padding added to right.
-echo Test 6.
+echo "Test 6.  Should print 1748767123 895 281226646 481 six times"
+# Padding added to right.
+
+pnmpad -right=${iw} -black maze.pbm | cksum | tr '\n' ' '
+echo ${maze_pbm_sum}
 
-pnmpad -right=14 -black testgrid.pbm | cksum
-for i in `seq 0 13`
+for border in 0 1 10 30 50
   do
-  pamcut -left=$((i+1)) -width=14 -pad testgrid.pbm > ${right_pbm}
-  pamcut -right=$i      -width=14 -pad testgrid.pbm > ${left_pbm}
-  pnmcat -lr ${left_pbm} ${right_pbm} ${left_pbm} | \
-    pamcut -left=$((14-i-1)) -width=28 | cksum
-  rm ${left_pbm} ${right_pbm}
+  pamcut -left=$((${border}+1)) -width=${iw} -pad maze.pbm > ${right_ppm}
+  pamcut -right=${border} -width=${iw} -pad maze.pbm > ${left_ppm}
+  pnmcat -lr ${left_ppm} ${right_ppm} ${left_ppm} | \
+    pamcut -left=$((${iw}-${border}-1))  -width=$((${iw}*2)) | \
+    tee ${padded_ppm} | cksum | tr '\n' ' '
+  pnmcrop -black -right ${padded_ppm} | cksum
+  rm ${left_ppm} ${right_ppm} ${padded_ppm}
   done
 
-# Test 7.  Should print 2425386270 41 sixteen times
-echo Test 7.
 
-cat testgrid.pbm | cksum
-for i in `seq 0 14`
+echo "Test 7.  Should print 281226646 481 seven times"
+
+echo ${maze_pbm_sum}
+for border in 0 1 12 21 31 44
   do
-  pamcut -top=$((i+1)) testgrid.pbm > ${bottom_pbm}
-  pamcut -bottom=$i    testgrid.pbm > ${top_pbm}
-  pnmcat -tb ${top_pbm} ${bottom_pbm} | \
-    pamcut -top=0 -height=16 | cksum
-  rm ${top_pbm} ${bottom_pbm}
+  pamcut -top=$((${border}+1)) maze.pbm > ${bottom_ppm}
+  pamcut -bottom=${border}     maze.pbm > ${top_ppm}
+  pnmcat -tb ${top_ppm} ${bottom_ppm} | \
+    pamcut -top=0 -height=${ih} | cksum
+  rm ${top_ppm} ${bottom_ppm}
   done
 
-# Test 8.  Should print 3221289196 73 seventeen times
-# Not roundtrip.  Padding added to bottom.
-echo Test 8.
+echo "Test 8.  Should print 1346655680 954 281226646 481 five times"
+# Padding added to bottom.
 
-pnmpad -bottom=16 -black testgrid.pbm | cksum
-for i in `seq 0 15`
+pnmpad -bottom=${ih} -black maze.pbm | cksum | tr '\n' ' '
+echo ${maze_pbm_sum}
+for border in 0 1 10 50
   do
-  pamcut -top=$((i+1)) -height=16 -pad testgrid.pbm > ${bottom_pbm}
-  pamcut -bottom=$i    -height=16 -pad testgrid.pbm > ${top_pbm}
-  pnmcat -tb ${top_pbm} ${bottom_pbm} ${top_pbm} | \
-    pamcut -top=$((16-i-1)) -height=32 | cksum
-  rm ${top_pbm} ${bottom_pbm}
+  pamcut -top=$((${border}+1)) -height=${ih} -pad maze.pbm > ${bottom_ppm}
+  pamcut -bottom=${border}     -height=${ih} -pad maze.pbm > ${top_ppm}
+  pnmcat -tb ${top_ppm} ${bottom_ppm} ${top_ppm} | \
+    pamcut -top=$((${ih}-${border}-1))  -height=$((${ih}*2)) | \
+    tee ${padded_ppm} | cksum | tr '\n' ' 'cksum
+  pnmcrop -black -bottom ${padded_ppm} | cksum
+  rm ${top_ppm} ${bottom_ppm} ${padded_ppm}
   done
-
diff --git a/test/g3-roundtrip.test b/test/g3-roundtrip.test
index 603e6408..f35c4935 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 pbmmake pbmpage pnmpad
+# Also requires: pamfile pnmcrop pbmmake pbmpage pnmpad pamenlarge
 
 tmpdir=${tmpdir:-/tmp}
 complete256_pbm=${tmpdir}/complete256.pbm
@@ -11,17 +11,19 @@ pagemax_pbm=${tmpdir}/pagemax.pbm
 
 echo "Test 1.  Should print 0 0 0 : 0 or 0 0 0 0 : 0 total three times"
 
-pbmtog3 -nofixedwidth testgrid.pbm | \
-g3topbm -width=14 | cmp -s - testgrid.pbm
+width=$(pamfile -size maze.pbm | cut -d" " -f1)
+
+pbmtog3 -nofixedwidth maze.pbm | \
+g3topbm -width=${width} | cmp -s - maze.pbm
 echo ${PIPESTATUS[@]} ":" $?
 
-pbmtog3 -nofixedwidth -reversebits testgrid.pbm | \
-g3topbm -width=14 -reversebits | cmp -s - testgrid.pbm
+pbmtog3 -nofixedwidth -reversebits maze.pbm | \
+g3topbm -width=${width} -reversebits | cmp -s - maze.pbm
 echo ${PIPESTATUS[@]} ":" $?
 
-pbmtog3 testgrid.pbm | \
+pbmtog3 maze.pbm | \
 g3topbm  | pnmcrop -white -right -bottom | \
- cmp -s - testgrid.pbm ; echo ${PIPESTATUS[@]} ":" $?
+ cmp -s - maze.pbm ; echo ${PIPESTATUS[@]} ":" $?
 
 
 echo "Test 2.  Should print 0 0 0 : 0 or 0 0 0 0 : 0 total seven times"
@@ -62,8 +64,6 @@ pbmmake -b 5000 5 > ${wideb_pbm}
 pbmtog3 -nofixedwidth ${wideb_pbm} | g3topbm | \
  cmp -s - ${wideb_pbm} ; echo ${PIPESTATUS[@]} ":" $?
 
-
-
 cat ${complete256_pbm} | cksum
 cat ${wideb_pbm} | cksum
 cat ${widew_pbm} | cksum
@@ -85,3 +85,4 @@ pbmtog3 -nofixedwidth  ${pagemax_pbm} | g3topbm  | \
 cat ${page_pbm} | cksum
 cat ${pagemax_pbm} | cksum
 
+rm ${page_pbm} ${pagemax_pbm} 
\ No newline at end of file
diff --git a/test/gem-roundtrip.ok b/test/gem-roundtrip.ok
index 845be5fb..5168378d 100644
--- a/test/gem-roundtrip.ok
+++ b/test/gem-roundtrip.ok
@@ -1 +1 @@
-2425386270 41
+281226646 481
diff --git a/test/gem-roundtrip.test b/test/gem-roundtrip.test
index 0fce59db..106fe2cf 100755
--- a/test/gem-roundtrip.test
+++ b/test/gem-roundtrip.test
@@ -3,5 +3,5 @@
 # Also requires:
 
 
-# Should print 2425386270 41, cksum of testgrid.pbm
-pbmtogem testgrid.pbm | gemtopnm | cksum
+# Should print 281226646 481, cksum of maze.pbm
+pbmtogem maze.pbm | gemtopnm | cksum
diff --git a/test/gif-roundtrip.ok b/test/gif-roundtrip.ok
index 607ebd5c..27d1bb47 100644
--- a/test/gif-roundtrip.ok
+++ b/test/gif-roundtrip.ok
@@ -1,18 +1,23 @@
+Test 1. Should print 1926073387 101484
 1926073387 101484
+Test 2. Should produce 1571496937 33838 six times
 1571496937 33838
 1571496937 33838
 1571496937 33838
 1571496937 33838
 1571496937 33838
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
+1571496937 33838
+Test 3. Should produce 281226646 481 six times
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+Test 4. Should produce P1 4 1 0101
 P1 4 1 0101 
-4030 : 0 0 0 0 : 0 , 4030 : 0 0 0 0 : 0
-4031 : 0 0 0 0 : 0 , 4031 : 0 0 0 0 : 0
-4097 : 0 0 0 0 : 0 , 4097 : 0 0 0 0 : 0
+Test 5. Should produce: N : 0 0 0 0 : 0 , N : 0 0 0 0 : 0
+(N=238, 239, 240, 241, 255, 256, 257, 4030, 4031, 4097)
 238 : 0 0 0 0 : 0 , 238 : 0 0 0 0 : 0
 239 : 0 0 0 0 : 0 , 239 : 0 0 0 0 : 0
 240 : 0 0 0 0 : 0 , 240 : 0 0 0 0 : 0
@@ -20,3 +25,6 @@ P1 4 1 0101
 255 : 0 0 0 0 : 0 , 255 : 0 0 0 0 : 0
 256 : 0 0 0 0 : 0 , 256 : 0 0 0 0 : 0
 257 : 0 0 0 0 : 0 , 257 : 0 0 0 0 : 0
+4030 : 0 0 0 0 : 0 , 4030 : 0 0 0 0 : 0
+4031 : 0 0 0 0 : 0 , 4031 : 0 0 0 0 : 0
+4097 : 0 0 0 0 : 0 , 4097 : 0 0 0 0 : 0
diff --git a/test/gif-roundtrip.test b/test/gif-roundtrip.test
index 1e6c7760..2bc3a98d 100755
--- a/test/gif-roundtrip.test
+++ b/test/gif-roundtrip.test
@@ -7,7 +7,8 @@ tmpdir=${tmpdir:-/tmp}
 # Test 1. Break up input image into three monochrome planes,
 # maxval 255.  Transform each plane to gif and back to pgm.
 # Reassemble the planes.  Result should be identical to input.
-# Should print 1926073387 101484
+
+echo "Test 1. Should print 1926073387 101484"
 
 test_ppm=${tmpdir}/testimg.ppm
 
@@ -29,13 +30,11 @@ pamtogif ${test_blu} | giftopnm | \
 
 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
-# five times
+echo "Test 2. Should produce 1571496937 33838 six times"
 
 test_gif=${tmpdir}/testimg.gif
 
+cat ${test_red} | cksum
 pamtogif ${test_red} | giftopnm | cksum
 pamtogif -interlace ${test_red} | giftopnm | cksum
 pamtogif -noclear ${test_red} | giftopnm | cksum
@@ -46,22 +45,23 @@ echo "junk" >> ${test_gif} && \
 
 rm  ${test_gif} ${test_red}
 
+echo "Test 3. Should produce 281226646 481 six times"
+# maze.pbm is too small for -noclear to take effect 
 
-# 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
-pamtogif -transparent=black testgrid.pbm | giftopnm | cksum
-pamtogif -alpha=testgrid.pbm testgrid.pbm | giftopnm | cksum
-pamtogif -transparent=white testgrid.pbm | giftopnm -alpha=- | \
+cat maze.pbm | cksum
+pamtogif maze.pbm | giftopnm | cksum
+pamtogif -nolzw maze.pbm | giftopnm | cksum
+pamtogif -transparent=black maze.pbm | giftopnm | cksum
+pamtogif -alpha=maze.pbm maze.pbm | giftopnm | cksum
+pamtogif -transparent=white maze.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
+
+echo "Test 4. Should produce P1 4 1 0101"
 
 pbmmake -g 4 1 | \
   pamtogif -verbose | giftopnm -plain | \
@@ -71,25 +71,18 @@ echo ""
 
 # Test 5.
 # Test whether saturated code tables are handled correctly.
-# Test input images which most use up the string code table or
+# Test input images which 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
+echo "Test 5. Should produce: N : 0 0 0 0 : 0 , N : 0 0 0 0 : 0"
+echo "(N=238, 239, 240, 241, 255, 256, 257, 4030, 4031, 4097)"
+
 test_pgm=${tmpdir}/testimg.pgm
 
-# The following awk script produces a PGM file with no repeated sequences.
+# The following awk scripts produce a PGM file with no repeated
+# sequences.  Obviously this cannot be compressed at all; the codes
+# are consumed without ever being used.  
 # Here is a smaller example with the same property:
 # P2
 # 8 8
@@ -103,7 +96,9 @@ test_pgm=${tmpdir}/testimg.pgm
 # 3 6 3 7 4 5 4 6
 # 4 7 5 6 5 7 6 7
 
-maxval=63
+test257_pgm=${tmpdir}/testimg257.pgm
+
+maxval=15
 awk -v maxval=${maxval} 'BEGIN \
 { print "P2"
          print "1 "(maxval+1) * (maxval+1) +1
@@ -115,26 +110,25 @@ awk -v maxval=${maxval} 'BEGIN \
              for (j=i+1; j<=maxval; ++j)
                  {print i; print j }
          print 0
-}' > ${test4097_pgm}
+}' >  ${test257_pgm}
 
-for size in 4030 4031 4097
+for size in 238 239 240 241 255 256 257
   do
-  pamcut -height ${size} ${test4097_pgm} > ${test_pgm} &&
+  pamcut -height=${size} ${test257_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} ":" ${PIPESTATUS[@]} ":" $? ", "
-  pamtogif -nolzw ${test_pgm} | giftopnm | pamdepth ${maxval} | \
+  pamtogif -nolzw -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
     cmp - ${test_pgm}
   echo ${size} ":" ${PIPESTATUS[@]} ":" $?
   rm ${test_pgm}
   done 
 
-rm ${test4097_pgm}
-test257_pgm=${tmpdir}/testimg257.pgm
+rm ${test257_pgm}
 
-maxval=15
+test4097_pgm=${tmpdir}/testimg4097.pgm
+
+maxval=63
 awk -v maxval=${maxval} 'BEGIN \
 { print "P2"
          print "1 "(maxval+1) * (maxval+1) +1
@@ -146,18 +140,20 @@ awk -v maxval=${maxval} 'BEGIN \
              for (j=i+1; j<=maxval; ++j)
                  {print i; print j }
          print 0
-}' >  ${test257_pgm}
+}' > ${test4097_pgm}
 
-for size in 238 239 240 241 255 256 257
+for size in 4030 4031 4097
   do
-  pamcut -height=${size} ${test257_pgm} > ${test_pgm} &&
+  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} ":" ${PIPESTATUS[@]} ":" $? ", "
-  pamtogif -nolzw -verbose ${test_pgm} | giftopnm | pamdepth ${maxval} | \
+  pamtogif -nolzw ${test_pgm} | giftopnm | pamdepth ${maxval} | \
     cmp - ${test_pgm}
   echo ${size} ":" ${PIPESTATUS[@]} ":" $?
   rm ${test_pgm}
   done 
 
-rm ${test257_pgm}
+rm ${test4097_pgm}
diff --git a/test/ilbm-roundtrip.ok b/test/ilbm-roundtrip.ok
index 54574a18..fcbdf4f6 100644
--- a/test/ilbm-roundtrip.ok
+++ b/test/ilbm-roundtrip.ok
@@ -1,10 +1,14 @@
-829921912 685
-829921912 685
-829921912 685
-829921912 685
+Test 1.  Should produce 669206373 10102 five times
+669206373 10102
+669206373 10102
+669206373 10102
+669206373 10102
+Test 2.  Should produce 1926073387 101484 three times
 1926073387 101484
 1926073387 101484
 1926073387 101484
+Test 3.  Should print 984199586 101484
 984199586 101484
+Test 4.  Should print 2059976475 661 twice
 2059976475 661
 2059976475 661
diff --git a/test/ilbm-roundtrip.test b/test/ilbm-roundtrip.test
index f62368ff..85e04b26 100755
--- a/test/ilbm-roundtrip.test
+++ b/test/ilbm-roundtrip.test
@@ -2,26 +2,27 @@
 # This script tests: ppmtoilbm ilbmtoppm
 # Also requires: pamseq pamdepth pamtopnm pnmremap
 
-#Test. 1  Should produce 829921912 685 four times
-#Output is PPM raw, 14 by 16  maxval 255
-ppmtoilbm testgrid.pbm | ilbmtoppm | cksum
-ppmtoilbm -aga testgrid.pbm | ilbmtoppm | cksum
-ppmtoilbm -ham6 testgrid.pbm | ilbmtoppm | cksum
-ppmtoilbm -ham8 testgrid.pbm | ilbmtoppm | cksum
+echo "Test 1.  Should produce 669206373 10102 five times"
+#Output is PPM raw, 57 by 59  maxval 255
 
+ppmtoilbm maze.pbm | ilbmtoppm | cksum
+ppmtoilbm -aga maze.pbm | ilbmtoppm | cksum
+ppmtoilbm -ham6 maze.pbm | ilbmtoppm | cksum
+ppmtoilbm -ham8 maze.pbm | ilbmtoppm | cksum
 
-#Test. 2  Should produce 1926073387 101484 three times
+
+echo "Test 2.  Should produce 1926073387 101484 three times"
 ppmtoilbm testimg.ppm | ilbmtoppm | cksum
 ppmtoilbm -24force testimg.ppm | ilbmtoppm | cksum
 ppmtoilbm -dcbits 8 8 8 -nocompress testimg.ppm | ilbmtoppm | cksum
 
 
-#Test. 3  Should print 984199586 101484
+echo "Test 3.  Should print 984199586 101484"
 pamseq 3 5 -tupletype=RGB | pamdepth 255 | pamtopnm | \
   pnmremap -mapfile=- testimg.ppm | ppmtoilbm | ilbmtoppm | cksum
 
 
-#Test. 4 Should print 2059976475 661 twice
+echo "Test 4.  Should print 2059976475 661 twice"
 pamseq 3 5 -tupletype=RGB | pamtopnm | \
   ppmtoilbm -compress | ilbmtoppm | cksum
 pamseq 3 5 -tupletype=RGB | pamtopnm | \
diff --git a/test/jbig-roundtrip.ok b/test/jbig-roundtrip.ok
index b98a694b..c9164120 100644
--- a/test/jbig-roundtrip.ok
+++ b/test/jbig-roundtrip.ok
@@ -1,2 +1,2 @@
-2425386270 41
+281226646 481
 1571496937 33838
diff --git a/test/jbig-roundtrip.test b/test/jbig-roundtrip.test
index 570d7336..eac742ff 100755
--- a/test/jbig-roundtrip.test
+++ b/test/jbig-roundtrip.test
@@ -2,8 +2,8 @@
 # This script tests: pnmtojbig jbigtopnm
 # Also requires: pamchannel pamtopnm
 
-# Test 1.  Should print 2425386270 41
-pnmtojbig testgrid.pbm | jbigtopnm | cksum
+# Test 1.  Should print 281226646 481
+pnmtojbig maze.pbm | jbigtopnm | cksum
 
 # Test 2.  Should print 1571496937 33838
 pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
diff --git a/test/lps-roundtrip.ok b/test/lps-roundtrip.ok
index 02b1d1a9..277907af 100644
--- a/test/lps-roundtrip.ok
+++ b/test/lps-roundtrip.ok
@@ -1 +1,2 @@
+Test.  Should print match
 match
diff --git a/test/lps-roundtrip.test b/test/lps-roundtrip.test
index f30062a8..71cd354d 100755
--- a/test/lps-roundtrip.test
+++ b/test/lps-roundtrip.test
@@ -1,22 +1,25 @@
 #! /bin/bash
 # This script tests: pbmtolps pstopnm
-# Also requires: gs pamdepth pamscale pnmcrop pnmpsnr
+# Also requires: gs pamdepth pamscale pnmcrop pnmpsnr pamfile
 
 # The ordinary round-trip does not work because of the way ghostscript
 # renders: a line is considered wider than a single pixel and all pixels
 # it touches are set to black if the output is PBM.  To work around this,
 # we tell pstopnm to output PGM at a high resolution (=large dpi value).
 
+tmpdir=${tmpdir:-/tmp}
+test_pgm=${tmpdir}/test.pgm
 
-test_pgm=${tmpdir}/testgrid.pgm
+echo "Test.  Should print match"
 
+xysize=$(pamfile -size testgrid.pbm | awk '{print "-xsize="$1,"-ysize="$2}')
 pamdepth 255 testgrid.pbm > ${test_pgm}
-
+  
 pbmtolps -dpi 72 testgrid.pbm | \
     pstopnm -dpi $((72*12)) -stdout -pgm | \
-    pnmcrop -white | pamscale -xsize=14 -ysize=16 | \
+    pnmcrop -white | pamscale ${xysize}  | \
     pnmpsnr -target=30 - ${test_pgm}
-
-# ghostscript version 8.71: pnmpsnr lumina 33.14dB
-
+  
+    # ghostscript version 8.71: pnmpsnr lumina 33.14dB
+  
 rm ${test_pgm}
diff --git a/test/macp-roundtrip.ok b/test/macp-roundtrip.ok
index 0c49cdf2..28c16ee0 100644
--- a/test/macp-roundtrip.ok
+++ b/test/macp-roundtrip.ok
@@ -1,6 +1,6 @@
-Test 1. Should produce 2425386270 41 twice
-2425386270 41
-2425386270 41
+Test 1. Should produce 281226646 481 twice
+281226646 481
+281226646 481
 Test 2. Should produce 2329957971 51851
 2329957971 51851
 Test 3. Should produce 2907103393 5086 three times
diff --git a/test/macp-roundtrip.test b/test/macp-roundtrip.test
index 94e67f35..b264e3d1 100755
--- a/test/macp-roundtrip.test
+++ b/test/macp-roundtrip.test
@@ -1,8 +1,6 @@
 #! /bin/bash
 # This script tests: pbmtomacp macptopbm
-# Also requires: pnmcrop pbmpage pbmupc pnmpad
-
-PATH=/home/netpbm/p4151/bin/:$PATH
+# Also requires: pnmcrop pbmpage pbmupc pnmpad pbmmake
 
 tmpdir=${tmpdir:-/tmp}
 temp1_pbm=${tmpdir}/temp1.pbm
@@ -11,25 +9,23 @@ tempupc_pbm=${tmpdir}/tempupc.pbm
 temp3_pbm=${tmpdir}/temp3.pbm
 temp3_macp=${tmpdir}/temp3.macp
 
-echo "Test 1. Should produce 2425386270 41 twice"
-
-# Because Macpaint files are fixed size (576 x 720 pixels)
+# Macpaint files are fixed size (576 x 720 pixels)
 # pbmtomacp automatically adds padding when input is smaller.
 
-pbmtomacp testgrid.pbm | macptopbm | tee ${temp1_pbm} | \
+echo "Test 1. Should produce 281226646 481 twice"
+pbmtomacp maze.pbm | macptopbm | tee ${temp1_pbm} | \
     pnmcrop | cksum
 
 pbmtomacp ${temp1_pbm} | macptopbm | pnmcrop | cksum
 
 rm ${temp1_pbm}
 
-
 echo "Test 2. Should produce 2329957971 51851"
 pbmpage 1 | pbmtomacp | macptopbm | cksum
 
-
 echo "Test 3. Should produce 2907103393 5086 three times"
-pbmupc 0 12345 67890 | tee ${tempupc_pbm} | pnmpad -black -t 44 -b 20 -l 100 -r 251 | \
+pbmupc 0 12345 67890 | tee ${tempupc_pbm} | \
+    pnmpad -black -t 44 -b 20 -l 100 -r 251 | \
     pbmtomacp | macptopbm | \
     tee ${temp2_pbm} | \
     pnmcrop | pnmcrop | cksum
@@ -49,6 +45,7 @@ pbmtomacp ${temp3_pbm} | tee ${temp3_macp} | macptopbm | cksum
 
 pbmtomacp -norle ${temp3_pbm} | macptopbm | cksum
 
-( head -c 128 /dev/zero ; cat ${temp3_macp} ) | macptopbm -extraskip 128 | cksum
+( head -c 128 /dev/zero ; cat ${temp3_macp} ) | \
+    macptopbm -extraskip 128 | cksum
 
 rm ${temp3_pbm} ${temp3_macp}
diff --git a/test/maze.pbm b/test/maze.pbm
new file mode 100644
index 00000000..9bdd80e1
--- /dev/null
+++ b/test/maze.pbm
Binary files differdiff --git a/test/mda-roundtrip.ok b/test/mda-roundtrip.ok
index ef27ffd0..ab449885 100644
--- a/test/mda-roundtrip.ok
+++ b/test/mda-roundtrip.ok
@@ -1,2 +1,5 @@
+Test 1.  Should print 1757803444 169 twice
 1757803444 169
-2425386270 41
+1757803444 169
+Test 2.  Should print 281226646 481
+281226646 481
diff --git a/test/mda-roundtrip.test b/test/mda-roundtrip.test
index 58376f3f..6b4d89b9 100755
--- a/test/mda-roundtrip.test
+++ b/test/mda-roundtrip.test
@@ -1,13 +1,15 @@
 #! /bin/bash
 # This script tests: pbmtomda mdatopbm
-# Also requires: pbmmake pnmpad pamcut
+# Also requires: pbmmake pnmpad pamcut pamfile
 
 
 # Pbmtomda requires input width and height to be multiples of 8.
 
-# Test 1.  Should print 1757803444 169
+echo "Test 1.  Should print 1757803444 169 twice"
+pbmmake -g 32 40 | cksum
 pbmmake -g 32 40 | pbmtomda | mdatopbm | cksum
 
-# Test 2.  Should print 2425386270 41
-pnmpad -right 2 testgrid.pbm | \
-  pbmtomda | mdatopbm | pamcut 0 0 14 16 | cksum
+echo "Test 2.  Should print 281226646 481"
+size=$(pamfile -size maze.pbm | awk '{print "-width="$1,"-height="$2}')
+pnmpad -mwidth=8 -halign=0 -mheight=8 -valign=0 ${size} maze.pbm | \
+    pbmtomda | mdatopbm | pamcut -left=0 -top=0 ${size} | cksum
diff --git a/test/mgr-roundtrip.ok b/test/mgr-roundtrip.ok
index 0263a8c6..0e845958 100644
--- a/test/mgr-roundtrip.ok
+++ b/test/mgr-roundtrip.ok
@@ -1,5 +1,5 @@
-Test 1.  Should print 2425386270 41
-2425386270 41
+Test 1.  Should print 281226646 481
+281226646 481
 Test 2.  Should print 429369764 1034, 448060073 4105 twice each
 429369764 1034
 429369764 1034
diff --git a/test/mgr-roundtrip.test b/test/mgr-roundtrip.test
index 7ca2ff3d..d96d836d 100755
--- a/test/mgr-roundtrip.test
+++ b/test/mgr-roundtrip.test
@@ -2,8 +2,8 @@
 # This script tests: pbmtomgr mgrtopbm
 # Also requires: pbmmake
 
-echo "Test 1.  Should print 2425386270 41"
-pbmtomgr testgrid.pbm | mgrtopbm | cksum
+echo "Test 1.  Should print 281226646 481"
+pbmtomgr maze.pbm | mgrtopbm | cksum
 
 echo "Test 2.  Should print 429369764 1034, 448060073 4105 twice each"
 # Maximum width and height allowed
diff --git a/test/mrf-roundtrip.ok b/test/mrf-roundtrip.ok
index 845be5fb..5168378d 100644
--- a/test/mrf-roundtrip.ok
+++ b/test/mrf-roundtrip.ok
@@ -1 +1 @@
-2425386270 41
+281226646 481
diff --git a/test/mrf-roundtrip.test b/test/mrf-roundtrip.test
index c9d8ce3a..8513a908 100755
--- a/test/mrf-roundtrip.test
+++ b/test/mrf-roundtrip.test
@@ -3,5 +3,5 @@
 # Also requires:
 
 
-# Should print 2425386270 41, cksum of testgrid.pbm
-pbmtomrf testgrid.pbm | mrftopbm | cksum
+# Should print 281226646 481, cksum of maze.pbm
+pbmtomrf maze.pbm | mrftopbm | cksum
diff --git a/test/pad-crop-roundtrip.ok b/test/pad-crop-roundtrip.ok
index 0e712ce7..764cadfa 100644
--- a/test/pad-crop-roundtrip.ok
+++ b/test/pad-crop-roundtrip.ok
@@ -1,4 +1,4 @@
 1926073387 101484
 1926073387 101484
-2425386270 41
-2425386270 41
+281226646 481
+281226646 481
diff --git a/test/pad-crop-roundtrip.test b/test/pad-crop-roundtrip.test
index 75979901..8cca8a5f 100755
--- a/test/pad-crop-roundtrip.test
+++ b/test/pad-crop-roundtrip.test
@@ -2,17 +2,25 @@
 # This script tests: pnmcrop pnmmargin pnmpad
 # Also requires:
 
+# Test 1. Should produce 1926073387 101484, cksum of testimg.ppm
+
 pnmmargin -white 10 testimg.ppm | \
   pnmcrop | cksum
 
+# Test 2. Should produce 1926073387 101484
+
 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 | \
+# Test 3. Should produce 281226646 481, cksum of maze.pbm
+
+pnmmargin -white 10 maze.pbm | \
   pnmcrop | cksum
 
-pnmpad -white -left 10 -top 10 testgrid.pbm | \
+# Test 4. Should produce 281226646 481
+
+pnmpad -white -left 10 -top 10 maze.pbm | \
   pnmpad -white -right 10 -bottom 10 | \
   pnmcrop -left -right | pnmcrop -top -bottom | cksum
 
diff --git a/test/palm-roundtrip.ok b/test/palm-roundtrip.ok
index b9ea3056..d69c3a96 100644
--- a/test/palm-roundtrip.ok
+++ b/test/palm-roundtrip.ok
@@ -1,10 +1,10 @@
-Test 1
-584219238 236
-584219238 236
-584219238 236
-584219238 236
-584219238 236
-Test 2
+Test 1. Should print 2067616594 3375 five times
+2067616594 3375
+2067616594 3375
+2067616594 3375
+2067616594 3375
+2067616594 3375
+Test 2. Should print 0 0 0  : 0 four times
 0 0 0 : 0
 0 0 0 : 0
 0 0 0 : 0
diff --git a/test/palm-roundtrip.test b/test/palm-roundtrip.test
index b00454ca..20fcefa9 100755
--- a/test/palm-roundtrip.test
+++ b/test/palm-roundtrip.test
@@ -6,11 +6,9 @@ tmpdir=${tmpdir:-/tmp}
 test4bit_pgm=${tmpdir}/test4bit.pgm
 test256color_ppm=${tmpdir}/test256color.ppm
 
-# Test 1. Should print 584219238 236  5 times
+echo "Test 1. Should print 2067616594 3375 five times"
 
-echo "Test 1"
-
-pamdepth 15 testgrid.pbm | tee ${test4bit_pgm} | cksum
+pamdepth 15 maze.pbm | tee ${test4bit_pgm} | cksum
 
 for flags in "" \
              "-scanline_compression" \
@@ -21,9 +19,7 @@ for flags in "" \
 rm ${test4bit_pgm}
 
 
-# Test 2. Should print 0 4 times
-
-echo "Test 2"
+echo "Test 2. Should print 0 0 0  : 0 four times"
 
 pnmquant 256 testimg.ppm > ${test256color_ppm} || echo "pnmquant failed"
 
diff --git a/test/pamarith-compare-equal.ok b/test/pamarith-compare-equal.ok
index ef1c2981..2a16d8bb 100644
--- a/test/pamarith-compare-equal.ok
+++ b/test/pamarith-compare-equal.ok
@@ -6,6 +6,17 @@ Test 1
 1:P3
 1:8 8
 1:2
+1:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 0 0 0 2 2 2 0 0 
+1:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 2 2 2 0 0 0 2 2 
+1:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 0 0 0 2 2 2 0 0 
+1:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 2 2 2 0 0 0 2 2 
+1:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 0 0 0 2 2 2 0 0 
+1:0 2 2 2 0 0 0 2 2 2 0 0 0 2 2 1 1 1 1 1 1 1 1 1 
+1:2 0 0 0 2 2 2 0 0 0 2 2 2 0 0 1 1 1 1 1 1 1 1 1 
+1:0 2 2 2 0 0 0 2 2 2 0 0 0 2 2 1 1 1 1 1 1 1 1 1 
+1:P3
+1:8 8
+1:2
 5:0 0 2 0 0 2 0 0 2 0 0 2 0 0 2 2 0 2 2 0 2 2 0 2 
 3:2 0 2 2 0 2 2 0 2 2 0 2 2 0 2 2 0 0 2 0 0 2 0 0 
 Test 2
@@ -16,16 +27,15 @@ Test 2
 1:P3
 1:8 8
 1:1
+5:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 
+3:0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 
+1:P3
+1:8 8
+1:1
 8:0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
 Test 3
 1:P1
 1:14 16
-16:00000000000000
-1:P1
-1:14 16
-16:11111111111111
-1:P1
-1:14 16
 8:10101010101010 11111111111111
 1:P1
 1:14 16
@@ -34,10 +44,6 @@ Test 4
 1:P2
 1:14 16
 1:2
-16:1 1 1 1 1 1 1 1 1 1 1 1 1 1 
-1:P2
-1:14 16
-1:2
 8:0 2 0 2 0 2 0 2 0 2 0 2 0 2  0 0 0 0 0 0 0 0 0 0 0 0 0 0 
 1:P2
 1:14 16
@@ -48,11 +54,11 @@ Test 4
 1:2
 8:1 2 1 2 1 2 1 2 1 2 1 2 1 2  1 1 1 1 1 1 1 1 1 1 1 1 1 1 
 Test 5
-Should produce 1285449498 54
+Should produce 1285449498 54 four times
 1285449498 54
 1285449498 54
 1285449498 54
 1285449498 54
-Should produce 244506188 54
+Should produce 244506188 54 twice
 244506188 54
 244506188 54
diff --git a/test/pamarith-compare-equal.test b/test/pamarith-compare-equal.test
index 903ad538..e143a04c 100755
--- a/test/pamarith-compare-equal.test
+++ b/test/pamarith-compare-equal.test
@@ -1,20 +1,25 @@
 #! /bin/bash
 # This script tests: pamarith
-# Also requires: ppmpat pnminvert pbmmake pgmmake
+# Also requires: ppmpat pnminvert pamfile pbmmake pgmmake pamcut
 
 tmpdir=${tmpdir:-/tmp}
 input1_ppm=${tmpdir}/input1.ppm
+inputm_ppm=${tmpdir}/inputm.ppm
 input2_ppm=${tmpdir}/input2.ppm
 
 echo "Test 1"
 
 ppmpat -tartan -color=rgb:00/80/ff,rgb:80/ff/00,rgb:ff/00/80 \
    8 8  > ${input1_ppm}
+ppmpat -tartan -color=rgb:00/80/ff,rgb:80/ff/00,rgb:ff/00/80 \
+   -mesh 8 8  > ${inputm_ppm}
 ppmpat -tartan -color=rgb:80/ff/00,rgb:ff/00/80,rgb:00/80/ff \
    8 8  > ${input2_ppm}
 
 pamarith -compare -plain ${input1_ppm} ${input1_ppm} | \
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+pamarith -compare -plain ${input1_ppm} ${inputm_ppm} | \
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
 pamarith -compare -plain ${input1_ppm} ${input2_ppm} | \
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
 
@@ -22,54 +27,66 @@ echo "Test 2"
 
 pamarith -equal -plain ${input1_ppm} ${input1_ppm} | \
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+pamarith -equal -plain ${input1_ppm} ${inputm_ppm} | \
+  uniq -c | sed -e 's/^ *//' -e 's/ /:/'
 pamarith -equal -plain ${input1_ppm} ${input2_ppm} | \
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
 
-rm ${input1_ppm} ${input2_ppm}
+rm ${input1_ppm} ${inputm_ppm} ${input2_ppm}
 
 echo "Test 3"
 
-pamarith -equal -plain testgrid.pbm testgrid.pbm  | \
+input3_pbm=${tmpdir}/input3.pbm
+pamcut maze.pbm -left=0 -right=0 -width=35 -height=33 > ${input3_pbm} 
+
+pamarith -equal -plain ${input3_pbm} ${input3_pbm}  | \
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
-pnminvert testgrid.pbm | pamarith -equal -plain testgrid.pbm - | \
+pnminvert ${input3_pbm} | pamarith -equal -plain ${input3_pbm} - | \
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
-pbmmake -w 14 16 | pamarith -equal -plain testgrid.pbm - | \
+
+xysize=$(pamfile -size testgrid.pbm)
+
+pbmmake -w ${xysize} | pamarith -equal -plain testgrid.pbm - | \
   awk '{printf("%s%c",$0, NR<3 || NR%2==0 ? "\n" : " ")}' | 
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
-pbmmake -b 14 16 | pamarith -equal -plain testgrid.pbm - | \
+pbmmake -b ${xysize} | pamarith -equal -plain testgrid.pbm - | \
   awk '{printf("%s%c",$0, NR<3 || NR%2==0 ? "\n" : " ")}' | 
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
 
 echo "Test 4"
-  
-pamarith -compare -plain testgrid.pbm testgrid.pbm  | \
+
+
+pamarith -compare -plain ${input3_pbm} ${input3_pbm}  | \
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
+
 pnminvert testgrid.pbm | pamarith -compare -plain testgrid.pbm - | \
   awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' | 
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
-pbmmake -w 14 16 | pamarith -compare -plain testgrid.pbm - | \
+pbmmake -w ${xysize} | pamarith -compare -plain testgrid.pbm - | \
   awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' | 
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
-pbmmake -b 14 16 | pamarith -compare -plain testgrid.pbm - | \
+pbmmake -b ${xysize} | pamarith -compare -plain testgrid.pbm - | \
   awk '{printf("%s%c",$0, NR<4 || NR%2==1 ? "\n" : " ")}' | 
   uniq -c | sed -e 's/^ *//' -e 's/ /:/'
 
+rm ${input3_pbm}
 
 echo "Test 5"
 # -closeness
 
 input40_pgm=${tmpdir}/input40.pgm
 input50_pgm=${tmpdir}/input50.pgm
-equal_pgm=${tmpdir}/equal.pgm
 
 pgmmake -maxval=99 0.40 7 3 > ${input40_pgm}
 pgmmake -maxval=99 0.50 7 3 > ${input50_pgm}
 
-echo "Should produce 1285449498 54"
+echo "Should produce 1285449498 54 four times"
 pamarith -equal -plain ${input40_pgm} ${input40_pgm} | cksum
 pamarith -equal -plain -closeness=10.2 ${input40_pgm} ${input50_pgm} | cksum
 pamarith -equal -plain -closeness=11 ${input40_pgm} ${input50_pgm} | cksum
 pamarith -equal -plain -closeness=90 ${input40_pgm} ${input50_pgm} | cksum
-echo "Should produce 244506188 54"
+echo "Should produce 244506188 54 twice"
 pamarith -equal -plain ${input40_pgm} ${input50_pgm} | cksum
-pamarith -equal -plain -closeness=09   ${input40_pgm} ${input50_pgm} | cksum
+pamarith -equal -plain -closeness=09  ${input40_pgm} ${input50_pgm} | cksum
+
+rm ${input40_pgm} ${input50_pgm}
\ No newline at end of file
diff --git a/test/pamarith.ok b/test/pamarith.ok
index 0862df8e..c9fc49db 100644
--- a/test/pamarith.ok
+++ b/test/pamarith.ok
@@ -193,19 +193,19 @@ Test 3
 3072492814 913
 3072492814 913
 Test 4 (input = output)
-cksum is 2425386270 41 or 2921940274 59
+Prints 281226646 481 five times, then 2921940274 59 five times
 input image
-2425386270 41
+281226646 481
 -minimum
-2425386270 41
+281226646 481
 -maximum
-2425386270 41
+281226646 481
 -mean
-2425386270 41
+281226646 481
 -and
-2425386270 41
+281226646 481
 -or
-2425386270 41
+281226646 481
 input image
 2921940274 59
 -minimum
@@ -219,13 +219,13 @@ input image
 -or
 2921940274 59
 Test 5 (blank output)
-cksum is 2817549367 41 or 320101399 59
+Prints 2247801875 481 three times, then 320101399 59 three times
 -subtract
-2817549367 41
+2247801875 481
 -difference
-2817549367 41
+2247801875 481
 -xor
-2817549367 41
+2247801875 481
 -subtract
 320101399 59
 -difference
diff --git a/test/pamarith.test b/test/pamarith.test
index b7fe3212..b6b4538c 100755
--- a/test/pamarith.test
+++ b/test/pamarith.test
@@ -88,9 +88,9 @@ for fn in "-subtract" "-divide" "-compare" "-shiftleft" "-shiftright"
 rm ${input3_ppm} ${input4_ppm} ${input4_pgm}
 
 echo "Test 4 (input = output)"
-echo "cksum is 2425386270 41 or 2921940274 59"
+echo "Prints 281226646 481 five times, then 2921940274 59 five times"
 
-for image in testgrid.pbm ${input1_ppm}
+for image in maze.pbm ${input1_ppm}
   do
   echo "input image"
   cat ${image} | cksum
@@ -103,9 +103,9 @@ for image in testgrid.pbm ${input1_ppm}
 
 
 echo "Test 5 (blank output)"
-echo "cksum is 2817549367 41 or 320101399 59"
+echo "Prints 2247801875 481 three times, then 320101399 59 three times"
 
-for image in testgrid.pbm ${input1_ppm}
+for image in maze.pbm ${input1_ppm}
   do
   for fn in "-subtract" "-difference" "-xor"
     do
@@ -116,7 +116,6 @@ for image in testgrid.pbm ${input1_ppm}
 
 rm ${input1_ppm}
 
-
 echo "Invalid command-line argument combinations." 1>&2
 echo "Error messages should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
diff --git a/test/pamcut.ok b/test/pamcut.ok
index 3d5c5a7f..fc4dc3de 100644
--- a/test/pamcut.ok
+++ b/test/pamcut.ok
@@ -1,22 +1,22 @@
-Test 1.
+Test 1.  Should print 2958909756 124815
 2958909756 124815
-Test 2.
+Test 2.  Should print 1550940962 10933
 1550940962 10933
-Test 3.
+Test 3.  Should print 708474423 14 twice
 708474423 14
 708474423 14
-Test 4.
+Test 4.  Should print 659346598 80124 four times
 659346598 80124
 659346598 80124
 659346598 80124
 659346598 80124
-Test 5.
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-Test 6.
+Test 5. Should print 281226646 481 five times
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+Test 6.  Should print 3412257956 129
 3412257956 129
 Test Invalid
 Expected failure 1 1
diff --git a/test/pamcut.test b/test/pamcut.test
index ced45f9c..f03365f9 100755
--- a/test/pamcut.test
+++ b/test/pamcut.test
@@ -1,28 +1,23 @@
 #! /bin/bash
 # This script tests: pamcut pbmmake
-# Also requires:
+# Also requires: pamfile
 
-# Test 1.  Should print 2958909756 124815
-echo Test 1.
+echo "Test 1.  Should print 2958909756 124815"
 
 pamcut -top 0 -left 0 -width 260 -height 160 \
   -pad testimg.ppm | cksum
 
-# Test 2.  Should print 1550940962 10933
-echo Test 2.
+echo "Test 2.  Should print 1550940962 10933"
 
 pamcut -top 200 -left 120 -width 40 -height 40 \
   -pad testimg.ppm | cksum
 
-# Test 3.  Should print 708474423 14 twice
-echo Test 3.
+echo "Test 3.  Should print 708474423 14 twice"
 
 pamcut -top 5 -left 5 -bottom 5 -right 5 testimg.ppm | cksum
 pamcut -width 1 -height 1 -bottom 5 -right 5 testimg.ppm | cksum
 
-
-# Test 4.  Should print 659346598 80124 four times
-echo Test 4.
+echo "Test 4.  Should print 659346598 80124 four times"
 
 pamcut -croptop 10 -cropleft 10 -cropbottom 10 -cropright 10 testimg.ppm | \
   cksum
@@ -30,19 +25,20 @@ pamcut -top 10 -left 10 -bottom 138 -right 216 testimg.ppm | cksum
 pamcut -top 10 -left 10 -bottom -11 -right -11 testimg.ppm | cksum
 pamcut -top 10 -left 10 -width 207 -height 129 testimg.ppm | cksum
 
+echo "Test 5. Should print 281226646 481 five times"
 
-# Test 5. Should print 2425386270 41 five times
-echo Test 5.
-
-pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 testgrid.pbm | \
+width=$(pamfile -size maze.pbm | awk '{print $1}')
+height=$(pamfile -size maze.pbm | awk '{print $2}')
+ 
+pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 maze.pbm | \
   cksum
-pamcut -top 0 -left 0 -bottom 15 -right 13 testgrid.pbm | cksum
-pamcut -top 0 -left 0 -bottom -1 -right -1 testgrid.pbm | cksum
-pamcut -top 0 -left 0 -width 14 -height 16 testgrid.pbm | cksum
-pamcut testgrid.pbm | cksum
-
-# Test 6.  Should print 3412257956 129
-echo Test 6.
+pamcut -top 0 -left 0 -bottom $((${height} -1)) -right $((${width} -1)) \
+  maze.pbm | cksum
+pamcut -top 0 -left 0 -bottom -1 -right -1 maze.pbm | cksum
+pamcut -top 0 -left 0 -width ${width} -height ${height} maze.pbm | cksum
+pamcut maze.pbm | cksum
+ 
+echo "Test 6.  Should print 3412257956 129"
 
 pbmmake -g 50 50 | pamcut 5 5 30 30 | cksum
 
diff --git a/test/pamdepth-roundtrip.ok b/test/pamdepth-roundtrip.ok
index 89db1a57..28db2ee1 100644
--- a/test/pamdepth-roundtrip.ok
+++ b/test/pamdepth-roundtrip.ok
@@ -5,4 +5,4 @@
 1926073387 101484
 1926073387 101484
 1926073387 101484
-2425386270 41
+281226646 481
diff --git a/test/pamdepth-roundtrip.test b/test/pamdepth-roundtrip.test
index 0c7cb8b0..d3f0d6d3 100755
--- a/test/pamdepth-roundtrip.test
+++ b/test/pamdepth-roundtrip.test
@@ -9,5 +9,5 @@ pamdepth $i testimg.ppm | \
   pamdepth 255 | cksum
 done
 
-pamdepth 255 testgrid.pbm | pamdepth 1 | \
+pamdepth 255 maze.pbm | pamdepth 1 | \
   pgmtopbm -th -val=0.5 | cksum
diff --git a/test/pamdice-roundtrip.ok b/test/pamdice-roundtrip.ok
index 4a850615..9f648fd0 100644
--- a/test/pamdice-roundtrip.ok
+++ b/test/pamdice-roundtrip.ok
@@ -1,18 +1,16 @@
-test 1
-2425386270 41
-test 2
-2425386270 41
-test 3
-2425386270 41
-test 4.
+Test 1.  Should print 281226646 481
+281226646 481
+Test 2.  Should print 281226646 481
+281226646 481
+Test 3.  Should print 281226646 481
+281226646 481
+Test 4.  Should print 281226646 481
+281226646 481
+Test 5.  Should print 1926073387 101484 five times
 1926073387 101484
-test 4.-hoverlap=0
 1926073387 101484
-test 4.-hoverlap=2
 1926073387 101484
-test 4.-voverlap=0
 1926073387 101484
-test 4.-voverlap=2
 1926073387 101484
-test 5
+Test 6.  Should print 1926073387 101484
 1926073387 101484
diff --git a/test/pamdice-roundtrip.test b/test/pamdice-roundtrip.test
index c5ccde66..b387a8ea 100755
--- a/test/pamdice-roundtrip.test
+++ b/test/pamdice-roundtrip.test
@@ -1,38 +1,60 @@
 #! /bin/bash
 # This script tests: pamdice pamundice
-# Also requires:
-
+# Also requires: pamfile
 
 tmpdir=${tmpdir:-/tmp}
 fname_stem=${tmpdir}/pamdice_part
 
-echo test 1
+mazesize=$(pamfile -size maze.pbm)
+mw=$(echo ${mazesize} | cut -d" " -f1)
+mh=$(echo ${mazesize} | cut -d" " -f2)
+
+echo "Test 1.  Should print 281226646 481"
 
-pamdice testgrid.pbm -outstem=${fname_stem}
+pamdice maze.pbm -outstem=${fname_stem}
 pamundice ${fname_stem}_%1d_%1a.pbm -down=1 -across=1 | cksum
 rm ${fname_stem}_0_0.pbm
 
-echo test 2
+echo "Test 2.  Should print 281226646 481"
+
+width=10
+tiles=$(( (${mw}+${width}-1) / ${width} ))
+
+
+pamdice maze.pbm -outstem=${fname_stem} -width=${width}
+pamundice ${fname_stem}_%1d_%1a.pbm -across=${tiles} | cksum
+rm ${fname_stem}_*_*.pbm
+
+echo "Test 3.  Should print 281226646 481"
 
-pamdice testgrid.pbm -outstem=${fname_stem} -width=3
-pamundice ${fname_stem}_%1d_%1a.pbm -across=5 | cksum
-rm ${fname_stem}_0_?.pbm
+width=5
+tiles=$(( (${mw}+${width}-1) / ${width} ))
 
-echo test 3
+pamdice maze.pbm -outstem=${fname_stem} -width=${width}
+pamundice ${fname_stem}_%1d_%2a.pbm -across=${tiles} | cksum
+rm ${fname_stem}_*_*.pbm
 
-pamdice testgrid.pbm -outstem=${fname_stem} -height=4
-pamundice ${fname_stem}_%1d_%1a.pbm -down=4 | cksum
-rm ${fname_stem}_?_0.pbm
 
-for flags in "" "-hoverlap=0" "-hoverlap=2" "-voverlap=0" "-voverlap=2"
+echo "Test 4.  Should print 281226646 481"
+
+height=10
+tiles=$(( (${mh}+${height}-1) / ${height} ))
+
+pamdice maze.pbm -outstem=${fname_stem} -height=${height}
+pamundice ${fname_stem}_%1d_%1a.pbm -down=${tiles} | cksum
+#rm ${fname_stem}_*_*.pbm
+
+echo "Test 5.  Should print 1926073387 101484 five times"
+
+for option in "" "-hoverlap=0" "-hoverlap=2" "-voverlap=0" "-voverlap=2"
   do
-  echo test 4.${flags}
   pamdice testimg.ppm -outstem=${fname_stem} -width=50 -height=40
   pamundice ${fname_stem}_%1d_%1a.ppm -down=4 -across=5 | cksum
   rm ${fname_stem}_?_?.ppm
   done
 
-echo test 5
+echo "Test 6.  Should print 1926073387 101484"
+
 pamdice testimg.ppm -outstem=${fname_stem} -width=20 -height=10
 ls ${fname_stem}*.ppm | pamundice -listfile=- -across=12 -down=15 | cksum
 rm ${fname_stem}_??_??.ppm
\ No newline at end of file
diff --git a/test/pamenlarge-pamscale-point.test b/test/pamenlarge-pamscale-point.test
index 08b34bb7..f0f0948b 100755
--- a/test/pamenlarge-pamscale-point.test
+++ b/test/pamenlarge-pamscale-point.test
@@ -29,8 +29,8 @@ enlarge_pbm=${tmpdir}/enlarge.pbm
 for option in "6 -nomix" "15 -nomix -linear" "24 -nomix"
   do
   scale=${option%% *}
-  pamenlarge $scale testgrid.pbm > ${enlarge_pbm}
-  pamscale   $option testgrid.pbm | cmp -s - ${enlarge_pbm}  
+  pamenlarge $scale maze.pbm > ${enlarge_pbm}
+  pamscale   $option maze.pbm | cmp -s - ${enlarge_pbm}  
   echo $option ${PIPESTATUS[@]} ":" $?
   rm  ${enlarge_pbm}
   done
diff --git a/test/pamenlarge.ok b/test/pamenlarge.ok
index a2408871..9107e870 100644
--- a/test/pamenlarge.ok
+++ b/test/pamenlarge.ok
@@ -1,4 +1,10 @@
+Test 1.  Should print 3424505894 913236
 3424505894 913236
+Test 2.  Should print 3763267672 304422
 3763267672 304422
-3342398172 297
+Test 3.  Should print 3748791794 3905
+3748791794 3905
+Test 4.  Should print 1618994486 1194
+1618994486 1194
+Test 5.  Should print 398497872 6806
 398497872 6806
diff --git a/test/pamenlarge.test b/test/pamenlarge.test
index 3820f47e..851362e8 100755
--- a/test/pamenlarge.test
+++ b/test/pamenlarge.test
@@ -2,13 +2,14 @@
 # This script tests: pamenlarge
 # Also requires: pamchannel pamseq pamtopnm
 
-
-# Test 1.  Should print 3424505894 913236
+echo "Test 1.  Should print 3424505894 913236"
 pamenlarge 3 testimg.ppm | cksum
-# Test 2.  Should print 3763267672 304422
+echo "Test 2.  Should print 3763267672 304422"
 pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
   pamenlarge 3 | cksum
-# Test 3.  Should print 3342398172 297
-pamenlarge 3 testgrid.pbm | cksum
-# Test 4.  Should print 398497872 6806
+echo "Test 3.  Should print 3748791794 3905"
+pamenlarge 3 maze.pbm | cksum
+echo "Test 4.  Should print 1618994486 1194"
+pamenlarge -xscale=21 -yscale=2 testgrid.pbm | cksum
+echo "Test 5.  Should print 398497872 6806"
 pamseq 3 4 | pamtopnm -assume | pamenlarge 3 -plain | cksum
diff --git a/test/pamflip-roundtrip.ok b/test/pamflip-roundtrip.ok
index ff469d0b..48d5ab62 100644
--- a/test/pamflip-roundtrip.ok
+++ b/test/pamflip-roundtrip.ok
@@ -1,22 +1,59 @@
-Test 1.  Should produce 1926073387 101484 14 times
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-1926073387 101484
-Test 2.  Should produce 2425386270 41 6 times
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
+Test 1.  Should produce 1988581932 2989 fifteen times
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+1988581932 2989
+Test 2.  Should produce 2729474106 27 nine times
+2729474106 27
+2729474106 27
+2729474106 27
+2729474106 27
+2729474106 27
+2729474106 27
+2729474106 27
+2729474106 27
+2729474106 27
+Test 3.  Should produce 1849343241 27 nine times
+1849343241 27
+1849343241 27
+1849343241 27
+1849343241 27
+1849343241 27
+1849343241 27
+1849343241 27
+1849343241 27
+1849343241 27
+Test 4.  Should print a single pixel PPM image maxval 65535 in 
+plain (ascii) format; then produce 2434897823 19 nine times
+P3
+1 1
+65535
+1 10000 65535 
+2434897823 19
+2434897823 19
+2434897823 19
+2434897823 19
+2434897823 19
+2434897823 19
+2434897823 19
+2434897823 19
+2434897823 19
+Test 4.  Should produce 281226646 481 seven times
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
diff --git a/test/pamflip-roundtrip.test b/test/pamflip-roundtrip.test
index d188c1a0..27a3c1f6 100755
--- a/test/pamflip-roundtrip.test
+++ b/test/pamflip-roundtrip.test
@@ -1,56 +1,108 @@
 #! /bin/bash
 # This script tests: pamflip
-# Also requires:
+# Also requires: ppmpat pamseq pamtopnm
 
-echo "Test 1.  Should produce 1926073387 101484 14 times"
+tmpdir=${tmpdir:-/tmp}
+tartan_ppm=${tmpdir}/test.ppm
+test1_pgm=${tmpdir}/test1.pgm
+test2_pgm=${tmpdir}/test2.pgm
+dot_ppm=${tmpdir}/dot.ppm
 
-# TODO use smaller image
+echo "Test 1.  Should produce 1988581932 2989 fifteen times"
 
-pamflip -lr testimg.ppm | pamflip -lr | cksum
-pamflip -tb testimg.ppm | pamflip -tb | cksum
-pamflip -r180 testimg.ppm | \
+ppmpat -tartan -mesh \
+       -color=rgb:0/0/0,rgb:ff/00/ff,rgb:80/90/20 31 32 > ${tartan_ppm}
+
+pamflip -null ${tartan_ppm} | cksum
+pamflip -lr ${tartan_ppm} | pamflip -lr | cksum
+pamflip -tb ${tartan_ppm} | pamflip -tb | cksum
+pamflip -r180 ${tartan_ppm} | \
   pamflip -r180 | cksum
-pamflip -xy testimg.ppm | pamflip -xy | cksum
-pamflip -r90 testimg.ppm | \
-  pamflip -r90 | \
-  pamflip -r90 | \
-  pamflip -r90 | cksum
-pamflip -r270 testimg.ppm | \
-  pamflip -r270 | \
-  pamflip -r270 | \
-  pamflip -r270 | cksum
-pamflip -xform=leftright testimg.ppm | pamflip -leftright | cksum
-pamflip -xform=topbottom testimg.ppm | pamflip -topbottom | cksum
-pamflip -xform=transpose testimg.ppm | pamflip -transpose | cksum
-pamflip -xform=leftright,leftright testimg.ppm | cksum
-pamflip -xform=topbottom,topbottom testimg.ppm | cksum
-pamflip -xform=transpose,transpose testimg.ppm | cksum
-pamflip -tb testimg.ppm | pamflip -lr | \
+pamflip -xy ${tartan_ppm} | pamflip -xy | cksum
+pamflip -r90 ${tartan_ppm} | pamflip -r90 | \
+  pamflip -r90 | pamflip -r90 | cksum
+pamflip -r270 ${tartan_ppm} | pamflip -r270 | \
+  pamflip -r270 | pamflip -r270 | cksum
+pamflip -xform=leftright ${tartan_ppm} | pamflip -leftright | cksum
+pamflip -xform=topbottom ${tartan_ppm} | pamflip -topbottom | cksum
+pamflip -xform=transpose ${tartan_ppm} | pamflip -transpose | cksum
+pamflip -xform=leftright,leftright ${tartan_ppm} | cksum
+pamflip -xform=topbottom,topbottom ${tartan_ppm} | cksum
+pamflip -xform=transpose,transpose ${tartan_ppm} | cksum
+pamflip -tb ${tartan_ppm} | pamflip -lr | \
   pamflip -xform=leftright,topbottom | cksum
-pamflip -tb testimg.ppm | pamflip -lr | pamflip -xy | \
+pamflip -tb ${tartan_ppm} | pamflip -lr | pamflip -xy | \
   pamflip -xform=leftright,topbottom,transpose | cksum
 
+rm ${tartan_ppm}
 
-echo "Test 2.  Should produce 2425386270 41 6 times"
+pamseq 1 15 | pamtopnm -assume > ${test1_pgm}
 
-pamflip -lr testgrid.pbm | \
-  pamflip -lr | cksum
-pamflip -tb testgrid.pbm | \
-  pamflip -tb | cksum
-pamflip -r180 testgrid.pbm | \
-  pamflip -r180 | cksum
-pamflip -xy testgrid.pbm | \
-  pamflip -xy | cksum
-pamflip -r90 testgrid.pbm | \
-  pamflip -r90 | \
-  pamflip -r90 | \
-  pamflip -r90 | cksum
-pamflip -r270 testgrid.pbm | \
-  pamflip -r270 | \
-  pamflip -r270 | \
-  pamflip -r270 | cksum
+echo "Test 2.  Should produce 2729474106 27 nine times"
+
+pamflip -null ${test1_pgm} | cksum
+pamflip -lr ${test1_pgm} | pamflip -lr | cksum
+pamflip -tb ${test1_pgm} | pamflip -tb | cksum
+pamflip -r180 ${test1_pgm} | pamflip -r180 | cksum
+pamflip -xy ${test1_pgm} | pamflip -xy | cksum
+pamflip -r90 ${test1_pgm} | pamflip -r270 | cksum
+pamflip -r270 ${test1_pgm} | pamflip -r90 | cksum
+pamflip -r90 ${test1_pgm} | pamflip -r90 | \
+  pamflip -r90 | pamflip -r90 | cksum
+pamflip -r270 ${test1_pgm} | pamflip -r270 | \
+  pamflip -r270 | pamflip -r270 | cksum
+
+pamflip -r180 ${test1_pgm} > ${test2_pgm}
+rm ${test1_pgm}
+
+echo "Test 3.  Should produce 1849343241 27 nine times"
+
+pamflip -null ${test2_pgm} | cksum
+pamflip -lr ${test2_pgm} | pamflip -lr | cksum
+pamflip -tb ${test2_pgm} | pamflip -tb | cksum
+pamflip -r180 ${test2_pgm} | pamflip -r180 | cksum
+pamflip -xy ${test2_pgm} | pamflip -xy | cksum
+pamflip -r90 ${test2_pgm} | pamflip -r270 | cksum
+pamflip -r270 ${test2_pgm} | pamflip -r90 | cksum
+pamflip -r90 ${test2_pgm} | pamflip -r90 | \
+    pamflip -r90 | pamflip -r90 | cksum
+pamflip -r270 ${test2_pgm} | pamflip -r270 | \
+    pamflip -r270 | pamflip -r270 | cksum
+
+rm ${test2_pgm}
+
+cat > ${dot_ppm} <<EOF
+P3
+1 1
+65535
+1 10000 65535
+EOF
+
+echo "Test 4.  Should print a single pixel PPM image maxval 65535 in "
+echo "plain (ascii) format; then produce 2434897823 19 nine times"
+
+pamflip -null -plain ${dot_ppm}
+pamflip -null ${dot_ppm} | cksum
+pamflip -lr ${dot_ppm} | pamflip -lr | cksum
+pamflip -tb ${dot_ppm} | pamflip -tb | cksum
+pamflip -r180 ${dot_ppm} | pamflip -r180 | cksum
+pamflip -xy ${dot_ppm} | pamflip -xy | cksum
+pamflip -r90 ${dot_ppm} | pamflip -r270 | cksum
+pamflip -r270 ${dot_ppm} | pamflip -r90 | cksum
+pamflip -r90 ${dot_ppm} | pamflip -r90 | pamflip -r90 | pamflip -r90 | cksum
+pamflip -r270 ${dot_ppm} | pamflip -r270 | \
+    pamflip -r270 | pamflip -r270 | cksum
+
+rm ${dot_ppm}
 
+echo "Test 4.  Should produce 281226646 481 seven times"
 
-# TODO: single pixel image, one-dimensional (single row, single column) image
-# PBM various lengths: samples with -lr
+pamflip -null maze.pbm | cksum
+pamflip -lr maze.pbm | pamflip -lr | cksum
+pamflip -tb maze.pbm | pamflip -tb | cksum
+pamflip -r180 maze.pbm | pamflip -r180 | cksum
+pamflip -xy maze.pbm | pamflip -xy | cksum
+pamflip -r90 maze.pbm | pamflip -r90 | pamflip -r90 | pamflip -r90 | cksum
+pamflip -r270 maze.pbm | pamflip -r270 | pamflip -r270 | pamflip -r270 | cksum
 
+# TODO: PBM various lengths: samples with -lr
diff --git a/test/pamflip1.ok b/test/pamflip1.ok
index 64e0407e..1169d773 100644
--- a/test/pamflip1.ok
+++ b/test/pamflip1.ok
@@ -1,5 +1,10 @@
-2116496681 101484
+Test 1.  Should print 1350702313 12336
+1350702313 12336
+Test 2.  Should print 1035759697 40048
+1035759697 40048
+Test 3.  Should print 217037000 101484
 217037000 101484
-2052917888 101484
-3375384165 41
-604323149 41
+Test 4.  Should print 1178735266 481
+1178735266 481
+Test 5.  Should print 2339906255 481
+2339906255 481
diff --git a/test/pamflip1.test b/test/pamflip1.test
index 840cac73..b30bf6b0 100755
--- a/test/pamflip1.test
+++ b/test/pamflip1.test
@@ -1,15 +1,19 @@
 #! /bin/bash
 # This script tests: pamflip
-# Also requires:
+# Also requires: pamseq
 
+echo "Test 1.  Should print 1350702313 12336"
+pamseq 3 15 | pamflip -lr | cksum
 
-# Test 1.  Should print 2116496681 101484
-pamflip -lr testimg.ppm | cksum
-# Test 2.  Should print 217037000 101484
+echo "Test 2.  Should print 1035759697 40048"
+pamseq 4 9 | pamflip -tb | cksum
+
+echo "Test 3.  Should print 217037000 101484"
 pamflip -cw testimg.ppm | cksum
-# Test 3.  Should print 2052917888 101484
-pamflip -tb testimg.ppm | cksum
-# Test 4.  Should print 3375384165 41
-pamflip -lr testgrid.pbm | cksum
-# Test 5.  Should print 604323149 41
-pamflip -tb testgrid.pbm | cksum
+
+echo "Test 4.  Should print 1178735266 481"
+pamflip -lr maze.pbm | cksum
+
+echo "Test 5.  Should print 2339906255 481"
+pamflip -tb maze.pbm | cksum
+
diff --git a/test/pamflip2.ok b/test/pamflip2.ok
index d2ea501e..e3b4185c 100644
--- a/test/pamflip2.ok
+++ b/test/pamflip2.ok
@@ -1,3 +1,6 @@
-490797850 37
-3727293411 37
-3511745816 37
+Test 1.  Should print 748061765 465
+748061765 465
+Test 2.  Should print 3217647947 465
+3217647947 465
+Test 2.  Should print 1086015439 465
+1086015439 465
diff --git a/test/pamflip2.test b/test/pamflip2.test
index 4dddb770..8df293b5 100755
--- a/test/pamflip2.test
+++ b/test/pamflip2.test
@@ -9,9 +9,11 @@
 ## optional SSE routine.  If you make a wrong choice during configure,
 ## this test will fail.
 
-# Test 1.  Should print 490797850 37
-pamflip -cw testgrid.pbm | cksum
-# Test 1.  Should print 3727293411 37
-pamflip -ccw testgrid.pbm | cksum
-# Test 2.  Should print 3511745816 37
-pamflip -xy testgrid.pbm | cksum
+echo "Test 1.  Should print 748061765 465"
+pamflip -cw maze.pbm | cksum
+
+echo "Test 2.  Should print 3217647947 465"
+pamflip -ccw maze.pbm | cksum
+
+echo "Test 2.  Should print 1086015439 465"
+pamflip -xy maze.pbm | cksum
diff --git a/test/pamfunc.ok b/test/pamfunc.ok
index 4a531577..d358355b 100644
--- a/test/pamfunc.ok
+++ b/test/pamfunc.ok
@@ -36,13 +36,13 @@ Test 4: Should print 1926073387 101484 eight times
 1926073387 101484
 1926073387 101484
 1926073387 101484
-Test 5: Should print 2425386270 41 six times
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
+Test 5: Should print 281226646 481 six times
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
 Test Invalid
 Expected failure 1 1
 Expected failure 2 1
diff --git a/test/pamfunc.test b/test/pamfunc.test
index e52584b4..fbb39164 100755
--- a/test/pamfunc.test
+++ b/test/pamfunc.test
@@ -73,16 +73,16 @@ pamfunc -shiftleft  0 testimg.ppm | cksum
 pamfunc -shiftright 0 testimg.ppm | cksum
 
 
-echo "Test 5: Should print 2425386270 41 six times"
+echo "Test 5: Should print 281226646 481 six times"
 
-cat testgrid.pbm | cksum
+cat maze.pbm | cksum
 
-pamfunc -andmask  0x1 testgrid.pbm | cksum
-pamfunc -ormask   0x0 testgrid.pbm | cksum
-pamfunc -xormask  0x1 testgrid.pbm | pamfunc -xormask 0x1 | cksum
+pamfunc -andmask  0x1 maze.pbm | cksum
+pamfunc -ormask   0x0 maze.pbm | cksum
+pamfunc -xormask  0x1 maze.pbm | pamfunc -xormask 0x1 | cksum
 
-pamfunc -shiftleft  0 testgrid.pbm | cksum
-pamfunc -shiftright 0 testgrid.pbm | cksum
+pamfunc -shiftleft  0 maze.pbm | cksum
+pamfunc -shiftright 0 maze.pbm | cksum
 
 echo "Invalid command-line argument combinations." 1>&2
 echo "Error messages should appear below the line." 1>&2
diff --git a/test/pamhue.test b/test/pamhue.test
index 47688175..627823b5 100755
--- a/test/pamhue.test
+++ b/test/pamhue.test
@@ -16,11 +16,11 @@ pamseq -tupletype=RGB 3 1 | pamdepth 255 | pamhue -huechange=60 | \
 
 echo "Test 3"
 # pamhue has no effect on monotone images
-# Should print 2425386270 41 twice
+# Should print 281226646 481 twice
 
-pamhue -huechange=45  testgrid.pbm | cmp -s - testgrid.pbm
+pamhue -huechange=45  maze.pbm | cmp -s - maze.pbm
   echo ${PIPESTATUS[@]} ":" $?
-pamhue -huechange=180 testgrid.pbm | cmp -s - testgrid.pbm
+pamhue -huechange=180 maze.pbm | cmp -s - maze.pbm
   echo ${PIPESTATUS[@]} ":" $?
 
 echo "Test 4"
diff --git a/test/pamslice-roundtrip.ok b/test/pamslice-roundtrip.ok
index eae64745..50e83b2a 100644
--- a/test/pamslice-roundtrip.ok
+++ b/test/pamslice-roundtrip.ok
@@ -1,4 +1,9 @@
-2425386270 41
-914327477 4864
-914327477 4864
-914327477 4864
+Test 1.  Should print 139976034 137 twice
+139976034 137
+139976034 137
+Test 2.  Should print 1624460505 574 three times
+1624460505 574
+1624460505 574
+1624460505 574
+Test 3.  Should print 1624460505 574
+1624460505 574
diff --git a/test/pamslice-roundtrip.test b/test/pamslice-roundtrip.test
index 6cb5533f..d1a8a72c 100755
--- a/test/pamslice-roundtrip.test
+++ b/test/pamslice-roundtrip.test
@@ -1,75 +1,77 @@
 #! /bin/bash
 # This script tests: pamslice pamdeinterlace
-# Also requires: pamcut pamtopnm pamflip
+# Also requires: pamfile pamcut pamtopnm pamflip
 
-
-# Test 1.
-# Slice rows, one by one, out of testgrid.pbm.
+echo "Test 1.  Should print 139976034 137 twice"
+# Slice rows, one by one, out of maze.pbm.
 # Add header and reconstruct pbm image.
 # Note that in pamslice output 0 is white and 1 is black: opposite of PBM
-# Should print 2425386270 41
+
+mwidth=$(pamfile -size maze.pbm | cut -d" " -f1)
+height=16
+
+pamcut -top=0 -left=0 -height=${height} maze.pbm | cksum
 
 (echo "P1"
- echo "14 16"
- seq 0 15 | while read i;
+ echo "${mwidth} ${height}"
+ for ((i = 0; i < ${height}; ++i))
      do
-     pamslice -row=$i testgrid.pbm
-     done | awk '{print $2}' | sed 'y/01/10/' ) \
+     pamslice -row=$i maze.pbm
+     done | cut -d" " -f2- | sed 'y/01/10/' ) \
  | pamtopnm | cksum
 
-# Test 2.
+
+echo "Test 2.  Should print 1624460505 574 three times"
 # Slice rows, one by one, out of ppm test image
 # We take a part out of testimg.ppm with pamcut for processing the
 # whole image takes much time.
 # Add header and reconstruct ppm image.
-# Should print 914327477 4864
 
-tmpdir=${tmpdir:-/tmp}
 
-test4933_ppm=${tmpdir}/test4933.ppm
+tmpdir=${tmpdir:-/tmp}
+test1711_ppm=${tmpdir}/test1711.ppm
 
-pamcut 50 50 49 33 testimg.ppm > ${test4933_ppm}
+pamcut -left=50 -top=50 -width=17 -height=11 testimg.ppm | \
+  tee ${test1711_ppm} | cksum
 
 (echo "P3"
- echo "49 33"
+ echo "17 11"
  echo "255"
- seq 0 32 | while read i;
+ for ((i = 0; i < 11; ++i))
      do
-     pamslice -row=$i ${test4933_ppm}
-     done | awk '{print $2, $3, $4}' ) \
+     pamslice -row=$i ${test1711_ppm}
+     done | cut -d" " -f2- ) \
  | pamtopnm | cksum
 
 # Same as above test 2, but take cols instead of rows.
 # Should print 914327477 4864
 
 (echo "P3"
- echo "33 49"
+ echo "11 17"
  echo "255"
- seq 0 48 | while read i;
+ for ((i = 0; i < 17; ++i))
      do
-     pamslice -col=$i ${test4933_ppm}
-     done | awk '{print $2, $3, $4}' ) \
- | pamflip -xy | cksum
+     pamslice -col=$i ${test1711_ppm}
+     done | cut -d " " -f2- ) | pamflip -xy | cksum
 
-# Test 4.
+echo "Test 3.  Should print 1624460505 574"
 # Divide input image into two with pamdeinterlace and recombine.
 
 testeven_ppm=${tmpdir}/testeven.ppm
 testodd_ppm=${tmpdir}/testodd.ppm
 
-pamdeinterlace -takeodd ${test4933_ppm} > ${testodd_ppm}
-pamdeinterlace -takeeven ${test4933_ppm} > ${testeven_ppm}
+pamdeinterlace -takeodd ${test1711_ppm} > ${testodd_ppm}
+pamdeinterlace -takeeven ${test1711_ppm} > ${testeven_ppm}
 
-(echo "P3"
- echo "49 33"
- echo "255"
- ( seq 0 15 | while read i;
-     do
-     pamslice -row=$i ${testeven_ppm}
-     pamslice -row=$i ${testodd_ppm}
-     done
-     pamslice -row=16 ${testeven_ppm};
- )  | awk '{print $2, $3, $4}' ) \
- | pamtopnm | cksum
+( echo "P3"
+  echo "17 11"
+  echo "255"
+  ( for ((i = 0; i < 5; ++i))
+        do
+        pamslice -row=$i ${testeven_ppm}
+        pamslice -row=$i ${testodd_ppm}
+        done
+        pamslice -row=5 ${testeven_ppm};
+  ) | cut -d" " -f2- ) | pamtopnm | cksum
 
-rm ${test4933_ppm} ${testodd_ppm} ${testeven_ppm}
+rm ${test1711_ppm} ${testodd_ppm} ${testeven_ppm}
diff --git a/test/pamsumm.ok b/test/pamsumm.ok
index 63b5f6bd..b9ce0269 100644
--- a/test/pamsumm.ok
+++ b/test/pamsumm.ok
@@ -1,9 +1,14 @@
-Test 1
+Test 1.  Should print in order: 56, 0, 1, 0.250000
 56
 0
 1
 0.250000
-Test 2
+Test 2.  Should print in order: 1627, 0, 1, 0.483794
+1627
+0
+1
+0.483794
+Test 3.  Should print in order: 10772432, 15, 255, 106.164760
 10772432
 15
 255
diff --git a/test/pamsumm.test b/test/pamsumm.test
index 3d008533..f98800ee 100755
--- a/test/pamsumm.test
+++ b/test/pamsumm.test
@@ -2,14 +2,21 @@
 # This script tests: pamsumm
 # Also requires:
 
-echo "Test 1"
+echo "Test 1.  Should print in order: 56, 0, 1, 0.250000"
 
 for type in -sum -min -max -mean
   do
   pamsumm -brief $type testgrid.pbm
   done
 
-echo "Test 2"
+echo "Test 2.  Should print in order: 1627, 0, 1, 0.483794"
+
+for type in -sum -min -max -mean
+  do
+  pamsumm -brief $type maze.pbm
+  done
+
+echo "Test 3.  Should print in order: 10772432, 15, 255, 106.164760"
 
 for type in -sum -min -max -mean
   do
diff --git a/test/pamtopam.ok b/test/pamtopam.ok
index dcb597d3..d84b2b6c 100644
--- a/test/pamtopam.ok
+++ b/test/pamtopam.ok
@@ -1,3 +1,18 @@
+Test 1. Should print five PAM headers
+P7
+WIDTH 14
+HEIGHT 16
+DEPTH 1
+MAXVAL 1
+TUPLTYPE BLACKANDWHITE
+ENDHDR
+P7
+WIDTH 1
+HEIGHT 1
+DEPTH 1
+MAXVAL 255
+TUPLTYPE GRAYSCALE
+ENDHDR
 P7
 WIDTH 227
 HEIGHT 149
@@ -6,11 +21,26 @@ MAXVAL 255
 TUPLTYPE RGB
 ENDHDR
 P7
-WIDTH 14
-HEIGHT 16
-DEPTH 1
+WIDTH 64
+HEIGHT 1
+DEPTH 2
+MAXVAL 7
+TUPLTYPE GRAYSCALE_ALPHA
+ENDHDR
+P7
+WIDTH 16
+HEIGHT 1
+DEPTH 4
 MAXVAL 1
-TUPLTYPE BLACKANDWHITE
+TUPLTYPE RGB_ALPHA
 ENDHDR
-1873848880 101532
+Test 2. Should print 2260748250 293
 2260748250 293
+Test 3. Should print 1873848880 101532
+1873848880 101532
+Test 4. Should print 1475247910 3432 twice
+1475247910 3432
+1475247910 3432
+Test 5. Should print 2347274358 101825 twice
+2347274358 101825
+2347274358 101825
diff --git a/test/pamtopam.test b/test/pamtopam.test
index 394d9904..e9b4f93d 100755
--- a/test/pamtopam.test
+++ b/test/pamtopam.test
@@ -1,10 +1,25 @@
 #! /bin/bash
 # This script tests: pamtopam
-# Also requires:
+# Also requires: pgmmake pamseq
 
+echo "Test 1. Should print five PAM headers"
 
-pamtopam < testimg.ppm  | sed '/ENDHDR/q'
 pamtopam < testgrid.pbm | sed '/ENDHDR/q'
+pgmmake 0.5 1 1 | pamtopam | sed '/ENDHDR/q'
+pamtopam < testimg.ppm  | sed '/ENDHDR/q'
+pamseq -tupletype="GRAYSCALE_ALPHA" 2 7 | pamtopam | sed '/ENDHDR/q'
+pamseq -tupletype="RGB_ALPHA" 4 1 | pamtopam | sed '/ENDHDR/q'
 
-pamtopam < testimg.ppm   | cksum
+echo "Test 2. Should print 2260748250 293"
 pamtopam < testgrid.pbm  | cksum
+
+echo "Test 3. Should print 1873848880 101532"
+pamtopam < testimg.ppm   | cksum
+
+echo "Test 4. Should print 1475247910 3432 twice"
+pamtopam < maze.pbm  | cksum
+pamtopam < maze.pbm  | pamtopam | cksum
+
+echo "Test 5. Should print 2347274358 101825 twice"
+cat testgrid.pbm testimg.ppm | pamtopam | cksum
+( pamtopam  < testgrid.pbm; pamtopam < testimg.ppm ) | cksum
diff --git a/test/pamtopdbimg.test b/test/pamtopdbimg.test
index 9afee8f1..d6c105bf 100755
--- a/test/pamtopdbimg.test
+++ b/test/pamtopdbimg.test
@@ -82,13 +82,13 @@ awk 'BEGIN { ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
 head -c 65533 ${text65597} > ${text65533}
 head -c 65534 ${text65597} > ${text65534}
-pamtopdbimg -uncompressed testgrid.pbm | \
+pamtopdbimg -uncompressed maze.pbm | \
   wc -c | tr -d ' '
   echo ${PIPESTATUS[0]}
-pamtopdbimg -uncompressed -notefile=${text65533} testgrid.pbm | \
+pamtopdbimg -uncompressed -notefile=${text65533} maze.pbm | \
   wc -c | tr -d ' '
   echo ${PIPESTATUS[0]}
-pamtopdbimg -uncompressed -notefile=${text65534} testgrid.pbm | \
+pamtopdbimg -uncompressed -notefile=${text65534} maze.pbm | \
   wc -c | tr -d ' '
   echo ${PIPESTATUS[0]}
 
diff --git a/test/pamundice.ok b/test/pamundice.ok
index ef0f6e13..1234431d 100644
--- a/test/pamundice.ok
+++ b/test/pamundice.ok
@@ -1,17 +1,17 @@
-Test 1.
+Test 1.  Should print 2096818803 2818 twice
 2096818803 2818
 2096818803 2818
-Test 2.
+Test 2.  Should print 2096818803 2818 twice
 2096818803 2818
 2096818803 2818
-Test 3.
+Test 3.  Should print 2096818803 2818 twice
 2096818803 2818
 2096818803 2818
-Test 4.
-557392151 459
-557392151 459
-557392151 459
-557392151 459
+Test 4.  Should print 2434390296 4436 four times
+2434390296 4436
+2434390296 4436
+2434390296 4436
+2434390296 4436
 Test Invalid
 Expected failure 1 1
 Expected failure 2 1
diff --git a/test/pamundice.test b/test/pamundice.test
index 5c1f9c6b..d412cde1 100755
--- a/test/pamundice.test
+++ b/test/pamundice.test
@@ -1,12 +1,11 @@
 #! /bin/bash
 # This script tests: pamundice
-# Also requires: pgmmake pnmtile pnmcat pnmpad
+# Also requires: pamfile pgmmake pnmtile pnmcat
 
 tmpdir=${tmpdir:-/tmp}
 fname_stem=${tmpdir}/part
 
-# Test 1.
-echo "Test 1."
+echo "Test 1.  Should print 2096818803 2818 twice"
 
 for ((x=0; x<3; ++x))
   do for ((y=0; y<5; ++y))
@@ -20,9 +19,7 @@ pamundice -across=3 -down=5 ${fname_stem}"_%1d_%1a".pgm | cksum
 ls ${fname_stem}_?_?.pgm | \
     pamundice -across=3 -down=5 -listfile=- | cksum
 
-
-# Test 2.
-echo "Test 2."
+echo "Test 2.  Should print 2096818803 2818 twice"
 
 tempfile=${tmpdir}/temp
 
@@ -46,8 +43,7 @@ rm ${tempfile}_[012]
 
 rm ${fname_stem}_?_?.pgm
 
-# Test 3.
-echo "Test 3."
+echo "Test 3.  Should print 2096818803 2818 twice"
 
 for ((x=0; x<2; ++x))
   do for ((y=0; y<5; ++y))
@@ -89,21 +85,22 @@ rm ${fname_stem}_?_?.pgm
 
 
 # Test 4.
-echo "Test 4."
+echo "Test 4.  Should print 2434390296 4436 four times"
 
-# Add margins to testgrid.pbm
+msize=$(pamfile -size maze.pbm)
+mw=$(echo ${msize} | cut -d" " -f1)
+mh=$(echo ${msize} | cut -d" " -f2)
 
-testimg_pbm=${tmpdir}/testimg.pbm
-pnmpad -top=2 -left=3 -black testgrid.pbm > ${testimg_pbm}
+pnmtile $((${mw} * 2)) $((${mh} * 5)) maze.pbm | cksum
 
 for x in `seq 0 1`
   do for y in `seq 0 4`
-    do cp ${testimg_pbm} ${fname_stem}_${y}_${x}.pbm; done
+    do cp maze.pbm ${fname_stem}_${y}_${x}.pbm; done
   done
 
 for (( i=0 ; i<=9; ++i))
   do
-  echo ${testimg_pbm}
+  echo maze.pbm
   done | pamundice -down=5 -across=2 -listfile=- | cksum
 
 pamundice -down=5 -across=2 ${fname_stem}_"%1d"_"%1a".pbm | cksum
@@ -111,11 +108,8 @@ pamundice -down=5 -across=2 ${fname_stem}_"%1d"_"%1a".pbm | cksum
 echo "A warning message should appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
-pamundice -down=5 -across=2 ${testimg_pbm} | cksum
-
-pnmtile 34 90 ${testimg_pbm} | cksum
+pamundice -down=5 -across=2 maze.pbm | cksum
 
-rm ${testimg_pbm}
 
 # Test Invalid.
 echo "Test Invalid"
@@ -176,14 +170,14 @@ pamundice -down=5 -across=2 ${fname_stem}_"%d"_"%a".pbm > ${test_out} || \
   rm -f {test_out}
 
 # -hoverlap too large
-pamundice -down=5 -across=2 -hoverlap=18 \
+pamundice -down=5 -across=2 -hoverlap=$((${mw}+1)) \
   ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \
   echo -n "Expected failure 9"
   test -s ${test_out}; echo " "$?
   rm -f {test_out}
 
 # -voverlap too large
-pamundice -down=5 -across=2 -voverlap=19 \
+pamundice -down=5 -across=2 -voverlap=$((${mh}+1)) \
   ${fname_stem}_"%1d"_"%1a".pbm > ${test_out} || \
   echo -n "Expected failure 10"
   test -s ${test_out}; echo " "$?
diff --git a/test/pbm-ppm-roundtrip.ok b/test/pbm-ppm-roundtrip.ok
index bcc090b6..91c502b5 100644
--- a/test/pbm-ppm-roundtrip.ok
+++ b/test/pbm-ppm-roundtrip.ok
@@ -1,10 +1,10 @@
-Test 1.  Should print 2425386270 41 five times.
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-Test 2.
+Test 1.  Should print 281226646 481 five times.
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+Test 2.  Should print three all-white, then three all-black PBM images
 P1
 7 3
 0000000
diff --git a/test/pbm-ppm-roundtrip.test b/test/pbm-ppm-roundtrip.test
index b8ef0ef6..23b6c1c4 100755
--- a/test/pbm-ppm-roundtrip.test
+++ b/test/pbm-ppm-roundtrip.test
@@ -1,18 +1,18 @@
 #! /bin/bash
 # This script tests: pgmtoppm ppmtopgm ppmtoppm pgmtopbm
-# Also requires: pbmmake pgmcolormask pnminvert
+# Also requires: pbmmake ppmcolormask pnminvert
 
-echo "Test 1.  Should print 2425386270 41 five times."
+echo "Test 1.  Should print 281226646 481 five times."
 
-cat testgrid.pbm | cksum
-pgmtoppm black-white testgrid.pbm | ppmtopgm | \
+cat maze.pbm | cksum
+pgmtoppm black-white maze.pbm | ppmtopgm | \
   pgmtopbm -th -val=0.5 | cksum
-pgmtoppm white-black testgrid.pbm | ppmtopgm | \
+pgmtoppm white-black maze.pbm | ppmtopgm | \
   pgmtopbm -th -val=0.5 | pnminvert | cksum
-pgmtoppm white-black testgrid.pbm | ppmcolormask white | cksum
-ppmtoppm < testgrid.pbm | ppmtopgm | pgmtopbm -th -val=0.5 | cksum
+pgmtoppm white-black maze.pbm | ppmcolormask white | cksum
+ppmtoppm < maze.pbm | ppmtopgm | pgmtopbm -th -val=0.5 | cksum
 
-echo "Test 2."
+echo "Test 2.  Should print three all-white, then three all-black PBM images"
 
 pbmmake -w 7 3  -plain
 echo
@@ -32,4 +32,3 @@ pbmmake -b 17 2 | pgmtoppm black-white | ppmtopgm | \
 echo
 pbmmake -b 17 2 | ppmtoppm | ppmtopgm | \
   pgmtopbm -th -val=0.5 -plain
-
diff --git a/test/pbmminkowski.ok b/test/pbmminkowski.ok
index 71a909ce..9780e3c2 100644
--- a/test/pbmminkowski.ok
+++ b/test/pbmminkowski.ok
@@ -21,3 +21,11 @@ vertices:	224
     area:	56
 perimeter:	224
  eulerchi:	56
+
+   tiles:	1627
+ x-edges:	2479
+ y-edges:	2427
+vertices:	3376
+    area:	1627
+perimeter:	3304
+ eulerchi:	97
diff --git a/test/pbmminkowski.test b/test/pbmminkowski.test
index 389ff44a..3ad96dfa 100755
--- a/test/pbmminkowski.test
+++ b/test/pbmminkowski.test
@@ -1,11 +1,12 @@
 #! /bin/bash
 # This script tests: pbmminkowski
-# Also requires: pbmmake pnmmargin pnmpad
+# Also requires: pbmmake pnmpad
 
-
-pbmmake -w 1 1 | pnmmargin -b 1 | \
+pbmmake -w 1 1 | pnmpad -black -top=1 -left=1 -bottom=1 -right=1 | \
   pbmminkowski
 echo
 pbmmake -g 3 3 | pbmminkowski
 echo
 pbmminkowski testgrid.pbm
+echo
+pbmminkowski maze.pbm
\ No newline at end of file
diff --git a/test/pbmpscale.ok b/test/pbmpscale.ok
index c26ffef3..9ea594d8 100644
--- a/test/pbmpscale.ok
+++ b/test/pbmpscale.ok
@@ -1,53 +1,178 @@
+Test 1.  Should print "abc" rendered in PBM plain format
 P1
-21 45
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-111111111111111111110
-111111111111111111111
-111111111111111111111
-001111100000000001111
-000111000000000000111
-000111000000000000111
-000111000000000000000
-000111000000000000000
-000111000000000000000
-000111000000000111000
-000111000000000111000
-000111100000001111000
-000111111111111111000
-000111111111111111000
-000111111111111111000
-000111100000001111000
-000111000000000111000
-000111000000000111000
-000111000000000000000
-000111000000000000000
-000111000000000000000
-000111000000000000000
-000111000000000000000
-001111100000000000000
-111111111111000000000
-111111111111000000000
-111111111111000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-000000000000000000000
-2150868536 457
-3761734242 1065
-3462719777 1803
+17 15
+00000000000000000
+00000000000000000
+00000000000000000
+00000011000000000
+00000001000000000
+00000001000000000
+00110001110000110
+01001001001001001
+00111001001001000
+01001001001001000
+01001001001001001
+00110101110000110
+00000000000000000
+00000000000000000
+00000000000000000
+Test 2.  "ABC" in PBM plain format
+P1
+48 30
+000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000
+000000001100000000111111111110000000000111100011
+000000001100000000111111111111100000011111110011
+000000001100000000011110000111100000011110011111
+000000011110000000001100000011110000111100001111
+000000010010000000001100000000110000111000000111
+000000110011000000001100000000110001110000000011
+000000110011000000001100000011110001100000000000
+000001100001100000001110000111100011000000000000
+000001000000100000001111111111000011000000000000
+000011000000110000001111111111000011000000000000
+000011111111110000001110000001100011000000000000
+000011111111110000001100000000110001100000000000
+000011100001110000001100000000110001110000000011
+000111000000111000001100000001110000111000000111
+001100000000001100001100000011110000111100001111
+011100000000001110011110000111100000011110011110
+111111000000111111111111111111100000011111111110
+111111000000111111111111111110000000000111111000
+000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000
+Test 3.  "D.!" in PBM plain format
+P1
+42 45
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+111111111111111110000000000000000000000111
+111111111111111111000000000000000000000111
+111111111111111111100000000000000000000111
+001111100000001111110000000000000000000111
+000111000000000111111000000000000000000111
+000111000000000111111000000000000000000111
+000111000000000001111000000000000000000111
+000111000000000000111000000000000000000111
+000111000000000000111100000000000000000111
+000111000000000000001110000000000000000111
+000111000000000000000111000000000000000111
+000111000000000000000111000000000000000111
+000111000000000000000111000000000000000111
+000111000000000000000111000000000000000111
+000111000000000000000111000000000000000111
+000111000000000000000111000000000000000111
+000111000000000000000111000000000000000111
+000111000000000000001110000000000000000111
+000111000000000000111100000000000000000111
+000111000000000000111000000000000000000111
+000111000000000001111000000000000000000111
+000111000000000111111000000000000000000000
+000111000000000111111000000000000000000000
+001111100000001111110000000000000000000000
+111111111111111111100000000000111000000111
+111111111111111111000000000000111000000111
+111111111111111110000000000000111000000111
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000
+Test 3.  "E,?" in PBM plain format
+P1
+60 60
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+011111111111111111111111110000000000000000000000011111100000
+111111111111111111111111111000000000000000000000111111110000
+111111111111111111111111111100000000000000000001111111111000
+011111111111111111111111111100000000000000000011111111111100
+001111111100000000000011111100000000000000000111110000111110
+000111111000000000000001111100000000000000001111100000011111
+000011110000000000000000111100000000000000001111000000001111
+000011110000000000000000011000000000000000000110000000001111
+000011110000000000000000000000000000000000000000000000001111
+000011110000000000000000000000000000000000000000000000001111
+000011110000000000000000000000000000000000000000000000011111
+000011110000000000000000000000000000000000000000000000111110
+000011110000000000000110000000000000000000000000000001111100
+000011110000000000001111000000000000000000000000000011111000
+000011111000000000011111000000000000000000000000000111110000
+000011111100000000111111000000000000000000000000001111100000
+000011111111111111111111000000000000000000000000011111000000
+000011111111111111111111000000000000000000000000111110000000
+000011111111111111111111000000000000000000000000111100000000
+000011111111111111111111000000000000000000000000111100000000
+000011111100000000111111000000000000000000000000111100000000
+000011111000000000011111000000000000000000000000111100000000
+000011110000000000001111000000000000000000000000111100000000
+000011110000000000000110000000000000000000000000111100000000
+000011110000000000000000000000000000000000000000111100000000
+000011110000000000000000000000000000000000000000111100000000
+000011110000000000000000000000000000000000000000111100000000
+000011110000000000000000000000000000000000000000011000000000
+000011110000000000000000011000000000000000000000000000000000
+000011110000000000000000111100000000000000000000000000000000
+000111111000000000000001111100000000000000000000000000000000
+001111111100000000000011111100000000000000000000000000000000
+011111111111111111111111111100000000011000000000011000000000
+111111111111111111111111111100000000111100000000111100000000
+111111111111111111111111111000000000111100000000111100000000
+011111111111111111111111110000000000111100000000011000000000
+000000000000000000000000000000000000111100000000000000000000
+000000000000000000000000000000000000111100000000000000000000
+000000000000000000000000000000000001111100000000000000000000
+000000000000000000000000000000000011111000000000000000000000
+000000000000000000000000000000000111110000000000000000000000
+000000000000000000000000000000001111100000000000000000000000
+000000000000000000000000000000001111000000000000000000000000
+000000000000000000000000000000000110000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000
+Test 5.  Should print 576003211 10631
+576003211 10631
+Test 6.  Should print 3501321825 369
+3501321825 369
+Test 7.  Should print 1588181271 535
+1588181271 535
+Test 8.  Should print 2843090781 610
+2843090781 610
+Test 9.  Should print 146160766 820
+146160766 820
+Test 10. Should print 3327221668 2111
+3327221668 2111
+Test Invalid
 Expected failure 1 1
 Expected failure 2 1
 Expected failure 3 1
diff --git a/test/pbmpscale.test b/test/pbmpscale.test
index 21ad6cd1..29621a8c 100755
--- a/test/pbmpscale.test
+++ b/test/pbmpscale.test
@@ -1,18 +1,35 @@
 #! /bin/bash
 # This script tests: pbmpscale
-# Also requires: pamenlarge pbmtext
-
-
-pbmtext -nomargin "F" | pbmpscale 3 -plain
-
-for i in 2 3 4
-do
-pamenlarge 2 testgrid.pbm | \
-  pbmpscale $i | cksum
-done
-
+# Also requires: pbmtext
+
+echo "Test 1.  Should print \"abc\" rendered in PBM plain format"
+pbmtext -nomargin "abc" | pbmpscale 1 -plain
+echo "Test 2.  \"ABC\" in PBM plain format"
+pbmtext -nomargin "ABC" | pbmpscale 2 -plain
+echo "Test 3.  \"D.!\" in PBM plain format"
+pbmtext -nomargin "D.!" | pbmpscale 3 -plain
+echo "Test 3.  \"E,?\" in PBM plain format"
+pbmtext -nomargin "E,?" | pbmpscale 4 -plain
+
+echo "Test 5.  Should print 576003211 10631"
+pbmpscale 5 maze.pbm | cksum
+
+echo "Test 6.  Should print 3501321825 369"
+pbmtext -nomargin "6" | pbmpscale 6 | cksum
+echo "Test 7.  Should print 1588181271 535"
+pbmtext -nomargin "7" | pbmpscale 7 | cksum
+echo "Test 8.  Should print 2843090781 610"
+pbmtext -nomargin "8" | pbmpscale 8 | cksum
+echo "Test 9.  Should print 146160766 820"
+pbmtext -nomargin "9" | pbmpscale 9 | cksum
+echo "Test 10. Should print 3327221668 2111"
+pbmtext -nomargin "10" | pbmpscale 10 | cksum
+
+tmpdir=${tmpdir:-/tmp}
 test_out=${tmpdir}/test_out
 
+echo "Test Invalid"
+
 echo 1>&2
 echo "Invalid command-line argument combinations." 1>&2
 echo "Error messages should appear below the line." 1>&2
diff --git a/test/pbmtog3.ok b/test/pbmtog3.ok
index cef9e3f9..6660206b 100644
--- a/test/pbmtog3.ok
+++ b/test/pbmtog3.ok
@@ -1,10 +1,20 @@
-3697098186 144
-1248301383 122
-686713716 144
-215463240 122
+Test 1.  Should print 2156383714 1106
+2156383714 1106
+Test 2.  Should print 162371073 1049
+162371073 1049
+Test 3.  Should print 750267045 1106
+750267045 1106
+Test 4.  Should print 1140269483 1049
+1140269483 1049
+Test 5.  Should print 28792587 47
 28792587 47
+Test 6.  Should print 277456854 32
 277456854 32
+Test 7.  Should print 28792587 47
 28792587 47
+Test 8.  Should print 3736247115 62
 3736247115 62
+Test 9.  Should print 2820255307 2191856
 2820255307 2191856
+Test 10.  Should print 4159089282 2226575
 4159089282 2226575
diff --git a/test/pbmtog3.test b/test/pbmtog3.test
index c5dc3357..c23e8af0 100755
--- a/test/pbmtog3.test
+++ b/test/pbmtog3.test
@@ -2,24 +2,33 @@
 # This script tests: pbmtog3
 # Also requires: pbmmake
 
-# Test 1.  Should print 3697098186 144
-pbmtog3 testgrid.pbm | cksum
-# Test 2.  Should print 1248301383 122
-pbmtog3 -nofixedwidth testgrid.pbm | cksum
-# Test 3.  Should print 686713716 144
-pbmtog3 -reverse testgrid.pbm | cksum
-# Test 4.  Should print 215463240 122
-pbmtog3 -nofixedwidth -reverse testgrid.pbm | cksum
-# Test 5.  Should print 28792587 47
+echo "Test 1.  Should print 2156383714 1106"
+pbmtog3 maze.pbm | cksum
+
+echo "Test 2.  Should print 162371073 1049"
+pbmtog3 -nofixedwidth maze.pbm | cksum
+
+echo "Test 3.  Should print 750267045 1106"
+pbmtog3 -reverse maze.pbm | cksum
+
+echo "Test 4.  Should print 1140269483 1049"
+pbmtog3 -nofixedwidth -reverse maze.pbm | cksum
+
+echo "Test 5.  Should print 28792587 47"
 pbmmake -w 10 10 | pbmtog3 | cksum
-# Test 6.  Should print 277456854 32
+
+echo "Test 6.  Should print 277456854 32"
 pbmmake -w 10 10 | \
   pbmtog3 -nofixedwidth | cksum
-# Test 7.  Should print 28792587 47
+
+echo "Test 7.  Should print 28792587 47"
 pbmmake -w 10000 10 | pbmtog3 | cksum
-# Test 8.  Should print 3736247115 62
+
+echo "Test 8.  Should print 3736247115 62"
 pbmmake -b 10 10 | pbmtog3 | cksum
-# Test 9.  Should print 2820255307 2191856
+
+echo "Test 9.  Should print 2820255307 2191856"
 pbmmake -g 1700 2286 | pbmtog3 | cksum
-# Test 10.  Should print 4159089282 2226575
+
+echo "Test 10.  Should print 4159089282 2226575"
 pbmmake -g 1800 2286 | pbmtog3 | cksum
diff --git a/test/pgmminkowski.test b/test/pgmminkowski.test
index 52e02e19..9d8c257d 100755
--- a/test/pgmminkowski.test
+++ b/test/pgmminkowski.test
@@ -1,8 +1,8 @@
 #! /bin/bash
 # This script tests: pgmminkowski
-# Also requires: pbmmake pgmmake pnmmargin pnmpad
+# Also requires: pbmmake pgmmake pnmpad
 
-pgmmake .5 1 1 | pnmmargin -b 1 | \
+pgmmake .5 1 1 | pnmpad -black -top=1 -left=1 -bottom=1 -right=1 | \
   pgmminkowski
 echo
 pbmmake -g 3 3 | pgmminkowski
diff --git a/test/pi3-roundtrip.ok b/test/pi3-roundtrip.ok
index 3fde31b1..c4351b83 100644
--- a/test/pi3-roundtrip.ok
+++ b/test/pi3-roundtrip.ok
@@ -1,2 +1,5 @@
+Test 1. Should print: 3139449799 32011 twice
 3139449799 32011
-2425386270 41
+3139449799 32011
+Test 2. Should print: 281226646 481, cksum of maze.pbm
+281226646 481
diff --git a/test/pi3-roundtrip.test b/test/pi3-roundtrip.test
index 5700337d..6c75acc7 100755
--- a/test/pi3-roundtrip.test
+++ b/test/pi3-roundtrip.test
@@ -1,16 +1,15 @@
 #! /bin/bash
 # This script tests: pbmtopi3 pi3topbm
-# Also requires: pbmmake pamcut
-
+# Also requires: pbmmake pamcut pamfile
 
 # The pi3 image format specifies a fixed image size of 640x400.
 # Pbmtopi3 rejects images that do not conform.
 
-# Test
-# Should print: 3139449799 32011
+echo "Test 1. Should print: 3139449799 32011 twice"
+pbmmake -g 640 400 | cksum
 pbmmake -g 640 400 | pbmtopi3 | pi3topbm | cksum
 
-# Test 2.
-# Should print: 2425386270 41
-pamcut -pad 0 0 640 400 testgrid.pbm | \
-  pbmtopi3 | pi3topbm | pamcut 0 0 14 16 | cksum
+echo "Test 2. Should print: 281226646 481, cksum of maze.pbm"
+size=$(pamfile -size maze.pbm | awk '{print "-width="$1,"-height="$2}')
+pamcut -pad -left=0 -top=0 -width=640 -height=400 maze.pbm | \
+  pbmtopi3 | pi3topbm | pamcut -left=0 -top=0 ${size} | cksum
diff --git a/test/pj-roundtrip.test b/test/pj-roundtrip.test
index 2b0d61e5..3ed30927 100755
--- a/test/pj-roundtrip.test
+++ b/test/pj-roundtrip.test
@@ -19,8 +19,8 @@ echo "Test 2. Should print:  0 0 : 0"
 
 testout_ppm=${tmpdir}/testout.ppm
 
-ppmtopj testgrid.pbm | pjtoppm > ${testout_ppm}
-  ppmtoppm < testgrid.pbm | cmp -s - ${testout_ppm} > /dev/null
+ppmtopj maze.pbm | pjtoppm > ${testout_ppm}
+  ppmtoppm < maze.pbm | cmp -s - ${testout_ppm} > /dev/null
   echo ${PIPESTATUS[@]} ":" $?
 
 rm ${testout_ppm}
diff --git a/test/png-roundtrip.ok b/test/png-roundtrip.ok
index 28b8c057..ec0a1937 100644
--- a/test/png-roundtrip.ok
+++ b/test/png-roundtrip.ok
@@ -16,21 +16,21 @@
 1926073387 101484
 1926073387 101484
 1926073387 101484
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
diff --git a/test/png-roundtrip.test b/test/png-roundtrip.test
index 7e7c4a9b..fcb5927a 100755
--- a/test/png-roundtrip.test
+++ b/test/png-roundtrip.test
@@ -28,7 +28,7 @@ for flags in "" -interlace \
 pnmtopng testimg.ppm $flags | pngtopam | cksum
 done
 
-# Test 2.  Should print 2425386270 41 18 times
+# Test 2.  Should print 281226646 481 18 times
 for flags in "" -interlace \
   -gamma=.45 \
   -hist \
@@ -47,5 +47,5 @@ for flags in "" -interlace \
   -comp_strategy=filtered \
   -force
   do
-  pnmtopng testgrid.pbm $flags | pngtopam | cksum
+  pnmtopng maze.pbm $flags | pngtopam | cksum
   done
diff --git a/test/png-roundtrip2.ok b/test/png-roundtrip2.ok
index 0e712ce7..764cadfa 100644
--- a/test/png-roundtrip2.ok
+++ b/test/png-roundtrip2.ok
@@ -1,4 +1,4 @@
 1926073387 101484
 1926073387 101484
-2425386270 41
-2425386270 41
+281226646 481
+281226646 481
diff --git a/test/png-roundtrip2.test b/test/png-roundtrip2.test
index af2ad029..5705a1ae 100755
--- a/test/png-roundtrip2.test
+++ b/test/png-roundtrip2.test
@@ -15,8 +15,8 @@ for flags in "" -gamma=.45
   pamtopng testimg.ppm $flags | pngtopam | cksum
   done
 
-# Test 2.  Should print 2425386270 41 twice
+# Test 2.  Should print 281226646 481 twice
 for flags in "" -gamma=.45
   do
-  pamtopng testgrid.pbm $flags | pngtopam | cksum
+  pamtopng maze.pbm $flags | pngtopam | cksum
   done
diff --git a/test/pnm-pam-roundtrip.ok b/test/pnm-pam-roundtrip.ok
index 67f7a1fe..ace97410 100644
--- a/test/pnm-pam-roundtrip.ok
+++ b/test/pnm-pam-roundtrip.ok
@@ -1,2 +1,2 @@
 1926073387 101484
-2425386270 41
+281226646 481
diff --git a/test/pnm-pam-roundtrip.test b/test/pnm-pam-roundtrip.test
index b8e60c88..13925f74 100755
--- a/test/pnm-pam-roundtrip.test
+++ b/test/pnm-pam-roundtrip.test
@@ -4,4 +4,4 @@
 
 
 pamtopam < testimg.ppm | pamtopnm | cksum
-pamtopam < testgrid.pbm | pamtopnm | cksum
+pamtopam < maze.pbm | pamtopnm | cksum
diff --git a/test/pnm-plain-roundtrip.ok b/test/pnm-plain-roundtrip.ok
index 67f7a1fe..ace97410 100644
--- a/test/pnm-plain-roundtrip.ok
+++ b/test/pnm-plain-roundtrip.ok
@@ -1,2 +1,2 @@
 1926073387 101484
-2425386270 41
+281226646 481
diff --git a/test/pnm-plain-roundtrip.test b/test/pnm-plain-roundtrip.test
index 3779d761..bf685e85 100755
--- a/test/pnm-plain-roundtrip.test
+++ b/test/pnm-plain-roundtrip.test
@@ -5,5 +5,5 @@
 
 pamtopnm -plain testimg.ppm | \
   pamtopnm | cksum
-pamtopnm -plain testgrid.pbm | \
+pamtopnm -plain maze.pbm | \
   pamtopnm | cksum
diff --git a/test/pnmcolormap.test b/test/pnmcolormap.test
index 9ac0ea9e..d14a7936 100755
--- a/test/pnmcolormap.test
+++ b/test/pnmcolormap.test
@@ -2,9 +2,9 @@
 # This script tests: pnmcolormap
 # Also requires:
 
-pnmcolormap -plain -sort 2 testgrid.pbm
-pnmcolormap -plain -sort -square 2 testgrid.pbm
-pnmcolormap -plain -sort all testgrid.pbm
+pnmcolormap -plain -sort 2 maze.pbm
+pnmcolormap -plain -sort -square 2 maze.pbm
+pnmcolormap -plain -sort all maze.pbm
 
 echo 1>&2
 echo "Invalid command-line arguments." 1>&2
diff --git a/test/pnminvert-roundtrip.ok b/test/pnminvert-roundtrip.ok
index 67f7a1fe..ace97410 100644
--- a/test/pnminvert-roundtrip.ok
+++ b/test/pnminvert-roundtrip.ok
@@ -1,2 +1,2 @@
 1926073387 101484
-2425386270 41
+281226646 481
diff --git a/test/pnminvert-roundtrip.test b/test/pnminvert-roundtrip.test
index 52d15039..ddc5dc5d 100755
--- a/test/pnminvert-roundtrip.test
+++ b/test/pnminvert-roundtrip.test
@@ -4,4 +4,4 @@
 
 
 pnminvert testimg.ppm | pnminvert | cksum
-pnminvert testgrid.pbm | pnminvert | cksum
+pnminvert maze.pbm | pnminvert | cksum
diff --git a/test/ppmchange-roundtrip.ok b/test/ppmchange-roundtrip.ok
index a676a1f2..4fb7d428 100644
--- a/test/ppmchange-roundtrip.ok
+++ b/test/ppmchange-roundtrip.ok
@@ -1,2 +1,2 @@
-2425386270 41
-2425386270 41
+281226646 481
+281226646 481
diff --git a/test/ppmchange-roundtrip.test b/test/ppmchange-roundtrip.test
index 78f5b548..c1a35078 100755
--- a/test/ppmchange-roundtrip.test
+++ b/test/ppmchange-roundtrip.test
@@ -3,10 +3,10 @@
 # Also requires: pgmtopbm pnminvert ppmtopgm
 
 
-ppmchange black white white black testgrid.pbm | \
+ppmchange black white white black maze.pbm | \
 pnminvert | ppmtopgm | \
 pgmtopbm -th -val=0.5 | cksum
 
-ppmchange  black white white black testgrid.pbm | \
+ppmchange  black white white black maze.pbm | \
 ppmchange  black white white black | \
 ppmtopgm | pgmtopbm -th -val=0.5 | cksum
diff --git a/test/ppmpat.ok b/test/ppmpat.ok
index 4a9cebd9..f2b355a9 100644
--- a/test/ppmpat.ok
+++ b/test/ppmpat.ok
@@ -1,14 +1,22 @@
-Test 1
+Test 1. Should print: 4008533639 781
 4008533639 781
-Test 2
+Test 2. Should print: 738714211 781
+738714211 781
+Test 3. Should print: 3805937800 9613
 3805937800 9613
-Test 3
+Test 4. Should print: 1586690955 9613
+1586690955 9613
+Test 5. Should print: 2698433077 1549
 2698433077 1549
-Test 4
+Test 6. Should print: 1526189097 1549
+1526189097 1549
+Test 7. Should print: 3705929501 781
 3705929501 781
-Test 5
+Test 8. Should print: 1996587666 781
+1996587666 781
+Test 9. Should print: 3057513592 661
 3057513592 661
-Test 6
+Test 10. Should print: 1861389287 661
 1861389287 661
 Test Invalid
 Expected failure 1 1
diff --git a/test/ppmpat.test b/test/ppmpat.test
index 88fb9fdd..ccba27c2 100755
--- a/test/ppmpat.test
+++ b/test/ppmpat.test
@@ -2,31 +2,43 @@
 # This script tests: ppmpat
 # 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
+echo "Test 1. Should print: 4008533639 781"
+ppmpat -gingham2 \
+       -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
+echo "Test 2. Should print: 738714211 781"
+ppmpat -g2 -mesh \
+       --color=rgb:32/0d/b7,rgb:31/58/a3 16 16 | 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
+echo "Test 3. Should print: 3805937800 9613"
+ppmpat -gingham3 \
+       -color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 64 50 | cksum
 
-# Test 4. Should print: 3705929501 781
-echo "Test 4"
+echo "Test 4. Should print: 1586690955 9613"
+ppmpat -g3 -mesh \
+       -color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 64 50 | cksum
+
+echo "Test 5. Should print: 2698433077 1549"
+ppmpat -madras \
+       --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 32 16 | cksum
+
+echo "Test 6. Should print: 1526189097 1549"
+ppmpat -madras -mesh \
+       --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 32 16 | cksum
+
+echo "Test 7. Should print: 3705929501 781"
 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"
+echo "Test 8. Should print: 1996587666 781"
+ppmpat -tartan -mesh \
+       --color=rgb:32/0d/b7,rgb:31/58/a3,rgb:e9/5e/d4 16 16 | cksum
+
+echo "Test 9. Should print: 3057513592 661"
 ppmpat -argyle1 --color=rgb:ff/ff/ff,rgb:ff/0/0 12 18 | cksum
 
-# Test 6. Should print: 1861389287 661
-echo "Test 6"
+echo "Test 10. Should print: 1861389287 661"
 ppmpat -argyle2 --color=rgb:00/00/00,rgb:ff/80/80,rgb:e0/e0/e0 12 18 | cksum
 
-# Test 7.
 echo "Test Invalid"
 
 tmpdir=${tmpdir:-/tmp}
diff --git a/test/sunicon-roundtrip.ok b/test/sunicon-roundtrip.ok
index 845be5fb..8bfdc3a0 100644
--- a/test/sunicon-roundtrip.ok
+++ b/test/sunicon-roundtrip.ok
@@ -1 +1,4 @@
-2425386270 41
+Test.  Should print 0 three times
+0
+0
+0
diff --git a/test/sunicon-roundtrip.test b/test/sunicon-roundtrip.test
index a52fda68..c5b85909 100755
--- a/test/sunicon-roundtrip.test
+++ b/test/sunicon-roundtrip.test
@@ -1,8 +1,27 @@
 #! /bin/bash
 # This script tests: pbmtosunicon sunicontopnm
-# Also requires: pamcut
+# Also requires: pamcut pnmpad
 
 # Width of Sun icons are multiples of 8.
 
-# Test.  Should print: 2425386270 41
-pbmtosunicon testgrid.pbm | sunicontopnm | pamcut 1 0 14 16 | cksum
+#imgsize=$(pamfile -size maze.pbm | awk '{print "-width="$1, "-height="$2}')
+
+tmpdir=${tmpdir:-/tmp}
+
+maze16_pbm=${tmpdir}/maze16.pbm
+maze32_pbm=${tmpdir}/maze32.pbm
+maze64_pbm=${tmpdir}/maze64.pbm
+
+pamcut -top=0 -left=0 -width=16 -height=16 maze.pbm > ${maze16_pbm} 
+pamcut -top=0 -left=0 -width=32 -height=32 maze.pbm > ${maze32_pbm} 
+pnmpad -width=64 -height=64 maze.pbm > ${maze64_pbm} 
+
+echo "Test.  Should print 0 three times"
+pbmtosunicon ${maze16_pbm} | sunicontopnm | cmp -s - ${maze16_pbm}
+echo $?
+pbmtosunicon ${maze32_pbm} | sunicontopnm | cmp -s - ${maze32_pbm}
+echo $?
+pbmtosunicon ${maze64_pbm} | sunicontopnm | cmp -s - ${maze64_pbm}
+echo $?
+
+rm ${maze16_pbm} ${maze32_pbm} ${maze64_pbm}
\ No newline at end of file
diff --git a/test/targa-roundtrip.ok b/test/targa-roundtrip.ok
index 514f970f..188833f0 100644
--- a/test/targa-roundtrip.ok
+++ b/test/targa-roundtrip.ok
@@ -1,15 +1,15 @@
-Test 1
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-2425386270 41
-Test 2
+Test 1: Should print 281226646 481, cksum of maze.pbm, ten times
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+281226646 481
+Test 2:  Should produce 1571496937 33838, cksum of testimg.red, ten times
 1571496937 33838
 1571496937 33838
 1571496937 33838
@@ -20,19 +20,19 @@ Test 2
 1571496937 33838
 1571496937 33838
 1571496937 33838
-Test 3
+Test 3: Should print 1926073387 101484, cksum of testimg.ppm, four times
 1926073387 101484
 1926073387 101484
 1926073387 101484
 1926073387 101484
-Test 4
+Test 4: Should print 0 0 0 : 0 six times
 0 0 0 : 0
 0 0 0 : 0
 0 0 0 : 0
 0 0 0 : 0
 0 0 0 : 0
 0 0 0 : 0
-Test 5
+Test 5: Should print 0 0 0 : 0 twice, then 0 0 0 0 : 0 six times
 0 0 0 : 0
 0 0 0 : 0
 0 0 0 0 : 0
diff --git a/test/targa-roundtrip.test b/test/targa-roundtrip.test
index 79b01b61..39ea8bd7 100755
--- a/test/targa-roundtrip.test
+++ b/test/targa-roundtrip.test
@@ -4,24 +4,21 @@
 
 tmpdir=${tmpdir:-/tmp}
 
-#Test 1: Should print 2425386270 41, cksum of testgrid.pbm, ten times
-
-echo "Test 1"
+echo "Test 1: Should print 281226646 481, cksum of maze.pbm, ten times"
 
 for mode in "-mono" "-mono -norle" \
             "-cmap" "-cmap -norle" "-cmap16" "-cmap16 -norle" \
             "-rgb"  "-rgb  -norle" "" "-norle"
   do
-  pamtotga ${mode} testgrid.pbm | \
+  pamtotga ${mode} maze.pbm | \
     tgatoppm | ppmtopgm | \
     pgmtopbm -threshold -val 0.5 | cksum
   done
 
-#Test 2:  Should produce 1571496937 33838, cksum of testimg.red, ten times
-
-echo "Test 2"
+echo \
+  "Test 2:  Should produce 1571496937 33838, cksum of testimg.red, ten times"
 
-test_pam=${tmpdir}/testimg.pgm
+test_pam=${tmpdir}/testimg.pam
 pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 > ${test_pam}
 
 for mode in "-mono" "-mono -norle" \
@@ -34,18 +31,15 @@ for mode in "-mono" "-mono -norle" \
 rm ${test_pam}
 
 
-#Test 3: Should print 1926073387 101484, cksum of testimg.ppm, four times
-
-echo "Test 3"
+echo \
+    "Test 3: Should print 1926073387 101484, cksum of testimg.ppm, four times"
 
 for mode in "-rgb" "-rgb -norle" "" "-norle"
   do
   pamtotga ${mode} testimg.ppm | tgatoppm | cksum
   done
 
-#Test 4: Should print 0 six times
-
-echo "Test 4"
+echo "Test 4: Should print 0 0 0 : 0 six times"
 
 test256_ppm=${tmpdir}/test256.ppm
 pnmquant 256 testimg.ppm > ${test256_ppm} || echo "pnmquant failed"
@@ -58,9 +52,8 @@ for mode in "-rgb" "-rgb -norle" "-cmap" "-cmap -norle" "" "-norle"
 done
 
 
-#Test 5: Should print 0 eight times
-
-echo "Test 5"
+echo \
+    "Test 5: Should print 0 0 0 : 0 twice, then 0 0 0 0 : 0 six times"
 
 test256_31_ppm=${tmpdir}/test256-31.ppm
 pamdepth 31 ${test256_ppm} > ${test256_31_ppm} || echo "pamdepth failed"
diff --git a/test/tiff-flate-lzw-roundtrip.ok b/test/tiff-flate-lzw-roundtrip.ok
index 4d5597cc..fb3d98d0 100644
--- a/test/tiff-flate-lzw-roundtrip.ok
+++ b/test/tiff-flate-lzw-roundtrip.ok
@@ -4,4 +4,4 @@
 1079668603 10237
 1079668603 10237
 1079668603 10237
-2425386270 41
+281226646 481
diff --git a/test/tiff-flate-lzw-roundtrip.test b/test/tiff-flate-lzw-roundtrip.test
index 59d4c483..95bedb71 100755
--- a/test/tiff-flate-lzw-roundtrip.test
+++ b/test/tiff-flate-lzw-roundtrip.test
@@ -29,6 +29,6 @@ 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
+pamtotiff -flate maze.pbm | tifftopnm | cksum
 
 rm ${tartan_ppm}
diff --git a/test/tiff-roundtrip.ok b/test/tiff-roundtrip.ok
index 14258de2..5636f3b2 100644
--- a/test/tiff-roundtrip.ok
+++ b/test/tiff-roundtrip.ok
@@ -27,9 +27,9 @@ PPM-bilevel-black-white
 1001018459 4954
 1001018459 4954
 PBM
-2425386270 41
-2425386270 41
-2425386270 41
+281226646 481
+281226646 481
+281226646 481
 Extract from multi-image TIFF
 1926073387 101484
 1646869394 29498
diff --git a/test/tiff-roundtrip.test b/test/tiff-roundtrip.test
index 55aba278..99e14588 100755
--- a/test/tiff-roundtrip.test
+++ b/test/tiff-roundtrip.test
@@ -78,12 +78,12 @@ pamtotiff -mb ${argylegray_ppm} -append -output ${multiimage_tiff} && \
   tifftopnm ${multiimage_tiff} | pampick 4 | cksum
 
 # PBM image
-# Should print 2425386270 41 three times
+# Should print 281226646 481 three times
 
 echo PBM
-pamtotiff testgrid.pbm | tifftopnm | cksum
-pamtotiff -g3 -fill testgrid.pbm | tifftopnm | cksum
-pamtotiff -g4 -mb testgrid.pbm -append -output ${multiimage_tiff} && \
+pamtotiff maze.pbm | tifftopnm | cksum
+pamtotiff -g3 -fill maze.pbm | tifftopnm | cksum
+pamtotiff -g4 -mb maze.pbm -append -output ${multiimage_tiff} && \
   tifftopnm ${multiimage_tiff} | pampick 5 | cksum
 
 # Extract individual images from multi-image tiff file
diff --git a/test/wbmp-roundtrip.ok b/test/wbmp-roundtrip.ok
index 845be5fb..5168378d 100644
--- a/test/wbmp-roundtrip.ok
+++ b/test/wbmp-roundtrip.ok
@@ -1 +1 @@
-2425386270 41
+281226646 481
diff --git a/test/wbmp-roundtrip.test b/test/wbmp-roundtrip.test
index b651c3d0..6197032c 100755
--- a/test/wbmp-roundtrip.test
+++ b/test/wbmp-roundtrip.test
@@ -3,5 +3,5 @@
 # Also requires:
 
 
-# Should print 2425386270 41, cksum of testgrid.pbm
-pbmtowbmp testgrid.pbm | wbmptopbm | cksum
+# Should print 281226646 481, cksum of maze.pbm
+pbmtowbmp maze.pbm | wbmptopbm | cksum
diff --git a/test/winicon-roundtrip.ok b/test/winicon-roundtrip.ok
index 4ba2606e..73e5030c 100644
--- a/test/winicon-roundtrip.ok
+++ b/test/winicon-roundtrip.ok
@@ -3,10 +3,10 @@ Test 1. Should print 4241318573 6973 four times
 4241318573 6973
 4241318573 6973
 4241318573 6973
-Test 1. Should print 819454437 1093 six times
-819454437 1093
-819454437 1093
-819454437 1093
-819454437 1093
-819454437 1093
-819454437 1093
+Test 1. Should print 1009647580 1093 six times
+1009647580 1093
+1009647580 1093
+1009647580 1093
+1009647580 1093
+1009647580 1093
+1009647580 1093
diff --git a/test/winicon-roundtrip.test b/test/winicon-roundtrip.test
index 00c78400..b4814fee 100755
--- a/test/winicon-roundtrip.test
+++ b/test/winicon-roundtrip.test
@@ -1,6 +1,6 @@
 #! /bin/bash
 # This script tests: pamtowinicon ppmtowinicon winicontopam
-# Also requires: pamchannel pamcut pamdepth pamtopam pngtopam pnmtile pnmtopng
+# Also requires: pamchannel pamcut pamdepth pamtopam
 
 tmpdir=${tmpdir:-/tmp}
 test_pam=${tmpdir}/testimg.pam
@@ -18,9 +18,9 @@ pamtowinicon -pngthreshold=1   ${test_pam} | winicontopam | \
 
 rm ${test_pam}
 
-echo "Test 1. Should print 819454437 1093 six times"
+echo "Test 1. Should print 1009647580 1093 six times"
 
-pnmtile 32 32 testgrid.pbm | pamtopam | \
+pamcut -top=0 -left=0 -width=32 -height=32 maze.pbm | pamtopam | \
   tee ${test_pam} | cksum
 pamtowinicon ${test_pam} | winicontopam | \
   pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum
@@ -33,5 +33,6 @@ pamtowinicon -pngthreshold=1   ${test_pam} | winicontopam |
 
 rm ${test_pam}
 
-pnmtile 32 32 testgrid.pbm | ppmtowinicon | winicontopam | \
+pamcut -top=0 -left=0 -width=32 -height=32 maze.pbm | \
+  ppmtowinicon | winicontopam | \
   pamdepth 1 | pamchannel -tupletype="BLACKANDWHITE" 0 | cksum
diff --git a/test/winicon-roundtrip2.test b/test/winicon-roundtrip2.test
index 9d55ebee..d1f29cc9 100755
--- a/test/winicon-roundtrip2.test
+++ b/test/winicon-roundtrip2.test
@@ -1,7 +1,6 @@
 #! /bin/bash
 # This script tests: pamtowinicon winicontopam
-# Also requires: pamchannel pamdepth pamstack pamtopam pbmmake pngtopam
-# Also requires: pnmtopng ppmpat
+# Also requires: pamchannel pamdepth pamstack pamtopam pbmmake ppmpat
 
 tmpdir=${tmpdir:-/tmp}
 test_pam=${tmpdir}/testimg.pam
diff --git a/test/xbm-roundtrip.ok b/test/xbm-roundtrip.ok
index a676a1f2..82c6b5d8 100644
--- a/test/xbm-roundtrip.ok
+++ b/test/xbm-roundtrip.ok
@@ -1,2 +1,3 @@
-2425386270 41
-2425386270 41
+Test.  Should print 281226646 481 twice
+281226646 481
+281226646 481
diff --git a/test/xbm-roundtrip.test b/test/xbm-roundtrip.test
index e84d6fc3..3f06e9a5 100755
--- a/test/xbm-roundtrip.test
+++ b/test/xbm-roundtrip.test
@@ -2,6 +2,7 @@
 # This script tests: pbmtoxbm xbmtopbm
 # Also requires:
 
+echo "Test.  Should print 281226646 481 twice"
 
-pbmtoxbm testgrid.pbm | xbmtopbm | cksum
-pbmtoxbm -x10 testgrid.pbm | xbmtopbm | cksum
+pbmtoxbm maze.pbm | xbmtopbm | cksum
+pbmtoxbm -x10 maze.pbm | xbmtopbm | cksum
diff --git a/test/xpm-roundtrip.ok b/test/xpm-roundtrip.ok
index 845be5fb..5168378d 100644
--- a/test/xpm-roundtrip.ok
+++ b/test/xpm-roundtrip.ok
@@ -1 +1 @@
-2425386270 41
+281226646 481
diff --git a/test/xpm-roundtrip.test b/test/xpm-roundtrip.test
index fd0253b1..61a5192d 100755
--- a/test/xpm-roundtrip.test
+++ b/test/xpm-roundtrip.test
@@ -5,5 +5,5 @@
 
 #ppmtoxpm -hexonly testimg.ppm | \
 # xpmtoppm  | cksum
-ppmtoxpm testgrid.pbm | xpmtoppm | \
+ppmtoxpm maze.pbm | xpmtoppm | \
   ppmtopgm | pgmtopbm -th -value=0.5 | cksum
diff --git a/test/xwd-roundtrip.ok b/test/xwd-roundtrip.ok
index 25d3d871..864d737a 100644
--- a/test/xwd-roundtrip.ok
+++ b/test/xwd-roundtrip.ok
@@ -1,3 +1,6 @@
+Test 1.  Should produce 1571496937 33838, cksum of testimg.red
 1571496937 33838
+Test 2.  Should produce 1926073387 101484
 1926073387 101484
-2425386270 41
+Test 3.  Should produce 281226646 481
+281226646 481
diff --git a/test/xwd-roundtrip.test b/test/xwd-roundtrip.test
index cd0d38ad..4dffbbb0 100755
--- a/test/xwd-roundtrip.test
+++ b/test/xwd-roundtrip.test
@@ -2,15 +2,14 @@
 # This script tests: pnmtoxwd xwdtopnm
 # Also requires: pamchannel pamtopnm pamdepth
 
-
-# Test 1.  Should produce 1571496937 33838, cksum of testimg.red
+echo "Test 1.  Should produce 1571496937 33838, cksum of testimg.red"
 pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
   pnmtoxwd | xwdtopnm | pamdepth 255 | cksum
 
-# Test 2.  Should produce 1926073387 101484
-pnmtoxwd --quiet  testimg.ppm | \
+echo "Test 2.  Should produce 1926073387 101484"
+pnmtoxwd --quiet testimg.ppm | \
   xwdtopnm --quiet | pamdepth 255 | cksum
 
-# Test 3.  Should produce 2425386270 41
-pnmtoxwd --quiet  testgrid.pbm | \
+echo "Test 3.  Should produce 281226646 481"
+pnmtoxwd --quiet maze.pbm | \
   xwdtopnm | cksum