blob: 407d46aa9e29a4a774ff5019dc397ef9ec00ce26 (
plain)
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
samba3_stop_sig_term() {
RET=0
kill -USR1 `cat $PIDDIR/timelimit.nmbd.pid` >/dev/null 2>&1 || \
kill -ALRM `cat $PIDDIR/timelimit.nmbd.pid` || RET=$?
kill -USR1 `cat $PIDDIR/timelimit.winbindd.pid` >/dev/null 2>&1 || \
kill -ALRM `cat $PIDDIR/timelimit.winbindd.pid` || RET=$?
kill -USR1 `cat $PIDDIR/timelimit.smbd.pid` >/dev/null 2>&1 || \
kill -ALRM `cat $PIDDIR/timelimit.smbd.pid` || RET=$?
return $RET;
}
samba3_stop_sig_kill() {
kill -ALRM `cat $PIDDIR/timelimit.nmbd.pid` >/dev/null 2>&1
kill -ALRM `cat $PIDDIR/timelimit.winbindd.pid` >/dev/null 2>&1
kill -ALRM `cat $PIDDIR/timelimit.smbd.pid` >/dev/null 2>&1
return 0;
}
samba3_check_or_start() {
if [ -n "$SERVER_TEST_FIFO" ];then
trap samba3_stop_sig_kill INT QUIT
trap samba3_stop_sig_kill TERM
if [ -p "$SERVER_TEST_FIFO" ];then
return 0;
fi
if [ -n "$SOCKET_WRAPPER_DIR" ];then
if [ -d "$SOCKET_WRAPPER_DIR" ]; then
rm -f $SOCKET_WRAPPER_DIR/*
else
mkdir -p $SOCKET_WRAPPER_DIR
fi
fi
rm -f $SERVER_TEST_FIFO
mkfifo $SERVER_TEST_FIFO
rm -f $NMBD_TEST_LOG
printf "%s" "STARTING NMBD..."
((
if test x"$NMBD_MAXTIME" = x; then
NMBD_MAXTIME=2700
fi
MAKE_TEST_BINARY=$BINDIR/nmbd
export MAKE_TEST_BINARY
timelimit $NMBD_MAXTIME $NMBD_VALGRIND $BINDIR/nmbd -F -S --no-process-group -d0 -s $SERVERCONFFILE > $NMBD_TEST_LOG 2>&1 &
TIMELIMIT_NMBD_PID=$!
MAKE_TEST_BINARY=
echo $TIMELIMIT_NMBD_PID > $PIDDIR/timelimit.nmbd.pid
wait $TIMELIMIT_NMBD_PID
ret=$?;
rm -f $SERVER_TEST_FIFO
if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then
rm -f $SOCKET_WRAPPER_DIR/*
fi
if [ x"$ret" = x"0" ];then
echo "nmbd exits with status $ret";
echo "nmbd exits with status $ret" >>$NMBD_TEST_LOG;
elif [ x"$ret" = x"137" ];then
echo "nmbd got SIGXCPU and exits with status $ret!"
echo "nmbd got SIGXCPU and exits with status $ret!">>$NMBD_TEST_LOG;
else
echo "nmbd failed with status $ret!"
echo "nmbd failed with status $ret!">>$NMBD_TEST_LOG;
fi
exit $ret;
) || exit $? &) 2>/dev/null || exit $?
echo "DONE"
rm -f $WINBINDD_TEST_LOG
printf "%s" "STARTING WINBINDD..."
((
if test x"$WINBINDD_MAXTIME" = x; then
WINBINDD_MAXTIME=2700
fi
MAKE_TEST_BINARY=$BINDIR/winbindd
export MAKE_TEST_BINARY
timelimit $WINBINDD_MAXTIME $WINBINDD_VALGRIND $BINDIR/winbindd -F -S --no-process-group -d0 -s $SERVERCONFFILE > $WINBINDD_TEST_LOG 2>&1 &
TIMELIMIT_WINBINDD_PID=$!
MAKE_TEST_BINARY=
echo $TIMELIMIT_WINBINDD_PID > $PIDDIR/timelimit.winbindd.pid
wait $TIMELIMIT_WINBINDD_PID
ret=$?;
rm -f $SERVER_TEST_FIFO
if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then
rm -f $SOCKET_WRAPPER_DIR/*
fi
if [ x"$ret" = x"0" ];then
echo "winbindd exits with status $ret";
echo "winbindd exits with status $ret" >>$WINBINDD_TEST_LOG;
elif [ x"$ret" = x"137" ];then
echo "winbindd got SIGXCPU and exits with status $ret!"
echo "winbindd got SIGXCPU and exits with status $ret!">>$WINBINDD_TEST_LOG;
else
echo "winbindd failed with status $ret!"
echo "winbindd failed with status $ret!">>$WINBINDD_TEST_LOG;
fi
exit $ret;
) || exit $? &) 2>/dev/null || exit $?
echo "DONE"
rm -f $SMBD_TEST_LOG
printf "%s" "STARTING SMBD..."
((
if test x"$SMBD_MAXTIME" = x; then
SMBD_MAXTIME=2700
fi
MAKE_TEST_BINARY=$BINDIR/smbd
export MAKE_TEST_BINARY
timelimit $SMBD_MAXTIME $SMBD_VALGRIND $BINDIR/smbd -F -S --no-process-group -d0 -s $SERVERCONFFILE > $SMBD_TEST_LOG 2>&1 &
TIMELIMIT_SMBD_PID=$!
MAKE_TEST_BINARY=
echo $TIMELIMIT_SMBD_PID > $PIDDIR/timelimit.smbd.pid
wait $TIMELIMIT_SMBD_PID
ret=$?;
rm -f $SERVER_TEST_FIFO
if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then
rm -f $SOCKET_WRAPPER_DIR/*
fi
if [ x"$ret" = x"0" ];then
echo "smbd exits with status $ret";
echo "smbd exits with status $ret" >>$SMBD_TEST_LOG;
elif [ x"$ret" = x"137" ];then
echo "smbd got SIGXCPU and exits with status $ret!"
echo "smbd got SIGXCPU and exits with status $ret!">>$SMBD_TEST_LOG;
else
echo "smbd failed with status $ret!"
echo "smbd failed with status $ret!">>$SMBD_TEST_LOG;
fi
exit $ret;
) || exit $? &) 2>/dev/null || exit $?
echo "DONE"
fi
return 0;
}
samba3_nmbd_test_log() {
if [ -n "$NMBD_TEST_LOG" ];then
if [ -r "$NMBD_TEST_LOG" ];then
return 0;
fi
fi
return 1;
}
samba3_winbindd_test_log() {
if [ -n "$WINBINDD_TEST_LOG" ];then
if [ -r "$WINBINDD_TEST_LOG" ];then
return 0;
fi
fi
return 1;
}
samba3_smbd_test_log() {
if [ -n "$SMBD_TEST_LOG" ];then
if [ -r "$SMBD_TEST_LOG" ];then
return 0;
fi
fi
return 1;
}
samba3_check_only() {
if [ -n "$SERVER_TEST_FIFO" ];then
if [ -p "$SERVER_TEST_FIFO" ];then
return 0;
fi
return 1;
fi
return 0;
}
testit() {
if [ -z "$PREFIX" ]; then
PREFIX=test_prefix
mkdir -p $PREFIX
fi
name=$1
shift 1
binary=$1
cmdline="$*"
SERVERS_ARE_UP="no"
shname=`echo $name | \
sed -e 's%[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\-]%_%g'`
UNIQUE_PID=`/bin/sh -c 'echo $$'`
TEST_LOG="$PREFIX/test_log.${UNIQUE_PID}"
TEST_PCAP="$PREFIX/test_${shname}_${UNIQUE_PID}.pcap"
trap "rm -f $TEST_LOG $TEST_PCAP" EXIT
if [ -z "$nmbd_log_size" ]; then
nmbd_log_size=`wc -l < $NMBD_TEST_LOG`;
fi
if [ -z "$winbindd_log_size" ]; then
winbindd_log_size=`wc -l < $WINBINDD_TEST_LOG`;
fi
if [ -z "$smbd_log_size" ]; then
smbd_log_size=`wc -l < $SMBD_TEST_LOG`;
fi
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
echo "--==--==--==--==--==--==--==--==--==--==--"
echo "Running test $name (level 0 stdout)"
echo "--==--==--==--==--==--==--==--==--==--==--"
date
echo "Testing $name"
else
echo "Testing $name ($failed)"
fi
samba3_check_only && SERVERS_ARE_UP="yes"
if [ x"$SERVERS_ARE_UP" != x"yes" ];then
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
echo "SERVERS are down! Skipping: $cmdline"
echo "=========================================="
echo "TEST SKIPPED: $name (reason SERVERS are down)"
echo "=========================================="
else
echo "TEST SKIPPED: $name (reason SERVERS are down)"
fi
return 1
fi
if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
SOCKET_WRAPPER_PCAP_FILE=$TEST_PCAP
export SOCKET_WRAPPER_PCAP_FILE
fi
MAKE_TEST_BINARY=$binary
export MAKE_TEST_BINARY
( $cmdline > $TEST_LOG 2>&1 )
status=$?
MAKE_TEST_BINARY=
# show any additional output from smbd that has happened in this test
samba3_nmbd_test_log && {
new_log_size=`wc -l < $NMBD_TEST_LOG`;
test "$new_log_size" = "$nmbd_log_size" || {
echo "NMBD OUTPUT:";
incr_log_size=`expr $new_log_size - $nmbd_log_size`;
tail -$incr_log_size $NMBD_TEST_LOG;
nmbd_log_size=$new_log_size;
}
}
samba3_winbindd_test_log && {
new_log_size=`wc -l < $WINBINDD_TEST_LOG`;
test "$new_log_size" = "$winbindd_log_size" || {
echo "WINBINDD OUTPUT:";
incr_log_size=`expr $new_log_size - $winbindd_log_size`;
tail -$incr_log_size $WINBINDD_TEST_LOG;
winbindd_log_size=$new_log_size;
}
}
samba3_smbd_test_log && {
new_log_size=`wc -l < $SMBD_TEST_LOG`;
test "$new_log_size" = "$smbd_log_size" || {
echo "SMBD OUTPUT:";
incr_log_size=`expr $new_log_size - $smbd_log_size`;
tail -$incr_log_size $SMBD_TEST_LOG;
smbd_log_size=$new_log_size;
}
}
if [ x"$status" != x"0" ]; then
echo "TEST OUTPUT:"
cat $TEST_LOG;
rm -f $TEST_LOG;
if [ x"$MAKE_TEST_ENABLE_PCAP" = x"yes" ];then
echo "TEST PCAP: $TEST_PCAP"
fi
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
echo "=========================================="
echo "TEST FAILED: $name (status $status)"
echo "=========================================="
else
echo "TEST FAILED: $cmdline (status $status)"
fi
trap "" EXIT
return 1;
fi
rm -f $TEST_LOG;
if [ x"$MAKE_TEST_KEEP_PCAP" = x"yes" ];then
echo "TEST PCAP: $TEST_PCAP"
else
rm -f $TEST_PCAP;
fi
if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
echo "ALL OK: $cmdline"
echo "=========================================="
echo "TEST PASSED: $name"
echo "=========================================="
fi
trap "" EXIT
return 0;
}
testok() {
name=`basename $1`
failed=$2
if [ x"$failed" = x"0" ];then
:
else
echo "$failed TESTS FAILED or SKIPPED ($name)";
fi
exit $failed
}
teststatus() {
name=`basename $1`
failed=$2
if [ x"$failed" = x"0" ];then
echo "TEST STATUS: $failed";
else
echo "TEST STATUS: $failed";
fi
exit $failed
}
if [ -z "$VALGRIND" ]; then
MALLOC_CHECK_=2
export MALLOC_CHECK_
fi
|