about summary refs log tree commit diff
path: root/test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2021-03-23 23:42:47 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2021-03-23 23:42:47 +0000
commitc99a377d51e2980dcd4766b533c2d05d5293e756 (patch)
treeb54f4b12dd6b7135a1f8d215f839b717feb30992 /test
parent7b8f9eec8c0936fea2b2b87f8652246a665d2998 (diff)
downloadnetpbm-mirror-c99a377d51e2980dcd4766b533c2d05d5293e756.tar.gz
netpbm-mirror-c99a377d51e2980dcd4766b533c2d05d5293e756.tar.xz
netpbm-mirror-c99a377d51e2980dcd4766b533c2d05d5293e756.zip
random number tests et al
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4060 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test')
-rwxr-xr-xtest/Execute-Tests11
-rw-r--r--test/Makefile21
-rwxr-xr-xtest/pamditherbw-random.ok6
-rwxr-xr-xtest/pamditherbw-random.test23
-rwxr-xr-xtest/pamexec.test5
-rwxr-xr-xtest/pamrecolor.ok11
-rwxr-xr-xtest/pamrecolor.test43
-rwxr-xr-xtest/pbmlife.ok63
-rwxr-xr-xtest/pbmlife.test13
-rw-r--r--test/pgmnoise.rand-ok3
-rwxr-xr-xtest/pgmnoise.test88
-rw-r--r--test/ppmforge-parameters.ok8
-rwxr-xr-xtest/ppmforge-parameters.test26
-rw-r--r--test/ppmforge.rand-ok3
-rw-r--r--test/ppmpat-random.rand-ok7
-rwxr-xr-xtest/ppmpat-random.test18
-rw-r--r--test/ppmrough.rand-ok3
-rwxr-xr-xtest/ppmshift.ok14
-rwxr-xr-xtest/ppmshift.test27
-rwxr-xr-xtest/ppmspread.ok6
-rwxr-xr-xtest/ppmspread.test12
-rw-r--r--test/random-generator.ok219
-rwxr-xr-xtest/random-generator.test68
-rw-r--r--test/winicon-roundtrip2.ok2
-rwxr-xr-xtest/winicon-roundtrip2.test10
25 files changed, 648 insertions, 62 deletions
diff --git a/test/Execute-Tests b/test/Execute-Tests
index 3530d978..7a02fdef 100755
--- a/test/Execute-Tests
+++ b/test/Execute-Tests
@@ -178,6 +178,7 @@ elif [ $VALGRIND_TESTS = "on" ]
   mkdir $valdir
  
   vg_command_base="valgrind --trace-children=yes";
+  # 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 \
@@ -185,6 +186,7 @@ elif [ $VALGRIND_TESTS = "on" ]
            testrandom Available-Testprog
 
     # Tell valgrind not to probe execution of the above programs.
+    # You may add programs in Netpbm to the above to speed up tests.
 
     do vg_skip=$vg_skip"/*/"$i","; done;
 
@@ -238,10 +240,11 @@ if [ $VALGRIND_TESTS = "on" ]
 fi
 
 # Execute a single test and test its result.
-# But first check if the .ok file exists.  (Some .ok files are
-# dynamically created.)  Then see if target programs and requirements
-# are in place.  If either of these conditions are not met, do
-# not execute the test and report "Not Testable".
+# But first check if the .ok file exists.
+# (In past versions certain .ok files were dynamically created.)
+# Then see if target programs and requirements are in place.  If
+# either of these conditions are not met, do not execute the test and
+# report "Not Testable".
 
 if [ ! -s ${srcdir}/${tname%.test}.ok ]
 then
diff --git a/test/Makefile b/test/Makefile
index c640dfff..732113f3 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -8,27 +8,14 @@ include $(BUILDDIR)/config.mk
 
 MERGE_OBJECTS =
 
-PROGS = testrandom
-
-OKSTOGENERATE = $(patsubst %.rand-ok, %.ok, $(wildcard *.rand-ok))
-
-all: $(PROGS) $(OKSTOGENERATE)
-
-testrandom.o: testrandom.c
-	$(CC_FOR_BUILD) -c -o $@ $(CFLAGS_FOR_BUILD) $<
-
-testrandom: testrandom.o
-	$(LD_FOR_BUILD) -o $@ $(LDFLAGS_FOR_BUILD) $<
-
-RAND_VARIETY ?= $(shell ./testrandom -x)
-
-$(OKSTOGENERATE): %.ok: %.rand-ok testrandom
-	sed -n "/^$(RAND_VARIETY)|/s/^$(RAND_VARIETY)|//p" $< > $@
+PROGS =
 
 OMIT_TEST_RULE = 1
 include $(SRCDIR)/common.mk
 
+all:
+
 distclean clean: cleanlocal
 .PHONY: cleanlocal
 cleanlocal:
