summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-10-02 12:43:50 -0700
committerAndrew Tridgell <tridge@samba.org>2010-10-02 21:11:52 -0700
commitb772871f4c85fe15b62cfca5c3a6d1f1a66540d6 (patch)
treee27e33b20d8e8beb433e547c82665f9213bb855a
parent507c413e488dfe374870bae3af0d89c3b015add2 (diff)
downloadsamba-b772871f4c85fe15b62cfca5c3a6d1f1a66540d6.tar.gz
samba-b772871f4c85fe15b62cfca5c3a6d1f1a66540d6.tar.bz2
samba-b772871f4c85fe15b62cfca5c3a6d1f1a66540d6.zip
s4-selftest: added --screen option for test
you can now do: make test TESTS="some test" SCREEN=1 while in GNU screen, and all the samba servers will launch in their own new screen, named after the server name. You can also do: make test TESTS="some test" SCREEN=1 VALGRIND_SERVER=1 to run valgrind on each samba server, or make test TESTS="some test" SCREEN=1 GDBTEST=1 to run gdb on each server
-rwxr-xr-xselftest/in_screen54
-rw-r--r--source4/selftest/wscript25
2 files changed, 75 insertions, 4 deletions
diff --git a/selftest/in_screen b/selftest/in_screen
new file mode 100755
index 0000000000..0704ae5390
--- /dev/null
+++ b/selftest/in_screen
@@ -0,0 +1,54 @@
+#!/bin/bash
+
+export TMPDIR="$SELFTEST_TMPDIR"
+
+SERVERNAME="$ENVNAME"
+[ -z "$SERVERNAME" ] && SERVERNAME="base"
+basedir=$TMPDIR
+
+# set most of the environment vars we have in the screen session too
+_ENV=""
+vars=$(mktemp)
+printenv |
+ egrep -v '^TERMCAP|^WINDOW|^SHELL|^STY|^SHLVL|^SAMBA_VALGRIND|\$' |
+ egrep '^[A-Z]' |
+ sed "s/\(^[^=]*=\)\(.*\)/export \1'\2'/g" > $basedir/$SERVERNAME.vars
+
+cat <<EOF > $basedir/$SERVERNAME.launch
+ echo \$\$ > $basedir/$SERVERNAME.pid
+ . $basedir/$SERVERNAME.vars
+ echo "\$(date) starting $@" >> $basedir/$SERVERNAME.log
+ $@
+ echo \$? > $basedir/$SERVERNAME.status
+ read parent < $basedir/$SERVERNAME.parent.pid
+ kill \$parent
+EOF
+pid=$$
+
+cleanup() {
+ [ -r $basedir/$SERVERNAME.status ] && {
+ read status < $basedir/$SERVERNAME.status
+ echo "$(date) samba exited with status $status" >> $basedir/$SERVERNAME.log
+ exit $status
+ }
+ read pid < $basedir/$SERVERNAME.pid
+ echo "$(date) Killing samba pid $pid" >> $basedir/$SERVERNAME.log
+ if [ "$pid" = "$$" ]; then
+ exit 1
+ fi
+ kill $pid 2>&1
+ exit 1
+}
+
+rm -f $basedir/$SERVERNAME.status $basedir/$SERVERNAME.log
+echo $$ > $basedir/$SERVERNAME.parent.pid
+trap cleanup SIGINT SIGTERM SIGPIPE
+screen -r -X screen -t test:$SERVERNAME bash $basedir/$SERVERNAME.launch
+echo "$(date) waiting in $$" >> $basedir/$SERVERNAME.log
+read stdin_var
+echo "$(date) EOF on stdin" >> $basedir/$SERVERNAME.log
+read pid < $basedir/$SERVERNAME.pid
+echo "$(date) killing $pid" >> $basedir/$SERVERNAME.log
+kill $pid 2> /dev/null
+echo "$(date) exiting" >> $basedir/$SERVERNAME.log
+exit 0
diff --git a/source4/selftest/wscript b/source4/selftest/wscript
index c693f1b677..0d662c6456 100644
--- a/source4/selftest/wscript
+++ b/source4/selftest/wscript
@@ -48,8 +48,11 @@ def set_options(opt):
gr.add_option('--valgrind-server',
help=("use valgrind on the server in the tests (opens an xterm)"),
action="store_true", dest='VALGRIND_SERVER', default=False)
+ gr.add_option('--screen',
+ help=("run the samba servers in screen sessions"),
+ action="store_true", dest='SCREEN', default=False)
gr.add_option('--gdbtest',
- help=("run the testsuite within a gdb xterm window"),
+ help=("run the servers within a gdb window"),
action="store_true", dest='GDBTEST', default=False)
gr.add_option('--fail-immediately',
help=("stop tests on first failure"),
@@ -85,6 +88,11 @@ def cmd_testonly(opt):
env.FORMAT_TEST_OUTPUT = '${SUBUNIT_FORMATTER}'
+ # put all command line options in the environment as TESTENV_*=*
+ for o in dir(Options.options):
+ if o[0:1] != '_':
+ os.environ['TESTENV_%s' % o.upper()] = str(getattr(Options.options, o, ''))
+
env.OPTIONS = ''
if not Options.options.SLOWTEST:
env.OPTIONS += ' --exclude=./selftest/slow'
@@ -109,11 +117,20 @@ def cmd_testonly(opt):
if Options.options.VALGRINDLOG is not None:
os.environ['VALGRIND'] += ' --log-file=%s' % Options.options.VALGRINDLOG
+ server_wrapper=''
+
if Options.options.VALGRIND_SERVER:
- os.environ['SAMBA_VALGRIND'] = 'xterm -n server -l -e ../selftest/valgrind_run DUMMY=X'
+ server_wrapper = '../selftest/valgrind_run _DUMMY=X'
+ elif Options.options.GDBTEST:
+ server_wrapper = '../selftest/gdb_run _DUMMY=X'
+
+ if Options.options.SCREEN:
+ server_wrapper = '../selftest/in_screen %s' % server_wrapper
+ elif server_wrapper != '':
+ server_wrapper = 'xterm -n server -l -e %s' % server_wrapper
- if Options.options.GDBTEST:
- os.environ['SAMBA_VALGRIND'] = 'xterm -n server -e ../selftest/gdb_run DUMMY=X'
+ if server_wrapper != '':
+ os.environ['SAMBA_VALGRIND'] = server_wrapper
# this is needed for systems without rpath, or with rpath disabled
ADD_LD_LIBRARY_PATH('bin/shared')