2006-06-05 00:36:52 +04:00
#!/bin/sh
2005-06-10 19:32:16 +04:00
smbd_check_or_start( ) {
if [ -n " $SMBD_TEST_FIFO " ] ; then
if [ -p " $SMBD_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 $SMBD_TEST_FIFO
mkfifo $SMBD_TEST_FIFO
2005-06-09 19:53:47 +04:00
2005-06-10 19:32:16 +04:00
rm -f $SMBD_TEST_LOG
echo -n "STARTING SMBD..."
( (
2005-11-11 03:50:40 +03:00
if [ -z " $SMBD_MAXTIME " ] ; then
2006-09-09 05:21:10 +04:00
SMBD_MAXTIME = 5400
2005-09-30 08:52:21 +04:00
fi
2006-11-06 13:38:13 +03:00
$SMBD_VALGRIND $SRCDIR /bin/smbd --maximum-runtime= $SMBD_MAXTIME -s $CONFFILE -M single -i --leak-report-full < $SMBD_TEST_FIFO > $SMBD_TEST_LOG 2>& 1;
2005-06-10 19:32:16 +04:00
ret = $? ;
rm -f $SMBD_TEST_FIFO ;
if [ -n " $SOCKET_WRAPPER_DIR " -a -d " $SOCKET_WRAPPER_DIR " ] ; then
rm -f $SOCKET_WRAPPER_DIR /*
fi
2005-06-11 21:55:58 +04:00
if [ x" $ret " = x"0" ] ; then
2005-08-30 06:15:52 +04:00
echo " smbd exits with status $ret " ;
echo " smbd exits with status $ret " >>$SMBD_TEST_LOG ;
2005-06-11 21:55:58 +04:00
elif [ x" $ret " = x"137" ] ; then
2005-08-30 06:15:52 +04:00
echo " smbd got SIGXCPU and exits with status $ret ! "
echo " smbd got SIGXCPU and exits with status $ret ! " >>$SMBD_TEST_LOG ;
2005-06-11 21:55:58 +04:00
else
echo " smbd failed with status $ret ! "
echo " smbd failed with status $ret ! " >>$SMBD_TEST_LOG ;
fi
2005-06-10 19:32:16 +04:00
exit $ret ;
) || exit $? & ) 2>/dev/null || exit $?
echo "DONE"
fi
return 0;
}
smbd_check_only( ) {
2005-06-09 19:53:47 +04:00
if [ -n " $SMBD_TEST_FIFO " ] ; then
2005-06-10 19:32:16 +04:00
if [ -p " $SMBD_TEST_FIFO " ] ; then
return 0;
fi
return 1;
fi
return 0;
}
smbd_have_test_log( ) {
if [ -n " $SMBD_TEST_LOG " ] ; then
if [ -r " $SMBD_TEST_LOG " ] ; then
2005-06-09 19:53:47 +04:00
return 0;
fi
fi
2005-06-10 19:32:16 +04:00
return 1;
}
2006-09-04 04:32:46 +04:00
slapd_start( ) {
OLDPATH = $PATH
PATH = /usr/local/sbin:/usr/sbin:/sbin:$PATH
export PATH
2006-09-13 14:26:32 +04:00
# running slapd in the background means it stays in the same process group, so it can be
# killed by timelimit
slapd -d0 -f $SLAPD_CONF -h $LDAPI_ESCAPE &
2006-09-04 04:32:46 +04:00
PATH = $OLDPATH
export PATH
2006-09-13 14:26:32 +04:00
return $? ;
2006-09-04 04:32:46 +04:00
}
2005-06-10 19:32:16 +04:00
testit( ) {
2005-06-11 08:07:20 +04:00
if [ -z " $PREFIX " ] ; then
PREFIX = test_prefix
mkdir -p $PREFIX
fi
name = $1
2005-06-10 19:32:16 +04:00
shift 1
cmdline = " $* "
2005-06-09 19:53:47 +04:00
2006-10-05 15:46:31 +04:00
SMBD_IS_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
2006-11-07 02:19:00 +03:00
if [ -n " $SMBD_TEST_LOG " -a -z " $smbd_log_size " ] ; then
2006-09-15 07:24:15 +04:00
smbd_log_size = ` wc -l < $SMBD_TEST_LOG ` ;
fi
2005-06-09 11:14:39 +04:00
if [ x" $RUN_FROM_BUILD_FARM " = x"yes" ] ; then
echo "--==--==--==--==--==--==--==--==--==--==--"
echo " Running test $name (level 0 stdout) "
echo "--==--==--==--==--==--==--==--==--==--==--"
date
2005-06-09 12:19:17 +04:00
echo " Testing $name "
2005-06-09 11:14:39 +04:00
else
2006-09-16 03:00:32 +04:00
nf = " `expr $failed + $totalfailed ` " ;
if [ " $nf " = "0" ] ; then
echo " Testing $name "
else
echo " Testing $name ( $nf tests failed so far) "
fi
2005-06-09 11:14:39 +04:00
fi
2005-06-10 19:32:16 +04:00
smbd_check_only && SMBD_IS_UP = "yes"
2005-06-11 12:49:12 +04:00
if [ x" $SMBD_IS_UP " != x"yes" ] ; then
2005-06-10 19:32:16 +04:00
if [ x" $RUN_FROM_BUILD_FARM " = x"yes" ] ; then
2005-06-10 20:09:41 +04:00
echo " SMBD is down! Skipping: $cmdline "
2005-06-10 19:32:16 +04:00
echo "=========================================="
echo " TEST SKIPPED: $name (reason SMBD is down) "
echo "=========================================="
else
echo " TEST SKIPPED: $name (reason SMBD is down) "
fi
return 1
fi
2006-10-05 15:46:31 +04:00
if [ x" $MAKE_TEST_ENABLE_PCAP " = x"yes" ] ; then
SOCKET_WRAPPER_PCAP_FILE = $TEST_PCAP
export SOCKET_WRAPPER_PCAP_FILE
fi
2005-06-10 19:32:16 +04:00
( $cmdline > $TEST_LOG 2>& 1 )
2005-06-09 11:14:39 +04:00
status = $?
2006-09-15 07:24:15 +04:00
# show any additional output from smbd that has happened in this test
smbd_have_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 ;
}
}
2005-06-09 11:14:39 +04:00
if [ x" $status " != x"0" ] ; then
2005-06-10 19:32:16 +04:00
echo "TEST OUTPUT:"
cat $TEST_LOG ;
rm -f $TEST_LOG ;
2006-10-05 15:46:31 +04:00
if [ x" $MAKE_TEST_ENABLE_PCAP " = x"yes" ] ; then
echo " TEST PCAP: $TEST_PCAP "
fi
2005-06-09 11:14:39 +04:00
if [ x" $RUN_FROM_BUILD_FARM " = x"yes" ] ; then
echo "=========================================="
2005-06-09 19:53:47 +04:00
echo " TEST FAILED: $name (status $status ) "
2005-06-09 11:14:39 +04:00
echo "=========================================="
else
2005-06-19 17:27:22 +04:00
echo " TEST FAILED: $cmdline (status $status ) "
2005-06-09 11:14:39 +04:00
fi
2006-10-21 15:50:34 +04:00
trap "" EXIT
2005-06-09 11:14:39 +04:00
return 1;
fi
2006-10-09 10:46:39 +04:00
rm -f $TEST_LOG ;
if [ x" $MAKE_TEST_KEEP_PCAP " = x"yes" ] ; then
echo " TEST PCAP: $TEST_PCAP "
else
rm -f $TEST_PCAP ;
fi
2005-06-09 11:14:39 +04:00
if [ x" $RUN_FROM_BUILD_FARM " = x"yes" ] ; then
2005-06-09 12:19:17 +04:00
echo " ALL OK: $cmdline "
2005-06-09 11:14:39 +04:00
echo "=========================================="
echo " TEST PASSED: $name "
echo "=========================================="
fi
2006-10-21 15:50:34 +04:00
trap "" EXIT
2005-06-09 11:14:39 +04:00
return 0;
}
testok( ) {
name = ` basename $1 `
failed = $2
2005-06-10 19:32:16 +04:00
2005-06-09 11:14:39 +04:00
if [ x" $failed " = x"0" ] ; then
:
else
2005-06-10 19:32:16 +04:00
echo " $failed TESTS FAILED or SKIPPED ( $name ) " ;
2005-06-09 11:14:39 +04:00
fi
exit $failed
}
teststatus( ) {
name = ` basename $1 `
failed = $2
2005-06-10 19:32:16 +04:00
2006-09-16 02:39:30 +04:00
echo " TEST STATUS: $failed failures " ;
test x" $failed " = x"0" || {
cat <<EOF
************************
*** TESTSUITE FAILED ***
************************
EOF
}
2005-06-09 11:14:39 +04:00
exit $failed
}
2005-06-26 07:39:48 +04:00
if [ -z " $VALGRIND " ] ; then
MALLOC_CHECK_ = 2
export MALLOC_CHECK_
fi
2006-09-16 02:39:30 +04:00
# initialise the local failed variable to zero when starting each of the tests
failed = 0