Skip to content

Commit 08750e9

Browse files
author
giraffedata
committed
various changes to test facility
git-svn-id: https://svn.code.sf.net/p/netpbm/code/trunk@1806 9d0c8265-081b-0410-96cb-a4ca84ce46f8
1 parent 6ff9c37 commit 08750e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+509
-108
lines changed

GNUmakefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -409,11 +409,12 @@ install.sharedlibstub:
409409
.PHONY: check
410410
check:
411411
# This works on typical Linux systems
412-
cd $(SRCDIR)/test; \
412+
if [ ! -d $(RESULTDIR) ]; then mkdir -pv $(RESULTDIR); fi
413+
cd $(RESULTDIR); \
413414
PBM_TESTPREFIX=$(PKGDIR)/bin \
414415
LD_LIBRARY_PATH=$(PKGDIR)/lib \
415416
RGBDEF=$(SRCDIR)/lib/rgb.txt \
416-
./Execute-Tests
417+
$(SRCDIR)/test/Execute-Tests 2>&1
417418

418419
clean: localclean
419420

common.mk

+13-1
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,24 @@ LDLIBS = $(LOADLIBES) $(LIBS)
109109
# disastrous if PKGDIR is a relative directory, and I don't know any
110110
# way to detect that case and fail, so I just add a '/' to the front
111111
# if it isn't already there.
112+
#
113+
# TODO: Convert 'pkgdir' to absolute path with # the $(abspath ...)
114+
# built-in function, available from GNU Make v 3.81 onward.
112115
ifneq ($(pkgdir)x,x)
113-
PKGDIR = $(patsubst //%, /%, /$(pkgdir))
116+
PKGDIR = $(patsubst //%,/%, /$(pkgdir))
114117
else
115118
PKGDIR = $(PKGDIR_DEFAULT)
116119
endif
117120

121+
122+
# 'resultdir', like 'pkgdir' is meant to be supplied from the make
123+
# command line. Unlike 'pkgdir' we allow relative paths.
124+
ifneq ($(resultdir)x,x)
125+
RESULTDIR = $(resultdir)
126+
else
127+
RESULTDIR = $(RESULTDIR_DEFAULT)
128+
endif
129+
118130
#===========================================================================
119131
# We build a directory full of symbolic links to the intra-Netpbm public
120132
# header files just so the compile commands don't have to be littered

config.mk.in

+4
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,10 @@ DONT_HAVE_PROCESS_MGMT = N
526526
# override it by setting 'pkgdir' on the Make command line.
527527
PKGDIR_DEFAULT = /tmp/netpbm
528528

529+
# This is where test results are written when you do 'make check', unless
530+
# you override it by setting 'resultdir' on the Make command line.
531+
RESULTDIR_DEFAULT = /tmp/netpbm-test
532+
529533
# Subdirectory of the package directory ($(pkgdir)) in which man pages
530534
# go.
531535
PKGMANDIR = man

test/411toppm.ok

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
240376509 9229

test/411toppm.test

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#! /bin/bash
2+
# This script tests: 411toppm
3+
# Also requires:
4+
5+
# Test 1. should produce: 240376509 9229
6+
# The above value is what 411toppm has been always producing.
7+
# 411toppm's author Steve Allen says he was not able to obtain accurate
8+
# specifications for the .411 format. Technically, the above can change.
9+
#
10+
# See comment at head of source file 411toppm.c.
11+
12+
head -c 4608 /dev/zero | ${PBM_TESTPREFIX}411toppm -quiet | cksum

test/Execute-Tests

+100-34
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
# Confirm that PBM_TESTPREFIX is set.
44
# PBM_TESTPREFIX is the directory with the Netpbm programs you want to
5-
# test. This can be null, but this is not recommended.
5+
# test. If set to null, executables will be sought from the default
6+
# execution path ($PATH). Usually you should explicitly set this.
67
#
7-
# You can set it here by decommenting and modifying the next line:
8-
# export PBM_TESTPREFIX="/usr/local/bin/"
9-
8+
# You can set it here by de-commenting and modifying the next line:
9+
#export PBM_TESTPREFIX="/usr/local/bin/"
1010

1111
if [ -z $PBM_TESTPREFIX ]
1212
then
@@ -20,7 +20,7 @@ elif [ ! -d $PBM_TESTPREFIX ]
2020
exit 1
2121
else
2222
# append "/" to end of string if necessary
23-
export PBM_TESTPREFIX=`echo $PBM_TESTPREFIX | sed '/\/$/!s@$@/@'`
23+
export PBM_TESTPREFIX=$(echo $PBM_TESTPREFIX | sed '/\/$/!s@$@/@')
2424
fi
2525

2626
# Set PBM_BINPREFIX.
@@ -30,7 +30,8 @@ fi
3030
#
3131
# If testing a fresh install, this should be the same as PBM_TESTPREFIX.
3232
# If you are developing a single Netpbm program, you may want to
33-
# set this to a directory with stable executables.
33+
# set this to a directory with stable executables. (Final "/" is
34+
# mandatory.)
3435
# If set to null, executables in the default execution path will
3536
# be used.
3637

@@ -47,67 +48,132 @@ if [ ! -z $PBM_BINPREFIX ]
4748
export PATH=${PBM_BINPREFIX}:$PATH
4849
fi
4950

50-
# Set tmpdir, which is used in some of the test scripts.
51-
# This must be an existing directory.
51+
# Set srcdir, which is the directory which contains Execute-Tests
52+
# (this script), Test-Order *.test and *.ok files.
53+
54+
srcdir=$(dirname $0)
55+
56+
# Set tmpdir, which is used in some of the test scripts. By default
57+
# this is created by mktemp. The user can override and specify tmpdir,
58+
# but in this case it must be an existing directory and must not be
59+
# either $srcdir or current work.
5260

5361
if [ -z $tmpdir ]
5462
then
55-
if [ -z $TMPDIR ]
56-
then
57-
export tmpdir=/tmp/
58-
else
59-
export tmpdir=$TMPDIR
63+
tmpdir_created=$(mktemp -p "" -d TestPBM-XXXXXXX) || exit 1;
64+
export tmpdir=${tmpdir_created}
65+
else
66+
tmpdir_created="";
67+
if [ ! -d ${tmpdir} ]
68+
then echo "Specified temporary directory $tmpdir does not exist."
69+
exit 1;
70+
elif [ ${tmpdir} -ef ${srcdir} ]
71+
then echo "Temporary directory must not be $srcdir."
72+
exit 1;
73+
elif [ ${tmpdir} -ef $PWD ]
74+
then echo "Temporary directory must not be current directory."
75+
exit 1;
6076
fi
6177
fi
6278

79+
6380
# If necessary set the RGBDEF environment variable.
6481
#export RGBDEF=/etc/rgb.txt
6582
#export RGBDEF=/usr/local/netpbm/lib/rgb.txt
6683
#export RGBDEF=/usr/share/emacs/*/etc/rgb.txt
6784

6885
# Declare arrays used to count and report test results.
6986
# For now only "SUCCESS" and "FAILURE" are used.
70-
declare -a array=(0 0 0 0 0)
71-
declare -a status=("SUCCESS" "FAILURE" "UNEXPECTED SUCCESS" \
72-
"EXPECTED FAILURE" "NOT SUPPORTED")
87+
declare -a array=(0 0 0 0 0 0)
88+
declare -a status=("SUCCESS" "FAILURE" "UNEXPECTED SUCCESS"
89+
"EXPECTED FAILURE" "NOT SUPPORTED" "TOTAL SUPPORTED")
90+
91+
# Copy test files to the current work directory
92+
93+
cp -n -t . ${srcdir}/testgrid.pbm ${srcdir}/testimg.ppm
7394

7495
# Execute the tests, as described in the "Test-Order" file.
7596
#
76-
# To execute just one test, or a few tests, replace the grep part
77-
# within backquotes with names of tests you want to run like this:
78-
#
79-
# for t in pbmmake.test pgmmake.test ppmmake.test
97+
# Each test outputs a ".out" file, which is compared against a
98+
# corresponding ".ok" file. For example the output from "pbmmake.test"
99+
# is "pbmmake.out" and when this matches "pbmmake.ok" we declare the
100+
# test a success.
101+
# In the error case the ".out" file is retained in the current work
102+
# directory.
103+
#
104+
# All tests are self-contained.
105+
#
106+
# By defeault the tests are executed in the order described in the
107+
# file Test-Order. Normally the Test-Order in the source directory
108+
# will be used, but the user can override this with a file named
109+
# Test-Order placed in the work directory. (This feature comes useful
110+
# when you want to pare down the list.)
111+
112+
if [ ! -f ./Test-Order ]
113+
then cp ${srcdir}/Test-Order ./Test-Order
114+
fi
80115

81-
for t in `grep -v "^#" Test-Order | grep "."`
116+
for t in `grep -v "^#" ./Test-Order | fgrep ".test"`
82117
do
83118
echo == $t ==
84-
./$t > ${t%.test}.out ; let result=$?
119+
${srcdir}/$t > ${t%.test}.out ; let result=$?
85120
case $result in
86-
0) cmp --quiet ${t%.test}.out ${t%.test}.ok ;
121+
0) cmp --quiet ${t%.test}.out ${srcdir}/${t%.test}.ok ;
87122
if [ $? -eq 0 ]
88123
then let result=0; rm ${t%.test}.out ;
89124
else let result=1;
90-
fi ;;
91-
1 | 2 | 3 ) ;;
92-
*) let result=1 ;;
125+
fi
126+
let supported=1 ;;
127+
*) let result=1 ; let supported=1;;
93128
esac
94129

