blob: 7910d0fc1ba9a8865c664461405f4f79521b9458 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#! /bin/sh
# This script tests: pnmquantall
# Also requires: ppmtorgb3 pgmhist pamcat
tmpdir=${tmpdir:-/tmp}
rose_ppm=${tmpdir}/rose.ppm
cp testimg.ppm ${rose_ppm} &&
ppmtorgb3 ${rose_ppm}
rose_red=${tmpdir}/rose.red
rose_grn=${tmpdir}/rose.grn
rose_blu=${tmpdir}/rose.blu
cp ${rose_red} ${rose_red}.1
cp ${rose_grn} ${rose_grn}.1
cp ${rose_blu} ${rose_blu}.1
echo "Test 1."
pnmquantall 20 ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1
for i in ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1
do
cat $i | cksum
done
pamcat ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1 -tb | \
pgmhist -m |\
awk '$2>0 {s++};
END { printf("color count %u: %s\n", s,
(s==20) ? "success" : "failure") }'
rm ${rose_red}.1 ${rose_grn}.1 ${rose_blu}.1
echo "Test 2."
pnmquantall -ext .2 1 ${rose_red} ${rose_grn} ${rose_blu}
for i in ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2
do
cat $i | cksum
done
pamcat ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2 -tb | \
pgmhist -m |\
awk '$2>0 {s++};
END { printf("color count %u: %s\n", s,
(s==1) ? "success" : "failure") }'
rm ${rose_red}.2 ${rose_grn}.2 ${rose_blu}.2
echo "Test Invalid"
echo 1>&2
echo "Invalid command-line argument combinations." 1>&2
echo "Error messages should appear below the line." 1>&2
echo "-----------------------------------------------------------" 1>&2
pnmquantall -ext xx 0 ${rose_red} ${rose_grn} ${rose_blu} || \
echo "Expected failure 1"
rm ${rose_red}xx ${rose_grn}xx ${rose_blu}xx || \
echo "Expected failure 1.rm"
pnmquantall -ext yy ${rose_red} ${rose_grn} ${rose_blu} || \
echo "Expected failure 2"
rm ${rose_red}yy ${rose_grn}yy ${rose_blu}yy || \
echo "Expected failure 2.rm"
pnmquantall -ext zz 2 || \
echo "Expected failure 3"
rm ${rose_red} ${rose_grn} ${rose_blu} ${rose_ppm}
|