about summary refs log tree commit diff
path: root/test/ps-roundtrip.test
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-12-06 17:58:55 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-12-06 17:58:55 +0000
commit4dae047849625a2acaac764d15d7a7b6549071f3 (patch)
tree02e7191ee290dd9bc5842cc2464c7b57ed687db9 /test/ps-roundtrip.test
parent1fd6937fcb290fa56cb882a819294605568e3b5f (diff)
downloadnetpbm-mirror-4dae047849625a2acaac764d15d7a7b6549071f3.tar.gz
netpbm-mirror-4dae047849625a2acaac764d15d7a7b6549071f3.tar.xz
netpbm-mirror-4dae047849625a2acaac764d15d7a7b6549071f3.zip
Add test for Pnmshear
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2046 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'test/ps-roundtrip.test')
-rwxr-xr-xtest/ps-roundtrip.test76
1 files changed, 54 insertions, 22 deletions
diff --git a/test/ps-roundtrip.test b/test/ps-roundtrip.test
index 60ecf60a..b7aa816c 100755
--- a/test/ps-roundtrip.test
+++ b/test/ps-roundtrip.test
@@ -1,38 +1,70 @@
 #! /bin/bash
 # This script tests: pnmtops pstopnm
-# Also requires: pnmtopnm pamtopnm gs
+# Also requires: pnmtopnm pamtopnm gs pbmmake pnmshear pnmpad pnmcat
 
-# Test 1.  Should print: 1926073387 101484
-${PBM_TESTPREFIX}pnmtops -nocenter -equalpixels -dpi 72 -noturn testimg.ppm \
-  > ${tmpdir}/testimg.ps
-xysize1=`awk  '/BoundingBox/ {print "-xsize="$4,"-ysize="$5}' \
-  ${tmpdir}/testimg.ps` 
-${PBM_TESTPREFIX}pstopnm -xborder=0 -yborder=0 $xysize1 -stdout \
-  -quiet ${tmpdir}/testimg.ps | \
-  ${PBM_BINPREFIX}pnmtopnm | cksum
+# Test 1.  Should print: 1926073387 101484 five times
+# *NOTE* Fifth iteration fails if pnmtops was compiled without zlib
+# (flate compression) support.
+for flag in "" "-ps" "-rle" "-ps -ascii" "-ps -flate"
+  do
+  ${PBM_TESTPREFIX}pnmtops -nocenter -equalpixels -dpi 72 -noturn \
+    ${flag} testimg.ppm \
+    > ${tmpdir}/testimg.ps
+  xysize1=`awk  '/BoundingBox/ {print "-xsize="$4,"-ysize="$5}' \
+    ${tmpdir}/testimg.ps` 
+  ${PBM_TESTPREFIX}pstopnm -xborder=0 -yborder=0 $xysize1 -stdout \
+    -quiet ${tmpdir}/testimg.ps | \
+    ${PBM_BINPREFIX}pnmtopnm | cksum
+  done
 
 
-# Test 2.  Should print: 2425386270 41
-${PBM_TESTPREFIX}pnmtops -nocenter -equalpixels -dpi 72 -noturn \
-  testgrid.pbm  > ${tmpdir}/testgrid.ps &&
-xysize2=`awk  '/BoundingBox/ {print "-xsize="$4,"-ysize="$5}' \
-  ${tmpdir}/testgrid.ps`
-${PBM_TESTPREFIX}pstopnm -xborder=0 -yborder=0 $xysize2 -stdout \
-  -quiet ${tmpdir}/testgrid.ps -pbm | \
-  ${PBM_BINPREFIX}pnmtopnm | cksum
+# Test 2.  Should print: 2918318199 62 seven times
+# Test image designed to detect problems with run-length compression
+#
+${PBM_BINPREFIX}pbmmake -g 2 2 > ${tmpdir}/g.pbm
+${PBM_BINPREFIX}pbmmake -g 8 4 | \
+  ${PBM_BINPREFIX}pnmshear 45 -noantialias -background=black | \
+  ${PBM_BINPREFIX}pnmpad -right 60 | \
+  ${PBM_BINPREFIX}pnmcat -tb -jright - ${tmpdir}/g.pbm > ${tmpdir}/t.pbm &&
+for flag in "" "-rle" "-ps -rle -ascii" \
+            "-bitspersample=2 -rle" "-ps -bitspersample=4 -rle" \
+            "-bitspersample=8 -rle" "-ps -bitspersample=12 -rle -dict" 
+  do
+  ${PBM_TESTPREFIX}pnmtops -nocenter -equalpixels -dpi 72 -noturn \
+    ${flag} ${tmpdir}/t.pbm  > ${tmpdir}/testgrid.ps &&
+  xysize2=`awk  '/BoundingBox/ {print "-xsize="$4,"-ysize="$5}' \
+    ${tmpdir}/testgrid.ps`
+  ${PBM_TESTPREFIX}pstopnm -xborder=0 -yborder=0 $xysize2 -stdout \
+    -quiet ${tmpdir}/testgrid.ps -pbm | \
+    ${PBM_BINPREFIX}pnmtopnm | cksum
+  done
 
 
-#Test 3. Should print: 1386192571 507420
+#Test 3. Should print: 1386192571 507420 three times
+# *NOTE* Second iteration fails if pnmtops was compiled without zlib
+# (flate compression) support.
+#
+# Special care is needed when conducting round-trips with multiple-image
+# files as input.
+# (1) pnmtops: -setpage is mandatory
+# (2) awk: xy values are taken from the first "BoundingBox" encountered.
+#          Subsequent BoundingBox values are ignored.
+# (3) pstopnm: input must be an ordinary file.  Input from stdin
+#     (by pipe or input redirection: "< file" ) does not work.              
+#
+for flag in "" "-ps" \
+            "-ps -bitspersample=12 -flate -rle -vmreclaim"
+  do
 cat testimg.ppm testimg.ppm testimg.ppm testgrid.pbm testgrid.pbm | \
 ${PBM_TESTPREFIX}pnmtops -nocenter -equalpixels -dpi 72 -noturn -setpage \
-  > ${tmpdir}/testimg5.ps
+  ${flag}  > ${tmpdir}/testimg5.ps
 xysize3=`awk  '/BoundingBox/ {print "-xsize="$4,"-ysize="$5 ; exit}' \
   ${tmpdir}/testimg5.ps`
 ${PBM_TESTPREFIX}pstopnm -xborder=0 -yborder=0 $xysize3 \
     -stdout  ${tmpdir}/testimg5.ps | \
   ${PBM_BINPREFIX}pnmtopnm | cksum
+  done
 
 
-#rm  ${tmpdir}/testgrid.ps  ${tmpdir}/testimg.ps  ${tmpdir}/testimg5.ps
-rm   ${tmpdir}/testimg.ps  ${tmpdir}/testimg5.ps
-mv ${tmpdir}/testgrid.ps /tmp
+rm ${tmpdir}/testgrid.ps  ${tmpdir}/testimg.ps  ${tmpdir}/testimg5.ps \
+   ${tmpdir}/t.pbm