Skip to content

Commit 7053e7f

Browse files
author
giraffedata
committed
new test for 'infotopam', color dictionary stuff
git-svn-id: https://svn.code.sf.net/p/netpbm/code/trunk@4909 9d0c8265-081b-0410-96cb-a4ca84ce46f8
1 parent be68d3a commit 7053e7f

File tree

7 files changed

+254
-257
lines changed

7 files changed

+254
-257
lines changed

test/Execute-Tests

+53-42
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,30 @@ esac
5353
export srcdir=$(dirname $0)
5454

5555
# Set tmpdir, which is used in some of the test scripts. By default
56-
# this is created by mktemp. The user can override and specify tmpdir,
57-
# but in this case it must be an existing directory and must not be
58-
# either $srcdir or current work.
56+
# this is created by mktemp. To override edit the following lines.
57+
58+
# When tmpdir is specified it must be an existing directory and must
59+
# not be either $srcdir or current work. tmpdir should not contain
60+
# whitespace, non-printable characters, etc.
61+
62+
tmpdir_created=$(mktemp -d "${TMPDIR:-/tmp}/netpbm.XXXXXXXX") || exit 1;
63+
export tmpdir=${tmpdir_created}
5964

60-
if [ -z $tmpdir ]
61-
then
62-
tmpdir_created=$(mktemp -d "${TMPDIR:-/tmp}/netpbm.XXXXXXXX") || exit 1;
63-
export tmpdir=${tmpdir_created}
64-
else
65-
tmpdir_created="";
66-
if [ ! -d ${tmpdir} ]
67-
then echo "Specified temporary directory $tmpdir does not exist."
68-
exit 1;
69-
elif [ ${tmpdir} -ef ${srcdir} ]
70-
then echo "Temporary directory must not be $srcdir."
71-
exit 1;
72-
elif [ ${tmpdir} -ef $PWD ]
73-
then echo "Temporary directory must not be current directory."
74-
exit 1;
75-
fi
76-
fi
7765

78-
# If necessary set the RGBDEF environment variable.
79-
#export RGBDEF=/etc/rgb.txt
80-
#export RGBDEF=/usr/local/netpbm/lib/rgb.txt
81-
#export RGBDEF=/usr/share/emacs/*/etc/rgb.txt
66+
# tmpdir_created=""
67+
# export tmpdir=/tmp/netpbm-test-tempdir
68+
69+
# if [ ! -d "${tmpdir}" ]
70+
# then echo "Specified temporary directory $tmpdir does not exist."
71+
# exit 1;
72+
# elif [ "${tmpdir}" -ef "${srcdir}" ]
73+
# then echo "Temporary directory must not be $srcdir."
74+
# exit 1;
75+
# elif [ "${tmpdir}" -ef "$PWD" ]
76+
# then echo "Temporary directory must not be current directory."
77+
# exit 1;
78+
# fi
79+
#fi
8280

8381

8482
# Declare arrays used to count and report test results.
@@ -100,17 +98,29 @@ status[4]="NOT TESTABLE"
10098
# Copy test image files to the current work directory
10199

102100
if [ ! -f ./testgrid.pbm ]
103-
then cp -v ${srcdir}/testgrid.pbm ./testgrid.pbm
101+
then cp -v "${srcdir}"/testgrid.pbm ./testgrid.pbm
104102
fi
105103

106104
if [ ! -f ./maze.pbm ]
107-
then cp -v ${srcdir}/maze.pbm ./maze.pbm
105+
then cp -v "${srcdir}"/maze.pbm ./maze.pbm
108106
fi
109107

110108
if [ ! -f ./testimg.ppm ]
111-
then cp -v ${srcdir}/testimg.ppm ./testimg.ppm
109+
then cp -v "${srcdir}"/testimg.ppm ./testimg.ppm
110+
fi
111+
112+
if [ ! -f ./rgbt.txt ]
113+
then cp -v "${srcdir}"/rgbt.txt ./rgbt.txt
114+
# Color name dictionary file rgbt.txt is a short digest.
115+
# If desired use the proper file:
116+
# cp -v /etc/rgb.txt ./rgbt.txt
117+
# cp -v $RGBDEF ./rgbt.txt
112118
fi
113119

