s3-netdomjoin-gui: cosmetic fix for empty hostnames.
[jra/samba/.git] / selftest / selftest.pl
index 7d40db5371a729aa3dedbbc716c178cac54150f6..36535235413fbb627f5f71d4eb2e2d2cffea8926 100755 (executable)
@@ -1,7 +1,20 @@
 #!/usr/bin/perl
 # Bootstrap Samba and run a number of tests against it.
 # Copyright (C) 2005-2008 Jelmer Vernooij <jelmer@samba.org>
-# Published under the GNU GPL, v3 or later.
+# Copyright (C) 2007-2009 Stefan Metzmacher <metze@samba.org>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 =pod
 
@@ -287,6 +300,7 @@ sub ShowHelp()
 {
        print "Samba test runner
 Copyright (C) Jelmer Vernooij <jelmer\@samba.org>
+Copyright (C) Stefan Metzmacher <metze\@samba.org>
 
 Usage: $Script [OPTIONS] TESTNAME-REGEX
 
@@ -365,7 +379,8 @@ unless (defined($ENV{VALGRIND})) {
        $ENV{MALLOC_CHECK_} = 2;
 }
 
-my $old_pwd = "$RealBin/..";
+my $bindir = ($opt_bindir or "$builddir/bin");
+my $bindir_abs = abs_path($bindir);
 
 # Backwards compatibility:
 if (defined($ENV{TEST_LDAP}) and $ENV{TEST_LDAP} eq "yes") {
@@ -393,6 +408,7 @@ mkdir($prefix, 0777) unless -d $prefix;
 
 my $prefix_abs = abs_path($prefix);
 my $srcdir_abs = abs_path($srcdir);
+my $builddir_abs = abs_path($builddir);
 
 die("using an empty absolute prefix isn't allowed") unless $prefix_abs ne "";
 die("using '/' as absolute prefix isn't allowed") unless $prefix_abs ne "/";
@@ -402,6 +418,9 @@ $ENV{KRB5CCNAME} = "$prefix/krb5ticket";
 $ENV{PREFIX_ABS} = $prefix_abs;
 $ENV{SRCDIR} = $srcdir;
 $ENV{SRCDIR_ABS} = $srcdir_abs;
+$ENV{BUILDDIR} = $builddir;
+$ENV{BUILDDIR_ABS} = $builddir_abs;
+$ENV{EXEEXT} = $exeext;
 
 if (defined($ENV{RUN_FROM_BUILD_FARM}) and 
        ($ENV{RUN_FROM_BUILD_FARM} eq "yes")) {
@@ -410,8 +429,8 @@ if (defined($ENV{RUN_FROM_BUILD_FARM}) and
 
 my $tls_enabled = not $opt_quick;
 $ENV{TLS_ENABLED} = ($tls_enabled?"yes":"no");
-$ENV{LDB_MODULES_PATH} = "$old_pwd/source4/bin/modules/ldb";
-$ENV{LD_SAMBA_MODULE_PATH} = "$old_pwd/source4/bin/modules";
+$ENV{LDB_MODULES_PATH} = "$bindir_abs/modules/ldb";
+$ENV{LD_SAMBA_MODULE_PATH} = "$bindir_abs/modules";
 sub prefix_pathvar($$)
 {
        my ($name, $newpath) = @_;
@@ -421,8 +440,8 @@ sub prefix_pathvar($$)
                $ENV{$name} = $newpath;
        }
 }
-prefix_pathvar("PKG_CONFIG_PATH", "$old_pwd/source4/bin/pkgconfig");
-prefix_pathvar("PYTHONPATH", "$old_pwd/source4/bin/python");
+prefix_pathvar("PKG_CONFIG_PATH", "$bindir_abs/pkgconfig");
+prefix_pathvar("PYTHONPATH", "$bindir_abs/python");
 
 if ($opt_socket_wrapper_keep_pcap) {
        # Socket wrapper keep pcap implies socket wrapper pcap
@@ -450,10 +469,8 @@ my $testenv_default = "none";
 if ($opt_target eq "samba4") {
        $testenv_default = "member";
        require target::Samba4;
-       $target = new Samba4($opt_bindir or "$builddir/bin",
-                            $ldap, "$srcdir/setup", $exeext);
+       $target = new Samba4($bindir, $ldap, "$srcdir/setup", $exeext);
 } elsif ($opt_target eq "samba3") {
-       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....");
        }
@@ -648,7 +665,6 @@ if ($opt_quick) {
 }
 $ENV{SELFTEST_TARGET} = $opt_target;
 $ENV{SELFTEST_MAXTIME} = $torture_maxtime;
-$ENV{SELFTEST_CONFFILE} = $conffile;
 
 my @available = ();
 foreach my $fn (@testlists) {
@@ -752,12 +768,13 @@ sub setup_env($)
        my $option = $name;
 
        $envname =~ s/:.*//;
-       $option =~ s/^[^:]*://;
+       $option =~ s/^[^:]*//;
+       $option =~ s/^://;
 
        $option = "client" if $option eq "";
 
        if ($envname eq "none") {
-               $testenv_vars = \{};
+               $testenv_vars = {};
        } elsif (defined(get_running_env($envname))) {
                $testenv_vars = get_running_env($envname);
                if (not $target->check_env($testenv_vars)) {
@@ -851,7 +868,7 @@ server is pid `cat \$PIDDIR/samba.pid`
 
 Some useful environment variables:
 TORTURE_OPTIONS=\$TORTURE_OPTIONS
-CONFIGURATION=\$CONFIGURATION
+SMB_CONF_PATH=\$SMB_CONF_PATH
 
 $envvarstr
 \" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash'");