Skip to content

Commit f0c05ff

Browse files
author
giraffedata
committed
Test invalid command line arguments
git-svn-id: https://svn.code.sf.net/p/netpbm/code/trunk@4090 9d0c8265-081b-0410-96cb-a4ca84ce46f8
1 parent eb5bd43 commit f0c05ff

Some content is hidden

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

44 files changed

+1051
-364
lines changed

test/pamarith.test

+74-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /bin/bash
22
# This script tests: pamarith
3-
# Also requires: pamtopnm rgb3toppm pamenlarge pnmcat pamseq pbmmake pgmmake
4-
# Also requires: ppmpat pamchannel
3+
# Also requires: pamtopnm rgb3toppm pamenlarge pnmcat pamseq pbmmake pgmmake
4+
# Also requires: ppmpat pamchannel
55

66
tmpdir=${tmpdir:-/tmp}
77
input1_pgm=${tmpdir}/input1.pgm
@@ -15,8 +15,8 @@ echo "Test 1"
1515
pamseq 1 15 | pamtopnm -assume > ${input1_pgm}
1616
pgmmake -maxval 15 0.15 16 1 > ${input2_pgm}
1717

18-
rgb3toppm ${input1_pgm} ${input1_pgm} ${input1_pgm} > ${input1_ppm}
19-
rgb3toppm ${input2_pgm} ${input2_pgm} ${input2_pgm} > ${input2_ppm}
18+
rgb3toppm ${input1_pgm} ${input1_pgm} ${input1_pgm} > ${input1_ppm}
19+
rgb3toppm ${input2_pgm} ${input2_pgm} ${input2_pgm} > ${input2_ppm}
2020

2121
pnmcat -tb -plain ${input1_pgm} ${input2_pgm}
2222

@@ -93,7 +93,7 @@ echo "cksum is 2425386270 41 or 2921940274 59"
9393
for image in testgrid.pbm ${input1_ppm}
9494
do
9595
echo "input image"
96-
cat ${image} | cksum
96+
cat ${image} | cksum
9797
for fn in "-minimum" "-maximum" "-mean" "-and" "-or"
9898
do
9999
echo ${fn}
@@ -130,98 +130,129 @@ output_ppm=${tmpdir}/output.ppm
130130
pamarith -add -subtract testimg.ppm testimg.ppm > ${output_ppm} || \
131131
echo -n "Expected failure 1"
132132
test -s ${output_ppm}; echo " "$?
133+
rm -f ${test_out}
134+
133135
pamarith -multiply -divide testimg.ppm testimg.ppm > ${output_ppm} || \
134136
echo -n "Expected failure 2"
135137
test -s ${output_ppm}; echo " "$?
138+
rm -f ${test_out}
139+
136140
pamarith -difference -minimum testimg.ppm testimg.ppm > ${output_ppm} || \
137141
echo -n "Expected failure 3"
138142
test -s ${output_ppm}; echo " "$?
143+
rm -f ${test_out}
144+
139145
pamarith -maximum -mean testimg.ppm testimg.ppm > ${output_ppm} || \
140146
echo -n "Expected failure 4"
141147
test -s ${output_ppm}; echo " "$?
148+
rm -f ${test_out}
149+
142150
pamarith -compare -and testimg.ppm testimg.ppm > ${output_ppm} || \
143151
echo -n "Expected failure 5"
144152
test -s ${output_ppm}; echo " "$?
153+
rm -f ${test_out}
154+
145155
pamarith -compare -equal testimg.ppm testimg.ppm > ${output_ppm} || \
146156
echo -n "Expected failure 6"
147157
test -s ${output_ppm}; echo " "$?
158+
rm -f ${test_out}
159+
148160
pamarith -or -nand testimg.ppm testimg.ppm > ${output_ppm} || \
149161
echo -n "Expected failure 7"
150162
test -s ${output_ppm}; echo " "$?
163+
rm -f ${test_out}
164+
151165
pamarith -nor -xor testimg.ppm testimg.ppm > ${output_ppm} || \
152166
echo -n "Expected failure 8"
153167
test -s ${output_ppm}; echo " "$?
168+
rm -f ${test_out}
169+
154170
pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${output_ppm} || \
155171
echo -n "Expected failure 9"
156172
test -s ${output_ppm}; echo " "$?
173+
rm -f ${test_out}
157174

158175
# -add does not take a value
159176

160177
pamarith -add=1 testimg.ppm testimg.ppm > ${output_ppm} || \
161178
echo -n "Expected failure 10"
162179
test -s ${output_ppm}; echo " "$?
180+
rm -f ${test_out}
163181

164182
# No function
165183

166184
pamarith -plain testimg.ppm testimg.ppm > ${output_ppm} || \
167185
echo -n "Expected failure 11"
168186
test -s ${output_ppm}; echo " "$?
187+
rm -f ${test_out}
169188

170189
pamarith testimg.ppm testimg.ppm > ${output_ppm} || \
171190
echo -n "Expected failure 12"
172191
test -s ${output_ppm}; echo " "$?
192+
rm -f ${test_out}
173193