95-
# Print out a summary report.
130+
131+
# Report whether a single test succeeded or failed.
132+
# Increment counters.
96133

97134
echo $t: ${status[${result}]}; echo
98135
let array[${result}]=${array[${result}]}+1
136+
let array[5]=${array[5]}+$supported
137+
99138
done
100139

140+
141+
# Erase temporary directory and its contents, if it was created.
142+
143+
if [ -n $tmpdir_created ]
144+
then rm -rf $tmpdir_created
145+
fi
146+
147+
148+
# Erase test image files in the current (work) directory.
149+
# (Do not erase them if we are working from the source directory.)
150+
151+
if [ ! $PWD -ef ${srcdir} ]
152+
then rm ./testimg.ppm ./testgrid.pbm
153+
fi
154+
155+
156+
# Calculate success / failure totals and print a summary report.
157+
# Report date and time of completion.
158+
101159
echo "Test summary:"
102160
echo ==================
103161

104-
for s in 0 1 2 3 4
105-
do
106-
if [[ ${array[${s}]} -gt 0 || s -eq 1 ]]
107-
then
108-
echo ${status[${s}]} ${array[${s}]}
109-
fi
110-
done
162+
for s in 0 1 2 3 4 5
163+
do
164+
if [[ ${array[${s}]} -gt 0 || s -eq 1 ]]
165+
then echo ${status[${s}]} ${array[${s}]}
166+
fi
167+
done
111168

