Fix out-of-bounds error when incorporating email from stdin
[mmh] / test / tests / ali / test-ali
1 #!/bin/sh
2 ######################################################
3 #
4 # Test ali
5 #
6 ######################################################
7
8 . "$MH_TEST_COMMON"
9
10 expected=$MH_TEST_DIR/$$.expected
11 expected_err=$MH_TEST_DIR/$$.expected_err
12 actual=$MH_TEST_DIR/$$.actual
13 actual_err=$MH_TEST_DIR/$$.actual_err
14
15
16 runandcheck "ali -help" <<!
17 Usage: ali [switches] aliases ...
18   switches are:
19   -file aliasfile
20   -[no]list
21   -[no]normalize
22   -[no]user
23   -Version
24   -help
25 !
26
27
28 # check -Version
29 case `ali -V` in
30   ali\ --*) ;;
31   *       ) echo "$0: ali -V generated unexpected output" 1>&2
32             failed=`expr "${failed:-0}" + 1`;;
33 esac
34
35
36 # check with no arguments and no AliasFile profile component
37 runandcheck 'ali' <<!
38 !
39
40 # check with nonexistent alias file
41 runandcheck 'ali -file nonexistent || :' <<!
42 ali: aliasing error in nonexistent: unable to read 'nonexistent'
43 !
44
45 cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
46 me: me@example.com
47 rush: geddy, alex, neil
48 geddy: geddy@example.com
49 alex: alex@example.com
50 neil: neil@example.com
51 EOF
52
53 # check -file
54 runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases" <<!
55 me: me@example.com
56 rush: geddy@example.com, alex@example.com, neil@example.com
57 geddy: geddy@example.com
58 alex: alex@example.com
59 neil: neil@example.com
60 !
61
62 # check for a specific alias
63 runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases rush" <<!
64 geddy@example.com, alex@example.com, neil@example.com
65 !
66
67 # check for a specific alias that doesn't exist
68 runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases nonexistent" <<!
69 nonexistent
70 !
71
72 # check -list
73 runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases -list" <<!
74 me: me@example.com
75 rush: geddy@example.com
76       alex@example.com
77       neil@example.com
78 geddy: geddy@example.com
79 alex: alex@example.com
80 neil: neil@example.com
81 !
82
83 # check -nolist, which is the default
84 runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases -list -nolist" <<!
85 me: me@example.com
86 rush: geddy@example.com, alex@example.com, neil@example.com
87 geddy: geddy@example.com
88 alex: alex@example.com
89 neil: neil@example.com
90 !
91
92 # check -user
93 runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases -user geddy@example.com" <<!
94 rush, geddy
95 !
96
97 # check -nouser
98 runandcheck \
99   "ali -file ${MH_TEST_DIR}/Mail/aliases -user -nouser geddy@example.com" <<!
100 geddy@example.com
101 !
102
103 # check expansion of first address of blind list [Bug #15604]
104 cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
105 rush: Rush: geddy, alex, neil
106 geddy: geddy@example.com
107 alex: alex@example.com
108 neil: neil@example.com
109 EOF
110
111 runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases rush" <<!
112 Rush: geddy@example.com, alex@example.com, neil@example.com
113 !
114
115 # check that aliases followed by ; are not expanded [Bug #15604]
116 cat >"${MH_TEST_DIR}/Mail/aliases" <<EOF
117 rush: Rush: geddy, alex, neil;
118 geddy: geddy@example.com
119 alex: alex@example.com
120 neil: neil@example.com
121 EOF
122
123 runandcheck "ali -file ${MH_TEST_DIR}/Mail/aliases rush" <<!
124 Rush: geddy@example.com, alex@example.com, neil;
125 !
126
127
128 exit $failed