174194
# Just one input image file
175195

176196
pamarith -add testimg.ppm > ${output_ppm} || \
177197
echo -n "Expected failure 13"
178198
test -s ${output_ppm}; echo " "$?
199+
rm -f ${test_out}
179200

180201
# No input image file
181202

182203
pamarith -add > ${output_ppm} || \
183204
echo -n "Expected failure 14"
184205
test -s ${output_ppm}; echo " "$?
206+
rm -f ${test_out}
185207

186208
# Input images with different depth (number of planes)
187209

188210
pamchannel -infile testimg.ppm 0 1 | \
189211
pamarith -add testimg.ppm - > ${output_ppm} || \
190212
echo -n "Expected failure 15"
191213
test -s ${output_ppm}; echo " "$?
192-
214+
rm -f ${test_out}
193215

194216
# Input images with different x/y dimensions
195217

196218
pamarith -add testimg.ppm testgrid.pbm > ${output_ppm} || \
197219
echo -n "Expected failure 16"
198220
test -s ${output_ppm}; echo " "$?
221+
rm -f ${test_out}
199222

200223
pamenlarge -xscale=2 testgrid.pbm | \
201224
pamarith -add testgrid.pbm - > ${output_ppm} || \
202225
echo -n "Expected failure 17"
203226
test -s ${output_ppm}; echo " "$?
227+
rm -f ${test_out}
204228

205229
pamenlarge -yscale=3 testgrid.pbm | \
206230
pamarith -add testgrid.pbm - > ${output_ppm} || \
207231
echo -n "Expected failure 18"
208232
test -s ${output_ppm}; echo " "$?
209-
233+
rm -f ${test_out}
210234

211235
# Invalid usage of -closeness
212236

213237
pamarith -equal -closeness=100.1 testgrid.pbm > ${output_ppm} || \
214238
echo -n "Expected failure 19"
215239
test -s ${output_ppm}; echo " "$?
240+
rm -f ${test_out}
241+
216242
pamarith -equal -closeness=-10 testgrid.pbm > ${output_ppm} || \
217243
echo -n "Expected failure 20"
218244
test -s ${output_ppm}; echo " "$?
245+
rm -f ${test_out}
246+
219247
pamarith -closeness -equal testgrid.pbm > ${output_ppm} || \
220248
echo -n "Expected failure 21"
221249
test -s ${output_ppm}; echo " "$?
250+
rm -f ${test_out}
251+
222252
pamarith -compare -closeness=10 testgrid.pbm > ${output_ppm} || \
223253
echo -n "Expected failure 22"
224254
test -s ${output_ppm}; echo " "$?
255+
rm -f ${test_out}
225256

226257
# Bit string functions
227258
# Create PGM test input
@@ -230,7 +261,7 @@ input3_pgm=${tmpdir}/input3.pgm
230261
input4_pgm=${tmpdir}/input4.pgm
231262
input5_pgm=${tmpdir}/input5.pgm
232263

233-
pgmmake -maxval=4095 1.0 3 1 > ${input3_pgm}
264+
pgmmake -maxval=4095 1.0 3 1 > ${input3_pgm}
234265
pgmmake -maxval=4096 1.0 3 1 > ${input4_pgm}
235266
pgmmake -maxval=8191 1.0 3 1 > ${input5_pgm}
236267

@@ -239,43 +270,64 @@ pgmmake -maxval=8191 1.0 3 1 > ${input5_pgm}
239270
pamarith -and ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
240271
echo -n "Expected failure 23"
241272
test -s ${output_ppm}; echo " "$?
273+
rm -f ${test_out}
274+
242275
pamarith -or ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
243276
echo -n "Expected failure 24"
244277
test -s ${output_ppm}; echo " "$?
278+
rm -f ${test_out}
279+
245280
pamarith -nand ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
246281
echo -n "Expected failure 25"
247282
test -s ${output_ppm}; echo " "$?
283+
rm -f ${test_out}
284+
248285
pamarith -nor ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
249286
echo -n "Expected failure 26"
250287
test -s ${output_ppm}; echo " "$?
288+
rm -f ${test_out}
289+
251290
pamarith -xor ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
252291
echo -n "Expected failure 27"
253292
test -s ${output_ppm}; echo " "$?
293+
rm -f ${test_out}
254294

255295
# Bit string functions - Maxval must be 2^n -1
256296

257297
pamarith -and ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
258298
echo -n "Expected failure 28"
259299
test -s ${output_ppm}; echo " "$?
300+
rm -f ${test_out}
301+
260302
pamarith -or ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
261303
echo -n "Expected failure 29"
262304
test -s ${output_ppm}; echo " "$?
305+
rm -f ${test_out}
306+
263307
pamarith -nand ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
264308
echo -n "Expected failure 30"
265309
test -s ${output_ppm}; echo " "$?
310+
rm -f ${test_out}
311+
266312
pamarith -nor ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
267313
echo -n "Expected failure 31"
268314
test -s ${output_ppm}; echo " "$?
315+
rm -f ${test_out}
316+
269317
pamarith -xor ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
270318
echo -n "Expected failure 32"
271319
test -s ${output_ppm}; echo " "$?
320+
rm -f ${test_out}
272321

