diff options
author | bubulle <bubulle@alioth.debian.org> | 2011-06-07 20:08:36 +0000 |
---|---|---|
committer | bubulle <bubulle@alioth.debian.org> | 2011-06-07 20:08:36 +0000 |
commit | 6fe9013ae23927a67fa6b6033e2711cef99b3533 (patch) | |
tree | 5018bffeace42912accb0d67ddd3893fd15b61d1 /selftest/in_screen | |
parent | 4d16e8d5702fb98dda73c5c0f3404d662ae62df6 (diff) | |
download | samba-6fe9013ae23927a67fa6b6033e2711cef99b3533.tar.gz |
Load samba-3.6.0rc2 into branches/samba/upstream.
git-svn-id: svn://svn.debian.org/svn/pkg-samba/branches/samba/upstream@3807 fc4039ab-9d04-0410-8cac-899223bdd6b0
Diffstat (limited to 'selftest/in_screen')
-rwxr-xr-x | selftest/in_screen | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/selftest/in_screen b/selftest/in_screen new file mode 100755 index 0000000000..8bfbc0101b --- /dev/null +++ b/selftest/in_screen @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +export TMPDIR="$SELFTEST_TMPDIR" + +SERVERNAME="$ENVNAME" +[ -z "$SERVERNAME" ] && SERVERNAME="base" +basedir=$TMPDIR +osname=$(uname) +if [ "$osname" = "Linux" ]; then + vars=$(mktemp) +else + vars=$(mktemp -t tmpsmb) + function seq() { + dpt=$1 + end=$2 + while [ $dpt -le $end ]; do + echo "$dpt" + dpt=$(( $dpt + 1)) + done + } +fi + +[ -r $basedir/$SERVERNAME.pid ] && { + for i in $(seq 2 100); do + if [ ! -r "$basedir/${SERVERNAME}-$i.pid" ]; then + SERVERNAME="${SERVERNAME}-$i" + break + fi + done +} + +rm -f $basedir/$SERVERNAME.* + +# set most of the environment vars we have in the screen session too +_ENV="" +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 +cd $PWD + echo \$\$ > $basedir/$SERVERNAME.pid + . $basedir/$SERVERNAME.vars + echo "\$(date) starting $SERVERNAME" >> $basedir/$SERVERNAME.log + $@ + echo \$? > $basedir/$SERVERNAME.status + read parent < $basedir/$SERVERNAME.parent.pid + kill \$parent +EOF +pid=$$ + +cleanup() { + trap "exit 1" SIGINT SIGTERM SIGPIPE + [ -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 from $$" >> $basedir/$SERVERNAME.log + if [ "$pid" = "$$" ]; then + exit 1 + fi + kill -9 $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 |