-	rm -f $(PROGS) $(patsubst %.rand-ok,%.ok,$(wildcard *.rand-ok))
+
diff --git a/test/pamditherbw-random.ok b/test/pamditherbw-random.ok
new file mode 100755
index 00000000..d21e3613
--- /dev/null
+++ b/test/pamditherbw-random.ok
@@ -0,0 +1,6 @@
+Test: Floyd-Steinberg
+Should print 3849876047 33894
+3849876047 33894
+Test: Atkinson
+Should print 2887295695 33894
+2887295695 33894
diff --git a/test/pamditherbw-random.test b/test/pamditherbw-random.test
new file mode 100755
index 00000000..5bff4bac
--- /dev/null
+++ b/test/pamditherbw-random.test
@@ -0,0 +1,23 @@
+#! /bin/bash
+# This script tests: pamditherbw
+# Also requires: pamchannel pamtopnm
+
+tmpdir=${tmpdir:-/tmp}
+test_red=${tmpdir}/testimg.red
+
+# Test 1.  Floyd-Steinberg
+echo "Test: Floyd-Steinberg"
+echo "Should print 3849876047 33894"
+
+pamchannel -infile=testimg.ppm -tupletype="GRAYSCALE" 0 | pamtopnm | \
+  tee ${test_red} | \
+  pamditherbw -fs -randomseed=1 | cksum
+
+
+# Test 2. Atkinson
+echo "Test: Atkinson"
+echo "Should print 2887295695 33894"
+
+pamditherbw -atkinson -randomseed=1 ${test_red} | cksum
+
+rm ${test_red}
\ No newline at end of file
diff --git a/test/pamexec.test b/test/pamexec.test
index 44c11339..ec57f4ae 100755
--- a/test/pamexec.test
+++ b/test/pamexec.test
@@ -27,7 +27,8 @@ pamexec "pbmtog3 -no | g3topbm" ${combined_pbm}  | cksum
 cat ${combined_pbm}  | cksum
 
 echo "Invalid command" 1>&2
-echo "Errors message should appear below the line." 1>&2
+echo "Executes quietly." 1>&2
+echo "Errors message should not appear below the line." 1>&2
 echo "-----------------------------------------------------------" 1>&2
 
 echo "Test Invalid: Should not print anything"
@@ -35,4 +36,4 @@ echo "Test Invalid: Should not print anything"
 pamexec "false" ${combined_pbm}
 pamexec "pamfile | false" ${combined_pbm}
 
-rm ${combined_pbm}
\ No newline at end of file
+rm ${combined_pbm}
diff --git a/test/pamrecolor.ok b/test/pamrecolor.ok
new file mode 100755
index 00000000..0a6b5413
--- /dev/null
+++ b/test/pamrecolor.ok
@@ -0,0 +1,11 @@
+Test 1. Should produce 3500040755 101532
+3500040755 101532
+Test 2. Should produce 3500040755 101532 twice
+3500040755 101532
+3500040755 101532
+Expected failure 1 1
+Expected failure 2 1
+Expected failure 3 1
+Expected failure 4 1
+Expected failure 5 1
+Expected failure 6 1
diff --git a/test/pamrecolor.test b/test/pamrecolor.test
new file mode 100755
index 00000000..cc79a124
--- /dev/null
+++ b/test/pamrecolor.test
@@ -0,0 +1,43 @@
+#! /bin/bash
+# This script tests: pamrecolor
+# Also requires: ppmtopgm pgmmake
+
+tmpdir=${tmpdir:-/tmp}
+base_pgm=${tmpdir}/base.pgm
+
+pgmmake 0.5 230 150 > ${base_pgm}
+
+echo "Test 1. Should produce 3500040755 101532"
+
+pamrecolor --colorfile=${base_pgm} testimg.ppm | cksum
+
+echo "Test 2. Should produce 3500040755 101532 twice"
+
+pamrecolor --targetcolor=rgb:80/80/80 testimg.ppm | cksum
+pamrecolor --colorspace=ntsc --targetcolor=rgb:80/80/80 testimg.ppm | cksum
+
+
+test_out=${tmpdir}/test_out
+truncated_file=${tmpdir}/truncated.txt
+echo P6 > ${truncated_file}
+
+echo 1>&2
+echo "Invalid command-line argument combinations." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pamrecolor --targetcolor=rgb:00/11/22 --colorfile={base1_pgm} testimg.ppm > ${test_out} || \
+   echo -n "Expected failure 1"; test -s ${test_out}; echo " "$?
+pamrecolor --rmult=0.3  --gmult=0.3  --bmult=0.3 --colorfile={base1_pgm} testimg.ppm > ${test_out} || \
+   echo -n "Expected failure 2"; test -s ${test_out}; echo " "$?
+pamrecolor --colorspace=void --targetcolor=rgb:80/80/80 testimg.ppm > ${test_out} || \
+   echo -n "Expected failure 3"; test -s ${test_out}; echo " "$?
+pamrecolor --targetcolor=vague testimg.ppm > ${test_out} || \
+   echo -n "Expected failure 4"; test -s ${test_out}; echo " "$?
+pamrecolor --colorfile=${truncated_file} testimg.ppm > ${test_out} || \
+   echo -n "Expected failure 5"; test -s ${test_out}; echo " "$?
+pamrecolor --rmult=0.2989 --gmult=0.5866 testimg.ppm > ${test_out} || \
+   echo -n "Expected failure 6"; test -s ${test_out}; echo " "$?
+
+
+rm ${base_pgm} ${test_out} ${truncated_file}
\ No newline at end of file
diff --git a/test/pbmlife.ok b/test/pbmlife.ok
new file mode 100755
index 00000000..bd214dfb
--- /dev/null
+++ b/test/pbmlife.ok
@@ -0,0 +1,63 @@
+P1
+63 29
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000001111111000111100000000000111000111000000000000000
+000000000000000100001001100110000000001000101001100000000000000
+000000000000000100000001000010000000001000101000100000000000000
+000000000000000100010010000001000010001100101000100000000000000
+000000000000000111110010000001000010000111001100100000000000000
+000000000000000100010010000001001111101001100111100000000000000
+000000000000000100000001000010000010001000100001000000000000000
+000000000000000100000001100110000010001000100011000000000000000
+000000000000001111000000111100000000000111001100000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+000000000000000000000000000000000000000000000000000000000000000
+
+   tiles:	1722
+ x-edges:	1812
+ y-edges:	1842
+vertices:	1920
+    area:	1722
+perimeter:	420
+ eulerchi:	-12
+
+   tiles:	17
+ x-edges:	33
+ y-edges:	33
+vertices:	64
+    area:	17
+perimeter:	64
+ eulerchi:	15
+
+   tiles:	2
+ x-edges:	3
+ y-edges:	4
+vertices:	6
+    area:	2
+perimeter:	6
+ eulerchi:	1
+
+   tiles:	0
+ x-edges:	0
+ y-edges:	0
+vertices:	0
+    area:	0
+perimeter:	0
+ eulerchi:	0
diff --git a/test/pbmlife.test b/test/pbmlife.test
new file mode 100755
index 00000000..b4d65ec4
--- /dev/null
+++ b/test/pbmlife.test
@@ -0,0 +1,13 @@
+#! /bin/bash
+# This script tests: pbmlife pbmminkowski
+# Also requires: pbmtext
+
+pbmtext FO+89 -plain
+echo
+pbmtext FO+89 | pbmminkowski
+echo
+pbmtext FO+89 | pbmlife | pbmminkowski
+echo
+pbmtext FO+89 | pbmlife | pbmlife | pbmminkowski
+echo
+pbmtext FO+89 | pbmlife | pbmlife | pbmlife | pbmminkowski
diff --git a/test/pgmnoise.rand-ok b/test/pgmnoise.rand-ok
deleted file mode 100644
index b69f48e5..00000000
--- a/test/pgmnoise.rand-ok
+++ /dev/null
@@ -1,3 +0,0 @@
-000|0
-081|2005134911 10015
-082|3516404574 10015
diff --git a/test/pgmnoise.test b/test/pgmnoise.test
index 03301ce6..21a2729e 100755
--- a/test/pgmnoise.test
+++ b/test/pgmnoise.test
@@ -1,7 +1,89 @@
 #! /bin/bash
 # This script tests: pgmnoise
