From 2fca3f9082a70e1f153f6c9f195d95b0d48e363d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 Mar 2007 15:57:07 +0000 Subject: r21909: Merge some of my recent improvements to the test infrastructure: - Allow tests to specify what environment they need to run in (dc and none are thecurrent supported ones). - Move more Samba4-specific code out of the common code (This used to be commit dbe9de10287c902f4a5ea5d431dea4a79f9b170b) --- source4/main.mk | 2 +- source4/script/tests/Samba3.pm | 129 +++++++++++ source4/script/tests/Samba4.pm | 100 ++++++--- source4/script/tests/TODO | 5 + source4/script/tests/Windows.pm | 40 ++++ source4/script/tests/mktestdc.sh | 300 ++++++++++++++++++++++++++ source4/script/tests/mktestdc.sh.share_ldb | 5 + source4/script/tests/mktestsetup.sh | 300 -------------------------- source4/script/tests/mktestsetup.sh.share_ldb | 5 - source4/script/tests/selftest.pl | 158 ++++++-------- source4/script/tests/test_binding_string.sh | 2 +- source4/script/tests/test_blackbox.sh | 4 +- source4/script/tests/test_echo.sh | 6 +- source4/script/tests/test_ejs.sh | 14 +- source4/script/tests/test_functions.sh | 104 +-------- source4/script/tests/test_ldap.sh | 10 +- source4/script/tests/test_local.sh | 4 +- source4/script/tests/test_nbt.sh | 6 +- source4/script/tests/test_net.sh | 2 +- source4/script/tests/test_pidl.sh | 2 +- source4/script/tests/test_posix.sh | 2 +- source4/script/tests/test_quick.sh | 2 +- source4/script/tests/test_rpc.sh | 4 +- source4/script/tests/test_rpc_quick.sh | 2 +- source4/script/tests/test_s3upgrade.sh | 4 +- source4/script/tests/test_session_key.sh | 10 +- source4/script/tests/test_simple.sh | 2 +- source4/script/tests/test_w2k3.sh | 8 +- source4/script/tests/test_w2k3_file.sh | 2 +- source4/script/tests/test_win.sh | 12 +- source4/script/tests/tests_win2k3_dc.sh | 2 +- source4/torture/config.mk | 17 +- source4/torture/local/torture.c | 2 +- 33 files changed, 686 insertions(+), 581 deletions(-) create mode 100644 source4/script/tests/Samba3.pm create mode 100644 source4/script/tests/TODO create mode 100644 source4/script/tests/Windows.pm create mode 100755 source4/script/tests/mktestdc.sh create mode 100755 source4/script/tests/mktestdc.sh.share_ldb delete mode 100755 source4/script/tests/mktestsetup.sh delete mode 100755 source4/script/tests/mktestsetup.sh.share_ldb diff --git a/source4/main.mk b/source4/main.mk index f17917dc30..0518882109 100644 --- a/source4/main.mk +++ b/source4/main.mk @@ -283,7 +283,7 @@ realdistclean: distclean removebackup check:: test -SELFTEST = $(srcdir)/script/tests/selftest.pl --prefix=${selftest_prefix} --builddir=$(builddir) --srcdir=$(srcdir) --expected-failures=samba4-knownfail --skip=samba4-skip +SELFTEST = $(srcdir)/script/tests/selftest.pl --prefix=${selftest_prefix} --builddir=$(builddir) --srcdir=$(srcdir) --expected-failures=samba4-knownfail --skip=samba4-skip $(TEST_OPTIONS) test: all libraries $(SELFTEST) $(DEFAULT_TEST_OPTIONS) $(TESTS) --immediate diff --git a/source4/script/tests/Samba3.pm b/source4/script/tests/Samba3.pm new file mode 100644 index 0000000000..0cde6e22c9 --- /dev/null +++ b/source4/script/tests/Samba3.pm @@ -0,0 +1,129 @@ +#!/usr/bin/perl +# Bootstrap Samba and run a number of tests against it. +# Copyright (C) 2005-2007 Jelmer Vernooij +# Published under the GNU GPL, v3 or later. + +package Samba3; + +use strict; +use FindBin qw($RealBin); +use POSIX; + +sub new($$$) { + my ($classname, $bindir, $setupdir) = @_; + my $self = { bindir => $bindir, setupdir => $setupdir }; + bless $self; + return $self; +} + +sub check_or_start($$$$) +{ + my ($self, $env_vars, $socket_wrapper_dir, $max_time) = @_; + return 0 if ( -p $env_vars->{SMBD_TEST_FIFO}); + + warn("Not using socket wrapper, but also not running as root. Will not be able to listen on proper ports") unless + defined($socket_wrapper_dir) or $< == 0; + + unlink($env_vars->{SMBD_TEST_FIFO}); + POSIX::mkfifo($env_vars->{SMBD_TEST_FIFO}, 0700); + unlink($env_vars->{SMBD_TEST_LOG}); + + my $valgrind = ""; + if (defined($ENV{SMBD_VALGRIND})) { + $valgrind = $ENV{SMBD_VALGRIND}; + } + + print "STARTING SMBD... "; + my $pid = fork(); + if ($pid == 0) { + open STDIN, $env_vars->{SMBD_TEST_FIFO}; + open STDOUT, ">$env_vars->{SMBD_TEST_LOG}"; + open STDERR, '>&STDOUT'; + my $optarg = ""; + if (defined($max_time)) { + $optarg = "--maximum-runtime=$max_time "; + } + my $ret = system("$valgrind $self->{bindir}/smbd $optarg -s $env_vars->{CONFFILE} -M single -i --leak-report-full"); + if ($? == -1) { + print "Unable to start smbd: $ret: $!\n"; + exit 1; + } + unlink($env_vars->{SMBD_TEST_FIFO}); + unlink(<$socket_wrapper_dir/*>) if (defined($socket_wrapper_dir) and -d $socket_wrapper_dir); + my $exit = $? >> 8; + if ( $ret == 0 ) { + print "smbd exits with status $exit\n"; + } elsif ( $ret & 127 ) { + print "smbd got signal ".($ret & 127)." and exits with $exit!\n"; + } else { + $ret = $? >> 8; + print "smbd failed with status $exit!\n"; + } + exit $exit; + } + print "DONE\n"; + + open(DATA, ">$env_vars->{SMBD_TEST_FIFO}"); + + return $pid; +} + +sub wait_for_start($) +{ + # give time for nbt server to register its names + print "delaying for nbt name registration\n"; + + # This will return quickly when things are up, but be slow if we + # need to wait for (eg) SSL init + system("bin/nmblookup $ENV{CONFIGURATION} $ENV{SERVER}"); + system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{SERVER}"); + system("bin/nmblookup $ENV{CONFIGURATION} $ENV{SERVER}"); + system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{NETBIOSNAME}"); + system("bin/nmblookup $ENV{CONFIGURATION} $ENV{NETBIOSNAME}"); + system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{NETBIOSNAME}"); + system("bin/nmblookup $ENV{CONFIGURATION} $ENV{NETBIOSNAME}"); + system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{NETBIOSNAME}"); +} + +sub provision($$$) +{ + my ($self, $environment, $prefix) = @_; + my %ret = (); + print "PROVISIONING..."; + open(IN, "$RealBin/mktestdc.sh $prefix|") or die("Unable to setup"); + while () { + die ("Error parsing `$_'") unless (/^([A-Z0-9a-z_]+)=(.*)$/); + $ret{$1} = $2; + } + close(IN); + + $ret{SMBD_TEST_FIFO} = "$prefix/smbd_test.fifo"; + $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log"; + return \%ret; +} + +sub stop($) +{ + my ($self) = @_; + + close(DATA); + + sleep(2); + + my $failed = $? >> 8; + + if (-f "$ENV{PIDDIR}/smbd.pid" ) { + open(IN, "<$ENV{PIDDIR}/smbd.pid") or die("unable to open smbd pid file"); + kill 9, ; + close(IN); + } + + return $failed; +} + +sub setup_env($$) +{ + my ($self, $name) = @_; +} + +1; diff --git a/source4/script/tests/Samba4.pm b/source4/script/tests/Samba4.pm index c4c0598ff5..0a92f36dc8 100644 --- a/source4/script/tests/Samba4.pm +++ b/source4/script/tests/Samba4.pm @@ -5,18 +5,21 @@ package Samba4; -use Exporter; -@ISA = qw(Exporter); -@EXPORT_OK = qw(slapd_start slapd_stop smbd_check_or_start provision); - use strict; use FindBin qw($RealBin); use POSIX; +sub new($$$$) { + my ($classname, $bindir, $ldap, $setupdir) = @_; + my $self = { ldap => $ldap, bindir => $bindir, setupdir => $setupdir }; + bless $self; + return $self; +} + sub slapd_start($$$) { - my $count = 0; - my ($bindir, $conf, $uri) = @_; + my $count = 0; + my ($self, $conf, $uri) = @_; # running slapd in the background means it stays in the same process group, so it can be # killed by timelimit if (defined($ENV{FEDORA_DS_PREFIX})) { @@ -27,10 +30,10 @@ sub slapd_start($$$) system("slapd -d$ENV{OPENLDAP_LOGLEVEL} -f $conf -h $uri > $ENV{LDAPDIR}/logs 2>&1 &"); $ENV{PATH} = $oldpath; } - while (system("$bindir/ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") != 0) { + while (system("$self->{bindir}/ldbsearch -H $uri -s base -b \"\" supportedLDAPVersion > /dev/null") != 0) { $count++; if ($count > 10) { - slapd_stop(); + $self->slapd_stop(); return 0; } sleep(1); @@ -38,8 +41,9 @@ sub slapd_start($$$) return 1; } -sub slapd_stop() +sub slapd_stop($) { + my ($self) = @_; if (defined($ENV{FEDORA_DS_PREFIX})) { system("$ENV{LDAPDIR}/slapd-samba4/stop-slapd"); } else { @@ -50,39 +54,48 @@ sub slapd_stop() } } -sub smbd_check_or_start($$$$$$) +sub check_or_start($$$$) { - my ($bindir, $test_fifo, $test_log, $socket_wrapper_dir, $max_time, $conffile) = @_; - return 0 if ( -p $test_fifo ); + my ($self, $env_vars, $socket_wrapper_dir, $max_time) = @_; + return 0 if ( -p $env_vars->{SMBD_TEST_FIFO}); + + # Start slapd before smbd + if ($self->{ldap}) { + $self->slapd_start($ENV{SLAPD_CONF}, $ENV{LDAP_URI}) or + die("couldn't start slapd"); + + print "LDAP PROVISIONING..."; + $self->provision_ldap(); + } warn("Not using socket wrapper, but also not running as root. Will not be able to listen on proper ports") unless defined($socket_wrapper_dir) or $< == 0; - unlink($test_fifo); - POSIX::mkfifo($test_fifo, 0700); - unlink($test_log); + unlink($env_vars->{SMBD_TEST_FIFO}); + POSIX::mkfifo($env_vars->{SMBD_TEST_FIFO}, 0700); + unlink($env_vars->{SMBD_TEST_LOG}); my $valgrind = ""; if (defined($ENV{SMBD_VALGRIND})) { $valgrind = $ENV{SMBD_VALGRIND}; } - print "STARTING SMBD..."; + print "STARTING SMBD... "; my $pid = fork(); if ($pid == 0) { - open STDIN, $test_fifo; - open STDOUT, ">$test_log"; + open STDIN, $env_vars->{SMBD_TEST_FIFO}; + open STDOUT, ">$env_vars->{SMBD_TEST_LOG}"; open STDERR, '>&STDOUT'; my $optarg = ""; if (defined($max_time)) { $optarg = "--maximum-runtime=$max_time "; } - my $ret = system("$valgrind $bindir/smbd $optarg -s $conffile -M single -i --leak-report-full"); + my $ret = system("$valgrind $self->{bindir}/smbd $optarg -s $env_vars->{CONFFILE} -M single -i --leak-report-full"); if ($? == -1) { print "Unable to start smbd: $ret: $!\n"; exit 1; } - unlink($test_fifo); + unlink($env_vars->{SMBD_TEST_FIFO}); unlink(<$socket_wrapper_dir/*>) if (defined($socket_wrapper_dir) and -d $socket_wrapper_dir); my $exit = $? >> 8; if ( $ret == 0 ) { @@ -97,10 +110,12 @@ sub smbd_check_or_start($$$$$$) } print "DONE\n"; + open(DATA, ">$env_vars->{SMBD_TEST_FIFO}"); + return $pid; } -sub wait_for_start() +sub wait_for_start($) { # give time for nbt server to register its names print "delaying for nbt name registration\n"; @@ -117,25 +132,54 @@ sub wait_for_start() system("bin/nmblookup $ENV{CONFIGURATION} -U $ENV{SERVER} $ENV{NETBIOSNAME}"); } -sub provision($) +sub provision($$$) { - my ($prefix) = @_; + my ($self, $environment, $prefix) = @_; my %ret = (); print "PROVISIONING..."; - open(IN, "$RealBin/mktestsetup.sh $prefix|") or die("Unable to setup"); + open(IN, "$RealBin/mktestdc.sh $prefix|") or die("Unable to setup"); while () { die ("Error parsing `$_'") unless (/^([A-Z0-9a-z_]+)=(.*)$/); $ret{$1} = $2; } close(IN); + + $ret{SMBD_TEST_FIFO} = "$prefix/smbd_test.fifo"; + $ret{SMBD_TEST_LOG} = "$prefix/smbd_test.log"; return \%ret; } -sub provision_ldap($$) +sub provision_ldap($) +{ + my ($self) = @_; + system("$self->{bindir}/smbscript $self->{setupdir}/provision $ENV{PROVISION_OPTIONS} \"$ENV{PROVISION_ACI}\" --ldap-backend=$ENV{LDAP_URI}") and + die("LDAP PROVISIONING failed: $self->{bindir}/smbscript $self->{setupdir}/provision $ENV{PROVISION_OPTIONS} \"$ENV{PROVISION_ACI}\" --ldap-backend=$ENV{LDAP_URI}"); +} + +sub stop($) +{ + my ($self) = @_; + + close(DATA); + + sleep(2); + + my $failed = $? >> 8; + + if (-f "$ENV{PIDDIR}/smbd.pid" ) { + open(IN, "<$ENV{PIDDIR}/smbd.pid") or die("unable to open smbd pid file"); + kill 9, ; + close(IN); + } + + $self->slapd_stop() if ($self->{ldap}); + + return $failed; +} + +sub setup_env($$) { - my ($bindir, $setupdir) = @_; - system("$bindir/smbscript $setupdir/provision $ENV{PROVISION_OPTIONS} \"$ENV{PROVISION_ACI}\" --ldap-backend=$ENV{LDAP_URI}") and - die("LDAP PROVISIONING failed: $bindir/smbscript $setupdir/provision $ENV{PROVISION_OPTIONS} \"$ENV{PROVISION_ACI}\" --ldap-backend=$ENV{LDAP_URI}"); + my ($self, $name) = @_; } 1; diff --git a/source4/script/tests/TODO b/source4/script/tests/TODO new file mode 100644 index 0000000000..4d327ce1ea --- /dev/null +++ b/source4/script/tests/TODO @@ -0,0 +1,5 @@ +- warn about unexpected successes +- support for environments +- better way to detect that smbd has finished initialization +- allow tests to specify what parameters they need + - UNC / DCERPC binding strings diff --git a/source4/script/tests/Windows.pm b/source4/script/tests/Windows.pm new file mode 100644 index 0000000000..710ffeda14 --- /dev/null +++ b/source4/script/tests/Windows.pm @@ -0,0 +1,40 @@ +#!/usr/bin/perl +# Bootstrap Samba and run a number of tests against it. +# Copyright (C) 2005-2007 Jelmer Vernooij +# Published under the GNU GPL, v3 or later. + +package Windows; + +use strict; +use FindBin qw($RealBin); +use POSIX; + +sub new($) +{ + my ($classname) = @_; + my $self = { }; + bless $self; + return $self; +} + +sub provision($$$) +{ + my ($self, $environment, $prefix) = @_; + + die ("Windows tests will not run without root privileges.") + if (`whoami` ne "root"); + + die("Environment variable WINTESTCONF has not been defined.\n". + "Windows tests will not run unconfigured.") if (not defined($ENV{WINTESTCONF})); + + die ("$ENV{WINTESTCONF} could not be read.") if (! -r $ENV{WINTESTCONF}); + + $ENV{WINTEST_DIR}="$ENV{SRCDIR}/script/tests/win"; +} + +sub setup_env($$) +{ + my ($self, $name) = @_; +} + +1; diff --git a/source4/script/tests/mktestdc.sh b/source4/script/tests/mktestdc.sh new file mode 100755 index 0000000000..2068728a49 --- /dev/null +++ b/source4/script/tests/mktestdc.sh @@ -0,0 +1,300 @@ +#!/bin/sh +# Build a test environment for running Samba + +if [ $# -lt 1 ] +then + echo "$0 PREFIX" + exit 1 +fi + +PREFIX=$1 + +if test -z "$SHARE_BACKEND"; then + SHARE_BACKEND=classic +fi + +if test -z "$SMBD_LOGLEVEL"; then + SMBD_LOGLEVEL=1 +fi + +DOMAIN=SAMBADOMAIN +USERNAME=administrator +REALM=SAMBA.EXAMPLE.COM +DNSNAME="samba.example.com" +BASEDN="dc=samba,dc=example,dc=com" +PASSWORD=penguin +AUTH="-U$USERNAME%$PASSWORD" +SRCDIR=`pwd` +ROOT=$USER +SERVER=localhost +NETBIOSNAME=localtest +if test -z "$ROOT"; then + ROOT=$LOGNAME +fi +if test -z "$ROOT"; then + ROOT=`whoami` +fi + +oldpwd=`pwd` +srcdir=`dirname $0`/../.. +mkdir -p $PREFIX || exit $? +cd $PREFIX +PREFIX_ABS=`pwd` +cd $oldpwd + +TEST_DATA_PREFIX=$PREFIX_ABS + +TMPDIR=$PREFIX_ABS/tmp +ETCDIR=$PREFIX_ABS/etc +PIDDIR=$PREFIX_ABS/pid +CONFFILE=$ETCDIR/smb.conf +KRB5_CONFIG=$ETCDIR/krb5.conf +PRIVATEDIR=$PREFIX_ABS/private +NCALRPCDIR=$PREFIX_ABS/ncalrpc +LOCKDIR=$PREFIX_ABS/lockdir + +WINBINDD_SOCKET_DIR=$PREFIX_ABS/winbind_socket +CONFIGURATION="--configfile=$CONFFILE" +LDAPDIR=$PREFIX_ABS/ldap + +rm -rf $PREFIX/* +mkdir -p $PRIVATEDIR $ETCDIR $PIDDIR $NCALRPCDIR $LOCKDIR $TMPDIR $LDAPDIR/db $LDAPDIR/db/bdb-logs $LDAPDIR/db/tmp + +if [ -z "$VALGRIND" ]; then + nativeiconv="true" +else + nativeiconv="false" +fi + +cat >$CONFFILE<$PRIVATEDIR/share.ldif</dev/null || exit 1 + +cat >$KRB5_CONFIG</dev/null 2>&1 || { + echo "">&2 + echo "Failed to create configuration!" >&2 + $srcdir/bin/testparm $CONFIGURATION >&2 + exit 1 +} + +( $srcdir/bin/testparm $CONFIGURATION -v --suppress-prompt --parameter-name="netbios name" --section-name=global 2> /dev/null | grep -i ^$NETBIOSNAME ) >/dev/null 2>&1 || { + echo "$?" >&2 + $srcdir/bin/testparm $CONFIGURATION -v --suppress-prompt --parameter-name="netbios name" --section-name=global --suppress-prompt 2> /dev/null | grep -i ^$NETBIOSNAME >&2 + echo "Failed to create configuration!" >&2 + exit 1 +} + +PROVISION_OPTIONS="$CONFIGURATION --host-name=$NETBIOSNAME --host-ip=127.0.0.1" +PROVISION_OPTIONS="$PROVISION_OPTIONS --quiet --domain $DOMAIN --realm $REALM" +PROVISION_OPTIONS="$PROVISION_OPTIONS --adminpass $PASSWORD --root=$ROOT" +PROVISION_OPTIONS="$PROVISION_OPTIONS --simple-bind-dn=cn=Manager,$BASEDN --password=$PASSWORD --root=$ROOT" +$srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS >&2 + +LDAP_URI="ldapi://"`echo $LDAPDIR/ldapi | sed 's|/|%2F|g'` + +. `dirname $0`/mk-openldap.sh + +test -z "$FEDORA_DS_PREFIX" || { + . `dirname $0`/mk-fedora-ds.sh +} + +cat >$PRIVATEDIR/wins_config.ldif</dev/null || exit 1 + +echo "KRB5_CONFIG=$KRB5_CONFIG" +echo "PREFIX_ABS=$PREFIX_ABS" +echo "TEST_DATA_PREFIX=$TEST_DATA_PREFIX" +echo "CONFIGURATION=$CONFIGURATION" +echo "CONFFILE=$CONFFILE" +echo "SLAPD_CONF=$SLAPD_CONF" +echo "PIDDIR=$PIDDIR" +echo "AUTH=$AUTH" +echo "SERVER=$SERVER" +echo "NETBIOSNAME=$NETBIOSNAME" +echo "LDAP_URI=$LDAP_URI" +echo "DOMAIN=$DOMAIN" +echo "USERNAME=$USERNAME" +echo "REALM=$REALM" +echo "DNSNAME=$DNSNAME" +echo "BASEDN=$BASEDN" +echo "PASSWORD=$PASSWORD" +echo "SRCDIR=$SRCDIR" +echo "PREFIX=$PREFIX" +echo "SMBD_LOGLEVEL=$SMBD_LOGLEVEL" +echo "LDAPDIR=$LDAPDIR" +echo "PROVISION_OPTIONS=$PROVISION_OPTIONS" +echo "PROVISION_ACI=$PROVISION_ACI" \ No newline at end of file diff --git a/source4/script/tests/mktestdc.sh.share_ldb b/source4/script/tests/mktestdc.sh.share_ldb new file mode 100755 index 0000000000..8aa0a046ab --- /dev/null +++ b/source4/script/tests/mktestdc.sh.share_ldb @@ -0,0 +1,5 @@ +#!/bin/sh + +SHARE_BACKEND="ldb" + +. `dirname $0`/mktestsetup.sh diff --git a/source4/script/tests/mktestsetup.sh b/source4/script/tests/mktestsetup.sh deleted file mode 100755 index 2068728a49..0000000000 --- a/source4/script/tests/mktestsetup.sh +++ /dev/null @@ -1,300 +0,0 @@ -#!/bin/sh -# Build a test environment for running Samba - -if [ $# -lt 1 ] -then - echo "$0 PREFIX" - exit 1 -fi - -PREFIX=$1 - -if test -z "$SHARE_BACKEND"; then - SHARE_BACKEND=classic -fi - -if test -z "$SMBD_LOGLEVEL"; then - SMBD_LOGLEVEL=1 -fi - -DOMAIN=SAMBADOMAIN -USERNAME=administrator -REALM=SAMBA.EXAMPLE.COM -DNSNAME="samba.example.com" -BASEDN="dc=samba,dc=example,dc=com" -PASSWORD=penguin -AUTH="-U$USERNAME%$PASSWORD" -SRCDIR=`pwd` -ROOT=$USER -SERVER=localhost -NETBIOSNAME=localtest -if test -z "$ROOT"; then - ROOT=$LOGNAME -fi -if test -z "$ROOT"; then - ROOT=`whoami` -fi - -oldpwd=`pwd` -srcdir=`dirname $0`/../.. -mkdir -p $PREFIX || exit $? -cd $PREFIX -PREFIX_ABS=`pwd` -cd $oldpwd - -TEST_DATA_PREFIX=$PREFIX_ABS - -TMPDIR=$PREFIX_ABS/tmp -ETCDIR=$PREFIX_ABS/etc -PIDDIR=$PREFIX_ABS/pid -CONFFILE=$ETCDIR/smb.conf -KRB5_CONFIG=$ETCDIR/krb5.conf -PRIVATEDIR=$PREFIX_ABS/private -NCALRPCDIR=$PREFIX_ABS/ncalrpc -LOCKDIR=$PREFIX_ABS/lockdir - -WINBINDD_SOCKET_DIR=$PREFIX_ABS/winbind_socket -CONFIGURATION="--configfile=$CONFFILE" -LDAPDIR=$PREFIX_ABS/ldap - -rm -rf $PREFIX/* -mkdir -p $PRIVATEDIR $ETCDIR $PIDDIR $NCALRPCDIR $LOCKDIR $TMPDIR $LDAPDIR/db $LDAPDIR/db/bdb-logs $LDAPDIR/db/tmp - -if [ -z "$VALGRIND" ]; then - nativeiconv="true" -else - nativeiconv="false" -fi - -cat >$CONFFILE<$PRIVATEDIR/share.ldif</dev/null || exit 1 - -cat >$KRB5_CONFIG</dev/null 2>&1 || { - echo "">&2 - echo "Failed to create configuration!" >&2 - $srcdir/bin/testparm $CONFIGURATION >&2 - exit 1 -} - -( $srcdir/bin/testparm $CONFIGURATION -v --suppress-prompt --parameter-name="netbios name" --section-name=global 2> /dev/null | grep -i ^$NETBIOSNAME ) >/dev/null 2>&1 || { - echo "$?" >&2 - $srcdir/bin/testparm $CONFIGURATION -v --suppress-prompt --parameter-name="netbios name" --section-name=global --suppress-prompt 2> /dev/null | grep -i ^$NETBIOSNAME >&2 - echo "Failed to create configuration!" >&2 - exit 1 -} - -PROVISION_OPTIONS="$CONFIGURATION --host-name=$NETBIOSNAME --host-ip=127.0.0.1" -PROVISION_OPTIONS="$PROVISION_OPTIONS --quiet --domain $DOMAIN --realm $REALM" -PROVISION_OPTIONS="$PROVISION_OPTIONS --adminpass $PASSWORD --root=$ROOT" -PROVISION_OPTIONS="$PROVISION_OPTIONS --simple-bind-dn=cn=Manager,$BASEDN --password=$PASSWORD --root=$ROOT" -$srcdir/bin/smbscript $srcdir/setup/provision $PROVISION_OPTIONS >&2 - -LDAP_URI="ldapi://"`echo $LDAPDIR/ldapi | sed 's|/|%2F|g'` - -. `dirname $0`/mk-openldap.sh - -test -z "$FEDORA_DS_PREFIX" || { - . `dirname $0`/mk-fedora-ds.sh -} - -cat >$PRIVATEDIR/wins_config.ldif</dev/null || exit 1 - -echo "KRB5_CONFIG=$KRB5_CONFIG" -echo "PREFIX_ABS=$PREFIX_ABS" -echo "TEST_DATA_PREFIX=$TEST_DATA_PREFIX" -echo "CONFIGURATION=$CONFIGURATION" -echo "CONFFILE=$CONFFILE" -echo "SLAPD_CONF=$SLAPD_CONF" -echo "PIDDIR=$PIDDIR" -echo "AUTH=$AUTH" -echo "SERVER=$SERVER" -echo "NETBIOSNAME=$NETBIOSNAME" -echo "LDAP_URI=$LDAP_URI" -echo "DOMAIN=$DOMAIN" -echo "USERNAME=$USERNAME" -echo "REALM=$REALM" -echo "DNSNAME=$DNSNAME" -echo "BASEDN=$BASEDN" -echo "PASSWORD=$PASSWORD" -echo "SRCDIR=$SRCDIR" -echo "PREFIX=$PREFIX" -echo "SMBD_LOGLEVEL=$SMBD_LOGLEVEL" -echo "LDAPDIR=$LDAPDIR" -echo "PROVISION_OPTIONS=$PROVISION_OPTIONS" -echo "PROVISION_ACI=$PROVISION_ACI" \ No newline at end of file diff --git a/source4/script/tests/mktestsetup.sh.share_ldb b/source4/script/tests/mktestsetup.sh.share_ldb deleted file mode 100755 index 8aa0a046ab..0000000000 --- a/source4/script/tests/mktestsetup.sh.share_ldb +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -SHARE_BACKEND="ldb" - -. `dirname $0`/mktestsetup.sh diff --git a/source4/script/tests/selftest.pl b/source4/script/tests/selftest.pl index 31d0118083..d3a7f217ab 100755 --- a/source4/script/tests/selftest.pl +++ b/source4/script/tests/selftest.pl @@ -90,8 +90,6 @@ Abort as soon as one test fails. =item I -=item I - =item I =item I @@ -117,6 +115,7 @@ use Getopt::Long; use POSIX; use Cwd; use lib "$RealBin"; +use Samba3; use Samba4; use SocketWrapper; @@ -131,6 +130,8 @@ my $opt_expected_failures = undef; my $opt_skip = undef; my $opt_verbose = 0; my $opt_testenv = 0; +my $opt_ldap = undef; +my $opt_analyse_cmd = undef; my $srcdir = "."; my $builddir = "."; @@ -305,12 +306,14 @@ Target Specific: --socket-wrapper-pcap=FILE save traffic to pcap file --socket-wrapper enable socket wrapper --expected-failures=FILE specify list of tests that is guaranteed to fail + --ldap run against ldap Behaviour: --quick run quick overall test --one abort when the first test fails --immediate print test output for failed tests during run --verbose be verbose + --analyse-cmd CMD command to run after each test "; exit(0); } @@ -329,7 +332,9 @@ my $result = GetOptions ( 'srcdir=s' => \$srcdir, 'builddir=s' => \$builddir, 'verbose' => \$opt_verbose, - 'testenv' => \$opt_testenv + 'testenv' => \$opt_testenv, + 'ldap' => \$opt_ldap, + 'analyse-cmd=s' => \$opt_analyse_cmd, ); exit(1) if (not $result); @@ -338,26 +343,31 @@ ShowHelp() if ($opt_help); my $tests = shift; -my $torture_maxtime = $ENV{TORTURE_MAXTIME}; -unless (defined($torture_maxtime)) { - $torture_maxtime = 1200; -} - # quick hack to disable rpc validation when using valgrind - its way too slow unless (defined($ENV{VALGRIND})) { $ENV{VALIDATE} = "validate"; } my $old_pwd = "$RealBin/../.."; -my $ldap = (defined($ENV{TEST_LDAP}) and ($ENV{TEST_LDAP} eq "yes"))?1:0; +my $ldap = 0; +if (defined($ENV{TEST_LDAP})) { + $ldap = ($ENV{TEST_LDAP} eq "yes"); +} +if (defined($opt_ldap)) { + $ldap = $opt_ldap; +} + +my $torture_maxtime = ($ENV{TORTURE_MAXTIME} or 1200); +if ($ldap) { + # LDAP is slow + $torture_maxtime *= 2; +} $prefix =~ s+//+/+; $ENV{PREFIX} = $prefix; $ENV{SRCDIR} = $srcdir; -my $bindir = "$srcdir/bin"; -my $setupdir = "$srcdir/setup"; my $testsdir = "$srcdir/script/tests"; my $tls_enabled = not $opt_quick; @@ -377,32 +387,6 @@ $ENV{PATH} = "$old_pwd/bin:$ENV{PATH}"; my @torture_options = (); -my $testenv_vars = {}; - -if ($opt_target eq "samba4") { - $testenv_vars = Samba4::provision($prefix); -} elsif ($opt_target eq "win") { - die ("Windows tests will not run without root privileges.") - if (`whoami` ne "root"); - - die("Windows tests will not run with socket wrapper enabled.") - if ($opt_socket_wrapper); - - die("Windows tests will not run quickly.") if ($opt_quick); - - die("Environment variable WINTESTCONF has not been defined.\n". - "Windows tests will not run unconfigured.") if (not defined($ENV{WINTESTCONF})); - - die ("$ENV{WINTESTCONF} could not be read.") if (! -r $ENV{WINTESTCONF}); - - $ENV{WINTEST_DIR}="$ENV{SRCDIR}/script/tests/win"; -} elsif ($opt_target eq "none") { -} else { - die("unknown target `$opt_target'"); -} - -foreach (keys %$testenv_vars) { $ENV{$_} = $testenv_vars->{$_}; } - if ($opt_socket_wrapper_pcap) { $ENV{SOCKET_WRAPPER_PCAP_FILE} = $opt_socket_wrapper_pcap; # Socket wrapper pcap implies socket wrapper @@ -416,15 +400,16 @@ if ($opt_socket_wrapper) print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n"; } -# Start slapd before smbd -if ($ldap) { - Samba4::slapd_start($bindir, $ENV{SLAPD_CONF}, $ENV{LDAP_URI}) or die("couldn't start slapd"); +my $target; - print "LDAP PROVISIONING..."; - Samba4::provision_ldap($bindir, $setupdir); - - # LDAP is slow - $torture_maxtime *= 2; +if ($opt_target eq "samba4") { + $target = new Samba4("$srcdir/bin", $ldap, "$srcdir/setup"); +} elsif ($opt_target eq "samba3") { + $target = new Samba3("$srcdir/bin", "$srcdir/setup"); +} elsif ($opt_target eq "win") { + die("Windows tests will not run with socket wrapper enabled.") + if ($opt_socket_wrapper); + $target = new Windows(); } if (defined($opt_expected_failures)) { @@ -445,18 +430,14 @@ if (defined($opt_skip)) { close(SKIP); } -my $test_fifo = "$prefix/smbd_test.fifo"; +my $testenv_vars; +$testenv_vars = $target->provision("dc", "$prefix/dc"); -$ENV{SMBD_TEST_FIFO} = $test_fifo; -$ENV{SMBD_TEST_LOG} = "$prefix/smbd_test.log"; +foreach (keys %$testenv_vars) { $ENV{$_} = $testenv_vars->{$_}; } SocketWrapper::set_default_iface(1); -my $max_time = 5400; -if (defined($ENV{SMBD_MAX_TIME})) { - $max_time = $ENV{SMBD_MAX_TIME}; -} -Samba4::smbd_check_or_start($bindir, $test_fifo, $ENV{SMBD_TEST_LOG}, - $socket_wrapper_dir, $max_time, $ENV{CONFFILE}); +$target->check_or_start($testenv_vars, $socket_wrapper_dir, + ($ENV{SMBD_MAX_TIME} or 5400)); SocketWrapper::set_default_iface(6); @@ -468,7 +449,7 @@ my $interfaces = join(',', ("127.0.0.6/8", "127.0.0.11/8")); push (@torture_options, "--option=interfaces=$interfaces"); -push (@torture_options, $ENV{CONFIGURATION}); +push (@torture_options, $testenv_vars->{CONFIGURATION}); # ensure any one smbtorture call doesn't run too long push (@torture_options, "--maximum-runtime=$torture_maxtime"); push (@torture_options, "--target=$opt_target"); @@ -479,34 +460,30 @@ push (@torture_options, "--option=torture:quick=yes") if ($opt_quick); $ENV{TORTURE_OPTIONS} = join(' ', @torture_options); print "OPTIONS $ENV{TORTURE_OPTIONS}\n"; -open(DATA, ">$test_fifo"); - my @todo = (); -if ($opt_target eq "win") { - system("$testsdir/test_win.sh"); -} else { - if ($opt_quick) { - open(IN, "$testsdir/tests_quick.sh|"); +if ($opt_quick) { + open(IN, "$testsdir/tests_quick.sh|"); +} else { + open(IN, "$testsdir/tests_all.sh|"); +} +while () { + if ($_ eq "-- TEST --\n") { + my $name = ; + $name =~ s/\n//g; + my $env = ; + $env =~ s/\n//g; + my $cmdline = ; + $cmdline =~ s/\n//g; + push (@todo, [$name, $env, $cmdline]) + if (not defined($tests) or $name =~ /$tests/); } else { - open(IN, "$testsdir/tests_all.sh|"); - } - while () { - if ($_ eq "-- TEST --\n") { - my $name = ; - $name =~ s/\n//g; - my $cmdline = ; - $cmdline =~ s/\n//g; - push (@todo, [$name, $cmdline]) - if (not defined($tests) or $name =~ /$tests/); - } else { - print; - } + print; } - close(IN) or die("Error creating recipe"); } +close(IN) or die("Error creating recipe"); -Samba4::wait_for_start(); +$target->wait_for_start(); # start off with 0 failures $ENV{failed} = 0; @@ -515,10 +492,11 @@ my $suitestotal = $#todo + 1; my $i = 0; $| = 1; +# The Kerberos tests fail if this variable is set. delete $ENV{DOMAIN}; if ($opt_testenv) { - my $term = $ENV{TERM} or "xterm"; + my $term = ($ENV{TERM} or "xterm"); system("$term -e 'echo -e \"Welcome to the Samba4 Test environment This matches the client environment used in make test smbd is pid `cat \$PIDDIR/smbd.pid` @@ -532,9 +510,10 @@ NETBIOSNAME=\$NETBIOSNAME\" && bash'"); } else { foreach (@todo) { $i++; - my $cmd = $$_[1]; + my $cmd = $$_[2]; $cmd =~ s/([\(\)])/\\$1/g; my $name = $$_[0]; + my $envname = $$_[1]; if (skip($name)) { print "SKIPPED: $name\n"; @@ -542,29 +521,23 @@ NETBIOSNAME=\$NETBIOSNAME\" && bash'"); next; } + $target->setup_env($envname); + if ($from_build_farm) { run_test_buildfarm($name, $cmd, $i, $suitestotal); } else { run_test_plain($name, $cmd, $i, $suitestotal); } + + if (defined($opt_analyse_cmd)) { + system("$opt_analyse_cmd \"$name\""); + } } } print "\n"; -close(DATA); - -sleep(2); - -my $failed = $? >> 8; - -if (-f "$ENV{PIDDIR}/smbd.pid" ) { - open(IN, "<$ENV{PIDDIR}/smbd.pid") or die("unable to open smbd pid file"); - kill 9, ; - close(IN); -} - -Samba4::slapd_stop() if ($ldap); +my $failed = $target->stop(); my $end = time(); my $duration = ($end-$start); @@ -573,7 +546,6 @@ if ($numfailed == 0) { my $ok = $statistics->{TESTS_EXPECTED_OK} + $statistics->{TESTS_EXPECTED_FAIL}; print "ALL OK ($ok tests in $statistics->{SUITES_OK} testsuites)\n"; } else { - unless ($from_build_farm) { if (not $opt_immediate and not $opt_verbose) { foreach (@$suitesfailed) { diff --git a/source4/script/tests/test_binding_string.sh b/source4/script/tests/test_binding_string.sh index ef1e91ed05..52bbf66b1f 100755 --- a/source4/script/tests/test_binding_string.sh +++ b/source4/script/tests/test_binding_string.sh @@ -28,7 +28,7 @@ for I in "ncacn_np:$server" \ "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_np:$server" \ "308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:$server" do - testit "$I" bin/smbtorture $TORTURE_OPTIONS "$I" -U"$username"%"$password" -W $domain --option=torture:quick=yes RPC-ECHO "$*" + testit "$I" rpc bin/smbtorture $TORTURE_OPTIONS "$I" -U"$username"%"$password" -W $domain --option=torture:quick=yes RPC-ECHO "$*" done testok $0 $failed diff --git a/source4/script/tests/test_blackbox.sh b/source4/script/tests/test_blackbox.sh index 484310605e..86b56c2d1a 100755 --- a/source4/script/tests/test_blackbox.sh +++ b/source4/script/tests/test_blackbox.sh @@ -20,7 +20,7 @@ ADDARGS="$@" incdir=`dirname $0` . $incdir/test_functions.sh -testit "smbclient" $incdir/../../../testprogs/blackbox/test_smbclient.sh "$SERVER" "$USERNAME" "$PASSWORD" "$DOMAIN" "$PREFIX" "$ADDARGS" -testit "cifsdd" $incdir/../../../testprogs/blackbox/test_cifsdd.sh "$SERVER" "$USERNAME" "$PASSWORD" "$DOMAIN" "$ADDARGS" +testit "smbclient" smb $incdir/../../../testprogs/blackbox/test_smbclient.sh "$SERVER" "$USERNAME" "$PASSWORD" "$DOMAIN" "$PREFIX" "$ADDARGS" +testit "cifsdd" smb $incdir/../../../testprogs/blackbox/test_cifsdd.sh "$SERVER" "$USERNAME" "$PASSWORD" "$DOMAIN" "$ADDARGS" testok $0 $failed diff --git a/source4/script/tests/test_echo.sh b/source4/script/tests/test_echo.sh index be6f08d719..f9fc7f3cad 100755 --- a/source4/script/tests/test_echo.sh +++ b/source4/script/tests/test_echo.sh @@ -30,7 +30,7 @@ for transport in $transports; do for ntlmoptions in \ "--option=socket:testnonblock=True --option=torture:quick=yes"; do name="RPC-ECHO on $transport with $bindoptions and $ntlmoptions" - testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $ntlmoptions -U"$username"%"$password" -W $domain RPC-ECHO "$*" + testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $ntlmoptions -U"$username"%"$password" -W $domain RPC-ECHO "$*" done done done @@ -49,12 +49,12 @@ for transport in $transports; do "--option=clientntlmv2auth=yes --option=ntlmssp_client:128bit=no --option=ntlmssp_client:keyexchange=no --option=torture:quick=yes" \ ; do name="RPC-ECHO on $transport with $bindoptions and $ntlmoptions" - testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $ntlmoptions -U"$username"%"$password" -W $domain RPC-ECHO "$*" + testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $ntlmoptions -U"$username"%"$password" -W $domain RPC-ECHO "$*" done done done name="RPC-ECHO on ncacn_np over smb2" -testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_np:"$server[smb2]" -U"$username"%"$password" -W $domain RPC-ECHO "$*" +testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS ncacn_np:"$server[smb2]" -U"$username"%"$password" -W $domain RPC-ECHO "$*" testok $0 $failed diff --git a/source4/script/tests/test_ejs.sh b/source4/script/tests/test_ejs.sh index 1ccbb323c0..f89c3556b4 100755 --- a/source4/script/tests/test_ejs.sh +++ b/source4/script/tests/test_ejs.sh @@ -23,12 +23,12 @@ DATADIR=../testdata PATH=bin:$PATH export PATH -testit "base.js" $SCRIPTDIR/base.js $CONFIGURATION -testit "samr.js" "$SCRIPTDIR/samr.js" $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD -testit "echo.js" "$SCRIPTDIR/echo.js" $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD -testit "ejsnet.js" $SCRIPTDIR/ejsnet.js $CONFIGURATION -U$USERNAME%$PASSWORD $DOMAIN ejstestuser -testit "ldb.js" $SCRIPTDIR/ldb.js `pwd` $CONFIGURATION -testit "samba3sam.js" $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/ -testit "winreg" scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U$USERNAME%$PASSWORD +testit "base.js" rpc "$SCRIPTDIR/base.js" $CONFIGURATION +testit "samr.js" rpc "$SCRIPTDIR/samr.js" $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD +testit "echo.js" rpc "$SCRIPTDIR/echo.js" $CONFIGURATION ncalrpc: -U$USERNAME%$PASSWORD +testit "ejsnet.js" rpc "$SCRIPTDIR/ejsnet.js" $CONFIGURATION -U$USERNAME%$PASSWORD $DOMAIN ejstestuser +testit "ldb.js" none "$SCRIPTDIR/ldb.js" `pwd` $CONFIGURATION +testit "samba3sam.js" none $SCRIPTDIR/samba3sam.js $CONFIGURATION `pwd` $DATADIR/samba3/ +testit "winreg" rpc scripting/bin/winreg $CONFIGURATION ncalrpc: 'HKLM' -U$USERNAME%$PASSWORD testok $0 $failed diff --git a/source4/script/tests/test_functions.sh b/source4/script/tests/test_functions.sh index 7f363fd04a..801d6dc05b 100755 --- a/source4/script/tests/test_functions.sh +++ b/source4/script/tests/test_functions.sh @@ -1,95 +1,13 @@ #!/bin/sh -smbd_check_or_start() { - if [ -n "$SMBD_TEST_FIFO" ];then - if [ -p "$SMBD_TEST_FIFO" ];then - return 0; - fi - - if [ -n "$SOCKET_WRAPPER_DIR" ];then - if [ -d "$SOCKET_WRAPPER_DIR" ]; then - rm -f $SOCKET_WRAPPER_DIR/* - else - mkdir -p $SOCKET_WRAPPER_DIR - fi - fi - - rm -f $SMBD_TEST_FIFO - mkfifo $SMBD_TEST_FIFO - - rm -f $SMBD_TEST_LOG - - echo -n "STARTING SMBD..." - (( - if [ -z "$SMBD_MAXTIME" ]; then - SMBD_MAXTIME=5400 - fi - $SMBD_VALGRIND $SRCDIR/bin/smbd --maximum-runtime=$SMBD_MAXTIME -s $CONFFILE -M single -i --leak-report-full < $SMBD_TEST_FIFO > $SMBD_TEST_LOG 2>&1; - ret=$?; - rm -f $SMBD_TEST_FIFO; - if [ -n "$SOCKET_WRAPPER_DIR" -a -d "$SOCKET_WRAPPER_DIR" ]; then - rm -f $SOCKET_WRAPPER_DIR/* - fi - if [ x"$ret" = x"0" ];then - echo "smbd exits with status $ret"; - echo "smbd exits with status $ret" >>$SMBD_TEST_LOG; - elif [ x"$ret" = x"137" ];then - echo "smbd got SIGXCPU and exits with status $ret!" - echo "smbd got SIGXCPU and exits with status $ret!">>$SMBD_TEST_LOG; - else - echo "smbd failed with status $ret!" - echo "smbd failed with status $ret!">>$SMBD_TEST_LOG; - fi - exit $ret; - ) || exit $? &) 2>/dev/null || exit $? - echo "DONE" - fi - return 0; -} - -smbd_check_only() { - if [ -n "$SMBD_TEST_FIFO" ];then - if [ -p "$SMBD_TEST_FIFO" ];then - return 0; - fi - return 1; - fi - return 0; -} - -smbd_have_test_log() { - if [ -n "$SMBD_TEST_LOG" ];then - if [ -r "$SMBD_TEST_LOG" ];then - return 0; - fi - fi - return 1; -} - -slapd_start() { - OLDPATH=$PATH - PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH - export PATH -# running slapd in the background means it stays in the same process group, so it can be -# killed by timelimit - slapd -d0 -f $SLAPD_CONF -h $LDAP_URI_ESCAPE & - PATH=$OLDPATH - export PATH - return $?; -} - -fedora_ds_start() { -# running slapd in the background means it stays in the same process group, so it can be -# killed by timelimit - $FEDORA_DS_PREFIX/sbin/ns-slapd -D $FEDORA_DS_DIR -d0 & - return $?; -} testit() { name=$1 - shift 1 + env=$2 + shift 2 cmdline="$*" echo "-- TEST --" echo $name + echo $env echo $cmdline } @@ -120,22 +38,6 @@ EOF exit $failed } -# wait for a pid with given timeout -# returns 1 if it timed out, 0 if the process exited itself -waitforpid() { - pid=$1 - timeout=$2 # in seconds - _wcount=0 - while kill -0 $pid 2> /dev/null; do - sleep 1; - _wcount=`expr $_wcount + 1` - if [ $_wcount -eq $timeout ]; then - return "1"; - fi - done - return "0"; -} - if [ -z "$VALGRIND" ]; then MALLOC_CHECK_=2 export MALLOC_CHECK_ diff --git a/source4/script/tests/test_ldap.sh b/source4/script/tests/test_ldap.sh index 9b25ca2803..7399c6463c 100755 --- a/source4/script/tests/test_ldap.sh +++ b/source4/script/tests/test_ldap.sh @@ -17,18 +17,18 @@ incdir=`dirname $0` p=ldap for options in "" "--option=socket:testnonblock=true" "-U$USERNAME%$PASSWORD --option=socket:testnonblock=true" "-U$USERNAME%$PASSWORD"; do - testit "TESTING PROTOCOL $p with options $options" ../testprogs/blackbox/test_ldb.sh $p $SERVER $options + testit "TESTING PROTOCOL $p with options $options" ldap ../testprogs/blackbox/test_ldb.sh $p $SERVER $options done # see if we support ldaps if grep ENABLE_GNUTLS.1 include/config.h > /dev/null; then p=ldaps for options in "" "-U$USERNAME%$PASSWORD"; do - testit "TESTING PROTOCOL $p with options $options" ../testprogs/blackbox/test_ldb.sh $p $SERVER $options + testit "TESTING PROTOCOL $p with options $options" ldap ../testprogs/blackbox/test_ldb.sh $p $SERVER $options done fi for t in LDAP-CLDAP LDAP-BASIC LDAP-SCHEMA LDAP-UPTODATENESS do - testit "$t" bin/smbtorture $TORTURE_OPTIONS "-U$USERNAME%$PASSWORD" //$SERVER/_none_ $t + testit "$t" ldap bin/smbtorture $TORTURE_OPTIONS "-U$USERNAME%$PASSWORD" //$SERVER/_none_ $t done # only do the ldb tests when not in quick mode - they are quite slow, and ldb @@ -36,11 +36,11 @@ done test "$TORTURE_QUICK" = "yes" || { LDBDIR=lib/ldb export LDBDIR - testit "ldb" $LDBDIR/tests/test-tdb.sh + testit "ldb" ldap $LDBDIR/tests/test-tdb.sh } SCRIPTDIR=../testprogs/ejs -testit "ejs ldap" $SCRIPTDIR/ldap.js $CONFIGURATION $SERVER -U$USERNAME%$PASSWORD +testit "ejs ldap" ldap $SCRIPTDIR/ldap.js $CONFIGURATION $SERVER -U$USERNAME%$PASSWORD testok $0 $failed diff --git a/source4/script/tests/test_local.sh b/source4/script/tests/test_local.sh index be80d56aa2..e3ff3c80a6 100755 --- a/source4/script/tests/test_local.sh +++ b/source4/script/tests/test_local.sh @@ -24,9 +24,9 @@ export SMBD_TEST_FIFO failed=0 for t in $local_tests; do - testit "$t" $VALGRIND bin/smbtorture $TORTURE_OPTIONS ncalrpc: $t "$*" + testit "$t" none $VALGRIND bin/smbtorture $TORTURE_OPTIONS ncalrpc: $t "$*" done -testit "tdb stress" $VALGRIND bin/tdbtorture +testit "tdb stress" none $VALGRIND bin/tdbtorture testok $0 $failed diff --git a/source4/script/tests/test_nbt.sh b/source4/script/tests/test_nbt.sh index 90bd827c90..a04feea079 100755 --- a/source4/script/tests/test_nbt.sh +++ b/source4/script/tests/test_nbt.sh @@ -20,13 +20,13 @@ SCRIPTDIR=../testprogs/ejs PATH=bin:$PATH export PATH -testit "nmblookup -U $SERVER $SERVER" bin/nmblookup $TORTURE_OPTIONS -U $SERVER $SERVER -testit "nmblookup $SERVER" bin/nmblookup $TORTURE_OPTIONS $SERVER +testit "nmblookup -U $SERVER $SERVER" netbios bin/nmblookup $TORTURE_OPTIONS -U $SERVER $SERVER +testit "nmblookup $SERVER" netbios bin/nmblookup $TORTURE_OPTIONS $SERVER NBT_TESTS=`bin/smbtorture --list | grep ^NBT` for f in $NBT_TESTS; do - testit "$f" bin/smbtorture $TORTURE_OPTIONS //$SERVER/_none_ $f -U$USERNAME%$PASSWORD + testit "$f" netbios bin/smbtorture $TORTURE_OPTIONS //$SERVER/_none_ $f -U$USERNAME%$PASSWORD done testok $0 $failed diff --git a/source4/script/tests/test_net.sh b/source4/script/tests/test_net.sh index fad5d327f8..05b42130ab 100755 --- a/source4/script/tests/test_net.sh +++ b/source4/script/tests/test_net.sh @@ -32,7 +32,7 @@ for bindoptions in seal,padcheck $VALIDATE bigendian; do esac for t in $tests; do name="$t on $transport with $bindoptions" - testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" + testit "$name" rpc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" done done done diff --git a/source4/script/tests/test_pidl.sh b/source4/script/tests/test_pidl.sh index ade68a555a..2271b7b4d8 100755 --- a/source4/script/tests/test_pidl.sh +++ b/source4/script/tests/test_pidl.sh @@ -11,7 +11,7 @@ failed=0 if $PERL -e 'eval require Test::More;' > /dev/null 2>&1; then for f in pidl/tests/*.pl; do - testit "$f" $PERL $f + testit "$f" none $PERL $f done else echo "Skipping pidl tests - Test::More not installed" diff --git a/source4/script/tests/test_posix.sh b/source4/script/tests/test_posix.sh index 9099fe31a0..9fdfa98147 100755 --- a/source4/script/tests/test_posix.sh +++ b/source4/script/tests/test_posix.sh @@ -30,5 +30,5 @@ for t in $tests; do continue; fi start="" - testit "$t" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t + testit "$t" smb $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t done diff --git a/source4/script/tests/test_quick.sh b/source4/script/tests/test_quick.sh index 31bbc75534..14d7e0865b 100755 --- a/source4/script/tests/test_quick.sh +++ b/source4/script/tests/test_quick.sh @@ -32,7 +32,7 @@ for t in $tests; do fi start="" name="$t" - testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t + testit "$name" base $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t done testok $0 $failed diff --git a/source4/script/tests/test_rpc.sh b/source4/script/tests/test_rpc.sh index 05b006651d..21a238b7b3 100755 --- a/source4/script/tests/test_rpc.sh +++ b/source4/script/tests/test_rpc.sh @@ -35,7 +35,7 @@ for bindoptions in seal,padcheck $VALIDATE bigendian; do esac for t in $tests; do name="$t on $transport with $bindoptions" - testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" + testit "$name" rpc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" done done done @@ -49,7 +49,7 @@ for bindoptions in connect $VALIDATE ; do esac for t in $tests; do name="$t on $transport with $bindoptions" - testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" + testit "$name" rpc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" done done done diff --git a/source4/script/tests/test_rpc_quick.sh b/source4/script/tests/test_rpc_quick.sh index 3aa7630026..e01c6d1d10 100755 --- a/source4/script/tests/test_rpc_quick.sh +++ b/source4/script/tests/test_rpc_quick.sh @@ -32,7 +32,7 @@ for bindoptions in seal,padcheck $VALIDATE bigendian; do esac for t in $tests; do name="$t on $transport with $bindoptions" - testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" + testit "$name" rpc $VALGRIND bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -U"$username"%"$password" -W $domain $t "$*" done done done diff --git a/source4/script/tests/test_s3upgrade.sh b/source4/script/tests/test_s3upgrade.sh index 580fd48821..30b7ee06e4 100755 --- a/source4/script/tests/test_s3upgrade.sh +++ b/source4/script/tests/test_s3upgrade.sh @@ -18,5 +18,5 @@ rm -f $PREFIX/* . script/tests/test_functions.sh -testit "parse samba3" bin/smbscript ../testdata/samba3/verify $CONFIGURATION ../testdata/samba3 -#testit "upgrade" bin/smbscript setup/upgrade $CONFIGURATION --verify --targetdir=$PREFIX ../testdata/samba3 ../testdata/samba3/smb.conf +testit "parse samba3" none bin/smbscript ../testdata/samba3/verify $CONFIGURATION ../testdata/samba3 +#testit "upgrade" none bin/smbscript setup/upgrade $CONFIGURATION --verify --targetdir=$PREFIX ../testdata/samba3 ../testdata/samba3/smb.conf diff --git a/source4/script/tests/test_session_key.sh b/source4/script/tests/test_session_key.sh index 1c5758d660..ca568c3516 100755 --- a/source4/script/tests/test_session_key.sh +++ b/source4/script/tests/test_session_key.sh @@ -37,18 +37,18 @@ for bindoptions in bigendian seal; do "-k no --option=gensec:spnego=no --option=clientntlmv2auth=yes" \ "-k no --option=usespnego=no"; do name="RPC-SECRETS on $transport with $bindoptions with NTLM2:$ntlm2 KEYEX:$keyexchange LM_KEY:$lm_key $ntlmoptions" - testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" --option=ntlmssp_client:keyexchange=$keyexchange --option=ntlmssp_client:ntlm2=$ntlm2 --option=ntlmssp_client:lm_key=$lm_key $ntlmoptions -U"$username"%"$password" -W $domain --option=gensec:target_hostname=$netbios_name RPC-SECRETS "$*" + testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" --option=ntlmssp_client:keyexchange=$keyexchange --option=ntlmssp_client:ntlm2=$ntlm2 --option=ntlmssp_client:lm_key=$lm_key $ntlmoptions -U"$username"%"$password" -W $domain --option=gensec:target_hostname=$netbios_name RPC-SECRETS "$*" done done done done name="RPC-SECRETS on $transport with $bindoptions with Kerberos" - testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -k yes -U"$username"%"$password" -W $domain "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" + testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -k yes -U"$username"%"$password" -W $domain "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" name="RPC-SECRETS on $transport with $bindoptions with Kerberos - use target principal" - testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -k yes -U"$username"%"$password" -W $domain "--option=clientusespnegoprincipal=yes" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" + testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" -k yes -U"$username"%"$password" -W $domain "--option=clientusespnegoprincipal=yes" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" done name="RPC-SECRETS on $transport with Kerberos - use Samba3 style login" - testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server" -k yes -U"$username"%"$password" -W $domain "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" + testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS $transport:"$server" -k yes -U"$username"%"$password" -W $domain "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" name="RPC-SECRETS on $transport with Kerberos - use Samba3 style login, use target principal" - testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server" -k yes -U"$username"%"$password" -W $domain "--option=clientusespnegoprincipal=yes" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" + testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS $transport:"$server" -k yes -U"$username"%"$password" -W $domain "--option=clientusespnegoprincipal=yes" "--option=gensec:fake_gssapi_krb5=yes" "--option=gensec:gssapi_krb5=no" "--option=gensec:target_hostname=$netbios_name" RPC-SECRETS "$*" testok $0 $failed diff --git a/source4/script/tests/test_simple.sh b/source4/script/tests/test_simple.sh index 7193cc8329..cec4f7f4c9 100755 --- a/source4/script/tests/test_simple.sh +++ b/source4/script/tests/test_simple.sh @@ -27,7 +27,7 @@ for t in $tests; do fi start="" name="$t" - testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t + testit "$name" smb $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t done testok $0 $failed diff --git a/source4/script/tests/test_w2k3.sh b/source4/script/tests/test_w2k3.sh index ccdf55a686..122e3ea7a7 100755 --- a/source4/script/tests/test_w2k3.sh +++ b/source4/script/tests/test_w2k3.sh @@ -29,7 +29,7 @@ OPTIONS="-U$username%$password -W $domain --option realm=$realm" failed=0 name="RPC-SPOOLSS on ncacn_np" -testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_np:"$server" $OPTIONS RPC-SPOOLSS "$*" +testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS ncacn_np:"$server" $OPTIONS RPC-SPOOLSS "$*" for bindoptions in padcheck connect sign seal ntlm,sign ntlm,seal $VALIDATE bigendian; do for transport in ncacn_ip_tcp ncacn_np; do @@ -39,14 +39,14 @@ for bindoptions in padcheck connect sign seal ntlm,sign ntlm,seal $VALIDATE bige esac for t in $tests; do name="$t on $transport with $bindoptions" - testit "$name" bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $OPTIONS $t "$*" + testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS $transport:"$server[$bindoptions]" $OPTIONS $t "$*" done done done name="RPC-DRSUAPI on ncacn_ip_tcp with seal" -testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_ip_tcp:"$server[seal]" $OPTIONS RPC-DRSUAPI "$*" +testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS ncacn_ip_tcp:"$server[seal]" $OPTIONS RPC-DRSUAPI "$*" name="RPC-DRSUAPI on ncacn_ip_tcp with seal,bigendian" -testit "$name" bin/smbtorture $TORTURE_OPTIONS ncacn_ip_tcp:"$server[seal,bigendian]" $OPTIONS RPC-DRSUAPI "$*" +testit "$name" rpc bin/smbtorture $TORTURE_OPTIONS ncacn_ip_tcp:"$server[seal,bigendian]" $OPTIONS RPC-DRSUAPI "$*" testok $0 $failed diff --git a/source4/script/tests/test_w2k3_file.sh b/source4/script/tests/test_w2k3_file.sh index 55de1c37c4..e39d9b8632 100755 --- a/source4/script/tests/test_w2k3_file.sh +++ b/source4/script/tests/test_w2k3_file.sh @@ -46,7 +46,7 @@ for t in $tests; do fi start="" name="$t" - testit "$name" $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t + testit "$name" smb $VALGRIND bin/smbtorture $TORTURE_OPTIONS $ADDARGS $unc -U"$username"%"$password" $t done testok $0 $failed diff --git a/source4/script/tests/test_win.sh b/source4/script/tests/test_win.sh index 577282b3ae..56d96c041c 100755 --- a/source4/script/tests/test_win.sh +++ b/source4/script/tests/test_win.sh @@ -17,26 +17,26 @@ if [ -z $SMBTORTURE_REMOTE_HOST ]; then fi name="BASE against Windows 2003" -testit "$name" $WINTEST_DIR/wintest_base.sh $SMBTORTURE_REMOTE_HOST \ +testit "$name" smb $WINTEST_DIR/wintest_base.sh $SMBTORTURE_REMOTE_HOST \ $SMBTORTURE_USERNAME $SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP name="RAW against Windows 2003" -testit "$name" $WINTEST_DIR/wintest_raw.sh $SMBTORTURE_REMOTE_HOST \ +testit "$name" smb $WINTEST_DIR/wintest_raw.sh $SMBTORTURE_REMOTE_HOST \ $SMBTORTURE_USERNAME $SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP name="RPC against Windows 2003" -testit "$name" $WINTEST_DIR/wintest_rpc.sh $SMBTORTURE_REMOTE_HOST \ +testit "$name" smb $WINTEST_DIR/wintest_rpc.sh $SMBTORTURE_REMOTE_HOST \ $SMBTORTURE_USERNAME $SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP name="NET against Windows 2003" -testit "$name" $WINTEST_DIR/wintest_net.sh $SMBTORTURE_REMOTE_HOST \ +testit "$name" smb $WINTEST_DIR/wintest_net.sh $SMBTORTURE_REMOTE_HOST \ $SMBTORTURE_USERNAME $SMBTORTURE_PASSWORD $SMBTORTURE_WORKGROUP name="Windows 2003 against smbd" -testit "$name" $WINTEST_DIR/wintest_client.sh $SMBTORTURE_REMOTE_HOST +testit "$name" smb $WINTEST_DIR/wintest_client.sh $SMBTORTURE_REMOTE_HOST dc_tests="RPC-DRSUAPI RPC-SPOOLSS ncacn_np ncacn_ip_tcp" for name in $dc_tests; do - testit "$name against Windows 2003 DC" $WINTEST_DIR/wintest_2k3_dc.sh \ + testit "$name against Windows 2003 DC" rpc $WINTEST_DIR/wintest_2k3_dc.sh \ "$name" done diff --git a/source4/script/tests/tests_win2k3_dc.sh b/source4/script/tests/tests_win2k3_dc.sh index 281361475f..5e22c37e97 100755 --- a/source4/script/tests/tests_win2k3_dc.sh +++ b/source4/script/tests/tests_win2k3_dc.sh @@ -18,5 +18,5 @@ export SRCDIR=$SRCDIR tests="RPC-DRSUAPI RPC-SPOOLSS ncacn_np ncacn_ip_tcp" for name in $tests; do - testit $name $SRCDIR/script/tests/win/wintest_2k3_dc.sh $name + testit $name rpc $SRCDIR/script/tests/win/wintest_2k3_dc.sh $name done diff --git a/source4/torture/config.mk b/source4/torture/config.mk index 9ba48c0c8c..640e79cd95 100644 --- a/source4/torture/config.mk +++ b/source4/torture/config.mk @@ -365,8 +365,10 @@ MANPAGE = man/locktest.1 GCOV_FLAGS = -ftest-coverage -fprofile-arcs GCOV_LIBS = -lgcov +COV_TARGET = test + test_cov: - @$(MAKE) test \ + @$(MAKE) $(COV_TARGET) \ HOSTCC_CFLAGS="$(HOSTCC_CFLAGS) $(GCOV_FLAGS)" \ CFLAGS="$(CFLAGS) $(GCOV_FLAGS)" \ LDFLAGS="$(LDFLAGS) $(GCOV_FLAGS) $(GCOV_LIBS)" \ @@ -377,8 +379,19 @@ gcov: test_cov do $(GCOV) -p -o $$I $$I/*.c; \ done +lcov-split: + rm -f samba.info + @$(MAKE) $(COV_TARGET) \ + HOSTCC_CFLAGS="$(HOSTCC_CFLAGS) $(GCOV_FLAGS)" \ + CFLAGS="$(CFLAGS) $(GCOV_FLAGS)" \ + LDFLAGS="$(LDFLAGS) $(GCOV_FLAGS) $(GCOV_LIBS)" \ + SHLD_FLAGS="$(SHLD_FLAGS) $(GCOV_FLAGS) $(GCOV_LIBS)" \ + TEST_OPTIONS="--analyse-cmd=\"lcov --base-directory `pwd` --directory . --capture --output-file samba.info -t\"" + -rm heimdal/lib/*/{lex,parse}.{gcda,gcno} + genhtml -o coverage samba.info + lcov: test_cov - rm heimdal/lib/*/{lex,parse}.{gcda,gcno} + -rm heimdal/lib/*/{lex,parse}.{gcda,gcno} lcov --base-directory `pwd` --directory . --capture --output-file samba.info genhtml -o coverage samba.info diff --git a/source4/torture/local/torture.c b/source4/torture/local/torture.c index 4a5bc99d35..653049f351 100644 --- a/source4/torture/local/torture.c +++ b/source4/torture/local/torture.c @@ -47,7 +47,7 @@ static bool test_setup_server(struct torture_context *tctx) torture_assert_ntstatus_ok(tctx, torture_setup_server(mem_ctx, "setupserver-success", - "./script/tests/mktestsetup.sh", + "./script/tests/mktestdc.sh", "./bin/smbd", &pid), "starting smbd failed"); -- cgit