273322
pamarith -shiftleft ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
274323
echo -n "Expected failure 33"
275324
test -s ${output_ppm}; echo " "$?
325+
rm -f ${test_out}
326+
276327
pamarith -shiftright ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
277328
echo -n "Expected failure 34"
278329
test -s ${output_ppm}; echo " "$?
330+
rm -f ${test_out}
279331

280332
rm ${input3_pgm} ${input4_pgm} ${input5_pgm}
281333

@@ -286,30 +338,44 @@ rm ${input3_pgm} ${input4_pgm} ${input5_pgm}
286338
pamarith -subtract testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
287339
echo -n "Expected failure 35"
288340
test -s ${output_ppm}; echo " "$?
341+
rm -f ${test_out}
342+
289343
pamarith -divide testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
290344
echo -n "Expected failure 36"
291345
test -s ${output_ppm}; echo " "$?
346+
rm -f ${test_out}
347+
292348
pamarith -compare testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
293349
echo -n "Expected failure 37"
294350
test -s ${output_ppm}; echo " "$?
351+
rm -f ${test_out}
352+
295353
pamarith -difference testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
296354
echo -n "Expected failure 38"
297355
test -s ${output_ppm}; echo " "$?
356+
rm -f ${test_out}
357+
298358
pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
299359
echo -n "Expected failure 39"
300360
test -s ${output_ppm}; echo " "$?
361+
rm -f ${test_out}
362+
301363
pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
302364
echo -n "Expected failure 40"
303365
test -s ${output_ppm}; echo " "$?
366+
rm -f ${test_out}
304367

305368
# Currently -equal and -mean do not allow more than two input images.
306369
# These two cases should be removed once improvements are made.
307370

308371
pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm > ${output_ppm} || \
309372
echo -n "Expected failure 41"
310373
test -s ${output_ppm}; echo " "$?
374+
rm -f ${test_out}
375+
311376
pamarith -mean testgrid.pbm testgrid.pbm testgrid.pbm > ${output_ppm} || \
312377
echo -n "Expected failure 42"
313378
test -s ${output_ppm}; echo " "$?
379+
rm -f ${test_out}
314380

315381
rm ${output_ppm}

test/pamchannel.test

+9-5
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ test_out=${tmpdir}/test_out
4646
echo "Test Invalid"
4747

4848
pamchannel -infile testgrid.pbm 1 > ${test_out} || \
49-
echo -n "Expected failure 1"; test -s ${test_out}; echo " "$?
49+
echo -n "Expected failure 1"
50+
test -s ${test_out}; echo " "$?
51+
rm -f {test_out}
5052

5153
pamchannel -infile testimg.ppm 3 > ${test_out} || \
52-
echo -n "Expected failure 2"; test -s ${test_out}; echo " "$?
54+
echo -n "Expected failure 2"
55+
test -s ${test_out}; echo " "$?
56+
rm -f {test_out}
5357

5458
pamtopam testimg.ppm | pamchannel -infile=- 4 > ${test_out} || \
55-
echo -n "Expected failure 3"; test -s ${test_out}; echo " "$?
56-
57-
rm ${test_out}
59+
echo -n "Expected failure 3"
60+
test -s ${test_out}; echo " "$?
61+
rm -f {test_out}

test/pamcrater.test

+12-6
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,21 @@ echo "Error messages should appear below the line." 1>&2
6464
echo "------------------------------" 1>&2
6565

6666
pamcrater -width 0 > ${test_out} || \
67-
echo -n "Expected failure 1"; test -s ${test_out}; echo " "$?
67+
echo -n "Expected failure 1"
68+
test -s ${test_out}; echo " "$?
69+
rm -f {test_out}
6870

6971
pamcrater -height 0 > ${test_out} || \
70-
echo -n "Expected failure 2"; test -s ${test_out}; echo " "$?
72+
echo -n "Expected failure 2"
73+
test -s ${test_out}; echo " "$?
74+
rm -f {test_out}
7175

7276
pamcrater -number 0 > ${test_out} || \
73-
echo -n "Expected failure 3"; test -s ${test_out}; echo " "$?
77+
echo -n "Expected failure 3"
78+
test -s ${test_out}; echo " "$?
79+
rm -f {test_out}
7480

7581
pamcrater -test -radius=10 | pamshadedrelief -gamma 0 > ${test_out} || \
76-
echo -n "Expected failure 4"; test -s ${test_out}; echo " "$?
77-
78-
rm -f ${test_out}
82+
echo -n "Expected failure 4"
83+
test -s ${test_out}; echo " "$?
84+
rm -f {test_out}

0 commit comments

Comments
 (0)