120+
if [ ! -f ./test-invalid.inc ]
121+
then cp -v "${srcdir}"/test-invalid.inc ./test-invalid.inc
122+
fi
123+
114124
# The block-bin directory
115125
#
116126
# This directory contains dummy executables with the names of the
@@ -130,14 +140,14 @@ if [ ! -z $PBM_TEST_PATH ]
130140
then rm -rf $blockbin
131141
fi
132142
mkdir $blockbin
133-
cp ${srcdir}/BLOCK $blockbin/BLOCK
143+
cp "${srcdir}"/BLOCK $blockbin/BLOCK
134144
chmod +x $blockbin/BLOCK
135145

136146
# Populate the block-bin directory using all-in-place.ok and
137147
# legacy-names.ok which together make a complete list of programs.
138148

139149
sed 's/: ok$//' \
140-
${srcdir}/all-in-place.ok ${srcdir}/legacy-names.ok | \
150+
"${srcdir}"/all-in-place.ok "${srcdir}"/legacy-names.ok | \
141151
tr ' ' '\n' | while read prog
142152
do
143153
ln -s $blockbin/BLOCK $blockbin/$prog
@@ -216,17 +226,17 @@ if [ ! -z $target ]
216226
echo $target | sed 's/,/\n/g' | \
217227
sed -e 's/^/# This script tests: .*\\</' -e 's/$/\\>/' \
218228
-e '/^$/q' | \
219-
grep -f - ${srcdir}/*.test -l | \
229+
grep -f - "${srcdir}"/*.test -l | \
220230
while read i ; do echo ${i##*/} ; done | \
221-
grep -f - ${srcdir}/Test-Order > ./Test-Order ;
231+
grep -f - "${srcdir}"/Test-Order > ./Test-Order ;
222232
if [ ! -s ./Test-Order ]
223233
then echo;
224234
echo "Error: No testable program names in target: "$target;
225235
echo; exit 1
226236
fi
227237
else
228-
cp ${srcdir}/Test-Order ./Test-Order ;
229-
#cp --no-clobber ${srcdir}/Test-Order ./Test-Order ;
238+
cp "${srcdir}"/Test-Order ./Test-Order ;
239+
#cp --no-clobber "${srcdir}"/Test-Order ./Test-Order ;
230240
fi
231241

232242
echo
@@ -250,25 +260,25 @@ fi
250260
# either of these conditions are not met, do not execute the test and
251261
# report "Not Testable".
252262

