about summary refs log tree commit diff
path: root/test/pamcat3.test
blob: fb89c3f6cd2363b89c119925ff2600c7dcee61ad (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! /bin/sh
# This script tests: pamcat
# Also requires:

tmpdir=${tmpdir:-/tmp}
list=${tmpdir}/list
list2=${tmpdir}/list2
list3=${tmpdir}/list3
liste1=${tmpdir}/liste1
liste2=${tmpdir}/liste2
liste3=${tmpdir}/liste3
files="maze.pbm testgrid.pbm testimg.ppm"

ls ${files} | tee ${list} | awk '{print ""; print $0; print ""}' > ${list3}
sed 's/maze.pbm/-/' ${list} > ${list2}

echo "Test 1.   Should print 585134073 133221 four times"
pamcat -lr -jt ${files} | cksum
pamcat -lr -jt -listfile=${list} | cksum
cat maze.pbm | pamcat -lr -jt -listfile=${list2} | cksum
pamcat -lr -jt -listfile=${list3} | cksum

echo "Test 2.   Should print 1331083756 152559 three times"
pamcat -tb -jl ${files} | cksum
pamcat -tb -jl -listfile=${list} | cksum
cat ${list} | pamcat -tb -jl -listfile=- | cksum

echo "Test Invalid"

test_out=${tmpdir}/test_out

echo 1>&2
echo "Invalid command-line argument combinations & listfile content." 1>&2
echo "Error messages should appear below the line." 1>&2
echo "-----------------------------------------------------------" 1>&2

# listfile not specified
pamcat -lr -listfile > ${test_out} || \
  printf "Expected failure 1 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

# listfile does not exist
pamcat -lr -listfile=`mktemp -u` > ${test_out} || \
  printf "Expected failure 2 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

# listfile empty
pamcat -lr -listfile=/dev/null > ${test_out} || \
  printf "Expected failure 3 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

# listfile from stdin, empty
cat /dev/null | pamcat -lr -listfile=- > ${test_out} || \
  printf "Expected failure 4 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

# Files provided from command line in addition to listfile
pamcat -lr -listfile=${list} testgrid.pbm testgrid.pbm > ${test_out} || \
  printf "Expected failure 5 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

# "-" (stdin) provided from command line in addition to listfile
pamcat -lr -listfile=${list} - > ${test_out} || \
  printf "Expected failure 6 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out}

# listfile has nothing but blank lines
sed 's/^.*$//' ${list3} > ${liste1}  
pamcat -lr -listfile=${liste1} > ${test_out} || \
  printf "Expected failure 7 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out} ${liste1}

# Non-existing file in listfile
( cat ${list} ; mktemp -u ) > ${liste2}
pamcat -lr -listfile=${liste2} > ${test_out} || \
  printf "Expected failure 8 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out} ${liste2}

# Multiple instances of "-" in listfile
( echo "-"; cat ${list}; echo "-"; echo "-" ) > ${liste3}
pamcat -lr -listfile=${liste3} > ${test_out} || \
  printf "Expected failure 9 "
  test -s ${test_out} && echo "unexpected output" || echo "(no output)"
  rm -f ${test_out} ${liste3}


rm ${list} ${list2} ${list3}