Modify OneFS module to support new NTIMES interfaces
[metze/samba/wip.git] / selftest / selftest.pl
index 1477d10d469bb590bb6ed4dfc552f2a54cdd9389..6f0883c585e296317eb66e27bf2316023f7b77a3 100755 (executable)
@@ -13,7 +13,7 @@ selftest - Samba test runner
 
 selftest --help
 
-selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win|kvm] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--immediate] [--testlist=FILE] [TESTS]
+selftest [--srcdir=DIR] [--builddir=DIR] [--exeext=EXT][--target=samba4|samba3|win|kvm] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--immediate] [--testlist=FILE] [TESTS]
 
 =head1 DESCRIPTION
 
@@ -35,6 +35,10 @@ Source directory.
 
 Build directory.
 
+=item I<--exeext=EXT>
+
+Executable extention
+
 =item I<--prefix=DIR>
 
 Change directory to run tests in. Default is 'st'.
@@ -156,6 +160,7 @@ my @testlists = ();
 
 my $srcdir = ".";
 my $builddir = ".";
+my $exeext = "";
 my $prefix = "./st";
 
 my @expected_failures = ();
@@ -283,30 +288,29 @@ sub ShowHelp()
        print "Samba test runner
 Copyright (C) Jelmer Vernooij <jelmer\@samba.org>
 
-Usage: $Script [OPTIONS] PREFIX
+Usage: $Script [OPTIONS] TESTNAME-REGEX
 
 Generic options:
  --help                     this help page
  --target=samba[34]|win|kvm Samba version to target
- --testlist=FILE                       file to read available tests from
+ --testlist=FILE           file to read available tests from
 
 Paths:
  --prefix=DIR               prefix to run tests in [st]
  --srcdir=DIR               source directory [.]
  --builddir=DIR             output directory [.]
+ --exeext=EXT               executable extention []
 
 Target Specific:
- --socket-wrapper-pcap         save traffic to pcap directories
+ --socket-wrapper-pcap     save traffic to pcap directories
  --socket-wrapper-keep-pcap keep all pcap files, not just those for tests that 
                             failed
  --socket-wrapper           enable socket wrapper
+ --bindir=PATH              path to target binaries
  --expected-failures=FILE   specify list of tests that is guaranteed to fail
 
 Samba4 Specific:
- --ldap=openldap|fedora-ds     back samba onto specified ldap server
-
-Samba3 Specific:
- --bindir=PATH              path to binaries
+ --ldap=openldap|fedora-ds  back samba onto specified ldap server
 
 Kvm Specific:
  --image=PATH               path to KVM image
