From 39db53a1391769fc6476fa55b02add08f1b8cd75 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 9 Aug 2021 12:31:07 +0200 Subject: [PATCH] selftest: add a test for the "deadtime" parameter BUG: https://bugzilla.samba.org/show_bug.cgi?id=14783 Signed-off-by: Ralph Boehme Reviewed-by: Samuel Cabrero Reviewed-by: Jeremy Allison --- selftest/knownfail.d/samba3.blackbox.deadtime | 1 + source3/script/tests/test_deadtime.sh | 67 +++++++++++++++++++ source3/selftest/tests.py | 4 ++ 3 files changed, 72 insertions(+) create mode 100644 selftest/knownfail.d/samba3.blackbox.deadtime create mode 100755 source3/script/tests/test_deadtime.sh diff --git a/selftest/knownfail.d/samba3.blackbox.deadtime b/selftest/knownfail.d/samba3.blackbox.deadtime new file mode 100644 index 00000000000..99d00fdef58 --- /dev/null +++ b/selftest/knownfail.d/samba3.blackbox.deadtime @@ -0,0 +1 @@ +^samba3.blackbox.deadtime.deadtime.* diff --git a/source3/script/tests/test_deadtime.sh b/source3/script/tests/test_deadtime.sh new file mode 100755 index 00000000000..68703008f02 --- /dev/null +++ b/source3/script/tests/test_deadtime.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +# +# Test deadtime parameter +# + +if [ $# -lt 1 ]; then + echo Usage: test_deadtime.sh IP + exit 1 +fi + +server=$1 + +incdir=`dirname $0`/../../../testprogs/blackbox +. $incdir/subunit.sh +. $incdir/common_test_fns.inc + +failed=0 + +smbclient="$BINDIR/smbclient" +smbcontrol="$BINDIR/smbcontrol" + +global_inject_conf=$(dirname $SMB_CONF_PATH)/global_inject.conf + +echo "deadtime = 1" > $global_inject_conf +$smbcontrol smbd reload-config + +cd $SELFTEST_TMPDIR || exit 1 + +# Create the smbclient communication pipes. +rm -f smbclient-stdin smbclient-stdout smbclient-stderr +mkfifo smbclient-stdin smbclient-stdout smbclient-stderr + +export CLI_FORCE_INTERACTIVE=1 +export SAMBA_DEPRECATED_SUPPRESS=1 + +# This gets inherited by smbclient and is required to smbclient doesn't get +# killed by an unhandled SIGPIPE when writing an SMB2 KEEPALIVE packet to the +# connection fd that was already closed by the server. +trap "" SIGPIPE + +$smbclient //$server/tmp -U${USER}%${PASSWORD} \ + < smbclient-stdin > smbclient-stdout 2>smbclient-stderr & +client_pid=$! + +sleep 1 + +exec 100>smbclient-stdin 101 $global_inject_conf +$smbcontrol smbd reload-config + +rm -f smbclient-stdin smbclient-stdout smbclient-stderr + +testok $0 $failed diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index faa201d4b79..a232deb99de 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -1092,6 +1092,10 @@ plantestsuite("samba3.blackbox.aio-outstanding", "simpleserver:local", '$SERVER_IP', "aio_delay_inject"]) +plantestsuite("samba3.blackbox.deadtime", "simpleserver:local", + [os.path.join(samba3srcdir, "script/tests/test_deadtime.sh"), + '$SERVER_IP']) + plantestsuite("samba3.blackbox.smbd_error", "simpleserver:local", [os.path.join(samba3srcdir, "script/tests/test_smbd_error.sh")])