samba_dnsupdate: Always fill out the nameservers of a dns object.
[obnox/samba/samba-obnox.git] / selftest / selftest.pl
index 2df50924782704696ea41f5fae23f965a4ca84ea..166d40aebe296610c8e8a6322910af81c9aa96ad 100755 (executable)
@@ -53,6 +53,7 @@ my $opt_resetup_env = undef;
 my $opt_binary_mapping = "";
 my $opt_load_list = undef;
 my $opt_libnss_wrapper_so_path = "";
+my $opt_libresolv_wrapper_so_path = "";
 my $opt_libsocket_wrapper_so_path = "";
 my $opt_libuid_wrapper_so_path = "";
 my @testlists = ();
@@ -190,6 +191,8 @@ Generic options:
  --help                     this help page
  --target=samba[3]|win      Samba version to target
  --testlist=FILE            file to read available tests from
+ --exclude=FILE             Exclude tests listed in the file
+ --include=FILE             Include tests listed in the file
 
 Paths:
  --prefix=DIR               prefix to run tests in [st]
@@ -198,6 +201,7 @@ Paths:
 
 Preload cwrap:
  --nss_wrapper_so_path=FILE the nss_wrapper library to preload
+ --resolv_wrapper_so_path=FILE the resolv_wrapper library to preload
  --socket_wrapper_so_path=FILE the socket_wrapper library to preload
  --uid_wrapper_so_path=FILE the uid_wrapper library to preload
 
@@ -241,6 +245,7 @@ my $result = GetOptions (
                'load-list=s' => \$opt_load_list,
                'binary-mapping=s' => \$opt_binary_mapping,
                'nss_wrapper_so_path=s' => \$opt_libnss_wrapper_so_path,
+               'resolv_wrapper_so_path=s' => \$opt_libresolv_wrapper_so_path,
                'socket_wrapper_so_path=s' => \$opt_libsocket_wrapper_so_path,
                'uid_wrapper_so_path=s' => \$opt_libuid_wrapper_so_path
            );
@@ -348,6 +353,14 @@ if ($opt_libnss_wrapper_so_path) {
        }
 }
 
+if ($opt_libresolv_wrapper_so_path) {
+       if ($ld_preload) {
+               $ld_preload = "$ld_preload:$opt_libresolv_wrapper_so_path";
+       } else {
+               $ld_preload = "$opt_libresolv_wrapper_so_path";
+       }
+}
+
 if ($opt_libsocket_wrapper_so_path) {
        if ($ld_preload) {
                $ld_preload = "$ld_preload:$opt_libsocket_wrapper_so_path";
@@ -566,17 +579,21 @@ sub read_testlist($)
        open(IN, $filename) or die("Unable to open $filename: $!");
 
        while (<IN>) {
-               if (/-- TEST(-LOADLIST|-IDLIST|) --\n/) {
+               if (/-- TEST(-LOADLIST|) --\n/) {
                        my $supports_loadlist = (defined($1) and $1 eq "-LOADLIST");
-                       my $supports_idlist = (defined($1) and $1 eq "-IDLIST");
                        my $name = <IN>;
                        $name =~ s/\n//g;
                        my $env = <IN>;
                        $env =~ s/\n//g;
+                       my $loadlist;
+                       if ($supports_loadlist) {
+                               $loadlist = <IN>;
+                               $loadlist =~ s/\n//g;
+                       }
                        my $cmdline = <IN>;
                        $cmdline =~ s/\n//g;
                        if (should_run_test($name) == 1) {
-                               push (@ret, [$name, $env, $cmdline, $supports_loadlist, $supports_idlist]);
+                               push (@ret, [$name, $env, $cmdline, $loadlist]);
                        }
                } else {
                        print;
@@ -821,7 +838,6 @@ sub setup_env($$)
                }
        }
 
-       
        return undef unless defined($testenv_vars);
 
        $running_envs{$envname} = $testenv_vars;
@@ -937,11 +953,12 @@ $envvarstr
        teardown_env($testenv_name);
 } elsif ($opt_list) {
        foreach (@todo) {
-               my $cmd = $$_[2];
                my $name = $$_[0];
                my $envname = $$_[1];
+               my $cmd = $$_[2];
+               my $listcmd = $$_[3];
 
-               unless($cmd =~ /\$LISTOPT/) {
+               unless (defined($listcmd)) {
                        warn("Unable to list tests in $name");
                        # Rather than ignoring this testsuite altogether, just pretend the entire testsuite is
                        # a single "test".
@@ -949,14 +966,12 @@ $envvarstr
                        next;
                }
 
-               $cmd =~ s/\$LISTOPT/--list/g;
-
-               system($cmd);
+               system($listcmd);
 
                if ($? == -1) {
-                       die("Unable to run $cmd: $!");
+                       die("Unable to run $listcmd: $!");
                } elsif ($? & 127) {
-                       die(sprintf("%s died with signal %d, %s coredump\n", $cmd, ($? & 127),  ($? & 128) ? 'with' : 'without'));
+                       die(sprintf("%s died with signal %d, %s coredump\n", $listcmd, ($? & 127),  ($? & 128) ? 'with' : 'without'));
                }
 
                my $exitcode = $? >> 8;
@@ -993,9 +1008,8 @@ $envvarstr
                                        print $fh substr($test, length($name)+1) . "\n";
                                }
                                $cmd =~ s/\$LOADLIST/--load-list=$listid_file/g;
-                       } elsif ($$_[4]) {
-                               $cmd =~ s/\s+[^\s]+\s*$//;
-                               $cmd .= " " . join(' ', @{$individual_tests->{$name}});
+                       } else {
+                               warn("Unable to run individual tests in $name, it does not support --loadlist.");
                        }
                }