1
1
#! /bin/bash
2
2
# 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
5
5
6
6
tmpdir=${tmpdir:-/ tmp}
7
7
input1_pgm=${tmpdir} /input1.pgm
@@ -15,8 +15,8 @@ echo "Test 1"
15
15
pamseq 1 15 | pamtopnm -assume > ${input1_pgm}
16
16
pgmmake -maxval 15 0.15 16 1 > ${input2_pgm}
17
17
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}
20
20
21
21
pnmcat -tb -plain ${input1_pgm} ${input2_pgm}
22
22
@@ -93,7 +93,7 @@ echo "cksum is 2425386270 41 or 2921940274 59"
93
93
for image in testgrid.pbm ${input1_ppm}
94
94
do
95
95
echo " input image"
96
- cat ${image} | cksum
96
+ cat ${image} | cksum
97
97
for fn in " -minimum" " -maximum" " -mean" " -and" " -or"
98
98
do
99
99
echo ${fn}
@@ -130,98 +130,129 @@ output_ppm=${tmpdir}/output.ppm
130
130
pamarith -add -subtract testimg.ppm testimg.ppm > ${output_ppm} || \
131
131
echo -n " Expected failure 1"
132
132
test -s ${output_ppm} ; echo " " $?
133
+ rm -f ${test_out}
134
+
133
135
pamarith -multiply -divide testimg.ppm testimg.ppm > ${output_ppm} || \
134
136
echo -n " Expected failure 2"
135
137
test -s ${output_ppm} ; echo " " $?
138
+ rm -f ${test_out}
139
+
136
140
pamarith -difference -minimum testimg.ppm testimg.ppm > ${output_ppm} || \
137
141
echo -n " Expected failure 3"
138
142
test -s ${output_ppm} ; echo " " $?
143
+ rm -f ${test_out}
144
+
139
145
pamarith -maximum -mean testimg.ppm testimg.ppm > ${output_ppm} || \
140
146
echo -n " Expected failure 4"
141
147
test -s ${output_ppm} ; echo " " $?
148
+ rm -f ${test_out}
149
+
142
150
pamarith -compare -and testimg.ppm testimg.ppm > ${output_ppm} || \
143
151
echo -n " Expected failure 5"
144
152
test -s ${output_ppm} ; echo " " $?
153
+ rm -f ${test_out}
154
+
145
155
pamarith -compare -equal testimg.ppm testimg.ppm > ${output_ppm} || \
146
156
echo -n " Expected failure 6"
147
157
test -s ${output_ppm} ; echo " " $?
158
+ rm -f ${test_out}
159
+
148
160
pamarith -or -nand testimg.ppm testimg.ppm > ${output_ppm} || \
149
161
echo -n " Expected failure 7"
150
162
test -s ${output_ppm} ; echo " " $?
163
+ rm -f ${test_out}
164
+
151
165
pamarith -nor -xor testimg.ppm testimg.ppm > ${output_ppm} || \
152
166
echo -n " Expected failure 8"
153
167
test -s ${output_ppm} ; echo " " $?
168
+ rm -f ${test_out}
169
+
154
170
pamarith -shiftleft -shiftright testimg.ppm testimg.ppm > ${output_ppm} || \
155
171
echo -n " Expected failure 9"
156
172
test -s ${output_ppm} ; echo " " $?
173
+ rm -f ${test_out}
157
174
158
175
# -add does not take a value
159
176
160
177
pamarith -add=1 testimg.ppm testimg.ppm > ${output_ppm} || \
161
178
echo -n " Expected failure 10"
162
179
test -s ${output_ppm} ; echo " " $?
180
+ rm -f ${test_out}
163
181
164
182
# No function
165
183
166
184
pamarith -plain testimg.ppm testimg.ppm > ${output_ppm} || \
167
185
echo -n " Expected failure 11"
168
186
test -s ${output_ppm} ; echo " " $?
187
+ rm -f ${test_out}
169
188
170
189
pamarith testimg.ppm testimg.ppm > ${output_ppm} || \
171
190
echo -n " Expected failure 12"
172
191
test -s ${output_ppm} ; echo " " $?
192
+ rm -f ${test_out}
173
193
174
194
# Just one input image file
175
195
176
196
pamarith -add testimg.ppm > ${output_ppm} || \
177
197
echo -n " Expected failure 13"
178
198
test -s ${output_ppm} ; echo " " $?
199
+ rm -f ${test_out}
179
200
180
201
# No input image file
181
202
182
203
pamarith -add > ${output_ppm} || \
183
204
echo -n " Expected failure 14"
184
205
test -s ${output_ppm} ; echo " " $?
206
+ rm -f ${test_out}
185
207
186
208
# Input images with different depth (number of planes)
187
209
188
210
pamchannel -infile testimg.ppm 0 1 | \
189
211
pamarith -add testimg.ppm - > ${output_ppm} || \
190
212
echo -n " Expected failure 15"
191
213
test -s ${output_ppm} ; echo " " $?
192
-
214
+ rm -f ${test_out}
193
215
194
216
# Input images with different x/y dimensions
195
217
196
218
pamarith -add testimg.ppm testgrid.pbm > ${output_ppm} || \
197
219
echo -n " Expected failure 16"
198
220
test -s ${output_ppm} ; echo " " $?
221
+ rm -f ${test_out}
199
222
200
223
pamenlarge -xscale=2 testgrid.pbm | \
201
224
pamarith -add testgrid.pbm - > ${output_ppm} || \
202
225
echo -n " Expected failure 17"
203
226
test -s ${output_ppm} ; echo " " $?
227
+ rm -f ${test_out}
204
228
205
229
pamenlarge -yscale=3 testgrid.pbm | \
206
230
pamarith -add testgrid.pbm - > ${output_ppm} || \
207
231
echo -n " Expected failure 18"
208
232
test -s ${output_ppm} ; echo " " $?
209
-
233
+ rm -f ${test_out}
210
234
211
235
# Invalid usage of -closeness
212
236
213
237
pamarith -equal -closeness=100.1 testgrid.pbm > ${output_ppm} || \
214
238
echo -n " Expected failure 19"
215
239
test -s ${output_ppm} ; echo " " $?
240
+ rm -f ${test_out}
241
+
216
242
pamarith -equal -closeness=-10 testgrid.pbm > ${output_ppm} || \
217
243
echo -n " Expected failure 20"
218
244
test -s ${output_ppm} ; echo " " $?
245
+ rm -f ${test_out}
246
+
219
247
pamarith -closeness -equal testgrid.pbm > ${output_ppm} || \
220
248
echo -n " Expected failure 21"
221
249
test -s ${output_ppm} ; echo " " $?
250
+ rm -f ${test_out}
251
+
222
252
pamarith -compare -closeness=10 testgrid.pbm > ${output_ppm} || \
223
253
echo -n " Expected failure 22"
224
254
test -s ${output_ppm} ; echo " " $?
255
+ rm -f ${test_out}
225
256
226
257
# Bit string functions
227
258
# Create PGM test input
@@ -230,7 +261,7 @@ input3_pgm=${tmpdir}/input3.pgm
230
261
input4_pgm=${tmpdir} /input4.pgm
231
262
input5_pgm=${tmpdir} /input5.pgm
232
263
233
- pgmmake -maxval=4095 1.0 3 1 > ${input3_pgm}
264
+ pgmmake -maxval=4095 1.0 3 1 > ${input3_pgm}
234
265
pgmmake -maxval=4096 1.0 3 1 > ${input4_pgm}
235
266
pgmmake -maxval=8191 1.0 3 1 > ${input5_pgm}
236
267
@@ -239,43 +270,64 @@ pgmmake -maxval=8191 1.0 3 1 > ${input5_pgm}
239
270
pamarith -and ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
240
271
echo -n " Expected failure 23"
241
272
test -s ${output_ppm} ; echo " " $?
273
+ rm -f ${test_out}
274
+
242
275
pamarith -or ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
243
276
echo -n " Expected failure 24"
244
277
test -s ${output_ppm} ; echo " " $?
278
+ rm -f ${test_out}
279
+
245
280
pamarith -nand ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
246
281
echo -n " Expected failure 25"
247
282
test -s ${output_ppm} ; echo " " $?
283
+ rm -f ${test_out}
284
+
248
285
pamarith -nor ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
249
286
echo -n " Expected failure 26"
250
287
test -s ${output_ppm} ; echo " " $?
288
+ rm -f ${test_out}
289
+
251
290
pamarith -xor ${input3_pgm} ${input5_pgm} > ${output_ppm} || \
252
291
echo -n " Expected failure 27"
253
292
test -s ${output_ppm} ; echo " " $?
293
+ rm -f ${test_out}
254
294
255
295
# Bit string functions - Maxval must be 2^n -1
256
296
257
297
pamarith -and ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
258
298
echo -n " Expected failure 28"
259
299
test -s ${output_ppm} ; echo " " $?
300
+ rm -f ${test_out}
301
+
260
302
pamarith -or ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
261
303
echo -n " Expected failure 29"
262
304
test -s ${output_ppm} ; echo " " $?
305
+ rm -f ${test_out}
306
+
263
307
pamarith -nand ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
264
308
echo -n " Expected failure 30"
265
309
test -s ${output_ppm} ; echo " " $?
310
+ rm -f ${test_out}
311
+
266
312
pamarith -nor ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
267
313
echo -n " Expected failure 31"
268
314
test -s ${output_ppm} ; echo " " $?
315
+ rm -f ${test_out}
316
+
269
317
pamarith -xor ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
270
318
echo -n " Expected failure 32"
271
319
test -s ${output_ppm} ; echo " " $?
320
+ rm -f ${test_out}
272
321
273
322
pamarith -shiftleft ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
274
323
echo -n " Expected failure 33"
275
324
test -s ${output_ppm} ; echo " " $?
325
+ rm -f ${test_out}
326
+
276
327
pamarith -shiftright ${input4_pgm} ${input4_pgm} > ${output_ppm} || \
277
328
echo -n " Expected failure 34"
278
329
test -s ${output_ppm} ; echo " " $?
330
+ rm -f ${test_out}
279
331
280
332
rm ${input3_pgm} ${input4_pgm} ${input5_pgm}
281
333
@@ -286,30 +338,44 @@ rm ${input3_pgm} ${input4_pgm} ${input5_pgm}
286
338
pamarith -subtract testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
287
339
echo -n " Expected failure 35"
288
340
test -s ${output_ppm} ; echo " " $?
341
+ rm -f ${test_out}
342
+
289
343
pamarith -divide testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
290
344
echo -n " Expected failure 36"
291
345
test -s ${output_ppm} ; echo " " $?
346
+ rm -f ${test_out}
347
+
292
348
pamarith -compare testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
293
349
echo -n " Expected failure 37"
294
350
test -s ${output_ppm} ; echo " " $?
351
+ rm -f ${test_out}
352
+
295
353
pamarith -difference testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
296
354
echo -n " Expected failure 38"
297
355
test -s ${output_ppm} ; echo " " $?
356
+ rm -f ${test_out}
357
+
298
358
pamarith -shiftleft testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
299
359
echo -n " Expected failure 39"
300
360
test -s ${output_ppm} ; echo " " $?
361
+ rm -f ${test_out}
362
+
301
363
pamarith -shiftright testimg.ppm testimg.ppm testimg.ppm > ${output_ppm} || \
302
364
echo -n " Expected failure 40"
303
365
test -s ${output_ppm} ; echo " " $?
366
+ rm -f ${test_out}
304
367
305
368
# Currently -equal and -mean do not allow more than two input images.
306
369
# These two cases should be removed once improvements are made.
307
370
308
371
pamarith -equal testgrid.pbm testgrid.pbm testgrid.pbm > ${output_ppm} || \
309
372
echo -n " Expected failure 41"
310
373
test -s ${output_ppm} ; echo " " $?
374
+ rm -f ${test_out}
375
+
311
376
pamarith -mean testgrid.pbm testgrid.pbm testgrid.pbm > ${output_ppm} || \
312
377
echo -n " Expected failure 42"
313
378
test -s ${output_ppm} ; echo " " $?
379
+ rm -f ${test_out}
314
380
315
381
rm ${output_ppm}
0 commit comments