Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/selftest/selftest.pl

    r740 r988  
    1616# You should have received a copy of the GNU General Public License
    1717# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18 
    19 =pod
    20 
    21 =head1 NAME
    22 
    23 selftest - Samba test runner
    24 
    25 =head1 SYNOPSIS
    26 
    27 selftest --help
    28 
    29 selftest [--srcdir=DIR] [--builddir=DIR] [--exeext=EXT][--target=samba4|samba3|win|kvm] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--testlist=FILE] [TESTS]
    30 
    31 =head1 DESCRIPTION
    32 
    33 A simple test runner. TESTS is a regular expression with tests to run.
    34 
    35 =head1 OPTIONS
    36 
    37 =over 4
    38 
    39 =item I<--help>
    40 
    41 Show list of available options.
    42 
    43 =item I<--srcdir=DIR>
    44 
    45 Source directory.
    46 
    47 =item I<--builddir=DIR>
    48 
    49 Build directory.
    50 
    51 =item I<--exeext=EXT>
    52 
    53 Executable extention
    54 
    55 =item I<--prefix=DIR>
    56 
    57 Change directory to run tests in. Default is 'st'.
    58 
    59 =item I<--target samba4|samba3|win|kvm>
    60 
    61 Specify test target against which to run. Default is 'samba4'.
    62 
    63 =item I<--quick>
    64 
    65 Run only a limited number of tests. Intended to run in about 30 seconds on
    66 moderately recent systems.
    67                
    68 =item I<--socket-wrapper>
    69 
    70 Use socket wrapper library for communication with server. Only works
    71 when the server is running locally.
    72 
    73 Will prevent TCP and UDP ports being opened on the local host but
    74 (transparently) redirects these calls to use unix domain sockets.
    75 
    76 =item I<--exclude>
    77 
    78 Specify a file containing a list of tests that should be skipped. Possible
    79 candidates are tests that segfault the server, flip or don't end.
    80 
    81 =item I<--include>
    82 
    83 Specify a file containing a list of tests that should be run. Same format
    84 as the --exclude flag.
    85 
    86 Not includes specified means all tests will be run.
    87 
    88 =item I<--one>
    89 
    90 Abort as soon as one test fails.
    91 
    92 =item I<--testlist>
    93 
    94 Load a list of tests from the specified location.
    95 
    96 =back
    97 
    98 =head1 ENVIRONMENT
    99 
    100 =over 4
    101 
    102 =item I<SMBD_VALGRIND>
    103 
    104 =item I<TORTURE_MAXTIME>
    105 
    106 =item I<VALGRIND>
    107 
    108 =item I<TLS_ENABLED>
    109 
    110 =item I<srcdir>
    111 
    112 =back
    113 
    114 =head1 LICENSE
    115 
    116 selftest is licensed under the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>.
    117 
    118 =head1 AUTHOR
    119 
    120 Jelmer Vernooij
    121 
    122 =cut
    12318
    12419use strict;
     
    13328use Subunit;
    13429use SocketWrapper;
     30use target::Samba;
    13531
    13632eval {
     
    14339
    14440my $opt_help = 0;
    145 my $opt_target = "samba4";
     41my $opt_target = "samba";
    14642my $opt_quick = 0;
    14743my $opt_socket_wrapper = 0;
    14844my $opt_socket_wrapper_pcap = undef;
    14945my $opt_socket_wrapper_keep_pcap = undef;
     46my $opt_random_order = 0;
    15047my $opt_one = 0;
    15148my @opt_exclude = ();
    15249my @opt_include = ();
    153 my $opt_verbose = 0;
    154 my $opt_image = undef;
    15550my $opt_testenv = 0;
    15651my $opt_list = 0;
    15752my $ldap = undef;
    15853my $opt_resetup_env = undef;
    159 my $opt_bindir = undef;
    16054my $opt_load_list = undef;
     55my $opt_libnss_wrapper_so_path = "";
     56my $opt_libresolv_wrapper_so_path = "";
     57my $opt_libsocket_wrapper_so_path = "";
     58my $opt_libuid_wrapper_so_path = "";
     59my $opt_use_dns_faking = 0;
    16160my @testlists = ();
    16261
    16362my $srcdir = ".";
    164 my $builddir = ".";
    165 my $exeext = "";
     63my $bindir = "./bin";
    16664my $prefix = "./st";
    16765
    16866my @includes = ();
    16967my @excludes = ();
    170 
    171 sub pipe_handler {
    172         my $sig = shift @_;
    173         print STDERR "Exiting early because of SIGPIPE.\n";
    174         exit(1);
    175 }
    176 
    177 $SIG{PIPE} = \&pipe_handler;
    17868
    17969sub find_in_list($$)
     
    301191Generic options:
    302192 --help                     this help page
    303  --target=samba[34]|win|kvm Samba version to target
    304  --testlist=FILE            file to read available tests from
     193 --target=samba[3]|win      Samba version to target
     194 --testlist=FILE            file to read available tests from
     195 --exclude=FILE             Exclude tests listed in the file
     196 --include=FILE             Include tests listed in the file
    305197
    306198Paths:
    307199 --prefix=DIR               prefix to run tests in [st]
    308200 --srcdir=DIR               source directory [.]
    309  --builddir=DIR             output directory [.]
    310  --exeext=EXT               executable extention []
     201 --bindir=DIR               binaries directory [./bin]
     202
     203Preload cwrap:
     204 --nss_wrapper_so_path=FILE the nss_wrapper library to preload
     205 --resolv_wrapper_so_path=FILE the resolv_wrapper library to preload
     206 --socket_wrapper_so_path=FILE the socket_wrapper library to preload
     207 --uid_wrapper_so_path=FILE the uid_wrapper library to preload
     208
     209DNS:
     210  --use-dns-faking          Fake DNS entries rather than talking to our
     211                            DNS implementation.
    311212
    312213Target Specific:
    313  --socket-wrapper-pcap      save traffic to pcap directories
     214 --socket-wrapper-pcap      save traffic to pcap directories
    314215 --socket-wrapper-keep-pcap keep all pcap files, not just those for tests that
    315216                            failed
    316217 --socket-wrapper           enable socket wrapper
    317  --bindir=PATH              path to target binaries
    318218
    319219Samba4 Specific:
    320220 --ldap=openldap|fedora-ds  back samba onto specified ldap server
    321 
    322 Kvm Specific:
    323  --image=PATH               path to KVM image
    324221
    325222Behaviour:
    326223 --quick                    run quick overall test
    327224 --one                      abort when the first test fails
    328  --verbose                  be verbose
    329225 --testenv                  run a shell in the requested test environment
    330226 --list                     list available tests
     
    345241                'include=s' => \@opt_include,
    346242                'srcdir=s' => \$srcdir,
    347                 'builddir=s' => \$builddir,
    348                 'exeext=s' => \$exeext,
    349                 'verbose' => \$opt_verbose,
     243                'bindir=s' => \$bindir,
    350244                'testenv' => \$opt_testenv,
    351245                'list' => \$opt_list,
    352246                'ldap:s' => \$ldap,
    353247                'resetup-environment' => \$opt_resetup_env,
    354                 'bindir:s' => \$opt_bindir,
    355                 'image=s' => \$opt_image,
    356248                'testlist=s' => \@testlists,
     249                'random-order' => \$opt_random_order,
    357250                'load-list=s' => \$opt_load_list,
     251                'nss_wrapper_so_path=s' => \$opt_libnss_wrapper_so_path,
     252                'resolv_wrapper_so_path=s' => \$opt_libresolv_wrapper_so_path,
     253                'socket_wrapper_so_path=s' => \$opt_libsocket_wrapper_so_path,
     254                'uid_wrapper_so_path=s' => \$opt_libuid_wrapper_so_path,
     255                'use-dns-faking' => \$opt_use_dns_faking
    358256            );
    359257
     
    372270unless (defined($ENV{VALGRIND})) {
    373271        $ENV{VALIDATE} = "validate";
    374         $ENV{MALLOC_CHECK_} = 2;
     272        $ENV{MALLOC_CHECK_} = 3;
    375273}
    376274
     
    378276$ENV{PYTHONUNBUFFERED} = 1;
    379277
    380 my $bindir = ($opt_bindir or "$builddir/bin");
    381278my $bindir_abs = abs_path($bindir);
    382279
     
    402299die("using an empty prefix isn't allowed") unless $prefix ne "";
    403300
    404 #Ensure we have the test prefix around
    405 mkdir($prefix, 0777) unless -d $prefix;
     301# Ensure we have the test prefix around.
     302#
     303# We need restrictive
     304# permissions on this as some subdirectories in this tree will have
     305# wider permissions (ie 0777) and this would allow other users on the
     306# host to subvert the test process.
     307mkdir($prefix, 0700) unless -d $prefix;
     308chmod 0700, $prefix;
    406309
    407310my $prefix_abs = abs_path($prefix);
     
    410313
    411314my $srcdir_abs = abs_path($srcdir);
    412 my $builddir_abs = abs_path($builddir);
    413315
    414316die("using an empty absolute prefix isn't allowed") unless $prefix_abs ne "";
     
    420322$ENV{SRCDIR} = $srcdir;
    421323$ENV{SRCDIR_ABS} = $srcdir_abs;
    422 $ENV{BUILDDIR} = $builddir;
    423 $ENV{BUILDDIR_ABS} = $builddir_abs;
    424324$ENV{BINDIR} = $bindir_abs;
    425 $ENV{EXEEXT} = $exeext;
    426325
    427326my $tls_enabled = not $opt_quick;
     
    449348        $opt_socket_wrapper = 1;
    450349}
     350
     351my $ld_preload = $ENV{LD_PRELOAD};
     352
     353if ($opt_libnss_wrapper_so_path) {
     354        if ($ld_preload) {
     355                $ld_preload = "$ld_preload:$opt_libnss_wrapper_so_path";
     356        } else {
     357                $ld_preload = "$opt_libnss_wrapper_so_path";
     358        }
     359}
     360
     361if ($opt_libresolv_wrapper_so_path) {
     362        if ($ld_preload) {
     363                $ld_preload = "$ld_preload:$opt_libresolv_wrapper_so_path";
     364        } else {
     365                $ld_preload = "$opt_libresolv_wrapper_so_path";
     366        }
     367}
     368
     369if ($opt_libsocket_wrapper_so_path) {
     370        if ($ld_preload) {
     371                $ld_preload = "$ld_preload:$opt_libsocket_wrapper_so_path";
     372        } else {
     373                $ld_preload = "$opt_libsocket_wrapper_so_path";
     374        }
     375}
     376
     377if ($opt_libuid_wrapper_so_path) {
     378        if ($ld_preload) {
     379                $ld_preload = "$ld_preload:$opt_libuid_wrapper_so_path";
     380        } else {
     381                $ld_preload = "$opt_libuid_wrapper_so_path";
     382        }
     383}
     384
     385$ENV{LD_PRELOAD} = $ld_preload;
     386print "LD_PRELOAD=$ENV{LD_PRELOAD}\n";
     387
     388# Enable uid_wrapper globally
     389$ENV{UID_WRAPPER} = 1;
     390
     391# Disable RTLD_DEEPBIND hack for Samba bind dlz module
     392#
     393# This is needed in order to allow the ldb_*ldap module
     394# to work with a preloaded socket wrapper.
     395$ENV{LDB_MODULES_DISABLE_DEEPBIND} = 1;
    451396
    452397my $socket_wrapper_dir;
     
    454399        $socket_wrapper_dir = SocketWrapper::setup_dir("$prefix_abs/w", $opt_socket_wrapper_pcap);
    455400        print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n";
    456 } else {
    457          unless ($< == 0) { 
    458                  print "WARNING: Not using socket wrapper, but also not running as root. Will not be able to listen on proper ports\n";
     401} elsif (not $opt_list) {
     402         unless ($< == 0) {
     403                 warn("not using socket wrapper, but also not running as root. Will not be able to listen on proper ports");
    459404         }
     405}
     406
     407if ($opt_use_dns_faking) {
     408        print "DNS: Faking nameserver\n";
     409        $ENV{SAMBA_DNS_FAKING} = 1;
    460410}
    461411
     
    463413my $testenv_default = "none";
    464414
    465 if ($opt_target eq "samba4") {
    466         $testenv_default = "all";
    467         require target::Samba4;
    468         $target = new Samba4($bindir, $ldap, $srcdir, $exeext);
    469 } elsif ($opt_target eq "samba3") {
    470         if ($opt_socket_wrapper and `$bindir/smbd -b | grep SOCKET_WRAPPER` eq "") {
    471                 die("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'.  Exiting....");
    472         }
    473         $testenv_default = "member";
    474         require target::Samba3;
    475         $target = new Samba3($bindir, $srcdir_abs);
    476 } elsif ($opt_target eq "win") {
    477         die("Windows tests will not run with socket wrapper enabled.")
    478                 if ($opt_socket_wrapper);
    479         $testenv_default = "dc";
    480         require target::Windows;
    481         $target = new Windows();
    482 } elsif ($opt_target eq "kvm") {
    483         die("Kvm tests will not run with socket wrapper enabled.")
    484                 if ($opt_socket_wrapper);
    485         require target::Kvm;
    486         die("No image specified") unless ($opt_image);
    487         $target = new Kvm($opt_image, undef);
    488 }
    489 
    490 #
    491 # Start a Virtual Distributed Ethernet Switch
    492 # Returns the pid of the switch.
    493 #
    494 sub start_vde_switch($)
    495 {
    496         my ($path) = @_;
    497 
    498         system("vde_switch --pidfile $path/vde.pid --sock $path/vde.sock --daemon");
    499 
    500         open(PID, "$path/vde.pid");
    501         <PID> =~ /([0-9]+)/;
    502         my $pid = $1;
    503         close(PID);
    504 
    505         return $pid;
    506 }
    507 
    508 # Stop a Virtual Distributed Ethernet Switch
    509 sub stop_vde_switch($)
    510 {
    511         my ($pid) = @_;
    512         kill 9, $pid;
     415# After this many seconds, the server will self-terminate.  All tests
     416# must terminate in this time, and testenv will only stay alive this
     417# long
     418
     419my $server_maxtime;
     420if ($opt_testenv) {
     421    # 1 year should be enough :-)
     422    $server_maxtime = 365 * 24 * 60 * 60;
     423} else {
     424    # make test should run under 4 hours
     425    $server_maxtime = 4 * 60 * 60;
     426}
     427
     428if (defined($ENV{SMBD_MAXTIME}) and $ENV{SMBD_MAXTIME} ne "") {
     429    $server_maxtime = $ENV{SMBD_MAXTIME};
     430}
     431
     432unless ($opt_list) {
     433        if ($opt_target eq "samba") {
     434                $testenv_default = "ad_dc_ntvfs";
     435                require target::Samba;
     436                $target = new Samba($bindir, $ldap, $srcdir, $server_maxtime);
     437        } elsif ($opt_target eq "samba3") {
     438                $testenv_default = "nt4_member";
     439                require target::Samba3;
     440                $target = new Samba3($bindir, $srcdir_abs, $server_maxtime);
     441        }
    513442}
    514443
     
    570499        }
    571500
     501        if ( -d "$clientdir/statedir" ) {
     502                unlink <$clientdir/statedir/*>;
     503        } else {
     504                mkdir("$clientdir/statedir", 0777);
     505        }
     506
     507        if ( -d "$clientdir/cachedir" ) {
     508                unlink <$clientdir/cachedir/*>;
     509        } else {
     510                mkdir("$clientdir/cachedir", 0777);
     511        }
     512
     513        # this is ugly, but the ncalrpcdir needs exactly 0755
     514        # otherwise tests fail.
     515        my $mask = umask;
     516        umask 0022;
     517        if ( -d "$clientdir/ncalrpcdir/np" ) {
     518                unlink <$clientdir/ncalrpcdir/np/*>;
     519                rmdir "$clientdir/ncalrpcdir/np";
     520        }
    572521        if ( -d "$clientdir/ncalrpcdir" ) {
    573522                unlink <$clientdir/ncalrpcdir/*>;
    574         } else {
    575                 mkdir("$clientdir/ncalrpcdir", 0777);
    576         }
     523                rmdir "$clientdir/ncalrpcdir";
     524        }
     525        mkdir("$clientdir/ncalrpcdir", 0755);
     526        umask $mask;
     527
     528        my $cadir = "$ENV{SRCDIR_ABS}/selftest/manage-ca/CA-samba.example.com";
     529        my $cacert = "$cadir/Public/CA-samba.example.com-cert.pem";
     530        my $cacrl_pem = "$cadir/Public/CA-samba.example.com-crl.pem";
     531        my $ca_users_dir = "$cadir/Users";
     532
     533        if ( -d "$clientdir/pkinit" ) {
     534                unlink <$clientdir/pkinit/*>;
     535        } else {
     536                mkdir("$clientdir/pkinit", 0700);
     537        }
     538
     539        # each user has a USER-${USER_PRINCIPAL_NAME}-cert.pem and
     540        # USER-${USER_PRINCIPAL_NAME}-private-key.pem symlink
     541        # We make a copy here and make the certificated easily
     542        # accessable in the client environment.
     543        my $mask = umask;
     544        umask 0077;
     545        opendir USERS, "${ca_users_dir}" or die "Could not open dir '${ca_users_dir}': $!";
     546        for my $d (readdir USERS) {
     547                my $user_dir = "${ca_users_dir}/${d}";
     548                next if ${d} =~ /^\./;
     549                next if (! -d "${user_dir}");
     550                opendir USER, "${user_dir}" or die "Could not open dir '${user_dir}': $!";
     551                for my $l (readdir USER) {
     552                        my $user_link = "${user_dir}/${l}";
     553                        next if ${l} =~ /^\./;
     554                        next if (! -l "${user_link}");
     555
     556                        my $dest = "${clientdir}/pkinit/${l}";
     557                        Samba::copy_file_content(${user_link}, ${dest});
     558                }
     559                closedir USER;
     560        }
     561        closedir USERS;
     562        umask $mask;
    577563
    578564        open(CF, ">$conffile");
    579565        print CF "[global]\n";
    580         if (defined($ENV{VALGRIND})) {
    581                 print CF "\ticonv:native = true\n";
    582         } else {
    583                 print CF "\ticonv:native = false\n";
    584         }
    585566        print CF "\tnetbios name = client\n";
    586567        if (defined($vars->{DOMAIN})) {
     
    596577        private dir = $clientdir/private
    597578        lock dir = $clientdir/lockdir
     579        state directory = $clientdir/statedir
     580        cache directory = $clientdir/cachedir
    598581        ncalrpc dir = $clientdir/ncalrpcdir
    599         name resolve order = bcast file
    600         panic action = $RealBin/gdb_backtrace \%PID\% \%PROG\%
     582        panic action = $RealBin/gdb_backtrace \%d
    601583        max xmit = 32K
    602584        notify:inotify = false
     
    608590#We don't want to pass our self-tests if the PAC code is wrong
    609591        gensec:require_pac = true
    610         resolv:host file = $prefix_abs/dns_host_file
    611592#We don't want to run 'speed' tests for very long
    612593        torture:timelimit = 1
     594        winbind separator = /
     595        tls cafile = ${cacert}
     596        tls crlfile = ${cacrl_pem}
     597        tls verify peer = no_check
    613598";
    614599        close(CF);
     
    639624
    640625        while (<IN>) {
    641                 if (/-- TEST(-LOADLIST|-IDLIST|) --\n/) {
     626                if (/-- TEST(-LOADLIST|) --\n/) {
    642627                        my $supports_loadlist = (defined($1) and $1 eq "-LOADLIST");
    643                         my $supports_idlist = (defined($1) and $1 eq "-IDLIST");
    644628                        my $name = <IN>;
    645629                        $name =~ s/\n//g;
    646630                        my $env = <IN>;
    647631                        $env =~ s/\n//g;
     632                        my $loadlist;
     633                        if ($supports_loadlist) {
     634                                $loadlist = <IN>;
     635                                $loadlist =~ s/\n//g;
     636                        }
    648637                        my $cmdline = <IN>;
    649638                        $cmdline =~ s/\n//g;
    650639                        if (should_run_test($name) == 1) {
    651                                 push (@ret, [$name, $env, $cmdline, $supports_loadlist, $supports_idlist]);
     640                                push (@ret, [$name, $env, $cmdline, $loadlist]);
    652641                        }
    653642                } else {
     
    655644                }
    656645        }
    657         close(IN) or die("Error creating recipe");
     646        close(IN) or die("Error creating recipe from $filename");
    658647        return @ret;
    659648}
     
    671660        $ENV{SELFTEST_INTERFACES} = "";
    672661}
    673 if ($opt_verbose) {
    674         $ENV{SELFTEST_VERBOSE} = "1";
    675 } else {
    676         $ENV{SELFTEST_VERBOSE} = "";
    677 }
    678662if ($opt_quick) {
    679663        $ENV{SELFTEST_QUICK} = "1";
     
    681665        $ENV{SELFTEST_QUICK} = "";
    682666}
    683 $ENV{SELFTEST_TARGET} = $opt_target;
    684667$ENV{SELFTEST_MAXTIME} = $torture_maxtime;
    685668
     
    728711                if ($match) {
    729712                        if (defined($skipreason)) {
     713                                if (not $opt_list) {
    730714                                        Subunit::skip_testsuite($name, $skipreason);
     715                                }
    731716                        } else {
    732717                                push(@todo, $testsuite);
     
    734719                }
    735720        } elsif (defined($skipreason)) {
    736                 Subunit::skip_testsuite($name, $skipreason);
     721                if (not $opt_list) {
     722                        Subunit::skip_testsuite($name, $skipreason);
     723                }
    737724        } else {
    738725                push(@todo, $testsuite);
     
    753740my $suitestotal = $#todo + 1;
    754741
    755 Subunit::progress($suitestotal);
    756 Subunit::report_time(time());
     742unless ($opt_list) {
     743        Subunit::progress($suitestotal);
     744        Subunit::report_time(time());
     745}
    757746
    758747my $i = 0;
     
    777766        "REALM",
    778767
     768        # stuff related to a trusted domain
     769        "TRUST_SERVER",
     770        "TRUST_SERVER_IP",
     771        "TRUST_SERVER_IPV6",
     772        "TRUST_NETBIOSNAME",
     773        "TRUST_USERNAME",
     774        "TRUST_PASSWORD",
     775        "TRUST_DOMAIN",
     776        "TRUST_REALM",
     777
    779778        # domain controller stuff
    780779        "DC_SERVER",
    781780        "DC_SERVER_IP",
     781        "DC_SERVER_IPV6",
    782782        "DC_NETBIOSNAME",
    783783        "DC_NETBIOSALIAS",
     
    786786        "MEMBER_SERVER",
    787787        "MEMBER_SERVER_IP",
     788        "MEMBER_SERVER_IPV6",
    788789        "MEMBER_NETBIOSNAME",
    789790        "MEMBER_NETBIOSALIAS",
     
    792793        "RPC_PROXY_SERVER",
    793794        "RPC_PROXY_SERVER_IP",
     795        "RPC_PROXY_SERVER_IPV6",
    794796        "RPC_PROXY_NETBIOSNAME",
    795797        "RPC_PROXY_NETBIOSALIAS",
     
    798800        "VAMPIRE_DC_SERVER",
    799801        "VAMPIRE_DC_SERVER_IP",
     802        "VAMPIRE_DC_SERVER_IPV6",
    800803        "VAMPIRE_DC_NETBIOSNAME",
    801804        "VAMPIRE_DC_NETBIOSALIAS",
     805
     806        "PROMOTED_DC_SERVER",
     807        "PROMOTED_DC_SERVER_IP",
     808        "PROMOTED_DC_SERVER_IPV6",
     809        "PROMOTED_DC_NETBIOSNAME",
     810        "PROMOTED_DC_NETBIOSALIAS",
    802811
    803812        # server stuff
    804813        "SERVER",
    805814        "SERVER_IP",
     815        "SERVER_IPV6",
    806816        "NETBIOSNAME",
    807817        "NETBIOSALIAS",
     
    814824        "DC_PASSWORD",
    815825
     826        # UID/GID for rfc2307 mapping tests
     827        "UID_RFC2307TEST",
     828        "GID_RFC2307TEST",
     829
    816830        # misc stuff
    817831        "KRB5_CONFIG",
    818         "WINBINDD_SOCKET_DIR",
     832        "SELFTEST_WINBINDD_SOCKET_DIR",
    819833        "WINBINDD_PRIV_PIPE_DIR",
    820834        "NMBD_SOCKET_DIR",
    821         "LOCAL_PATH"
     835        "LOCAL_PATH",
     836
     837        # nss_wrapper
     838        "NSS_WRAPPER_PASSWD",
     839        "NSS_WRAPPER_GROUP",
     840        "NSS_WRAPPER_HOSTS",
     841        "NSS_WRAPPER_MODULE_SO_PATH",
     842        "NSS_WRAPPER_MODULE_FN_PREFIX",
     843
     844        # resolv_wrapper
     845        "RESOLV_WRAPPER_CONF",
     846        "RESOLV_WRAPPER_HOSTS",
    822847);
    823848
    824 $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
     849sub sighandler($)
     850{
    825851        my $signame = shift;
     852
     853        $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = 'DEFAULT';
     854        $SIG{PIPE} = 'IGNORE';
     855
     856        open(STDOUT, ">&STDERR") or die "can't dup STDOUT to STDERR: $!";
     857
     858        print "$0: PID[$$]: Got SIG${signame} teardown environments.\n";
    826859        teardown_env($_) foreach(keys %running_envs);
    827         die("Received signal $signame");
     860        system("pstree -p $$");
     861        print "$0: PID[$$]: Exiting...\n";
     862        exit(1);
    828863};
     864
     865$SIG{INT} = $SIG{QUIT} = $SIG{TERM} = $SIG{PIPE} = \&sighandler;
    829866
    830867sub setup_env($$)
     
    843880        $option = "client" if $option eq "";
    844881
    845         if ($envname eq "none") {
    846                 $testenv_vars = {};
    847         } elsif (defined(get_running_env($envname))) {
     882        if (defined(get_running_env($envname))) {
    848883                $testenv_vars = get_running_env($envname);
    849884                if (not $testenv_vars->{target}->check_env($testenv_vars)) {
     
    853888        } else {
    854889                $testenv_vars = $target->setup_env($envname, $prefix);
    855                 if (defined($testenv_vars) && not defined($testenv_vars->{target})) {
    856                        $testenv_vars->{target} = $target;
     890                if (defined($testenv_vars) and $testenv_vars eq "UNKNOWN") {
     891                    return $testenv_vars;
     892                } elsif (defined($testenv_vars) && not defined($testenv_vars->{target})) {
     893                        $testenv_vars->{target} = $target;
     894                }
     895                if (not defined($testenv_vars)) {
     896                        warn("$opt_target can't start up known environment '$envname'");
    857897                }
    858898        }
     
    908948{
    909949        my ($envname) = @_;
    910         return 1 if ($envname eq "none");
    911950        my $env = get_running_env($envname);
    912951        return $env->{target}->check_env($env);
     
    917956        my ($envname) = @_;
    918957        return if ($envname eq "none");
     958        print STDERR "teardown_env($envname)\n";
    919959        my $env = get_running_env($envname);
    920960        $env->{target}->teardown_env($env);
     
    924964# This 'global' file needs to be empty when we start
    925965unlink("$prefix_abs/dns_host_file");
     966unlink("$prefix_abs/hosts");
     967
     968if ($opt_random_order) {
     969        require List::Util;
     970        my @newtodo = List::Util::shuffle(@todo);
     971        @todo = @newtodo;
     972}
    926973
    927974if ($opt_testenv) {
     
    931978        my $testenv_vars = setup_env($testenv_name, $prefix);
    932979
    933         die("Unable to setup environment $testenv_name") unless ($testenv_vars);
     980        if (not $testenv_vars or $testenv_vars eq "UNKNOWN") {
     981                die("Unable to setup environment $testenv_name");
     982        }
    934983
    935984        $ENV{PIDDIR} = $testenv_vars->{PIDDIR};
     
    938987        my $envvarstr = exported_envvars_str($testenv_vars);
    939988
    940         my $term = ($ENV{TERMINAL} or "xterm -e");
    941         system("$term 'echo -e \"
     989        my @term_args = ("echo -e \"
    942990Welcome to the Samba4 Test environment '$testenv_name'
    943991
     
    950998
    951999$envvarstr
    952 \" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash'");
     1000\" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash");
     1001        my @term = ();
     1002        if ($ENV{TERMINAL}) {
     1003            @term = ($ENV{TERMINAL});
     1004        } else {
     1005            @term = ("xterm", "-e");
     1006            unshift(@term_args, ("bash", "-c"));
     1007        }
     1008
     1009        system(@term, @term_args);
     1010
    9531011        teardown_env($testenv_name);
    9541012} elsif ($opt_list) {
    9551013        foreach (@todo) {
    956                 my $cmd = $$_[2];
    9571014                my $name = $$_[0];
    9581015                my $envname = $$_[1];
    959 
    960                 unless($cmd =~ /\$LISTOPT/) {
     1016                my $cmd = $$_[2];
     1017                my $listcmd = $$_[3];
     1018
     1019                unless (defined($listcmd)) {
    9611020                        warn("Unable to list tests in $name");
     1021                        # Rather than ignoring this testsuite altogether, just pretend the entire testsuite is
     1022                        # a single "test".
     1023                        print "$name\n";
    9621024                        next;
    9631025                }
    9641026
    965                 $cmd =~ s/\$LISTOPT/--list/g;
    966 
    967                 system($cmd);
     1027                system($listcmd);
    9681028
    9691029                if ($? == -1) {
    970                         die("Unable to run $cmd: $!");
     1030                        die("Unable to run $listcmd: $!");
    9711031                } elsif ($? & 127) {
    972                         die(snprintf("%s died with signal %d, %s coredump\n", $cmd, ($? & 127),  ($? & 128) ? 'with' : 'without'));
     1032                        die(sprintf("%s died with signal %d, %s coredump\n", $listcmd, ($? & 127),  ($? & 128) ? 'with' : 'without'));
    9731033                }
    9741034
     
    9901050                        Subunit::end_testsuite($name, "error",
    9911051                                "unable to set up environment $envname - exiting");
     1052                        next;
     1053                } elsif ($envvars eq "UNKNOWN") {
     1054                        Subunit::start_testsuite($name);
     1055                        Subunit::end_testsuite($name, "skip",
     1056                                "environment $envname is unknown in this test backend - skipping");
    9921057                        next;
    9931058                }
     
    10021067                                }
    10031068                                $cmd =~ s/\$LOADLIST/--load-list=$listid_file/g;
    1004                         } elsif ($$_[4]) {
    1005                                 $cmd =~ s/\s+[^\s]+\s*$//;
    1006                                 $cmd .= " " . join(' ', @{$individual_tests->{$name}});
     1069                        } else {
     1070                                warn("Unable to run individual tests in $name, it does not support --loadlist.");
    10071071                        }
    10081072                }
Note: See TracChangeset for help on using the changeset viewer.