summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-10-02 14:23:43 -0700
committerAndrew Tridgell <tridge@samba.org>2010-10-02 21:11:53 -0700
commitdfb664a1822f41cbd4f1f5a8ce6fcac4e1547bf6 (patch)
treec4271f8edf108c8d4e4b353be3c67f9fb68a7ca1
parent29e1a847ddb28aee8ae04578b74cb8ab97427b96 (diff)
downloadsamba-dfb664a1822f41cbd4f1f5a8ce6fcac4e1547bf6.tar.gz
samba-dfb664a1822f41cbd4f1f5a8ce6fcac4e1547bf6.tar.bz2
samba-dfb664a1822f41cbd4f1f5a8ce6fcac4e1547bf6.zip
s4-selftest: support 'make testenv SCREEN=1'
this can be used to start a test envioronment in screen windows. Use: make testenv SCREEN=1 SELFTEST_TESTENV=dc to launch just one environment (in this case, "dc")
-rwxr-xr-xselftest/in_screen18
-rwxr-xr-xselftest/selftest.pl5
-rw-r--r--selftest/target/Samba4.pm5
-rw-r--r--source4/selftest/wscript4
4 files changed, 27 insertions, 5 deletions
diff --git a/selftest/in_screen b/selftest/in_screen
index 0704ae5390..8a3cc5c601 100755
--- a/selftest/in_screen
+++ b/selftest/in_screen
@@ -6,6 +6,17 @@ SERVERNAME="$ENVNAME"
[ -z "$SERVERNAME" ] && SERVERNAME="base"
basedir=$TMPDIR
+[ -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=""
vars=$(mktemp)
@@ -17,7 +28,7 @@ printenv |
cat <<EOF > $basedir/$SERVERNAME.launch
echo \$\$ > $basedir/$SERVERNAME.pid
. $basedir/$SERVERNAME.vars
- echo "\$(date) starting $@" >> $basedir/$SERVERNAME.log
+ echo "\$(date) starting $SERVERNAME" >> $basedir/$SERVERNAME.log
$@
echo \$? > $basedir/$SERVERNAME.status
read parent < $basedir/$SERVERNAME.parent.pid
@@ -26,17 +37,18 @@ 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" >> $basedir/$SERVERNAME.log
+ echo "$(date) Killing samba pid $pid from $$" >> $basedir/$SERVERNAME.log
if [ "$pid" = "$$" ]; then
exit 1
fi
- kill $pid 2>&1
+ kill -9 $pid 2>&1
exit 1
}
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index d102d43779..08ee52c55e 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -923,11 +923,12 @@ if ($opt_testenv) {
die("Unable to setup environment $testenv_name") unless ($testenv_vars);
$ENV{PIDDIR} = $testenv_vars->{PIDDIR};
+ $ENV{ENVNAME} = $testenv_name;
my $envvarstr = exported_envvars_str($testenv_vars);
- my $term = ($ENV{TERMINAL} or "xterm");
- system("$term -e 'echo -e \"
+ my $term = ($ENV{TERMINAL} or "xterm -e");
+ system("$term 'echo -e \"
Welcome to the Samba4 Test environment '$testenv_name'
This matches the client environment used in make test
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 1e65c66384..36023f21c7 100644
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -1286,10 +1286,12 @@ sub setup_env($$$)
return $self->setup_rodc("$path/rodc", $self->{vars}->{dc});
} elsif ($envname eq "all") {
if (not defined($self->{vars}->{dc})) {
+ $ENV{ENVNAME} = "dc";
$self->setup_dc("$path/dc");
}
my $ret = $self->setup_member("$path/member", $self->{vars}->{dc});
if (not defined($self->{vars}->{rpc_proxy})) {
+ $ENV{ENVNAME} = "rpc_proxy";
my $rpc_proxy_ret = $self->setup_rpc_proxy("$path/rpc_proxy", $self->{vars}->{dc});
$ret->{RPC_PROXY_SERVER} = $rpc_proxy_ret->{SERVER};
@@ -1300,6 +1302,7 @@ sub setup_env($$$)
$ret->{RPC_PROXY_PASSWORD} = $rpc_proxy_ret->{PASSWORD};
}
if (not defined($self->{vars}->{fl2000dc})) {
+ $ENV{ENVNAME} = "fl2000dc";
my $fl2000dc_ret = $self->setup_fl2000dc("$path/fl2000dc", $self->{vars}->{dc});
$ret->{FL2000DC_SERVER} = $fl2000dc_ret->{SERVER};
@@ -1310,6 +1313,7 @@ sub setup_env($$$)
$ret->{FL2000DC_PASSWORD} = $fl2000dc_ret->{PASSWORD};
}
if (not defined($self->{vars}->{fl2003dc})) {
+ $ENV{ENVNAME} = "fl2003dc";
my $fl2003dc_ret = $self->setup_fl2003dc("$path/fl2003dc", $self->{vars}->{dc});
$ret->{FL2003DC_SERVER} = $fl2003dc_ret->{SERVER};
@@ -1320,6 +1324,7 @@ sub setup_env($$$)
$ret->{FL2003DC_PASSWORD} = $fl2003dc_ret->{PASSWORD};
}
if (not defined($self->{vars}->{fl2008r2dc})) {
+ $ENV{ENVNAME} = "fl2008r2dc";
my $fl2008r2dc_ret = $self->setup_fl2008r2dc("$path/fl2008r2dc", $self->{vars}->{dc});
$ret->{FL2008R2DC_SERVER} = $fl2008r2dc_ret->{SERVER};
diff --git a/source4/selftest/wscript b/source4/selftest/wscript
index 4606c6681a..561baeb6e1 100644
--- a/source4/selftest/wscript
+++ b/source4/selftest/wscript
@@ -90,6 +90,9 @@ def cmd_testonly(opt):
env.FORMAT_TEST_OUTPUT = '${SUBUNIT_FORMATTER}'
+ # clean any previous temporary files
+ os.system("rm -rf %s/tmp" % env.SELFTEST_PREFIX);
+
# put all command line options in the environment as TESTENV_*=*
for o in dir(Options.options):
if o[0:1] != '_':
@@ -128,6 +131,7 @@ def cmd_testonly(opt):
if Options.options.SCREEN:
server_wrapper = '../selftest/in_screen %s' % server_wrapper
+ os.environ['TERMINAL'] = '../selftest/in_screen'
elif server_wrapper != '':
server_wrapper = 'xterm -n server -l -e %s' % server_wrapper