-
Notifications
You must be signed in to change notification settings - Fork 5
/
tests.sh
191 lines (139 loc) · 4.22 KB
/
tests.sh
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/sh
# $Id: tests.sh,v 1.8 2015/11/04 00:02:45 gilles Exp gilles $
# $Log: tests.sh,v $
# Revision 1.8 2015/11/04 00:02:45 gilles
# Added ll_timeout2()
#
# Revision 1.7 2015/10/16 22:30:44 gilles
# Added justlogin.
#
# Revision 1.6 2013/09/22 22:29:05 gilles
# Change to pass new machine "petite".
#
# Revision 1.5 2008/09/01 01:31:15 gilles
# noidatefromheader() added to regression list.
#
# Revision 1.4 2008/09/01 01:27:52 gilles
# Added test noidatefromheader()
#
# Revision 1.3 2008/08/05 16:31:52 gilles
# Added ll_quiet()
# Added ll_ssl()
#
# Revision 1.2 2008/08/05 16:17:00 gilles
# Adapted all tests to localhost
#
# Revision 1.1 2003/08/19 01:17:14 gilles
# Initial revision
#
#### Shell pragmas
exec 3>&2 #
#set -x # debug mode. See what is running
set -e # exit on first failure
#### functions definitions
echo3() {
#echo '#####################################################' >&3
echo "$*" >&3
}
run_test() {
echo3 "#### $test_count $1"
$1
if test x"$?" = x"0"; then
echo "$1 passed"
else
echo "$1 failed" >&2
fi
}
run_tests() {
for t in $*; do
test_count=`expr 1 + $test_count`
run_test $t
sleep 1
done
}
#### Variable definitions
prog=pop2imap
test_count=0
##### The tests functions
perl_syntax() {
perl -c ./${prog}
}
no_args() {
./${prog}
}
sendtestmessage() {
email=${1:-"toto"}
rand=`pwgen 16 1`
mess='test:'$rand
cmd="echo $mess""| mail -s ""$mess"" $email"
echo $cmd
eval "$cmd"
}
ll_justlogin() {
./pop2imap --host1 localhost --user1 toto --passfile1 /home/gilles/var/pass/secret.toto \
--host2 localhost --user2 titi --passfile2 /home/gilles/var/pass/secret.titi \
--justlogin
}
ll_basic() {
sendtestmessage
./pop2imap --host1 localhost --user1 toto --passfile1 /home/gilles/var/pass/secret.toto \
--host2 localhost --user2 titi --passfile2 /home/gilles/var/pass/secret.titi
}
ll_quiet() {
sendtestmessage
./pop2imap --host1 localhost --user1 toto --passfile1 /home/gilles/var/pass/secret.toto \
--host2 localhost --user2 titi --passfile2 /home/gilles/var/pass/secret.titi \
--quiet
}
ll_timeout2() {
./pop2imap --host1 localhost --user1 toto --passfile1 /home/gilles/var/pass/secret.toto \
--host2 localhost --user2 titi --passfile2 /home/gilles/var/pass/secret.titi \
--timeout2 4
}
badpophost() {
! ./pop2imap --host1 nogoodhost --user1 toto --passfile1 /home/gilles/var/pass/secret.toto \
--host2 localhost --user2 titi --passfile2 /home/gilles/var/pass/secret.titi
}
connect_refused() {
! ./pop2imap --host1 localhost --port1 109 --user1 toto --passfile1 /home/gilles/var/pass/secret.toto \
--host2 localhost --user2 titi --passfile2 /home/gilles/var/pass/secret.titi
}
dry_mode() {
./pop2imap --host1 localhost --user1 toto --passfile1 /home/gilles/var/pass/secret.toto \
--host2 localhost --user2 titi --passfile2 /home/gilles/var/pass/secret.titi \
--dry
}
delete_opt() {
./pop2imap --host1 localhost --user1 toto --passfile1 /home/gilles/var/pass/secret.toto \
--host2 localhost --user2 titi --passfile2 /home/gilles/var/pass/secret.titi \
--delete
}
ll_ssl() {
./pop2imap --host1 localhost --user1 toto --passfile1 /home/gilles/var/pass/secret.toto \
--host2 localhost --user2 titi --passfile2 /home/gilles/var/pass/secret.titi \
--ssl1 --ssl2
}
noidatefromheader() {
./pop2imap --host1 localhost --user1 toto --passfile1 /home/gilles/var/pass/secret.toto \
--host2 localhost --user2 titi --passfile2 /home/gilles/var/pass/secret.titi \
--noidatefromheader
}
# mandatory tests
run_tests perl_syntax
# All tests
test $# -eq 0 && run_tests \
no_args \
ll_justlogin \
ll_basic \
ll_timeout2 \
ll_quiet \
badpophost \
connect_refused \
dry_mode \
delete_opt \
ll_ssl \
noidatefromheader
# selective tests
test $# -gt 0 && run_tests "$@"
# If there, all is good
echo3 ALL $test_count TESTS SUCCESSFUL