-# Also requires:
+# Also requires: pgmhist pamvalidate
 
-# Should print: 1663614689 10015 (Glibc)
-#               3516404574 10015 (MAC OS)
+echo "Test 1."
+echo "Should print: 2132901423 10015" # (Mersenne Twister)
+#                   1663614689 10015 (Glibc rand())
+#                   3516404574 10015 (MAC OS rand())
 pgmnoise --randomseed=0 100 100 | cksum
+
+
+echo "Test 2."
+# Output is similar to that of Test 2. of random-generator.test
+# The lowest four decimal digits are printed.
+
+pgmnoise --randomseed=5489 -maxval=9999 -plain 5 20
+
+
+echo "Test 3."
+for maxval in `seq 16` 255 65535
+  do
+  echo ${maxval}
+  pgmnoise -maxval=${maxval} -randomseed=1 -plain 16 1 | tr '\n' ' ' 
+  done
+echo
+
+echo "Test 4."
+# Check for maxval violation
+for maxval in `seq 16` 30 31 32 254 255 256 65534 65535
+  do
+  echo -n ${maxval} " "
+  pgmnoise -maxval=${maxval} -randomseed=1 -plain ${maxval} 10 | \
+    pamvalidate | pamfile
+  done
+
+echo "Test 5."
+echo "Should print four identical lines"
+# width height values do not affect random number sequence 
+for xysize in "1 10000" "100 100" "250 40" "1000 10"
+  do pgmnoise --randomseed=0 ${xysize} | pgmhist -mach | cksum
+  done
+
+
+tmpdir=${tmpdir:-/tmp}
+messages=${tmpdir}/messages
+
+echo "Test 6."
+echo "First column should be 2^n - 1"
+# The "pool" method of generating pixvals is used iff maxval is
+# a power of 2 minus 1: 1, 3, 7, 15, 31 ...
+for maxval in `seq 35; seq 60 69; seq 120 129; seq 250 259` 
+  do
+  pgmnoise -maxval=${maxval} -randomseed=1 -verbose 1 1 > /dev/null \
+  2> ${messages}
+  awk -v mval=${maxval} '/method/ && /pool/ { print mval, $0 }' ${messages}
+  done
+
+  rm ${messages}
+
+
+echo "Test Invalid"
+
+test_out=${tmpdir}/test_out
+
+echo 1>&2
+echo "Invalid command-line arguments." 1>&2
+echo "Error messages should appear below the line." 1>&2
+echo "-----------------------------------------------------------" 1>&2
+
+pgmnoise 0 0  > ${test_out} || \
+   echo -n "Expected failure 1"; test -s ${test_out}; echo " "$?
+pgmnoise 0 1  > ${test_out} || \
+   echo -n "Expected failure 2"; test -s ${test_out}; echo " "$?
+pgmnoise 1 0  > ${test_out} || \
+   echo -n "Expected failure 3"; test -s ${test_out}; echo " "$?
+pgmnoise      > ${test_out} || \
+   echo -n "Expected failure 4"; test -s ${test_out}; echo " "$?
+pgmnoise 1    > ${test_out} || \
+   echo -n "Expected failure 5"; test -s ${test_out}; echo " "$?
+pgmnoise 100 -1 > ${test_out} || \
+   echo -n "Expected failure 6"; test -s ${test_out}; echo " "$?
+pgmnoise -randomseed=-1 100 100  > ${test_out} || \
+   echo -n "Expected failure 7"; test -s ${test_out}; echo " "$?
+pgmnoise -maxval=-1 100 100  > ${test_out} || \
+   echo -n "Expected failure 8"; test -s ${test_out}; echo " "$?
+pgmnoise -maxval=0 100 100  > ${test_out} || \
+   echo -n "Expected failure 9"; test -s ${test_out}; echo " "$?
+pgmnoise -maxval=$((256 * 256 * 256 * 256)) 10 10 > ${test_out} || \
+   echo -n "Expected failure 10"; test -s ${test_out}; echo " "$?
diff --git a/test/ppmforge-parameters.ok b/test/ppmforge-parameters.ok
index 37d89ccd..c8edc5dd 100644
--- a/test/ppmforge-parameters.ok
+++ b/test/ppmforge-parameters.ok
@@ -1,6 +1,8 @@
-Test 1
+Test 1: Should print 256 256
 256 256
