about summary refs log tree commit diff
path: root/test/legacy-names.test
blob: df40e62df68e96566f217b31b72a00e7651d9026 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#! /bin/bash
# Tests whether the executable files listed below are in place.

# We test with the methods used in all-in-place.test.
# The sole exception is hpcdtoppm.  We just confirm that it exists.

# Failure message
## If all-in-place.test succeeds and this test fails, a likely cause is a
## problem with symbolic links.
##
## Important: This test checks obsoleted names.
## Programs here do not appear in other tests.


# Skip this test if CHECK_TYPE = tree

if [ ${CHECK_TYPE} = tree ]
  then echo "Skipping." 1>&2
  exit 80;
fi


function testExitStatus () {

# This function takes 3 positional parameters:
#   $1: filename
#   $2: expected exit status   (In some cases we expect error.)
#   $3: actual exit status

    case $3 in
      126) if [ ! -x $1 ]
             then echo $1": NOT EXECUTABLE";
             else echo $1": ERROR: "$3;    echo $1": error: "$3 1>&2 ;
           fi ;;
      127) type -p $1 > /dev/null
           if [ $? -ne 0 ]
             then echo $1": NO SUCH FILE";
             else echo $1": ERROR: "$3;    echo $1": error: "$3 1>&2 ;
           fi ;;
      88)  echo $1": NO SUCH FILE" ;;
      $2)  echo $1": ok" ;;
      *)   echo $1": ERROR: "$3;    echo $1": error: "$3 1>&2 ;;
    esac

}


# Test programs which have the --version flag.
# See showVersion() in lib/libpm.c for the standard version announcement.

ordinary_testprogs="\
  bmptoppm \
  gemtopbm \
  icontopbm \
  pamfixtrunc \
  pamrgbatopng \
  pbmtoicon \
  pgmedge \
  pgmnorm \
  pgmoil \
  pgmslice \
  pngtopnm \
  pnmarith \
  pnmcomp \
  pnmcut \
  pnmdepth \
  pnmenlarge \
  pnmfile \
  pnmflip \
  pnminterp \
  pnmscale \
  pnmsplit \
  pnmtofits \
  pnmtopnm \
  pnmtotiff \
  ppmnorm \
  ppmtogif \
  ppmtojpeg \
  ppmtompeg \
  ppmtotga \
  ppmtouil \
"

for i in $ordinary_testprogs
  do
    $i --version  2>&1 | \
    egrep -v \
    "(Using libnetpbm|Compiled|(BSD|SYSV|MSDOS|AMIGA) defined|RGB_?ENV=)" \
      1>&2;
    testExitStatus $i 0 ${PIPESTATUS[0]}
  done


# Test pgmcrater

pgmcrater -number 1 -xsize 15 -ysize 15 -randomseed 1 > /dev/null
testExitStatus pgmcrater 0 $?


# Test pbmtox10bm, pnmnoraw, pnmtoplainpnm, ppmquantall, ppmrainbow
# with trivial input.

$i ${tmpdir}/test.pbm > /dev/null 2> /dev/null;
tmpdir=${tmpdir:-/tmp}
test_pbm=${tmpdir}/test.pbm

cat > ${test_pbm} <<EOF
P1
1 1
1
EOF

for i in pbmtox10bm pnmnoraw pnmtoplainpnm
  do
    $i ${tmpdir}/test.pbm > /dev/null 2> /dev/null;
    testExitStatus $i 0 $?
  done

for i in ppmquant ppmquantall
  do
    $i 2 ${tmpdir}/test.pbm > /dev/null 2> /dev/null;
    testExitStatus $i 0 $?
  done


rm ${test_pbm}


# Test hpcdtoppm.  Simply confirm its existence.

type -p hpcdtoppm > /dev/null
testExitStatus hpcdtoppm 0 $?