112169
echo ==================
113170
echo "All tests done."
171+
date --rfc-3339=seconds
172+
173+
174+
# Exit with status 0 if all supported tests succeeded, 1 otherwise.
175+
176+
if [[ ${array[0]} -eq ${array[5]} ]]
177+
then exit 0
178+
else exit 1
179+
fi

test/Test-Order

+27-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pgmramp.test
1616
ppmgauss.test
1717
ppmcie.test
1818
ppmwheel.test
19+
ppmpat.test
1920

2021
# Analyzer tests
2122

@@ -60,6 +61,12 @@ ppmmix.test
6061
# Format converter tests
6162

6263
pbmtog3.test
64+
411toppm.test
65+
eyuvtoppm.test
66+
67+
# Miscellaneous utility tests
68+
69+
ppmdfont.test
6370

6471
# Round-trip tests : editors
6572

@@ -77,13 +84,31 @@ pamslice-roundtrip.test
7784

7885
# Round-trip tests : lossless converters
7986

80-
g3-roundtrip.test
87+
atk-roundtrip.test
88+
avs-roundtrip.test
8189
bmp-roundtrip.test
90+
cmuw-roundtrip.test
91+
facesaver-roundtrip.test
92+
fits-roundtrip.test
93+
g3-roundtrip.test
94+
gem-roundtrip.test
8295
gif-roundtrip.test
96+
hdiff-roundtrip.test
97+
leaf-roundtrip.test
98+
mgr-roundtrip.test
99+
mrf-roundtrip.test
100+
pfm-roundtrip.test
83101
png-roundtrip.test
84102
ps-roundtrip.test
103+
sunrast-roundtrip.test
104+
targa-roundtrip.test
85105
tiff-roundtrip.test
106+
utahrle-roundtrip.test
107+
wbmp-roundtrip.test
86108
xbm-roundtrip.test
87109
xpm-roundtrip.test
88110
xwd-roundtrip.test
89-
hdiff-roundtrip.test
111+
112+
# Round-trip tests : lossy converter
113+
114+
yuv-roundtrip.test

test/all-in-place.ok

+7-8
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ ppmmix: ok
262262
ppmnorm: ok
263263
ppmntsc: ok
264264
ppmpat: ok
265-
ppmquant: ok
266265
ppmrelief: ok
267266
ppmrough: ok
268267
ppmshift: ok
@@ -335,17 +334,17 @@ yuvsplittoppm: ok
335334
yuvtoppm: ok
336335
zeisstopnm: ok
337336
fiascotopnm: ok
338-
anytopnm: ok
339-
hpcdtoppm: ok
340337
manweb: ok
341-
pbmtox10bm: ok
342338
pnmmargin: ok
339+
anytopnm: ok
340+
pbmtox10bm: ok
343341
pnmnoraw: ok
342+
pnmtoplainpnm: ok
343+
ppmtomap: ok
344+
ppmshadow: ok
344345
pnmquant: ok
345346
pnmquantall: ok
346-
pnmtoplainpnm: ok
347-
ppmfade: ok
347+
ppmquant: ok
348348
ppmquantall: ok
349349
ppmrainbow: ok
350-
ppmshadow: ok
351-
ppmtomap: ok
350+
ppmfade: ok

0 commit comments

Comments
 (0)