@@ -336,6 +340,7 @@ my $result = GetOptions (
                'include=s' => \@opt_include,
                'srcdir=s' => \$srcdir,
                'builddir=s' => \$builddir,
+               'exeext=s' => \$exeext,
                'verbose' => \$opt_verbose,
                'testenv' => \$opt_testenv,
                'ldap:s' => \$ldap,
@@ -434,7 +439,9 @@ if ($opt_socket_wrapper) {
        $socket_wrapper_dir = SocketWrapper::setup_dir("$prefix/w", $opt_socket_wrapper_pcap);
        print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n";
 } else {
-       warn("Not using socket wrapper, but also not running as root. Will not be able to listen on proper ports") unless $< == 0;
+        unless ($< == 0) { 
+                print "WARNING: Not using socket wrapper, but also not running as root. Will not be able to listen on proper ports\n";
+        }
 }
 
 my $target;
@@ -443,14 +450,16 @@ my $testenv_default = "none";
 if ($opt_target eq "samba4") {
        $testenv_default = "member";
        require target::Samba4;
-       $target = new Samba4($opt_bindir or "$srcdir/bin", $ldap, "$srcdir/setup");
+       $target = new Samba4($opt_bindir or "$builddir/bin",
+                            $ldap, "$srcdir/setup", $exeext);
 } elsif ($opt_target eq "samba3") {
-       if ($opt_socket_wrapper and `$opt_bindir/smbd -b | grep SOCKET_WRAPPER` eq "") {
+       my $bindir = ($opt_bindir or "$builddir/bin");
+       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 = "dc";
        require target::Samba3;
-       $target = new Samba3($opt_bindir);
+       $target = new Samba3($bindir);
 } elsif ($opt_target eq "win") {
        die("Windows tests will not run with socket wrapper enabled.") 
                if ($opt_socket_wrapper);
@@ -517,10 +526,6 @@ foreach (@opt_exclude) {
        push (@excludes, read_test_regexes($_));
 }
 
-if ($opt_quick) {
-       push (@includes, read_test_regexes("samba4-quick"));
-}
-
 foreach (@opt_include) {
        push (@includes, read_test_regexes($_));
 }
@@ -533,6 +538,7 @@ my $interfaces = join(',', ("127.0.0.6/8",
                            "127.0.0.11/8"));
 
 my $conffile = "$prefix_abs/client/client.conf";
+$ENV{SMB_CONF_PATH} = $conffile;
 
 sub write_clientconf($$)
 {
@@ -575,11 +581,12 @@ sub write_clientconf($$)
        print CF "
        private dir = $prefix_abs/client/private
        name resolve order = bcast
-       panic action = $srcdir_abs/script/gdb_backtrace \%PID\% \%PROG\%
+       panic action = $RealBin/gdb_backtrace \%PID\% \%PROG\%
        max xmit = 32K
        notify:inotify = false
        ldb:nosync = true
        system:anonymous = true
+       client lanman auth = Yes
        torture:basedir = $prefix_abs/client
 #We don't want to pass our self-tests if the PAC code is wrong
        gensec:require_pac = true
@@ -588,24 +595,9 @@ sub write_clientconf($$)
        close(CF);
 }
 
-my @torture_options = ();
-push (@torture_options, "--configfile=$conffile");
-# ensure any one smbtorture call doesn't run too long
-push (@torture_options, "--maximum-runtime=$torture_maxtime");
-push (@torture_options, "--target=$opt_target");
-push (@torture_options, "--basedir=$prefix_abs");
-push (@torture_options, "--option=torture:progress=no") unless ($opt_verbose);
-push (@torture_options, "--format=subunit");
-push (@torture_options, "--option=torture:quick=yes") if ($opt_quick);
-
-$ENV{TORTURE_OPTIONS} = join(' ', @torture_options);
-print "OPTIONS $ENV{TORTURE_OPTIONS}\n";
-
 my @todo = ();
 
 my $testsdir = "$srcdir/selftest";
-$ENV{SMB_CONF_PATH} = "$conffile";
-$ENV{CONFIGURATION} = "--configfile=$conffile";
 
 my %required_envs = ();
 
@@ -640,6 +632,26 @@ if ($#testlists == -1) {
        die("No testlists specified");
 }
 
+$ENV{SELFTEST_PREFIX} = "$prefix_abs";
+if ($opt_socket_wrapper) {
+       $ENV{SELFTEST_INTERFACES} = $interfaces;
+} else {
+       $ENV{SELFTEST_INTERFACES} = "";
+}
+if ($opt_verbose) {
+       $ENV{SELFTEST_VERBOSE} = "1";
+} else {
+       $ENV{SELFTEST_VERBOSE} = "";
+}
+if ($opt_quick) {
+       $ENV{SELFTEST_QUICK} = "1";
+} else {
+       $ENV{SELFTEST_QUICK} = "";
+}
+$ENV{SELFTEST_TARGET} = $opt_target;
+$ENV{SELFTEST_MAXTIME} = $torture_maxtime;
+$ENV{SELFTEST_CONFFILE} = $conffile;
+
 my @available = ();
 foreach my $fn (@testlists) {
        foreach (read_testlist($fn)) {