Fixed test suite to work with Solaris Bourne shell:
[mmh] / test / mhparam / test-mhparam
1 #!/bin/sh
2 ######################################################
3 #
4 # Test mhparam
5 #
6 ######################################################
7
8 set -e
9
10 if test -z "${MH_OBJ_DIR}"; then
11     srcdir=`dirname $0`/../..
12     MH_OBJ_DIR=`cd $srcdir && pwd`; export MH_OBJ_DIR
13 fi
14
15 . "$MH_OBJ_DIR/test/common.sh"
16
17 setup_test
18
19 expected=$MH_TEST_DIR/$$.expected
20 expected_err=$MH_TEST_DIR/$$.expected_err
21 actual=$MH_TEST_DIR/$$.actual
22 actual_err=$MH_TEST_DIR/$$.actual_err
23
24
25 # check -help
26 cat >$expected <<EOF
27 Usage: mhparam [profile-components] [switches]
28   switches are:
29   -[no]components
30   -all
31   -version
32   -help
33 EOF
34 # The exit status is 1 with -help, so temporarily disable -e.
35 set +e
36 mhparam -help >$actual 2>&1
37 set -e
38 check $expected $actual
39
40 # check -version
41 if mhparam -v | grep '^mhparam --' >/dev/null; then
42   :
43 else
44   echo "$0: mhparam -v generated unexpected output" 1>&2
45   failed=`expr ${failed:-0} + 1`
46 fi
47
48 # check unknown option
49 run_test 'mhparam -nonexistent' 'mhparam: -nonexistent unknown'
50
51 # check -all
52 cp $MH_TEST_DIR/Mail/.mh_profile $expected
53 # -all adds current folder
54 echo 'Current-Folder: '`folder -f` >>$expected
55 mhparam -all >$actual
56 check $expected $actual 'keep first'
57
58 # check -all with a component
59 echo 'mhparam: profile-components ignored with -all' >$expected_err
60 mhparam -all path >$actual 2>$actual_err
61 check $expected $actual 'keep first'
62 check $expected_err $actual_err
63
64 # check -all with -components
65 echo 'mhparam: -components ignored with -all' >$expected_err
66 mhparam -all -components >$actual 2>$actual_err
67 check $expected $actual
68 check $expected_err $actual_err
69
70 # check one component
71 run_test 'mhparam path' "$MH_TEST_DIR/Mail"
72
73 # check more than one component, which enables -component
74 echo 'AliasFile: aliases' >>"$MH_TEST_DIR/Mail/.mh_profile"
75 run_test 'mhparam path AliasFile' "path: $MH_TEST_DIR/Mail
76 AliasFile: aliases"
77
78 # check each component in procs array in uip/mhparam.c
79 # The tests don't override these, so they're default or configured values.
80 cat >$expected <<EOF
81 context
82 .mh_sequences
83 $bindir/mhbuild
84 $MH_INST_DIR$bindir/refile
85 700
86 $bindir/inc
87 $auxexecdir/install-mh
88 $pagerpath
89 $bindir/mhmail
90 $MH_INST_DIR$auxexecdir/mhl
91 $pagerpath
92 600
93 $bindir/msh
94 $bindir/packf
95 $MH_INST_DIR$auxexecdir/post
96 $bindir/send
97 $bindir/mhshow
98 $MH_INST_DIR$auxexecdir/mhl
99 nmh-`cat ${srcdir}/VERSION`
100 $bindir/msh
101 $bindir/whatnow
102 $bindir/whom
103 $sysconfdir
104 $auxexecdir
105 EOF
106
107 mhparam -nocomponent \
108 context \
109 mh-sequences \
110 buildmimeproc \
111 fileproc \
112 foldprot \
113 incproc \
114 installproc \
115 lproc \
116 mailproc \
117 mhlproc \
118 moreproc \
119 msgprot \
120 mshproc \
121 packproc \
122 postproc \
123 sendproc \
124 showmimeproc \
125 showproc \
126 version \
127 vmhproc \
128 whatnowproc \
129 whomproc \
130 etcdir \
131 libdir >$actual 2>&1
132
133 check $expected $actual
134
135 #### This exits with non-zero status, so let run_test squash that:
136 run_test 'mhparam faceproc formatproc rmmproc' ''
137
138 #### test sbackup separately because it's only passed as a -D compile option
139 if mhparam sbackup | grep -F ',
140 #' >/dev/null; then
141   :
142 else
143   echo mhparam sbackup failed
144   failed=`expr ${failed:-0} + 1`
145 fi
146
147 # check -component
148 run_test 'mhparam -component Path' "Path: $MH_TEST_DIR/Mail"
149
150 # check -component, note that component name of argument is echoed exactly
151 run_test 'mhparam -component path' "path: $MH_TEST_DIR/Mail"
152 run_test 'mhparam -component PATH' "PATH: $MH_TEST_DIR/Mail"
153
154 # check -nocomponent
155 run_test 'mhparam -component -nocomponent path' "$MH_TEST_DIR/Mail"
156 run_test 'mhparam -nocomponent path AliasFile' "$MH_TEST_DIR/Mail
157 aliases"
158
159 # check nonexistent component
160 run_test 'mhparam nonexistent' ''
161
162 # check that return status counts nonexistent components
163 set +e
164 mhparam path context nonexistent1 nonexistent2 nonexistent3 >/dev/null
165 run_test "echo $?" 3
166 set -e
167
168 # mhparam -debug (undocumented)
169 # Some of its output depends on configure options, so don't bother to
170 # check for correctness here.
171 mhparam -debug >/dev/null
172
173 exit $failed