-100 90
+Test 2: Should print 40 30
+40 30
+Test 3: Should print 90 90
 90 90
 Test Invalid
 Expected failure 1 1
@@ -8,3 +10,5 @@ Expected failure 2 1
 Expected failure 3 1
 Expected failure 4 1
 Expected failure 5 1
+Expected failure 6 1
+Expected failure 7 1
diff --git a/test/ppmforge-parameters.test b/test/ppmforge-parameters.test
index 28a92916..39f199ea 100755
--- a/test/ppmforge-parameters.test
+++ b/test/ppmforge-parameters.test
@@ -2,17 +2,21 @@
 # This script tests: ppmforge
 # Also requires: pamfile
 
-echo "Test 1"
+echo "Test 1: Should print 256 256"
 
-# Should print 256 256
+# Default size is 256 256
 ppmforge -night | pamfile -size
 
+echo "Test 2: Should print 40 30"
+
 # Width is adjusted if not even
-# becomes 100 in this case
-ppmforge -night -width=99 -height=90 | pamfile -size
+# becomes 40 in this case
+ppmforge -night -width=39 -height=30 | pamfile -size
+
+echo "Test 3: Should print 90 90"
 
 # Width is adjusted if smaller than height
-# brought up to 100 in this case
+# brought up to 90 in this case
 ppmforge -night -width=80 -height=90 | pamfile -size
 
 echo "Test Invalid"
@@ -27,13 +31,17 @@ echo "-----------------------------------------------------------" 1>&2
 
 ppmforge -night  -dimension=0  > ${test_out} || \
    echo -n "Expected failure 1"; test -s ${test_out}; echo " "$?
-ppmforge -clouds -mesh=1.99    > ${test_out} || \
+ppmforge  -dimension=10  > ${test_out} || \
    echo -n "Expected failure 2"; test -s ${test_out}; echo " "$?
-ppmforge -clouds -power=0      > ${test_out} || \
+ppmforge  -dimension=-1  > ${test_out} || \
    echo -n "Expected failure 3"; test -s ${test_out}; echo " "$?
-ppmforge         -ice=0        > ${test_out} || \
+ppmforge -clouds -mesh=1.99    > ${test_out} || \
    echo -n "Expected failure 4"; test -s ${test_out}; echo " "$?
-ppmforge         -glaciers=0   > ${test_out} || \
+ppmforge -clouds -power=0      > ${test_out} || \
    echo -n "Expected failure 5"; test -s ${test_out}; echo " "$?
+ppmforge         -ice=-1       > ${test_out} || \
+   echo -n "Expected failure 6"; test -s ${test_out}; echo " "$?
+ppmforge         -glaciers=-1  > ${test_out} || \
+   echo -n "Expected failure 7"; test -s ${test_out}; echo " "$?
 
 rm ${test_out}
diff --git a/test/ppmforge.rand-ok b/test/ppmforge.rand-ok
deleted file mode 100644
index c8b3ac9f..00000000
--- a/test/ppmforge.rand-ok
+++ /dev/null
@@ -1,3 +0,0 @@
-000|0
-081|3634219838 196623
-082|3262664440 196623
diff --git a/test/ppmpat-random.rand-ok b/test/ppmpat-random.rand-ok
deleted file mode 100644
index eb8779ab..00000000
--- a/test/ppmpat-random.rand-ok
+++ /dev/null
@@ -1,7 +0,0 @@
-000|0
-081|2219119109 36015
-081|3436846137 16813
-081|908097729 16813
-082|3606254242 36015
-082|3615722579 16813
-082|1756684515 16813
diff --git a/test/ppmpat-random.test b/test/ppmpat-random.test
index a6daa982..44dd2485 100755
--- a/test/ppmpat-random.test
+++ b/test/ppmpat-random.test
@@ -7,16 +7,22 @@
 
 # These tests require random numbers.
 
-# Test 1. Should print: 2219119109 36015 (glibc)
-#                       3606254242 36015 (MAC OS)
+echo "Test 1. Should print: 1366170000 36015" # Mersenne Twister
+#                           2219119109 36015 (glibc rand())
+#                           3606254242 36015 (MAC OS rand())
+
 ppmpat --randomseed=0 -camo 100 120 | cksum
 
-# Test 2. Should print: 3436846137 16813 (glibc)
-#                       3615722579 16813 (MAC OS)
+echo "Test 2. Should print: 4073196212 16813" # Mersenne Twister
+#                       3436846137 16813 (glibc)
+#                       3615722579 16813 (MAC OS rand())
+
 ppmpat --randomseed=0 -anticamo 80 70 | cksum
 
-# Test 3. Should print: 908097729 16813 (glibc)
-#                       1756684515 16813 (MAC OS)
+echo "Test 3. Should print: 2292015301 16813" # Mersenne Twister 
+#                       908097729 16813 (glibc rand())
+#                       1756684515 16813 (MAC OS rand())
+
 ppmpat --randomseed=0 --color \
   rgb:55/c0/34,rgb:0/ff/0,rgb:0/ee/0,rgb:0/cd/0,rgb:0/8b/0,rgb:4f/4f/2f \
   -camo 80 70 | cksum
