TODO... selftest: add Samba34 target
authorStefan Metzmacher <metze@samba.org>
Wed, 4 Feb 2009 10:26:04 +0000 (11:26 +0100)
committerStefan Metzmacher <metze@samba.org>
Sat, 21 Mar 2009 10:30:04 +0000 (11:30 +0100)
selftest/knownfail34 [new file with mode: 0644]
selftest/selftest.pl
selftest/skip34 [new file with mode: 0644]
selftest/target/Samba34.pm [new file with mode: 0644]
selftest/tests34.sh [new file with mode: 0755]
source3/samba4.mk

diff --git a/selftest/knownfail34 b/selftest/knownfail34
new file mode 100644 (file)
index 0000000..e69de29
index ef4c385d33fd0a53713af5af48fb7073830367e7..82be64124ad534f29a6c9c5ff5b06cef29f85772 100755 (executable)
@@ -465,6 +465,13 @@ if ($opt_target eq "samba4") {
        $testenv_default = "member";
        require target::Samba3;
        $target = new Samba3($bindir);
        $testenv_default = "member";
        require target::Samba3;
        $target = new Samba3($bindir);
+} elsif ($opt_target eq "samba34") {
+       if ($opt_socket_wrapper and `$bindir/smbd -b | grep SOCKET_WRAPPER` eq "") {
+               die("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'.  Exiting....");
+       }
+       $testenv_default = "franky_dc";
+       require target::Samba34;
+       $target = new Samba34($bindir);
 } elsif ($opt_target eq "win") {
        die("Windows tests will not run with socket wrapper enabled.") 
                if ($opt_socket_wrapper);
 } elsif ($opt_target eq "win") {
        die("Windows tests will not run with socket wrapper enabled.") 
                if ($opt_socket_wrapper);
diff --git a/selftest/skip34 b/selftest/skip34
new file mode 100644 (file)
index 0000000..a5e6d95
--- /dev/null
@@ -0,0 +1 @@
+samba34.base.bench.holdcon
diff --git a/selftest/target/Samba34.pm b/selftest/target/Samba34.pm
new file mode 100644 (file)
index 0000000..f2a0e05
--- /dev/null
@@ -0,0 +1,226 @@
+#!/usr/bin/perl
+# Copyright (C) 2009 Stefan Metzmacher <metze@samba.org>
+# Published under the GNU GPL, v3 or later.
+
+package Samba34;
+
+use strict;
+use Cwd qw(abs_path);
+use FindBin qw($RealBin);
+use POSIX;
+
+use target::Samba3;
+use target::Samba4;
+
+sub new($$) {
+       my ($classname, $bindir) = @_;
+       my $self = {
+               bindir => $bindir,
+               target3 => new Samba3($bindir),
+               target4 => new Samba4($bindir, undef, "../source4/setup", "4")
+       };
+       bless $self;
+       return $self;
+}
+
+sub teardown_env($$)
+{
+       my ($self, $envvars) = @_;
+
+       return 0;
+}
+
+sub getlog_env($$)
+{
+       my ($self, $envvars) = @_;
+
+       return "";
+}
+
+sub check_env($$)
+{
+       my ($self, $envvars) = @_;
+
+       return 1;
+}
+
+sub setup_franky_dc($$)
+{
+       my ($self, $path) = @_;
+       my $ret = undef;
+       my $target3 = $self->{target3};
+       my $target4 = $self->{target4};
+
+       my $smbd_path = $target3->binpath("smbd");
+       my $net3 = $target3->binpath("net");
+       my $net4 = $target4->bindir_path("net");
+       my $bindir_abs = abs_path($self->{bindir});
+
+       my $domsid = "S-1-5-21-123260556-2972382748-1729953856";
+
+       my $ctx4 = $target4->provision_raw_prepare($path, "domain controller",
+                                                  "FRANKYDC4",
+                                                  "FRANKYDC",
+                                                  "4",
+                                                  "frankydc4pass",
+                                                  "127.0.0.4");
+
+       push (@{$ctx4->{provision_options}}, "--domain-sid=$domsid");
+
+       $ctx4->{tmpdir} = "$ctx4->{prefix_abs}/tmp";
+       push(@{$ctx4->{directories}}, "$ctx4->{tmpdir}");
+
+       $ctx4->{sysvoldir} = "$ctx4->{prefix_abs}/sysvol";
+       push(@{$ctx4->{directories}}, "$ctx4->{sysvoldir}");
+
+       $ctx4->{netlogondir} = "$ctx4->{sysvoldir}/$ctx4->{dnsname}/scripts";
+       push(@{$ctx4->{directories}}, "$ctx4->{sysvoldir}/$ctx4->{dnsname}");
+       push(@{$ctx4->{directories}}, "$ctx4->{netlogondir}");
+
+       $ctx4->{smb_conf_extra_options} = "
+
+       # Samba3 options
+       security = user
+       auth methods = netlogond guest
+       auth_netlogond:socket = $ctx4->{ncalrpcdir}/DEFAULT
+       auth_netlogond:machinepwscript = $net4 -d -1 machinepw $ctx4->{netbiosname}\$
+       domain master = yes
+       domain logons = yes
+       winbindd:socket dir = $ctx4->{winbindd_socket_dir}
+       log file = $ctx4->{prefix_abs}/smbd3.log
+       kernel oplocks = no
+       kernel change notify = no
+       syslog = no
+       printing = bsd
+       printcap name = /dev/null
+       idmap uid = 100000-200000
+       idmap gid = 100000-200000
+
+       # Samba4 options
+       server services = rpc ldap cldap kdc ntp_signd samba3_smb
+       dcerpc endpoint servers = epmapper srvsvc wkssvc samr netlogon lsarpc drsuapi winreg dssetup
+       samba3:smbd = $smbd_path
+
+       # Share defaults
+       smbd:sharedelay = 100000
+       smbd:writetimeupdatedelay = 500000
+       map hidden = yes
+       map system = yes
+       create mask = 755
+       vfs objects = $bindir_abs/xattr_tdb.so $bindir_abs/streams_depot.so
+
+[tmp]
+       path = $ctx4->{tmpdir}
+       read only = no
+
+[sysvol]
+       path = $ctx4->{sysvoldir}
+       read only = no
+
+[netlogon]
+       path = $ctx4->{netlogondir}
+       read only = no
+
+";
+
+       my $env4 = $target4->provision_raw_step1($ctx4);
+
+       $env4 = $target4->provision_raw_step2($ctx4, $env4);
+
+       $ret->{s4} = $env4;
+       $ret->{s3}->{NMBD_TEST_LOG}             = "$ctx4->{prefix_abs}/nmbd_test.log";
+       $ret->{s3}->{NMBD_TEST_LOG_POS}         = 0;
+       $ret->{s3}->{WINBINDD_TEST_LOG}         = "$ctx4->{prefix_abs}/winbindd_test.log";
+       $ret->{s3}->{WINBINDD_TEST_LOG_POS}     = 0;
+       $ret->{s3}->{SMBD_TEST_LOG}             = "$ctx4->{prefix_abs}/smbd_test.log";
+       $ret->{s3}->{SMBD_TEST_LOG_POS}         = 0;
+       $ret->{s3}->{SERVERCONFFILE}            = $env4->{SERVERCONFFILE};
+       $ret->{s3}->{CONFIGURATION}             = "-s $env4->{SERVERCONFFILE}";
+       $ret->{s3}->{PIDDIR}                    = $env4->{PIDDIR};
+       $ret->{s3}->{WINBINDD_SOCKET_DIR}       = $env4->{WINBINDD_SOCKET_DIR};
+       $ret->{s3}->{WINBINDD_PRIV_PIPE_DIR}    = $env4->{WINBINDD_PRIV_PIPE_DIR};
+       $ret->{s3}->{SOCKET_WRAPPER_DEFAULT_IFACE}=$env4->{SOCKET_WRAPPER_DEFAULT_IFACE};
+       $ret->{s3}->{NSS_WRAPPER_PASSWD}        = $env4->{NSS_WRAPPER_PASSWD};
+       $ret->{s3}->{NSS_WRAPPER_GROUP}         = $env4->{NSS_WRAPPER_GROUP};
+       $ret->{s3}->{SERVER}                    = $env4->{SERVER};
+       $ret->{s3}->{SERVER_IP}                 = $env4->{SERVER_IP};
+       $ret->{s3}->{NETBIOSNAME}               = $env4->{NETBIOSNAME};
+       $ret->{s3}->{DOMAIN}                    = $env4->{DOMAIN};
+       $ret->{s3}->{USERNAME}                  = $env4->{USERNAME};
+       $ret->{s3}->{PASSWORD}                  = $env4->{PASSWORD};
+
+       $ret->{SERVERCONFFILE}                  = $env4->{SERVERCONFFILE};
+       $ret->{CONFIGURATION}                   = "-s $env4->{SERVERCONFFILE}";
+       $ret->{PIDDIR}                          = $env4->{PIDDIR};
+       $ret->{WINBINDD_SOCKET_DIR}             = $env4->{WINBINDD_SOCKET_DIR};
+       $ret->{WINBINDD_PRIV_PIPE_DIR}          = $env4->{WINBINDD_PRIV_PIPE_DIR};
+       $ret->{SOCKET_WRAPPER_DEFAULT_IFACE}    = $env4->{SOCKET_WRAPPER_DEFAULT_IFACE};
+       $ret->{NSS_WRAPPER_PASSWD}              = $env4->{NSS_WRAPPER_PASSWD};
+       $ret->{NSS_WRAPPER_GROUP}               = $env4->{NSS_WRAPPER_GROUP};
+       $ret->{KRB5_CONFIG}                     = $env4->{KRB5_CONFIG};
+       $ret->{NCALRPCDIR}                      = $env4->{NCALRPCDIR};
+       $ret->{LOCKDIR}                         = $env4->{LOCKDIR};
+       $ret->{SERVER}                          = $env4->{SERVER};
+       $ret->{SERVER_IP}                       = $env4->{SERVER_IP};
+       $ret->{NETBIOSNAME}                     = $env4->{NETBIOSNAME};
+       $ret->{DOMAIN}                          = $env4->{DOMAIN};
+       $ret->{REALM}                           = $env4->{REALM};
+
+       $ret->{USERNAME}                        = "metze";
+       $ret->{PASSWORD}                        = "geheim";
+
+       my @newuser_options = ();
+       push (@newuser_options, "NSS_WRAPPER_PASSWD=\"$ret->{NSS_WRAPPER_PASSWD}\"");
+       push (@newuser_options, "NSS_WRAPPER_GROUP=\"$ret->{NSS_WRAPPER_GROUP}\"");
+       if (defined($ENV{PYTHON})) {
+               push (@newuser_options, $ENV{PYTHON});
+       }
+       push (@newuser_options, "../source4/setup/newuser");
+       push (@newuser_options, split(' ', $ret->{CONFIGURATION}));
+       push (@newuser_options, "--quiet");
+       push (@newuser_options, $ret->{USERNAME});
+       push (@newuser_options, $ret->{PASSWORD});
+
+       my $newuser_cmd = join(" ", @newuser_options);
+       (system($newuser_cmd) == 0) or die("Unable to add new user: \n$newuser_cmd\n");
+
+       my $setlocalsid = "$net3 $ret->{s3}->{CONFIGURATION} setlocalsid $domsid";
+       (system("$setlocalsid") == 0) or die("Failed to run[$?]: $setlocalsid");
+       my $setdomainsid = "$net3 $ret->{s3}->{CONFIGURATION} setdomainsid $domsid";
+       (system("$setdomainsid") == 0) or die("Failed to run[$?]: $setdomainsid");
+
+       my $maxruntime = ($ENV{SMBD_MAXTIME} or 7500);
+       $target3->check_or_start($ret->{s3},
+                                $maxruntime,   # nmbd
+                                $maxruntime,   # don't start winbindd
+                                "skip");       # don't start smbd
+       my $tmp = $ENV{SMB_CONF_PATH};
+       $ENV{SMB_CONF_PATH} = $ret->{SERVERCONFFILE};
+       $target4->check_or_start($ret->{s4}, $maxruntime);
+       $ENV{SMB_CONF_PATH} = $tmp;
+
+       $target3->wait_for_start($ret->{s3});
+       $target4->wait_for_start($ret->{s4});
+
+       $self->{vars}->{franky_dc} = $ret;
+
+       return $ret;
+}
+
+sub setup_env($$$)
+{
+       my ($self, $envname, $path) = @_;
+
+       if ($envname eq "franky_dc") {
+               return $self->setup_franky_dc("$path/franky_dc");
+       }
+
+       die("Samba34 can't provide environment '$envname'");
+}
+
+sub stop($)
+{
+       my ($self) = @_;
+}
+
+1;
diff --git a/selftest/tests34.sh b/selftest/tests34.sh
new file mode 100755 (executable)
index 0000000..0d5a34e
--- /dev/null
@@ -0,0 +1,108 @@
+#!/bin/sh
+# This script generates a list of testsuites that should be run as part of
+# the Samba 34 test suite.
+
+# The output of this script is parsed by selftest.pl, which then decides
+# which of the tests to actually run. It will, for example, skip all tests
+# listed in selftest/skip34 or only run a subset during "make quicktest".
+
+# The idea is that this script outputs all of the tests of Samba 34, not
+# just those that are known to pass, and list those that should be skipped
+# or are known to fail in selftest/skip34 or selftest/knownfail34. This makes it
+# very easy to see what functionality is still missing in Samba 34 and makes
+# it possible to run the testsuite against other servers, such as
+# Windows that have a different set of features.
+
+# The syntax for a testsuite is "-- TEST --" on a single line, followed
+# by the name of the test, the environment it needs and the command to run, all
+# three separated by newlines. All other lines in the output are considered
+# comments.
+
+if [ ! -n "$PERL" ]
+then
+       PERL=perl
+fi
+
+plantest() {
+       name=$1
+       env=$2
+       shift 2
+       cmdline="$*"
+       echo "-- TEST --"
+       if [ "$env" = "none" ]; then
+               echo "samba34.$name"
+       else
+               echo "samba34.$name ($env)"
+       fi
+       echo $env
+       echo $cmdline
+}
+
+normalize_testname() {
+       name=$1
+       shift 1
+       echo $name | tr "A-Z-" "a-z."
+}
+
+plansmbtorture4test() {
+       name=$1
+       env=$2
+       shift 2
+       other_args="$*"
+       modname=`normalize_testname $name`
+       cmdline="$VALGRIND $smb4torture $other_args $name"
+       plantest "$modname" "$env" $cmdline
+}
+
+samba4srcdir="`dirname $0`/.."
+samba4bindir="$BUILDDIR/bin"
+smb4torture="$samba4bindir/smbtorture4"
+$smb4torture -V
+
+TORTURE_OPTIONS=""
+TORTURE_OPTIONS="$TORTURE_OPTIONS $CONFIGURATION"
+TORTURE_OPTIONS="$TORTURE_OPTIONS --maximum-runtime=$SELFTEST_MAXTIME"
+TORTURE_OPTIONS="$TORTURE_OPTIONS --target=samba3"
+TORTURE_OPTIONS="$TORTURE_OPTIONS --basedir=$SELFTEST_PREFIX"
+if [ -n "$SELFTEST_VERBOSE" ]; then
+       TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:progress=no"
+fi
+TORTURE_OPTIONS="$TORTURE_OPTIONS --format=subunit"
+if [ -n "$SELFTEST_QUICK" ]; then
+       TORTURE_OPTIONS="$TORTURE_OPTIONS --option=torture:quick=yes"
+fi
+smb4torture="$smb4torture $TORTURE_OPTIONS"
+
+echo "OPTIONS $TORTURE_OPTIONS"
+
+plantest `normalize_testname Hello World` none echo "Hello World"
+
+plantest `normalize_testname Hello World` franky_dc echo "Hello World"
+
+for t in LDAP-CLDAP LDAP-BASIC LDAP-SCHEMA
+# LDAP-UPTODATEVECTOR
+do
+       plansmbtorture4test "$t" franky_dc "-U\$USERNAME%\$PASSWORD" //\$SERVER_IP/_none_
+done
+
+# Tests against the NTVFS POSIX backend
+NTVFSARGS=""
+NTVFSARGS="${NTVFSARGS} --option=torture:sharedelay=100000"
+NTVFSARGS="${NTVFSARGS} --option=torture:oplocktimeout=3"
+NTVFSARGS="${NTVFSARGS} --option=torture:writetimeupdatedelay=500000"
+
+#The QFILEINFO-IPC test needs to be on ipc$
+raw=`$smb4torture --list | grep "^RAW-" | grep -v "RAW-QFILEINFO-IPC"| xargs`
+base=`$smb4torture --list | grep "^BASE-" | xargs`
+
+for t in $base $raw; do
+    plansmbtorture4test "$t" franky_dc $ADDARGS //\$SERVER_IP/tmp -U"\$USERNAME"%"\$PASSWORD" $NTVFSARGS
+done
+
+plansmbtorture4test "RAW-QFILEINFO-IPC" franky_dc $ADDARGS //\$SERVER_IP/ipc$ -U"\$USERNAME"%"\$PASSWORD"
+
+rap=`$smb4torture --list | grep "^RAP-" | xargs`
+for t in $rap; do
+    plansmbtorture4test "$t" franky_dc $ADDARGS //\$SERVER_IP/IPC\\\$ -U"\$USERNAME"%"\$PASSWORD"
+done
+
index 3f661bdd14e83e7ef96fe60f279b9c6a0055d9c6..cf0ee732f3c40398a271569b95cc427417f0a437 100644 (file)
@@ -253,4 +253,19 @@ gdbtest4-env:: everything
        SAMBA_VALGRIND="xterm -n server -e $(selftestdir)/gdb_run $(LD_LIBPATH_OVERRIDE)" \
        $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --socket-wrapper --testenv
 
        SAMBA_VALGRIND="xterm -n server -e $(selftestdir)/gdb_run $(LD_LIBPATH_OVERRIDE)" \
        $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --socket-wrapper --testenv
 
+S34_LD_LIBPATH_OVERRIDE = $(LIB_PATH_VAR)="$(builddir)/bin/shared:$(builddir)/bin"
+
+SELFTEST34 = $(S34_LD_LIBPATH_OVERRIDE) PYTHON="$(PYTHON)" PERL="$(PERL)" \
+       $(PERL) $(selftestdir)/selftest.pl \
+       --prefix=$(selftest_prefix)/34 --target=samba34 \
+       --builddir=$(builddir) --srcdir=$(srcdir) \
+       --expected-failures=../selftest/knownfail34 \
+       --format=$(SELFTEST_FORMAT) \
+       --exclude=../selftest/skip34 \
+       --testlist="../selftest/tests34.sh|" \
+       $(TEST34_OPTIONS)
+
+selftest34:: everything bin/timelimit
+       $(SELFTEST34) $(DEFAULT_TEST_OPTIONS) --immediate $(TESTS)
+
 plugins: $(PLUGINS)
 plugins: $(PLUGINS)