253-
if [ ! -s ${srcdir}/${tname%.test}.ok ]
263+
if [ ! -s "${srcdir}"/${tname%.test}.ok ]
254264
then
255265
echo "${tname%.test}.ok does not exist"
256266
let result=4;
257267
else
258-
${srcdir}/Available-Testprog \
268+
"${srcdir}"/Available-Testprog \
259269
`sed -n -e '/^# This script tests: /s/# This script tests: //p' \
260270
-e '/^# Also requires: /s/^# Also requires: //p' \
261-
-e '/^$/q' ${srcdir}/$tname | tr '\n' ' '`
271+
-e '/^$/q' "${srcdir}"/$tname | tr '\n' ' '`
262272
case $? in
263273
0)
264-
PATH=${testpath} $vg_command ${srcdir}/$tname > ${tname%.test}.out;
274+
PATH=${testpath} $vg_command "${srcdir}"/$tname > ${tname%.test}.out;
265275
let retval=$?
266276
case $retval in
267-
0) cmp -s ${tname%.test}.out ${srcdir}/${tname%.test}.ok ;
277+
0) cmp -s ${tname%.test}.out "${srcdir}"/${tname%.test}.ok ;
268278
if [ $? -eq 0 ]
269279
then let result=0; rm ${tname%.test}.out ;
270280
else let result=1;
271-
grep "^##" ${srcdir}/$tname # Print failure message.
281+
grep "^##" "${srcdir}"/$tname # Print failure message.
272282
fi ;;
273283
80) let result=4 ;;
274284
*) let result=1 ;;
@@ -290,7 +300,7 @@ done
290300

291301
# Erase temporary bin directory and its contents.
292302

293-
rm -rf ${srcdir}/bin
303+
rm -rf "${srcdir}"/bin
294304

295305

296306
# Erase temporary directory and its contents, if it was created.
@@ -303,8 +313,9 @@ fi
303313
# Erase test image files in the current (work) directory.
304314
# (Do not erase them if we are working from the source directory.)
305315

306-
if [ ! $PWD -ef ${srcdir} ]
307-
then rm ./testimg.ppm ./testgrid.pbm ./maze.pbm
316+
if [ ! $PWD -ef "${srcdir}" ]
317+
then rm ./testimg.ppm ./testgrid.pbm ./maze.pbm \
318+
./rgbt.txt ./test-invalid.inc
308319
fi
309320

310321

test/Test-Order

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ ppmtoapplevol.test
178178
ppmtomitsu.test
179179
411toppm.test
180180
eyuvtoppm.test
181+
infotopam.test
181182
rawtoppm.test
182183

183184
gif-transparent1.test

test/pamcut.ok

-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,3 @@ Expected failure 10 (no output)
100100
Expected failure 11 (no output)
101101
Expected failure 12 (no output)
102102
Expected failure 13 (no output)
103-
Expected failure 14 (no output)
104-
Expected failure 15 (no output)
105-
Expected failure 16 (no output)
106-
Expected failure 17 (no output)

test/pamcut.test

+28-28
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 \
6666
-reportonly maze.pbm
6767
pamcut -top 0 -left 0 \
6868
-bottom $((${height} -1)) -right $((${width} -1)) \
69-
-reportonly maze.pbm
69+
-reportonly maze.pbm
7070
pamcut -top 0 -left 0 -bottom -1 -right -1 -reportonly maze.pbm
7171
pamcut -top 0 -left 0 -width ${width} -height ${height} \
7272
-reportonly maze.pbm
@@ -75,10 +75,10 @@ pamcut -reportonly maze.pbm
7575
echo "Test 5b. Should print 281226646 481 twice"
7676

7777
pamcut -croptop 0 -cropleft 0 -cropbottom 0 -cropright 0 maze.pbm | \
78-
cksum
78+
cksum
7979
pamcut maze.pbm | cksum
8080

81-
test50_pbm=${tmpdir}/test50.pbm
81+
test50_pbm="${tmpdir}"/test50.pbm
8282

8383
echo "Test 6a. Should print 5 34 5 34 50 50 30 30"
8484

@@ -92,7 +92,7 @@ rm ${test50_pbm}
9292

9393
echo "Test 7. Should print 284857390 12 sixteen times"
9494

95-
test1_pbm=${tmpdir}/test1.pbm
95+
test1_pbm="${tmpdir}"/test1.pbm
9696

9797
pbmmake -b 1 1 > ${test1_pbm}
9898

@@ -121,12 +121,12 @@ pamcut -pad -cropright=17 -width=5 -height=5 ${test1_pbm} | cksum
121121

122122
echo "Test 8. Should print 3125257619 29 four times"
123123

124-
test3_pbm=${tmpdir}/test3.pbm
124+
test3_pbm="${tmpdir}"/test3.pbm
125125

126126
pbmmake -g 3 3 > ${test3_pbm}
127127

128-
pamcut -pad -cropleft=10 -croptop=10 -width=10 -height=10 ${test3_pbm} | cksum
129-
pamcut -pad -cropright=10 -croptop=10 -width=10 -height=10 ${test3_pbm} |\
128+
pamcut -pad -cropleft=10 -croptop=10 -width=10 -height=10 ${test3_pbm} | cksum
129+
pamcut -pad -cropright=10 -croptop=10 -width=10 -height=10 ${test3_pbm} |\
130130
pamflip -lr | cksum
131131
pamcut -pad -cropleft=10 -cropbottom=10 -width=10 -height=10 ${test3_pbm} |\
132132
pamflip -tb | cksum
@@ -137,7 +137,7 @@ rm ${test3_pbm}
137137

138138
echo "Test 9. Should print 3338453023 36 sixteen times"
139139

140-
testb_pgm=${tmpdir}/testb.pgm
140+
testb_pgm="${tmpdir}"/testb.pgm
141141

142142
pgmmake 0.0 1 1 > ${testb_pgm}
143143

@@ -167,7 +167,7 @@ rm ${testb_pgm}
167167

168168
echo "Test 10. Should print 3957742883 302 four times"
169169

170-
testg_pgm=${tmpdir}/testg.pgm
170+
testg_pgm="${tmpdir}"/testg.pgm
171171

172172
pgmmake 0.5 2 2 > ${testg_pgm}
173173

@@ -185,7 +185,7 @@ rm ${testg_pgm}
185185

186186
echo "Test 11. Should print 1576602925 8 four times"
187187

188-
test5_pbm=${tmpdir}/test5.pbm
188+
test5_pbm="${tmpdir}"/test5.pbm
189189

190190
pbmmake -g 5 5 > ${test5_pbm}
191191

@@ -198,29 +198,29 @@ rm ${test1_pbm} ${test5_pbm}
198198

199199
echo "Test Invalid"
200200

201-
. ${srcdir}/test-invalid.inc
201+
. ./test-invalid.inc
202202

203203
# overspecification
204-
invCmd "pamcut -left=1 -right=1 -width=14 testgrid.pbm"
205-
invCmd "pamcut -top=1 -bottom=1 -height=16 testgrid.pbm"
206-
invCmd "pamcut -right=1 -cropright=1 testgrid.pbm"
207-
invCmd "pamcut -top=1 -croptop=1 testgrid.pbm"
208-
invCmd "pamcut -bottom=1 -cropbottom=1 testgrid.pbm"
209-
invCmd "pamcut -left=1 -cropleft=1 testgrid.pbm"
204+
invCmd 'pamcut -left=1 -right=1 -width=14 testgrid.pbm"
205+
invCmd 'pamcut -top=1 -bottom=1 -height=16 testgrid.pbm"
206+
invCmd 'pamcut -right=1 -cropright=1 testgrid.pbm"
207+
invCmd 'pamcut -top=1 -croptop=1 testgrid.pbm"
208+
invCmd 'pamcut -bottom=1 -cropbottom=1 testgrid.pbm"
209+
invCmd 'pamcut -left=1 -cropleft=1 testgrid.pbm"
210210

211211
# excessive amounts
212-
invCmd "pamcut -cropleft=14 testgrid.pbm"
213-
invCmd "pamcut -cropleft=7 -cropright=8 testgrid.pbm"
214-
invCmd "pamcut -left=7 -right=6 testgrid.pbm"
215-
invCmd "pamcut -croptop=16 testgrid.pbm"
216-
invCmd "pamcut -croptop=8 -cropbottom=8 testgrid.pbm"
217-
invCmd "pamcut -top=10 -bottom=9 testgrid.pbm"
212+
invCmd 'pamcut -cropleft=14 testgrid.pbm'
213+
invCmd 'pamcut -cropleft=7 -cropright=8 testgrid.pbm'
214+
invCmd 'pamcut -left=7 -right=6 testgrid.pbm'
215+
invCmd 'pamcut -croptop=16 testgrid.pbm'
216+
invCmd 'pamcut -croptop=8 -cropbottom=8 testgrid.pbm'
217+
invCmd 'pamcut -top=10 -bottom=9 testgrid.pbm'
218218

219219
# pad absent
220-
invCmd "pamcut -cropleft=1 -width=14 testgrid.pbm"
221-
invCmd "pamcut -croptop=1 -height=16 testgrid.pbm"
220+
invCmd 'pamcut -cropleft=1 -width=14 testgrid.pbm'
221+
invCmd 'pamcut -croptop=1 -height=16 testgrid.pbm'
222222

223223
# legacy style: insufficient number of positional parameters
224-
invCmd "pamcut 5 testimg.ppm"
225-
invCmd "pamcut 5 4 testimg.ppm"
226-
invCmd "pamcut 5 5 30 testimg.ppm"
224+
invCmd 'pamcut 5 testimg.ppm'
225+
invCmd 'pamcut 5 4 testimg.ppm'
226+
invCmd 'pamcut 5 5 30 testimg.ppm'

0 commit comments

Comments
 (0)