summaryrefslogtreecommitdiff
path: root/source4/script/tests
diff options
context:
space:
mode:
Diffstat (limited to 'source4/script/tests')
-rwxr-xr-xsource4/script/tests/selftest.sh115
-rwxr-xr-xsource4/script/tests/test_functions.sh98
2 files changed, 117 insertions, 96 deletions
diff --git a/source4/script/tests/selftest.sh b/source4/script/tests/selftest.sh
index eda2e40f16..96ae855f27 100755
--- a/source4/script/tests/selftest.sh
+++ b/source4/script/tests/selftest.sh
@@ -104,6 +104,107 @@ if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:progress=no"
fi
+ runtest() {
+ if [ -z "$PREFIX" ]; then
+ PREFIX=test_prefix
+ mkdir -p $PREFIX
+ fi
+ name=$1
+ shift 1
+ cmdline="$*"
+
+ 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
+
+ if [ -n "$SMBD_TEST_LOG" -a -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
+ nf="`expr $failed + $totalfailed`";
+ if [ "$nf" = "0" ]; then
+ echo "Testing $name"
+ else
+ echo "Testing $name ($nf tests failed so far)"
+ fi
+ fi
+
+ smbd_check_only && SMBD_IS_UP="yes"
+ if [ x"$SMBD_IS_UP" != x"yes" ];then
+ if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
+ echo "SMBD is down! Skipping: $cmdline"
+ echo "=========================================="
+ echo "TEST SKIPPED: $name (reason SMBD is down)"
+ echo "=========================================="
+ else
+ echo "TEST SKIPPED: $name (reason SMBD is 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
+
+ ( $cmdline > $TEST_LOG 2>&1 )
+ status=$?
+ # 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;
+ }
+ }
+ 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;
+}
+
START=`date`
(
# give time for nbt server to register its names
@@ -123,7 +224,19 @@ export failed
totalfailed=0
export totalfailed
- . script/tests/tests_$TESTS.sh
+. script/tests/tests_$TESTS.sh | (
+ while read LINE
+ do
+ if [ "$LINE" = "-- TEST --" ]; then
+ read NAME
+ read CMDLINE
+ runtest "$NAME" "$CMDLINE"
+ else
+ echo "$LINE"
+ fi
+ done
+ )
+
exit $totalfailed
) 9>$SMBD_TEST_FIFO
failed=$?
diff --git a/source4/script/tests/test_functions.sh b/source4/script/tests/test_functions.sh
index 6999748c88..7e24f2e0b6 100755
--- a/source4/script/tests/test_functions.sh
+++ b/source4/script/tests/test_functions.sh
@@ -78,104 +78,12 @@ slapd_start() {
}
testit() {
- if [ -z "$PREFIX" ]; then
- PREFIX=test_prefix
- mkdir -p $PREFIX
- fi
name=$1
shift 1
cmdline="$*"
-
- 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
-
- if [ -n "$SMBD_TEST_LOG" -a -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
- nf="`expr $failed + $totalfailed`";
- if [ "$nf" = "0" ]; then
- echo "Testing $name"
- else
- echo "Testing $name ($nf tests failed so far)"
- fi
- fi
-
- smbd_check_only && SMBD_IS_UP="yes"
- if [ x"$SMBD_IS_UP" != x"yes" ];then
- if [ x"$RUN_FROM_BUILD_FARM" = x"yes" ];then
- echo "SMBD is down! Skipping: $cmdline"
- echo "=========================================="
- echo "TEST SKIPPED: $name (reason SMBD is down)"
- echo "=========================================="
- else
- echo "TEST SKIPPED: $name (reason SMBD is 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
-
- ( $cmdline > $TEST_LOG 2>&1 )
- status=$?
- # 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;
- }
- }
- 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;
+ echo "-- TEST --"
+ echo $name
+ echo $cmdline
}
testok() {