diff options
author | Henning Makholm <henning@makholm.net> | 2006-01-27 18:00:00 (EST) |
---|---|---|
committer | Julien Jorge <julien.jorge@stuff-o-matic.com> | 2013-01-10 16:00:40 (EST) |
commit | 7b7cd6da61b1fcc0f2a3ecce2cb9e6c42782c717 (patch) | |
tree | 98d2772f50aaddb02ac94492d2b8b151aa3e9465 /test | |
download | xcftools-7b7cd6da61b1fcc0f2a3ecce2cb9e6c42782c717.zip xcftools-7b7cd6da61b1fcc0f2a3ecce2cb9e6c42782c717.tar.gz xcftools-7b7cd6da61b1fcc0f2a3ecce2cb9e6c42782c717.tar.bz2 |
Import of release 0.7
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 8 | ||||
-rw-r--r-- | test/README | 27 | ||||
-rw-r--r-- | test/answer/Addition.png | bin | 0 -> 1236 bytes | |||
-rw-r--r-- | test/answer/Burn.png | bin | 0 -> 1501 bytes | |||
-rw-r--r-- | test/answer/DarkenOnly.png | bin | 0 -> 1056 bytes | |||
-rw-r--r-- | test/answer/Difference.png | bin | 0 -> 1823 bytes | |||
-rw-r--r-- | test/answer/Divide.png | bin | 0 -> 1750 bytes | |||
-rw-r--r-- | test/answer/Dodge.png | bin | 0 -> 2076 bytes | |||
-rw-r--r-- | test/answer/GrainExtract.png | bin | 0 -> 1523 bytes | |||
-rw-r--r-- | test/answer/GrainMerge.png | bin | 0 -> 1506 bytes | |||
-rw-r--r-- | test/answer/Hardlight.png | bin | 0 -> 2142 bytes | |||
-rw-r--r-- | test/answer/LightenOnly.png | bin | 0 -> 1035 bytes | |||
-rw-r--r-- | test/answer/Multiply.png | bin | 0 -> 2255 bytes | |||
-rw-r--r-- | test/answer/Overlay.png | bin | 0 -> 1364 bytes | |||
-rw-r--r-- | test/answer/Screen.png | bin | 0 -> 2235 bytes | |||
-rw-r--r-- | test/answer/Subtract.png | bin | 0 -> 1438 bytes | |||
-rw-r--r-- | test/answer/burmid.png | bin | 0 -> 234 bytes | |||
-rw-r--r-- | test/answer/comptest.png | bin | 0 -> 374 bytes | |||
-rw-r--r-- | test/answer/comptestB.png | bin | 0 -> 692 bytes | |||
-rw-r--r-- | test/answer/crisp1.png | bin | 0 -> 248 bytes | |||
-rw-r--r-- | test/answer/crisp2.png | bin | 0 -> 118 bytes | |||
-rw-r--r-- | test/answer/doodle.png | bin | 0 -> 559 bytes | |||
-rw-r--r-- | test/answer/gray.png | bin | 0 -> 1725 bytes | |||
-rw-r--r-- | test/answer/i255t.png | bin | 0 -> 1563 bytes | |||
-rw-r--r-- | test/answer/i255tt.png | bin | 0 -> 1576 bytes | |||
-rw-r--r-- | test/answer/index255.png | bin | 0 -> 1284 bytes | |||
-rw-r--r-- | test/answer/index256.png | bin | 0 -> 1284 bytes | |||
-rw-r--r-- | test/answer/index4.png | bin | 0 -> 309 bytes | |||
-rw-r--r-- | test/answer/indextest.png | bin | 0 -> 438 bytes | |||
-rw-r--r-- | test/answer/mid.png | bin | 0 -> 281 bytes | |||
-rw-r--r-- | test/answer/misc1.png | bin | 0 -> 2182 bytes | |||
-rw-r--r-- | test/answer/modeA.png | bin | 0 -> 243 bytes | |||
-rw-r--r-- | test/answer/modeB.png | bin | 0 -> 491 bytes | |||
-rw-r--r-- | test/answer/mono.png | bin | 0 -> 1004 bytes | |||
-rw-r--r-- | test/answer/mono1.png | bin | 0 -> 307 bytes | |||
-rw-r--r-- | test/answer/odoodle.png | bin | 0 -> 1036 bytes | |||
-rw-r--r-- | test/answer/tiletest.png | bin | 0 -> 8542 bytes | |||
-rwxr-xr-x | test/dotest | 506 | ||||
-rw-r--r-- | test/pngtype.pl | 58 | ||||
-rw-r--r-- | test/source/comptest.xcf.gz | bin | 0 -> 1788 bytes | |||
-rw-r--r-- | test/source/i255.xcf.gz | bin | 0 -> 1211 bytes | |||
-rw-r--r-- | test/source/i256.xcf.gz | bin | 0 -> 1215 bytes | |||
-rw-r--r-- | test/source/indextest.xcf.gz | bin | 0 -> 941 bytes | |||
-rw-r--r-- | test/source/mkbase.i | 60 | ||||
-rw-r--r-- | test/source/mkgradient256.pl | 6 | ||||
-rw-r--r-- | test/source/mkmodebase.c | 50 | ||||
-rw-r--r-- | test/source/mktile0.pl | 15 | ||||
-rw-r--r-- | test/source/mktile1.c | 35 | ||||
-rw-r--r-- | test/source/modetest.xcf.gz | bin | 0 -> 836 bytes | |||
-rw-r--r-- | test/source/tiletest.xcf.gz | bin | 0 -> 11130 bytes |
50 files changed, 765 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..379e6c7 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,8 @@ +check: + ./dotest -k + $(MAKE) clean +test: check +clean: + for a in * ; do case $$a in \ + README | Makefile | dotest | pngtype.pl ) ;; \ + * ) [ -d $$a ] || rm $$a ;; esac ; done diff --git a/test/README b/test/README new file mode 100644 index 0000000..d7d0006 --- /dev/null +++ b/test/README @@ -0,0 +1,27 @@ +This regression test requires perl, bash, and some programs from +netpbm: pngtopnm, pnmdepth and pgmtoppm. + +The expected outputs are stored as PNG files, which compress better +than just gzipped PxM, but the output from xcf2png is not compared +byte-to-byte with the stored files, because different libpng and zlib +versions may take different, but legitimate, decisions about IDAT +chunk division and compression. Instead pixel comparisions are +done with cmp(1) on PxM representations, which have less possibility +for variations. + +The test of xcftopnm assumes that the layout of the ascii header +in the output from xcftopnm matches byte-for-byte what netpbm produces. +There is an undocumented -@ switch that does this, but if you have a +wildly different version of netpbm you may need to fiddle with the +implementation of -@ and/or insert filters in the test driver +routines. + + + +There are yet no tests for correct reporting of errors. + + + +Note: display(1) from imagemagick 6.0.6.2 apparently does not display + PNG files with grayscale+alpha correctly - the alpha channel is + ignored.
\ No newline at end of file diff --git a/test/answer/Addition.png b/test/answer/Addition.png Binary files differnew file mode 100644 index 0000000..93024de --- /dev/null +++ b/test/answer/Addition.png diff --git a/test/answer/Burn.png b/test/answer/Burn.png Binary files differnew file mode 100644 index 0000000..b6e747e --- /dev/null +++ b/test/answer/Burn.png diff --git a/test/answer/DarkenOnly.png b/test/answer/DarkenOnly.png Binary files differnew file mode 100644 index 0000000..58f71dd --- /dev/null +++ b/test/answer/DarkenOnly.png diff --git a/test/answer/Difference.png b/test/answer/Difference.png Binary files differnew file mode 100644 index 0000000..9a1c5fb --- /dev/null +++ b/test/answer/Difference.png diff --git a/test/answer/Divide.png b/test/answer/Divide.png Binary files differnew file mode 100644 index 0000000..a7668ec --- /dev/null +++ b/test/answer/Divide.png diff --git a/test/answer/Dodge.png b/test/answer/Dodge.png Binary files differnew file mode 100644 index 0000000..05d274b --- /dev/null +++ b/test/answer/Dodge.png diff --git a/test/answer/GrainExtract.png b/test/answer/GrainExtract.png Binary files differnew file mode 100644 index 0000000..c386af2 --- /dev/null +++ b/test/answer/GrainExtract.png diff --git a/test/answer/GrainMerge.png b/test/answer/GrainMerge.png Binary files differnew file mode 100644 index 0000000..616e232 --- /dev/null +++ b/test/answer/GrainMerge.png diff --git a/test/answer/Hardlight.png b/test/answer/Hardlight.png Binary files differnew file mode 100644 index 0000000..8a4739d --- /dev/null +++ b/test/answer/Hardlight.png diff --git a/test/answer/LightenOnly.png b/test/answer/LightenOnly.png Binary files differnew file mode 100644 index 0000000..bb2200f --- /dev/null +++ b/test/answer/LightenOnly.png diff --git a/test/answer/Multiply.png b/test/answer/Multiply.png Binary files differnew file mode 100644 index 0000000..17e43b1 --- /dev/null +++ b/test/answer/Multiply.png diff --git a/test/answer/Overlay.png b/test/answer/Overlay.png Binary files differnew file mode 100644 index 0000000..628d2b5 --- /dev/null +++ b/test/answer/Overlay.png diff --git a/test/answer/Screen.png b/test/answer/Screen.png Binary files differnew file mode 100644 index 0000000..9335e59 --- /dev/null +++ b/test/answer/Screen.png diff --git a/test/answer/Subtract.png b/test/answer/Subtract.png Binary files differnew file mode 100644 index 0000000..e5f03c5 --- /dev/null +++ b/test/answer/Subtract.png diff --git a/test/answer/burmid.png b/test/answer/burmid.png Binary files differnew file mode 100644 index 0000000..81f5371 --- /dev/null +++ b/test/answer/burmid.png diff --git a/test/answer/comptest.png b/test/answer/comptest.png Binary files differnew file mode 100644 index 0000000..7c6d6e2 --- /dev/null +++ b/test/answer/comptest.png diff --git a/test/answer/comptestB.png b/test/answer/comptestB.png Binary files differnew file mode 100644 index 0000000..197af42 --- /dev/null +++ b/test/answer/comptestB.png diff --git a/test/answer/crisp1.png b/test/answer/crisp1.png Binary files differnew file mode 100644 index 0000000..927308e --- /dev/null +++ b/test/answer/crisp1.png diff --git a/test/answer/crisp2.png b/test/answer/crisp2.png Binary files differnew file mode 100644 index 0000000..934d9ab --- /dev/null +++ b/test/answer/crisp2.png diff --git a/test/answer/doodle.png b/test/answer/doodle.png Binary files differnew file mode 100644 index 0000000..42c68e3 --- /dev/null +++ b/test/answer/doodle.png diff --git a/test/answer/gray.png b/test/answer/gray.png Binary files differnew file mode 100644 index 0000000..c917ae9 --- /dev/null +++ b/test/answer/gray.png diff --git a/test/answer/i255t.png b/test/answer/i255t.png Binary files differnew file mode 100644 index 0000000..d96416d --- /dev/null +++ b/test/answer/i255t.png diff --git a/test/answer/i255tt.png b/test/answer/i255tt.png Binary files differnew file mode 100644 index 0000000..9e43321 --- /dev/null +++ b/test/answer/i255tt.png diff --git a/test/answer/index255.png b/test/answer/index255.png Binary files differnew file mode 100644 index 0000000..d4a5ba0 --- /dev/null +++ b/test/answer/index255.png diff --git a/test/answer/index256.png b/test/answer/index256.png Binary files differnew file mode 100644 index 0000000..0669aa5 --- /dev/null +++ b/test/answer/index256.png diff --git a/test/answer/index4.png b/test/answer/index4.png Binary files differnew file mode 100644 index 0000000..3de2398 --- /dev/null +++ b/test/answer/index4.png diff --git a/test/answer/indextest.png b/test/answer/indextest.png Binary files differnew file mode 100644 index 0000000..c8ff807 --- /dev/null +++ b/test/answer/indextest.png diff --git a/test/answer/mid.png b/test/answer/mid.png Binary files differnew file mode 100644 index 0000000..f4bcbe8 --- /dev/null +++ b/test/answer/mid.png diff --git a/test/answer/misc1.png b/test/answer/misc1.png Binary files differnew file mode 100644 index 0000000..277519d --- /dev/null +++ b/test/answer/misc1.png diff --git a/test/answer/modeA.png b/test/answer/modeA.png Binary files differnew file mode 100644 index 0000000..597099b --- /dev/null +++ b/test/answer/modeA.png diff --git a/test/answer/modeB.png b/test/answer/modeB.png Binary files differnew file mode 100644 index 0000000..d9836da --- /dev/null +++ b/test/answer/modeB.png diff --git a/test/answer/mono.png b/test/answer/mono.png Binary files differnew file mode 100644 index 0000000..8b8b3be --- /dev/null +++ b/test/answer/mono.png diff --git a/test/answer/mono1.png b/test/answer/mono1.png Binary files differnew file mode 100644 index 0000000..aa64ace --- /dev/null +++ b/test/answer/mono1.png diff --git a/test/answer/odoodle.png b/test/answer/odoodle.png Binary files differnew file mode 100644 index 0000000..50e1800 --- /dev/null +++ b/test/answer/odoodle.png diff --git a/test/answer/tiletest.png b/test/answer/tiletest.png Binary files differnew file mode 100644 index 0000000..58854bc --- /dev/null +++ b/test/answer/tiletest.png diff --git a/test/dotest b/test/dotest new file mode 100755 index 0000000..c444c98 --- /dev/null +++ b/test/dotest @@ -0,0 +1,506 @@ +#! /bin/bash + +# Regression test for Xcftools +# Copyright (C) 2006 Henning Makholm +# +# This test script is free software; you can redistribute it and/or +# modify it under the terms of version 2 of the GNU General Public +# License as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +export LC_CTYPE=C +export LC_MESSAGES=C + +TESTFROM=.. + +totaltests=0 +failedtests=0 +lastfailed=0 +keepgoing=0 +if [ x"$1" = x"-k" ] +then + keepgoing=1 +fi + +failed() { + if (( lastfailed != totaltests )) + then + echo FAILED + (( lastfailed = totaltests )) + (( failedtests++ )) + fi + (( keepgoing )) || exit 1 +} + + +testrun() { + if [ x$1 == x--exit ] + then + want=$2 ; + shift ; + shift ; + else + want=0 ; + fi + (( totaltests++ )) + echo "===>" "$@" + "$@" > stdout.txt 2> stderr.txt + got=$? + if [ $want = $got ] + then + diff -u expected.stdout stdout.txt || failed + diff -u expected.stderr stderr.txt || failed + else + echo ===STDOUT=== + cat stdout.txt + echo ===STDERR=== + cat stderr.txt + echo ===EXIT STATUS=== + echo $got + failed + fi +} + +testinfo() { + testrun $TESTFROM/xcfinfo "$@" +} + +testpnm() { + oanswer='' + aanswer='' + ofilter=cat + afilter=cat + oext=pnm + while true + do + arg="`echo $1 | cut -c 3-`" + case $arg in + -pgm) arg="pnmdepth 255" ;; + -ppm) arg="pgmtoppm 1,1,1" ;; + esac + case $1 in + o:*) oanswer="$arg" ;; + a:*) aanswer="$arg" ;; + O:*) ofilter="$arg" ;; + A:*) afilter="$arg" ;; + x:*) oext="$arg" ;; + *) break ;; + esac + shift + done + rm -f o.* a.* + [ "$oanswer" ] && pngtopnm answer/$oanswer.png | $ofilter > o.want + [ "$aanswer" ] && pngtopnm -alpha answer/$aanswer.png | $afilter > a.want + aopt= + if [ -n "$aanswer" ] ; then + aopt="-aa.pnm" + fi + source="$1" + shift + testrun $TESTFROM/xcf2pnm -@ -oo.$oext $aopt source/$source.xcf.gz "$@" + [ -z "$oanswer" ] || cmp o.want o.$oext || failed + [ -z "$aanswer" ] || cmp a.want a.pnm || failed +} + +testpng() { + ofilter=cat + afilter=cat + oargs="" + aargs="" + while true + do + arg="`echo $1 | cut -c 3-`" + case $arg in + -pgm) arg="pnmdepth 255" ;; + -ppm) arg="pgmtoppm 1,1,1" ;; + esac + case $1 in + O:*) ofilter="$arg" ;; + A:*) afilter="$arg" ;; + b:*) oargs="-background $arg -mix" ;; + B:*) aargs="-background $arg -mix" ;; + *) answer="$1" ; shift ; break ;; + esac + shift + done + rm -f o.* a.* + [ -s pngtype.want ] || perl pngtype.pl < answer/$answer.png > pngtype.want + pngtopnm $aargs answer/$answer.png | $ofilter > o.want + pngtopnm -alpha answer/$answer.png | $afilter > a.want + source="$1" + shift + testrun $TESTFROM/xcf2png -oo.png source/$source.xcf.gz "$@" + perl pngtype.pl < o.png > pngtype + diff -u pngtype.want pngtype || failed + pngtopnm $oargs o.png > o.pnm + cmp o.want o.pnm || failed + if [ "$afilter" != : ] ; then + pngtopnm -alpha o.png > a.pnm + cmp a.want a.pnm || failed + fi + rm pngtype.want +} +rm -f pngtype.want + +S=source + +cp /dev/null expected.stderr + +############################################################################# +# +# Use all of the example XCF inputs as checks of xcfinfo +# + +cat <<EOF > expected.stdout +Version 0, 256x256 Grayscale, 2 layers, compressed RLE ++ 256x256+0+0 Grayscale-alpha Normal Partially transparent ++ 256x256+0+0 Grayscale Normal Background +EOF +testinfo $S/comptest.xcf.gz + +cat <<EOF > expected.stdout +Version 0, 64x64 RGB color, 4 layers, compressed RLE +- 10x10+27+27 RGB-alpha Normal AE=AE ++ 64x64+0+0 RGB-alpha Subtract B ++ 64x64+0+0 RGB-alpha Addition A +- 64x64+0+0 RGB Normal Background +EOF +testinfo $S/modetest.xcf.gz + +cat <<EOF > expected.stdout +Version 1, 64x64 Indexed color, 3 layers, compressed RLE ++ 64x64+0+0 Indexed-alpha Subtract/mask B ++ 64x64+0+0 Indexed-alpha Addition/mask A +- 64x64+0+0 Indexed Normal Background +EOF +testinfo $S/indextest.xcf.gz + +cat <<EOF > expected.stdout +Version 0, 161x161 RGB color, 10 layers, compressed RLE ++ 122x13+19+74 RGB-alpha Normal Long and low ++ 13x122+74+19 RGB-alpha Difference Tall and narrow ++ 118x118+38+47 RGB-alpha Normal/65% Displaced loop +- 161x161+0+0 RGB-alpha Normal Doodle ++ 161x161+0+0 RGB-alpha Normal Straight loop ++ 50x50+100+105 RGB-alpha Normal/mask Crossed ++ 50x50+8+8 RGB-alpha Normal Mid ++ 50x50+8+102 RGB-alpha Normal/83%/mask Horiz ++ 50x50+101+7 RGB-alpha Normal Vert ++ 161x161+0+0 RGB Normal Background +EOF +testinfo $S/tiletest.xcf.gz + +cat <<EOF > expected.stdout +Version 1, 64x64 Indexed color, 1 layers, compressed RLE ++ 64x64+0+0 Indexed Normal Background +EOF +testinfo $S/i256.xcf.gz +testinfo $S/i255.xcf.gz + +cp /dev/null expected.stdout + +############################################################################# +############################################################################# + + +############################################################################# +# +# comptest.xcf.gz tests primarily that the scaling tables used during +# flattening are internally consistent, such that two pixels of the +# same color always composite to that color no matter what the +# alpha of the upper one is. + +testpnm o:comptest comptest +testpnm o:comptest comptest Background + +############################################################################# +# +# modetest.xcf.gz is the primary test of the various compositing modes. +# + +testpnm o:Subtract a:modeA modetest +testpnm o:Addition a:modeB modetest B A -f +for mode in Multiply Screen Overlay Difference DarkenOnly \ + LightenOnly Divide Dodge Burn GrainExtract GrainMerge \ + Hardlight +do + testpnm o:$mode a:modeA modetest A B --mode $mode +done +testpnm o:Overlay a:modeA modetest AE=AE A --mode Normal B --mode Softlight + + +############################################################################# +# +# tiletest.xcf.gz tests various ways a layer can interact with the +# tile boundaries, as well as layer selection, masks, global opacity. +# + +testpnm o:tiletest tiletest + +############################################################################# +# +# Test output format selection for xcf2pnn with and without -f +# + +testpnm o:mono O:-ppm tiletest Background 'Straight loop' +testpnm o:mono O:-ppm tiletest Background 'Straight loop' -c +testpnm o:mono O:-pgm tiletest Background 'Straight loop' -g +testpnm o:mono tiletest Background 'Straight loop' -m + +testpnm x:ppm o:mono O:-ppm tiletest Background 'Straight loop' +testpnm x:pgm o:mono O:-pgm tiletest Background 'Straight loop' +testpnm x:pbm o:mono tiletest Background 'Straight loop' +testpnm x:pbm o:mono O:-ppm tiletest Background 'Straight loop' -c +testpnm o:gray O:-ppm tiletest Background 'Straight loop' 'Long and low' +testpnm o:gray tiletest Background 'Straight loop' 'Long and low' -g + +testpnm o:mono tiletest Background 'Straight loop' -f +testpnm o:mono O:-ppm tiletest Background 'Straight loop' -f -c +testpnm o:gray tiletest Background 'Straight loop' 'Long and low' -f + +# Test -A flag + +testpnm o:mid tiletest -O17,17 -S32x32 Mid +testpnm o:mid a:mid A:-pgm tiletest -O17,17 -S32x32 Mid +testpnm o:mid tiletest -O17,17 -S32x32 Mid -f +testpnm o:mid a:mid tiletest -O17,17 -S32x32 -A +testpnm o:mid a:mid A:-pgm tiletest -O17,17 -S32x32 Mid +testpnm o:mid a:mid tiletest -O17,17 -S32x32 -Af +testpnm o:mid a:mid tiletest -O17,17 -S32x32 Mid -Af + +############################################################################# +# +# Test indexed images +# + +testpnm o:indextest a:indextest indextest +testpnm o:Subtract a:modeA indextest -T +testpnm o:index4 indextest Background +testpnm o:index256 i256 + +############################################################################# +# +# Various tests of xcf2pnm +# + +testpnm o:burmid tiletest Mid -S 27x25 -O 5,5 -b '#963' + +############################################################################# +############################################################################# +# +# Tests of xcf2png +# + +############################################################################# +# +# Basic functionality +# + +testpng tiletest tiletest +testpng modeA modetest A + +############################################################################# +# +# Output color-format selection +# + +cat <<EOF > common +161x161x8 +color +z0 f0 i0 +EOF +cp common pngtype.want +testpng O:-ppm mono tiletest Background 'Straight loop' +cp common pngtype.want +testpng O:-ppm mono tiletest Background 'Straight loop' -c +cp common pngtype.want +testpng O:-ppm mono tiletest Background 'Straight loop' -f -c +cp common pngtype.want +testpng O:-ppm gray tiletest Background 'Straight loop' 'Long and low' + +cat <<EOF > common +161x161x8 +gray +z0 f0 i0 +EOF +cp common pngtype.want +testpng O:-pgm mono tiletest Background 'Straight loop' -g +cp common pngtype.want +testpng gray tiletest Background 'Straight loop' 'Long and low' -g + +cat <<EOF > pngtype.want +161x161x1 +gray +z0 f0 i0 +EOF +testpng mono tiletest Background 'Straight loop' -f + +cat <<EOF > pngtype.want +161x161x8 +color+index +z0 f0 i0 +PLTE(60) + FF FF FF 00 00 00 B6 B6 B6 A1 A1 A1 81 81 81 51 51 51 2E 2E 2E 80 80 80 + E2 E2 E2 41 41 41 30 30 30 12 12 12 0E 0E 0E 0B 0B 0B 13 13 13 2D 2D 2D + 7F 7F 7F 40 40 40 50 50 50 6A 6A 6A +EOF +testpng gray tiletest Background 'Straight loop' 'Long and low' -f + +############################################################################# +# +# Try all combinations of alpha and color modes +# + +# gray +testpng gray tiletest Background 'Straight loop' 'Long and low' -g +testpng comptest comptest + +# RGB: many of the layer mode tests test this + +# gray+alpha +testpng comptestB comptest 'Partially transparent' -f + +# RGB+alpha +cat <<EOF > pngtype.want +16x20x8 +color+alpha +z0 f0 i0 +EOF +testpng A:-pgm b:0,0,0 crisp1 modetest -S16x20 -O48,46 -c + +# gray, one transparent color +testpng crisp2 comptest -S25x250 -O235,0 -f -g + +# RGB, one transparent color +cat <<EOF > pngtype.want +16x20x8 +color +z0 f0 i0 +tRNS(6) + 00 01 00 01 00 01 +EOF +testpng "b:0,0,0" crisp1 modetest -S16x20 -O48,46 -c -f + +# index, no transparency: palette selection tests test this + +# index, one transparent color +testpng crisp1 modetest -S16x20 -O48,46 -f + +# index, various transparent colors +testpng modeB modetest B -f + +############################################################################# +# +# Special tests for palette selection +# + +# monochrome +testpng mono tiletest Background 'Straight loop' -f + +# monochrome with black and white first met in the opposite order. +testpng mono1 tiletest Background -S65x64 -O63,64 -f + +# 1 color plus transparency +testpng doodle tiletest Doodle -f + +# 2 colors +cat <<EOF > pngtype.want +161x161x1 +color+index +z0 f0 i0 +PLTE(6) + FF 00 00 EE 6F 00 +EOF +testpng A:: B:1,0,0 doodle tiletest Doodle -b '#f00' -f + +# 2 colors plus transparency +testpng odoodle tiletest Doodle 'Straight loop' -f + +# 3 colors +cat <<EOF > pngtype.want +161x161x2 +color+index +z0 f0 i0 +PLTE(9) + 00 00 FF EE 6F 00 FF FF FF +EOF +testpng A:: B:0,0,1 odoodle tiletest Doodle 'Straight loop' -fb '#00F' + +# 4 colors +cat <<EOF > pngtype.want +64x64x2 +color+index +z0 f0 i0 +PLTE(12) + DC 98 85 FF 00 77 10 36 38 FF B4 23 +EOF +testpng index4 indextest Background -f + +# 16 colors, no transparency +testpng mid tiletest -O17,17 -S32x32 -f + +# 17 colors, including a background +testpng burmid tiletest Mid -O5,5 -S27x25 -b '#963' -f + +# 38 colors, original colormap +testpng index4 indextest Background + +# 255 colors, original colormap +testpng index255 i255 + +# 255 colors plus transparency +testpng i255t i255 -O0,2 +testpng i255t i255 -O0,2 -f +testpng i255tt i255 -O2,0 -f +perl pngtype.pl < answer/index256.png > pngtype.want +testpng A:"tr '\377' '\0'" B:"#F4F4F4" i255t i255 -O0,2 -b "#F4F4F4" +# 255 colors, background already in palette +perl pngtype.pl < answer/index255.png > pngtype.want +testpng A:"tr '\3' '\0'" B:"#66CC33" i255tt i255 -O2,0 -b "#6c3" + +# 256 colors, original colormap +testpng index256 i256 + +# 256 colors, no room for transparency +cat <<EOF > pngtype.want +64x64x8 +color+alpha +z0 f0 i0 +EOF +testpng A:-pgm index256 i256 -A + +############################################################################# +# +# Various tests for regression of bugs that slipped through the +# systematic testing. +# + +# Exotic modes with an opaque layer +testpnm o:misc1 a:misc1 tiletest Mid Crossed \ + Background --mode LightenOnly 'Straight loop' -f + +############################################################################# +# +# Report the final status + +echo ======================================================= +if (( failedtests )) +then + echo $failedtests of $totaltests tests FAILED + echo ======================================================= + exit 1 +else + echo All $totaltests tests PASSED + echo ======================================================= + exit 0 +fi + +# End
\ No newline at end of file diff --git a/test/pngtype.pl b/test/pngtype.pl new file mode 100644 index 0000000..d7577a8 --- /dev/null +++ b/test/pngtype.pl @@ -0,0 +1,58 @@ +use warnings ; +use strict ; + +binmode(STDIN); + +my $a ; +read STDIN,$a,8 ; +if( $a ne "\x89PNG\x0d\x0a\x1a\x0a" ) { + die "Malformed PNG header\n" ; +} +sub bv($) { + ord(substr($a,$_[0],1)) ; +} +sub wv($) { + my $a = shift ; + return (bv($a) << 24) + (bv($a+1) << 16) + (bv($a+2)<<8) + bv($a+3); +} +my %all ; +while( !eof STDIN ) { + read STDIN,$a,4 ; + my $len = wv(0); + read STDIN,$a,$len+8 ; + my $type = substr($a,0,4) ; + next if $type eq 'IDAT' ; + last if $type eq 'IEND' ; + if( $type eq 'IHDR' && $len == 13 ) { + print wv(4),"x",wv(8),"x",bv(12),"\n" ; + my $cmode = bv(13) ; + print $cmode & 3 ? "color" : "gray" ; + print "+index" if $cmode & 1 ; + print "+alpha" if $cmode & 4 ; + print "\nz",bv(14)," f",bv(15)," i",bv(16),"\n" ; + next ; + } + my $aref = ($all{$type} ||= []) ; + push @$aref, "$type($len)" ; + { + my $w = 16 ; + $w = 24 if $type eq 'PLTE' ; + $w = 8 if $type eq 'tRNS' ; + for my $i ( 0 .. $len - 1 ) { + push @$aref, sprintf("%s%02X", $i%$w ? " " : "\n ", bv($i+4) ) ; + push @$aref, " " if + $type eq 'PLTE' && + $i%3 == 2 && + ($i+1)%$w != 0 && + $i != $len-1 ; + } + push @$aref, "\n" ; + } +} +for my $k ( sort keys %all ) { + print @{$all{$k}} ; +} + + + + diff --git a/test/source/comptest.xcf.gz b/test/source/comptest.xcf.gz Binary files differnew file mode 100644 index 0000000..4a69918 --- /dev/null +++ b/test/source/comptest.xcf.gz diff --git a/test/source/i255.xcf.gz b/test/source/i255.xcf.gz Binary files differnew file mode 100644 index 0000000..086bafb --- /dev/null +++ b/test/source/i255.xcf.gz diff --git a/test/source/i256.xcf.gz b/test/source/i256.xcf.gz Binary files differnew file mode 100644 index 0000000..38c23c4 --- /dev/null +++ b/test/source/i256.xcf.gz diff --git a/test/source/indextest.xcf.gz b/test/source/indextest.xcf.gz Binary files differnew file mode 100644 index 0000000..b782acf --- /dev/null +++ b/test/source/indextest.xcf.gz diff --git a/test/source/mkbase.i b/test/source/mkbase.i new file mode 100644 index 0000000..ec408ef --- /dev/null +++ b/test/source/mkbase.i @@ -0,0 +1,60 @@ +/* -*- C -*- + * This program is written by Henning Makholm, and is in the + * public domain. + */ + +#include <png.h> +#include <stdio.h> +#include <stdlib.h> + +static void +error(png_structp png_ptr, png_const_charp errormsg) +{ + fprintf(stderr,"PNG error: %s\n",errormsg); + exit(1); +} + + +int +main(void) +{ + png_structp libpng = NULL ; + png_infop libpng2 = NULL ; + unsigned char row[TEST_IMAGE_WIDTH*4] ; + unsigned x,y ; + int r,g,b,a ; + + libpng = png_create_write_struct(PNG_LIBPNG_VER_STRING, + png_voidp_NULL, + error, + png_error_ptr_NULL); + if( !libpng ) + error(libpng,"Couldn't initialize libpng library"); + + libpng2 = png_create_info_struct(libpng); + if( !libpng2 ) + error(libpng,"Couldn't create PNG info structure"); + + png_init_io(libpng,stdout); + + png_set_IHDR(libpng,libpng2,TEST_IMAGE_WIDTH,TEST_IMAGE_HEIGHT, + 8, PNG_COLOR_TYPE_RGB_ALPHA, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); + + png_write_info(libpng,libpng2); + + for( y=0; y<TEST_IMAGE_HEIGHT; y++ ) { + for( x=0; x<TEST_IMAGE_WIDTH; x++ ) { + makepixel(x,y,&r,&g,&b,&a); + row[x*4+0] = r ; + row[x*4+1] = g ; + row[x*4+2] = b ; + row[x*4+3] = a ; + } + png_write_row(libpng,row); + } + png_write_end(libpng,libpng2); + return 0 ; +} diff --git a/test/source/mkgradient256.pl b/test/source/mkgradient256.pl new file mode 100644 index 0000000..e03912c --- /dev/null +++ b/test/source/mkgradient256.pl @@ -0,0 +1,6 @@ +print "P2 256 256 255\n" ; +for $y ( 0 .. 255 ) { + for $x ( 0 .. 255 ) { + print "$x\n" ; + } +} diff --git a/test/source/mkmodebase.c b/test/source/mkmodebase.c new file mode 100644 index 0000000..3e5c656 --- /dev/null +++ b/test/source/mkmodebase.c @@ -0,0 +1,50 @@ +/* This program is written by Henning Makholm, and is in the + * public domain. + */ + +#define TEST_IMAGE_WIDTH 64 +#define TEST_IMAGE_HEIGHT 64 + +void +makepixel(int x,int y,int *r,int *g,int *b,int *a) { + if( y < 3 || y >= 61 ) { + *a = 0 ; + return ; + } + if( x < 3 || x >= 61 || + y < 6 || y >= 58 ) { + *r=*g=*b=*a=255 ; + return ; + } + if( x < 6 || x >= 58 ) { + *a=0 ; + return ; + } + x -= 6 ; + if( x <= 17 ) { + *a = x*15 ; + *r = 255 ; + *g = 0 ; + *b = 17*7 ; + return ; + } + *a = 255 ; + x -= 17 ; + if( x <= 17 ) { + *r = 255 ; + *g = x*15 ; + *b = (17-x)*7 ; + return ; + } + x -= 17 ; + if( x <= 17 ) { + *r = (17-x)*15 ; + *g = 255 ; + *b = x*15 ; + return ; + } + *r=255 ; + *g=*b=0 ; +} + +#include "mkbase.i" diff --git a/test/source/mktile0.pl b/test/source/mktile0.pl new file mode 100644 index 0000000..b932ed0 --- /dev/null +++ b/test/source/mktile0.pl @@ -0,0 +1,15 @@ +$L = 64 ; +print "P3 $L $L 255\n" ; +for $y ( 0 .. $L-1 ) { + for $x ( 0 .. $L-1 ) { + $m = int($y / 4)*16 + int($x/4) ; + if( $m < 216 ) { + print( 51 * ($m % 6), " ", + 51 * (int($m/6) % 6), " ", + 51 * (int($m/36)), "\n" ); + } else { + $m = ($m-216) * 6 + 10 ; + print( "$m $m $m\n" ); + } + } +} diff --git a/test/source/mktile1.c b/test/source/mktile1.c new file mode 100644 index 0000000..50709df --- /dev/null +++ b/test/source/mktile1.c @@ -0,0 +1,35 @@ +/* This program is written by Henning Makholm, and is in the + * public domain. + */ + +#define TEST_IMAGE_WIDTH 50 +#define TEST_IMAGE_HEIGHT 50 + +#include <math.h> +#include <stdlib.h> + +void +makepixel(int x,int y,int *r,int *g,int *b,int *a) { + double yy = 2*(double)y/(TEST_IMAGE_HEIGHT-1) - 1 ; + double xx = 2*(double)x/(TEST_IMAGE_WIDTH-1) - 1 ; + double rad = sqrt(xx*xx+yy*yy) ; + unsigned t = x + abs((y - TEST_IMAGE_HEIGHT/2)) ; + t = t / 10 + ((600 + y - TEST_IMAGE_HEIGHT/2) / 10)*77 ; + if( rad < 0.9 ) + *a = 255 ; + else if( rad < 1 ) + *a = 190 ; + else if( rad < 1.2 ) + *a = 73 ; + else + *a = 0 ; + + t *= 3847822 ; + t ^= 29938132 ; + t %= 2093847 ; + *r = 120 * ((t >> 3) % 3) + 3 ; + *g = 120 * ((t >> 7) % 3) + 3 ; + *b = 120 * ((t >> 10) % 3) + 3 ; +} + +#include "mkbase.i" diff --git a/test/source/modetest.xcf.gz b/test/source/modetest.xcf.gz Binary files differnew file mode 100644 index 0000000..c2d7f8a --- /dev/null +++ b/test/source/modetest.xcf.gz diff --git a/test/source/tiletest.xcf.gz b/test/source/tiletest.xcf.gz Binary files differnew file mode 100644 index 0000000..c2fbc45 --- /dev/null +++ b/test/source/tiletest.xcf.gz |