diff --git a/test/ppmrough.rand-ok b/test/ppmrough.rand-ok
deleted file mode 100644
index 216545c7..00000000
--- a/test/ppmrough.rand-ok
+++ /dev/null
@@ -1,3 +0,0 @@
-000|0
-081|378403602 30015
-082|378403602 30015
diff --git a/test/ppmshift.ok b/test/ppmshift.ok
new file mode 100755
index 00000000..e18de8f0
--- /dev/null
+++ b/test/ppmshift.ok
@@ -0,0 +1,14 @@
+Test 1. Should print: 3705777303 101484
+3705777303 101484
+Test 2. Should print: 202790723 685
+202790723 685
+Test 3. Should print: 0 : 0
+0 : 0
+Test 4. (15) Should print: 0 : 0
+0 : 0
+Test 4. (16) Should print: 0 : 0
+0 : 0
+Test 4. (20) Should print: 0 : 0
+0 : 0
+Test 4. (1000) Should print: 0 : 0
+0 : 0
diff --git a/test/ppmshift.test b/test/ppmshift.test
new file mode 100755
index 00000000..cd086d68
--- /dev/null
+++ b/test/ppmshift.test
@@ -0,0 +1,27 @@
+#! /bin/bash
+# This script tests: ppmshift
+# Also requires:
+
+echo "Test 1. Should print: 3705777303 101484"
+ppmshift -seed=1 10 testimg.ppm | cksum
+
+echo "Test 2. Should print: 202790723 685"
+ppmshift -seed=1 1 testgrid.pbm | cksum
+
+echo "Test 3. Should print: 0 : 0"
+ppmshift -seed=1 0 testimg.ppm | cmp -s - testimg.ppm | \
+  echo ${PIPESTATUS[@]} ":" $?
+
+tmpdir=${tmpdir:-/tmp}
+test_pbm=${tmpdir}/test.pbm
+
+ppmshift -seed=2 14 testgrid.pbm > ${test_pbm}
+
+for i in 15 16 20 1000
+  do
+  echo "Test 4. ("$i") Should print: 0 : 0"
+  ppmshift -seed=2 $i testgrid.pbm > ${test_pbm} | cmp -s - testgrid.ppm | \
+    echo ${PIPESTATUS[@]} ":" $?
+  done
+
+rm ${test_pbm}
\ No newline at end of file
diff --git a/test/ppmspread.ok b/test/ppmspread.ok
new file mode 100755
index 00000000..7d44ab8e
--- /dev/null
+++ b/test/ppmspread.ok
@@ -0,0 +1,6 @@
+Test 1. Should print 639729144 101484
+639729144 101484
+Test 2. Should print 3278353642 685
+3278353642 685
+Test 3. Should print 2425386270 41
+2425386270 41
diff --git a/test/ppmspread.test b/test/ppmspread.test
new file mode 100755
index 00000000..871f7438
--- /dev/null
+++ b/test/ppmspread.test
@@ -0,0 +1,12 @@
+#! /bin/bash
+# This script tests: ppmspread
+# Also requires: ppmtopgm pgmtopbm
+
+echo "Test 1. Should print 639729144 101484"
+ppmspread -randomseed=1 10 testimg.ppm | cksum
+
+echo "Test 2. Should print 3278353642 685"
+ppmspread -randomseed=1 1 testgrid.pbm | cksum
+
+echo "Test 3. Should print 2425386270 41"
+ppmspread -randomseed=1 0 testgrid.pbm | ppmtopgm | pgmtopbm | cksum
diff --git a/test/random-generator.ok b/test/random-generator.ok
new file mode 100644
index 00000000..e137d901
--- /dev/null
+++ b/test/random-generator.ok
@@ -0,0 +1,219 @@
+Test 1: Should produce:
+P2
+12 1
+1023
+720 296 192 858 101 57 298 629 804 1019 64 617
+Above output is for Mersenne Twister
+P2
+12 1
+1023
+720 296 192 858 101 57 298 629 804 1019 64 617
+
+Test 2: Mersenne Twister random number generator
+Should produce:
+3499211612  581869302 3890346734 3586334585  545404204
+4161255391 3922919429  949333985 2715962298 1323567403
+ ... 
+ 297480282 1101405687 1473439254 2634793792 1341017984
+ Total 1000 integers, 200 lines
+
+3499211612  581869302 3890346734 3586334585  545404204 
+4161255391 3922919429  949333985 2715962298 1323567403 
+ 418932835 2350294565 1196140740  809094426 2348838239 
+4264392720 4112460519 4279768804 4144164697 4156218106 
+ 676943009 3117454609 4168664243 4213834039 4111000746 
+ 471852626 2084672536 3427838553 3437178460 1275731771 
+ 609397212   20544909 1811450929  483031418 3933054126 
+2747762695 3402504553 3772830893 4120988587 2163214728 
+2816384844 3427077306  153380495 1551745920 3646982597 
+ 910208076 4011470445 2926416934 2915145307 1712568902 
+3254469058 3181055693 3191729660 2039073006 1684602222 
+1812852786 2815256116  746745227  735241234 1296707006 
+3032444839 3424291161  136721026 1359573808 1189375152 
+3747053250  198304612  640439652  417177801 4269491673 
+3536724425 3530047642 2984266209  537655879 1361931891 
+3280281326 4081172609 2107063880  147944788 2850164008 
+1884392678  540721923 1638781099  902841100 3287869586 
+ 219972873 3415357582  156513983  802611720 1755486969 
+2103522059 1967048444 1913778154 2094092595 2775893247 
+3410096536 3046698742 3955127111 3241354600 3468319344 
+1185518681 3031277329 2919300778   12105075 2813624502 
+3052449900  698412071 2765791248  511091141 1958646067 
+2140457296 3323948758 4122068897 2464257528 1461945556 
+3765644424 2513705832 3471087299  961264978   76338300 
+3226667454 3527224675 1095625157 3525484323 2173068963 
+4037587209 3002511655 1772389185 3826400342 1817480335 
+4120125281 2495189930 2350272820  678852156  595387438 
+3271610651  641212874  988512770 1105989508 3477783405 
+3610853094 4245667946 1092133642 1427854500 3497326703 
+1287767370 1045931779   58150106 3991156885  933029415 
+1503168825 3897101788  844370145 3644141418 1078396938 
+4101769245 2645891717 3345340191 2032760103 4241106803 
+1510366103  290319951 3568381791 3408475658 2513690134 
+2553373352 2361044915 3147346559 3939316793 2986002498 
+1227669233 2919803768 3252150224 1685003584 3237241796 
+2411870849 1634002467  893645500 2438775379 2265043167 
+ 325791709 1736062366  231714000 1515103006 2279758133 
+2546159170 3346497776 1530490810 4011545318 4144499009 
+ 557942923  663307952 2443079012 1696117849 2016017442 
+1663423246   51119001 3122246755 1447930741 1668894615 
+ 696567687 3983551422 3411426125 1873110678 1336658413 
+3705174600 2270032533 2664425968  711455903  513451233 
+2585492744 2027039028 1129453058 1461232481 2809248324 
+2275654012 2960153730 3075629128 3213286615 4245057188 
+1935061435 3094495853  360010077 3919490483  983448591 
+2171099548 3922754098 2397746050  654458600 2161184684 
+3546856898 1986311591 2312163142 2347594600 4278366025 
+1922360368  335761339 3669839044 1901288696 2595154464 
+ 458070173 2141230976 4131320786 4208748424   19903848 
+ 147391738 3328215103 4196191786 3510290616 1559873971 
+3731015357 2918514861  362649214 1487061100 1717053387 
+3675955720 1116134897  193529268 3436267940 2835191639 
+1852908272 3220971953 3911201640  571213604  781027019 
+4219206494 1133024903  409547355  625085180 1214072539 
+ 584409985 3445042528 3733581611  333104904 2489812253 
+2694595213 2361631596   34763086  622576118 2921810672 
+3663740744 2293225236 2671706445 1884059696 1507329019 
+ 857065948 2204390003  592711182 1725752375 1642107460 
+ 326274448 3274574484 1030432041  173822100  529650788 
+1086437636  789877945 2167974914 1030588245 3533061365 
+1792148406 4216468704  213264131 3536714075 3877136173 
+1296338417 4057830103  205919137 2108245233 1064497347 
+2101324080 2336703164 1450493809 3812754708 3865701845 
+1476779561 1585902852  142887412  477612192  699530444 
+3351157089 3768249319 1673915577  903239649 1038056164 
+1171465372 1734789440 2115022236  414269055  959581346 
+ 566820984 2105828892 4046076449 4101450561 4106566571 
+2800184123 2470502098 3253453343  256751188 1869365987 
+1008372035 2374606708 1516804538  228288551 3527001547 
+1385173098   66157275 1739381798  184785808 3901692666 
+ 725806641 3475217997 2787929747 1109372433 3142723729 
+ 557686578 2782047723 2118822689 1936702581 1625646963 
+2349385293 3085804937 1272688179 1236112995 3198431244 
+2677635414  811555596 3486972196 2949678043 1342211552 
+ 788174404 1656614077 1582629285 1477167035 2687011245 
+3503701453 3351051324 2874557775  348432514 1629591495 
+3991682351 1969229192 3331660584 1304012077 2090754125 
+3910846836 1871998370 2098597104 1918921592 3246092887 
+1315760974  464122393 2184028058 1690455542 2193747147 
+3737423698 3511684278 1549884962 3413774919 3938991454 
+2767325310 2335626851 1626114941  601913200 3485711542 
+ 858447440 2288468476 4075602213 1506361431 4252489875 
+4032981007 1031118352 3762145731   70955369 2362903502 
+1669089455 2673510137 3348740333 2521337794 2047144929 
+ 892246357 2319875070 1293843163   79245769 2022600352 
+3866257397  989939126  835351312 3626278636 3805332945 
+ 836506264 1895040349  970326679  634920763  733185481 
+1028655248  977810701 3434484235 1871311609 2031584214 
+1336174158  385787519 3965885375 2768323462 1847726660 
+2718987737  793780050 2509902580 3886434164 3120956802 
+4207987247 1523159183 1884932179 2922324286  477253416 
+3037922812 1108379444  697195677 1755438379  574393398 
+2555059183 1930828628 1126190880  180621093 2589191337 
+3424652760 3054648512  719646637  952394946 3570038180 
+ 504304985 1395707758 1274213163 2816553213 1369142370 
+1804702100 1821782344 3358274235 2181234724  486158240 
+ 367287522 4267199121 1127352639  779850007 3440331597 
+3276765484  125500149 1142120513 3989398167 1048565860 
+3136747194  432668526 2098559576 1478877150 2484746208 
+1209580219 1019125185 4160278734 1970740713  918146921 
+4136433784 2602441845 2348512686  973030509 2238261365 
+ 815637919  994690313 1724736366 2099799816 1775069742 
+2680317667  730798472 2916864943 1284417767 1698724919 
+2733611686 1578128411  651006053 4243350375 3303874296 
+ 162087183 3796616231 3801767645 4119825424 3922537059 
+  77594039 3419583692 2503306160  423966005 3293613218 
+1124728190 1407880681 1440346680  554334954 2919409323 
+1253962019  586491243 3638308238 3097648541  991125519 
+ 458538714 2155963569 2807866455    6862945 2122460897 
+  53853750 3346001678 1230879976 3071060893  423909157 
+3881450262 1652511030 3826483009 1526211009 1435219366 
+3092251623 3001090498  281084412  849586749 2207008400 
+ 131172352 1820973075 3195774605 2962673849 2147580010 
+1090677336 2061249893 1724513375 3885752424 1135918139 
+2619357288 4012575714 2652856935 2029480458 3691276589 
+2623865075 3459550738 2097670126 2477000057 2209844713 
+ 785646024 1052349661 1030500157 1430246618 3807539761 
+2157629976  123154542 2560049331 2104110449 1332109867 
+ 721241591 4136042859 4203401395  998151922 3060999432 
+3207929139 2149509272 1385268511 2023309182 1366796638 
+ 256061060 4090836236 2929047008 2296609403  182240337 
+3744374619  306855912 4014087816 2240468995 2865233169 
+ 415452309 1244206523 3513921306  281425419 3511338031 
+ 995954022 3102854413 3026765331  643667197  837979907 
+2832983005 1813414171 2227348307 4020325887 4178893912 
+ 610818241 2787397224 2762441380 3437393657 2030369078 
+1949046312 1876612561 1857107382 1049344864 3544695775 
+2172907342  358500115 3895295219  571965125  328582064 
+ 744698407 3066193991 1679065087 2650874932 3570748805 
+ 812110431 3450423805 1705023874  259721746 1192558045 
+1714799045 3685508436 2262914445 3903852862 1790140070 
+2651193482 2821191752  776610414 2697125035 2212010032 
+1254062056 3541766210 1853927671 1543286708   66516686 
+3505195914 4226521519 1260092911  717982876  739240369 
+ 456195732 2116515161 1599487648  838913496  850912042 
+3712172413 2103192411  877020153 1458113119 2646869271 
+4087221703 3771198399 3952796001 1685641891  226245966 
+4065518354 3169076409  715963611 1155859114 4174181651 
+1816065125 2422210778 2353087594 2569974907 4049024520 
+ 563593555 1794197249 2434290377 4222178191 2381045132 
+1294739153 1333544226 3011196239  518183212 2861903570 
+3168787443 2315530531 1042490149 2998340365 3534153126 
+2862715604  796613230  765073073 1342937225  549817636 
+3786981820 4291017601 2895722553  734959362 3175258828 
+ 140019477  268621172 2410334776  565052604 3787587805 
+ 386344800 2874086067   35710270  817904650 1960697289 
+1584484509 2724312018 1978802819 2275314726 4216102886 
+2138332912  671754166 1442240992 3674442465 1085868016 
+2769242611 1003628378 1616076847  743729558  820011032 
+2559719034 1839332599 3121982280 2070268989 3769147733 
+ 518022934 3037227899 2531915367 1008310588  971468687 
+2052976098 1651926578   78218926 2503907441 3209763057 
+1081499040 2812016370 1247433164  335294964 2650385171 
+2030527826 1139372809 4279827824 3540669095 2285341455 
+4220507154 3863048231 3136394663 3319584205 1476940506 
+ 875141230 2508558662 3896001866  462864388 1609807693 
+3892563868 3642514037 3778083990 1403162576 3512254868 
+1403323269 1119818229 2831288053 2552740643 2520136409 
+  96690857  210381252 1826474872 3306977352 1343117402 
+2112059492  693571694 2096734379  767794921 1843084587 
+1816280216 1695342628  404711915 3334843684 2570639553 
+4186538211 2022604264 3214805180 2989079529 2725165355 
+3005995436  310011850 2742468706 2720274646  144327376 
+2271696819  295519962 1272030376 1372670420 1397272558 
+2280044719 2710639434 2810822904 4271368265 1750711132 
+2216408539 3521792518 3111505866 3085328191 1054735512 
+4160317205 1427385632 2282061755 3215251668 1396490078 
+2933318719  453673969 2926038256 2624047458  338625410 
+3344930154 1971116345 1818716442 2998517928  390083048 
+ 291563131 1144486353  296954266  659950561 2263631666 
+1206908601 1125491020 1890151284 2076080514 2264060846 
+ 561805191 1964622705  405620012 3759692386  517035386 
+2225016848 4165419081 4052828294 3248204933 2738939733 
+1151808775 4113264137 3113447491 1033828852 1785686386 
+2903923175 2038900010 1241522880  238119113 2885394101 
+2636011022 2985605703 2107193353  292026696 3884689974 
+1094315383 4016714705  962244585 3943968050 2868319718 
+1304919603 3626636694 3393461291 1479454799  971639318 
+3352306399 1928233566 2900529135 2190901098   28842068 
+ 990556577 2586302532 3057504668 1661169605 4228191763 
+3934152427 2814119472    4943754 1171095774 1986204006 
+2014406505 1822565279   12890078 1979620724 1917376192 
+3307810835 4170173371 1385005883 1308519769 3370429606 
+ 923886311 2024463563 1063369787  153599761 3463680785 
+ 755374878 2088947962 3099927142 1750207400 2033606872 
+ 926120766  655932557 2320365045 1465119024 3105365454 
+2608716819 1218456091  823539591 2331574954 3171519129 
+3246671799 1043031086 1425831588 3940307546 3443545749 
+1155610704 3681098065 3287797558   63959365  810297004 
+3800799806 1234795257 2547289014  391329364  370300179 
+2474800443 3972311925 2935022755 3924395679 2347599539 
+4212318274 1828491430 3865565525 2767860661 4078993078 
+2781496513 4013741232 2916354756   35752471 2730683119 
+3340599926 4059491907  111492530  897368671 2524912702 
+3046341697 2790787159 1014602604 1409764839  512802978 
+ 477082227 2608350570  533747000 1933326657 4182933327 
+1970210993 2290203137 2843031053 2844558050 3308351089 
+3041943368 1504174920  295229952 2843309586  884572473 
+1787387521 1861566286 3616058184   48071792 3577350513 
+ 297480282 1101405687 1473439254 2634793792 1341017984 
diff --git a/test/random-generator.test b/test/random-generator.test
new file mode 100755
index 00000000..88c9d31d
--- /dev/null
+++ b/test/random-generator.test
@@ -0,0 +1,68 @@
+#! /bin/bash
+# This script tests: pgmnoise
+# Also requires:
+
+echo "Test 1: Should produce:"
+
+echo "P2"
+echo "12 1"
+echo "1023"
+echo "720 296 192 858 101 57 298 629 804 1019 64 617"
+echo "Above output is for Mersenne Twister"
+
+# GNU libc rand(): 593 252 207 990 507 824 961 805 559 110 167 172
+# MAC OS rand():   9 782 60 418 364 654 670 172 1022 515 593 903 
+
+pgmnoise -maxval=1023 -randomseed=3791 -plain 12 1
+
+echo
+echo "Test 2: Mersenne Twister random number generator"
+echo "Should produce:"
+
+echo "3499211612  581869302 3890346734 3586334585  545404204"
+echo "4161255391 3922919429  949333985 2715962298 1323567403"
+echo " ... "
+echo " 297480282 1101405687 1473439254 2634793792 1341017984"
+echo " Total 1000 integers, 200 lines"
+echo
+
+# Use perl to avoid mawk limitation
+# (cannot convert 32 bit integers)
+
+perlPgmProcessorProgram='
+  if (($#F+1) == 10) {
+    for (my $i = 0; $i <= 9; $i += 2) {
+      my $r = $F[$i + 1] * 65536 + $F[$i];
+      printf "%10u ", $r;
+    }
+    print "";
+  }
+'
+
+pgmnoise -randomseed=5489 -plain -maxval=65535 10 200 | tee /tmp/z |
+  perl -walne "$perlPgmProcessorProgram"
+
+#    Method to generate output for Test 2 from original
+#    Mersenne Twister source code
+
+# Download Mersenne Twister code.  See lib/util/randmersenne.c for URL.
+# Edit mt19937ar.c:
+#   In function main() at bottom of file, replace
+#     init_by_array(init, length);
+#   with
+#     init_genrand(5489UL);
+#
+# We need only the output of genrand_int32().
+# Remove the second loop which produces double-precision floating point
+# random numbers with genrand_real2().
+#
+# Compile: gcc mt19937ar.c -o mt1000
+# Execute: ./mt1000
+
+# 1000 may seem like a large number of samples but there is a reason
+# for this.  The generator produces random integers in batches of 624.
+# The number of samples must be larger than 624 to ensure proper
+# generation in batches after the first.
+
+
+
diff --git a/test/winicon-roundtrip2.ok b/test/winicon-roundtrip2.ok
index bb8c77d8..54ba54e6 100644
--- a/test/winicon-roundtrip2.ok
+++ b/test/winicon-roundtrip2.ok
@@ -1,3 +1,4 @@
+Should print: former checksum values
 16 24 32 48 64 : 1 plane
 Should print 2588356089 8591 or 3783949470 69390 four times
 2588356089 8591
@@ -38,6 +39,7 @@ Should print 2704877198 33359 or 1699833476 276750 four times
 Should print 2567279592 41655 or 4154838752 345902 twice
 2567279592 41655
 2567279592 41655
+Should print: latter checksum values
 16 32 48 256 : 1 plane
 Should print 2588356089 8591 or 3783949470 69390 four times
 3783949470 69390
diff --git a/test/winicon-roundtrip2.test b/test/winicon-roundtrip2.test
index ec074055..9d55ebee 100755
--- a/test/winicon-roundtrip2.test
+++ b/test/winicon-roundtrip2.test
@@ -7,7 +7,7 @@ tmpdir=${tmpdir:-/tmp}
 test_pam=${tmpdir}/testimg.pam
 test1_pam=${tmpdir}/testimg1.pam
 test2_pam=${tmpdir}/testimg2.pam
-#test3_pam=${tmpdir}/testimg3.pam
+
 test4_pam=${tmpdir}/testimg4.pam
 test5_pam=${tmpdir}/testimg5.pam
 black_pam=${tmpdir}/black.pam
@@ -19,6 +19,10 @@ gray_pam=${tmpdir}/gray.pam
 
 for sizes in "16 24 32 48 64" "16 32 48 256"
   do
+  if  echo $sizes | awk '{exit !($NF==64)}' ;
+  then echo "Should print: former checksum values";
+  else echo "Should print: latter checksum values";
+  fi
 
   for size in ${sizes}
     do
@@ -65,11 +69,11 @@ for sizes in "16 24 32 48 64" "16 32 48 256"
   pamstack ${gray_pam} ${gray_pam} | \
   pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | tee ${test2_pam} | cksum
   pamtowinicon ${test2_pam} | winicontopam -allimages | \
-    pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | cksum
+    pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | pamdepth 255 | cksum
   pamtowinicon -pngthreshold=300 ${test2_pam} | winicontopam -allimages | \
     pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | cksum
   pamtowinicon -pngthreshold=1   ${test2_pam} | winicontopam -allimages | \
-    pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | cksum
+    pamchannel -tupletype="GRAYSCALE_ALPHA" 0 1 | pamdepth 255 | cksum
 
   rm ${test2_pam}