]> diplodocus.org Git - nmh/blob - test/mhparam/test-mhparam
Replace getcpy() with mh_xstrdup() where the string isn't NULL.
[nmh] / 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 -(debug)
34 EOF
35
36 #### Skip nmh intro text.
37 mhparam -help | sed '/^$/,$d' >"$actual" 2>&1
38 check "$expected" "$actual"
39
40 # check -version
41 case `mhparam -v` in
42 mhparam\ --*) ;;
43 * ) echo "$0: mhparam -v generated unexpected output" 1>&2
44 failed=`expr ${failed:-0} + 1`;;
45 esac
46
47 # check unknown option
48 run_test 'mhparam -nonexistent' 'mhparam: -nonexistent unknown'
49
50 # check -all
51 cp "$MH" $expected
52 # -all adds current folder and Version
53 echo 'Current-Folder: '`folder -f` >>$expected
54 echo "Version: nmh-$MH_VERSION" >>$expected
55 run_prog 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 run_prog 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 run_prog 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"
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 # Note that cat is hardcoded here because the testsuite uses it for moreproc.
81 cat >$expected <<EOF
82 context
83 .mh_sequences
84 $MH_INST_DIR$bindir/mhbuild
85 $MH_INST_DIR$bindir/refile
86 700
87 $bindir/inc
88 more
89 $MH_INST_DIR$bindir/mhmail
90 $MH_INST_DIR$nmhlibexecdir/mhl
91 cat
92 600
93 $bindir/packf
94 $MH_INST_DIR$nmhlibexecdir/post
95 $MH_INST_DIR$bindir/send
96 $MH_INST_DIR$bindir/mhshow
97 $MH_INST_DIR$nmhlibexecdir/mhl
98 nmh-$MH_VERSION
99 $MH_INST_DIR$bindir/whatnow
100 $MH_INST_DIR$bindir/whom
101 $nmhetcdirinst
102 $MH_LIBEXEC_DIR
103 fcntl
104 ${default_locking}
105 EOF
106
107 run_prog mhparam -nocomponent \
108 context \
109 mh-sequences \
110 buildmimeproc \
111 fileproc \
112 foldprot \
113 incproc \
114 lproc \
115 mailproc \
116 mhlproc \
117 moreproc \
118 msgprot \
119 packproc \
120 postproc \
121 sendproc \
122 showmimeproc \
123 showproc \
124 version \
125 whatnowproc \
126 whomproc \
127 etcdir \
128 libexecdir \
129 datalocking \
130 spoollocking >$actual 2>&1
131
132 check $expected $actual
133
134 #### This exits with non-zero status, so let run_test squash that:
135 run_test 'mhparam formatproc rmmproc' ''
136
137 #### Test sbackup separately because it's only passed as a -D compile option.
138 case `mhparam sbackup` in
139 ,|\#) ;;
140 * ) echo mhparam sbackup failed
141 failed=`expr ${failed:-0} + 1` ;;
142 esac
143
144 # check -component
145 run_test 'mhparam -component Path' "Path: $MH_TEST_DIR/Mail"
146
147 # check -component, note that component name of argument is echoed exactly
148 run_test 'mhparam -component path' "path: $MH_TEST_DIR/Mail"
149 run_test 'mhparam -component PATH' "PATH: $MH_TEST_DIR/Mail"
150
151 # check -nocomponent
152 run_test 'mhparam -component -nocomponent path' "$MH_TEST_DIR/Mail"
153 run_test 'mhparam -nocomponent path AliasFile' "$MH_TEST_DIR/Mail
154 aliases"
155
156 # check nonexistent component
157 run_test 'mhparam nonexistent' ''
158
159 # check that return status counts nonexistent components
160 set +e
161 mhparam path context nonexistent1 nonexistent2 nonexistent3 >/dev/null
162 run_test "echo $?" 3
163 set -e
164
165 # mhparam -debug
166 # Some of its output depends on configure options, so don't bother to
167 # check for correctness here.
168 mhparam -debug >/dev/null
169
170 # check with text file that does not end with newline
171 printf 'Editor: emacs' >>"$MH"
172 run_test 'mhparam -nocomponent editor' 'emacs'
173
174 exit $failed