diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-10-02 12:43:50 -0700 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-10-02 21:11:52 -0700 |
commit | b772871f4c85fe15b62cfca5c3a6d1f1a66540d6 (patch) | |
tree | e27e33b20d8e8beb433e547c82665f9213bb855a /selftest | |
parent | 507c413e488dfe374870bae3af0d89c3b015add2 (diff) | |
download | samba-b772871f4c85fe15b62cfca5c3a6d1f1a66540d6.tar.gz |
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
Diffstat (limited to 'selftest')
-rwxr-xr-x | selftest/in_screen | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/selftest/in_screen b/selftest/in_screen new file mode 100755 index 00000000000..0704ae53909 --- /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 |