Changeset 988 for vendor/current/selftest/selftest.pl
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/selftest/selftest.pl
r740 r988 16 16 # You should have received a copy of the GNU General Public License 17 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 19 =pod20 21 =head1 NAME22 23 selftest - Samba test runner24 25 =head1 SYNOPSIS26 27 selftest --help28 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 DESCRIPTION32 33 A simple test runner. TESTS is a regular expression with tests to run.34 35 =head1 OPTIONS36 37 =over 438 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 extention54 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 on66 moderately recent systems.67 68 =item I<--socket-wrapper>69 70 Use socket wrapper library for communication with server. Only works71 when the server is running locally.72 73 Will prevent TCP and UDP ports being opened on the local host but74 (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. Possible79 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 format84 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 =back97 98 =head1 ENVIRONMENT99 100 =over 4101 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 =back113 114 =head1 LICENSE115 116 selftest is licensed under the GNU General Public License L<http://www.gnu.org/licenses/gpl.html>.117 118 =head1 AUTHOR119 120 Jelmer Vernooij121 122 =cut123 18 124 19 use strict; … … 133 28 use Subunit; 134 29 use SocketWrapper; 30 use target::Samba; 135 31 136 32 eval { … … 143 39 144 40 my $opt_help = 0; 145 my $opt_target = "samba 4";41 my $opt_target = "samba"; 146 42 my $opt_quick = 0; 147 43 my $opt_socket_wrapper = 0; 148 44 my $opt_socket_wrapper_pcap = undef; 149 45 my $opt_socket_wrapper_keep_pcap = undef; 46 my $opt_random_order = 0; 150 47 my $opt_one = 0; 151 48 my @opt_exclude = (); 152 49 my @opt_include = (); 153 my $opt_verbose = 0;154 my $opt_image = undef;155 50 my $opt_testenv = 0; 156 51 my $opt_list = 0; 157 52 my $ldap = undef; 158 53 my $opt_resetup_env = undef; 159 my $opt_bindir = undef;160 54 my $opt_load_list = undef; 55 my $opt_libnss_wrapper_so_path = ""; 56 my $opt_libresolv_wrapper_so_path = ""; 57 my $opt_libsocket_wrapper_so_path = ""; 58 my $opt_libuid_wrapper_so_path = ""; 59 my $opt_use_dns_faking = 0; 161 60 my @testlists = (); 162 61 163 62 my $srcdir = "."; 164 my $builddir = "."; 165 my $exeext = ""; 63 my $bindir = "./bin"; 166 64 my $prefix = "./st"; 167 65 168 66 my @includes = (); 169 67 my @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;178 68 179 69 sub find_in_list($$) … … 301 191 Generic options: 302 192 --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 305 197 306 198 Paths: 307 199 --prefix=DIR prefix to run tests in [st] 308 200 --srcdir=DIR source directory [.] 309 --builddir=DIR output directory [.] 310 --exeext=EXT executable extention [] 201 --bindir=DIR binaries directory [./bin] 202 203 Preload 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 209 DNS: 210 --use-dns-faking Fake DNS entries rather than talking to our 211 DNS implementation. 311 212 312 213 Target Specific: 313 --socket-wrapper-pcap 214 --socket-wrapper-pcap save traffic to pcap directories 314 215 --socket-wrapper-keep-pcap keep all pcap files, not just those for tests that 315 216 failed 316 217 --socket-wrapper enable socket wrapper 317 --bindir=PATH path to target binaries318 218 319 219 Samba4 Specific: 320 220 --ldap=openldap|fedora-ds back samba onto specified ldap server 321 322 Kvm Specific:323 --image=PATH path to KVM image324 221 325 222 Behaviour: 326 223 --quick run quick overall test 327 224 --one abort when the first test fails 328 --verbose be verbose329 225 --testenv run a shell in the requested test environment 330 226 --list list available tests … … 345 241 'include=s' => \@opt_include, 346 242 'srcdir=s' => \$srcdir, 347 'builddir=s' => \$builddir, 348 'exeext=s' => \$exeext, 349 'verbose' => \$opt_verbose, 243 'bindir=s' => \$bindir, 350 244 'testenv' => \$opt_testenv, 351 245 'list' => \$opt_list, 352 246 'ldap:s' => \$ldap, 353 247 'resetup-environment' => \$opt_resetup_env, 354 'bindir:s' => \$opt_bindir,355 'image=s' => \$opt_image,356 248 'testlist=s' => \@testlists, 249 'random-order' => \$opt_random_order, 357 250 '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 358 256 ); 359 257 … … 372 270 unless (defined($ENV{VALGRIND})) { 373 271 $ENV{VALIDATE} = "validate"; 374 $ENV{MALLOC_CHECK_} = 2;272 $ENV{MALLOC_CHECK_} = 3; 375 273 } 376 274 … … 378 276 $ENV{PYTHONUNBUFFERED} = 1; 379 277 380 my $bindir = ($opt_bindir or "$builddir/bin");381 278 my $bindir_abs = abs_path($bindir); 382 279 … … 402 299 die("using an empty prefix isn't allowed") unless $prefix ne ""; 403 300 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. 307 mkdir($prefix, 0700) unless -d $prefix; 308 chmod 0700, $prefix; 406 309 407 310 my $prefix_abs = abs_path($prefix); … … 410 313 411 314 my $srcdir_abs = abs_path($srcdir); 412 my $builddir_abs = abs_path($builddir);413 315 414 316 die("using an empty absolute prefix isn't allowed") unless $prefix_abs ne ""; … … 420 322 $ENV{SRCDIR} = $srcdir; 421 323 $ENV{SRCDIR_ABS} = $srcdir_abs; 422 $ENV{BUILDDIR} = $builddir;423 $ENV{BUILDDIR_ABS} = $builddir_abs;424 324 $ENV{BINDIR} = $bindir_abs; 425 $ENV{EXEEXT} = $exeext;426 325 427 326 my $tls_enabled = not $opt_quick; … … 449 348 $opt_socket_wrapper = 1; 450 349 } 350 351 my $ld_preload = $ENV{LD_PRELOAD}; 352 353 if ($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 361 if ($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 369 if ($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 377 if ($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; 386 print "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; 451 396 452 397 my $socket_wrapper_dir; … … 454 399 $socket_wrapper_dir = SocketWrapper::setup_dir("$prefix_abs/w", $opt_socket_wrapper_pcap); 455 400 print "SOCKET_WRAPPER_DIR=$socket_wrapper_dir\n"; 456 } els e{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"); 459 404 } 405 } 406 407 if ($opt_use_dns_faking) { 408 print "DNS: Faking nameserver\n"; 409 $ENV{SAMBA_DNS_FAKING} = 1; 460 410 } 461 411 … … 463 413 my $testenv_default = "none"; 464 414 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 419 my $server_maxtime; 420 if ($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 428 if (defined($ENV{SMBD_MAXTIME}) and $ENV{SMBD_MAXTIME} ne "") { 429 $server_maxtime = $ENV{SMBD_MAXTIME}; 430 } 431 432 unless ($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 } 513 442 } 514 443 … … 570 499 } 571 500 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 } 572 521 if ( -d "$clientdir/ncalrpcdir" ) { 573 522 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; 577 563 578 564 open(CF, ">$conffile"); 579 565 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 }585 566 print CF "\tnetbios name = client\n"; 586 567 if (defined($vars->{DOMAIN})) { … … 596 577 private dir = $clientdir/private 597 578 lock dir = $clientdir/lockdir 579 state directory = $clientdir/statedir 580 cache directory = $clientdir/cachedir 598 581 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 601 583 max xmit = 32K 602 584 notify:inotify = false … … 608 590 #We don't want to pass our self-tests if the PAC code is wrong 609 591 gensec:require_pac = true 610 resolv:host file = $prefix_abs/dns_host_file611 592 #We don't want to run 'speed' tests for very long 612 593 torture:timelimit = 1 594 winbind separator = / 595 tls cafile = ${cacert} 596 tls crlfile = ${cacrl_pem} 597 tls verify peer = no_check 613 598 "; 614 599 close(CF); … … 639 624 640 625 while (<IN>) { 641 if (/-- TEST(-LOADLIST| -IDLIST|) --\n/) {626 if (/-- TEST(-LOADLIST|) --\n/) { 642 627 my $supports_loadlist = (defined($1) and $1 eq "-LOADLIST"); 643 my $supports_idlist = (defined($1) and $1 eq "-IDLIST");644 628 my $name = <IN>; 645 629 $name =~ s/\n//g; 646 630 my $env = <IN>; 647 631 $env =~ s/\n//g; 632 my $loadlist; 633 if ($supports_loadlist) { 634 $loadlist = <IN>; 635 $loadlist =~ s/\n//g; 636 } 648 637 my $cmdline = <IN>; 649 638 $cmdline =~ s/\n//g; 650 639 if (should_run_test($name) == 1) { 651 push (@ret, [$name, $env, $cmdline, $ supports_loadlist, $supports_idlist]);640 push (@ret, [$name, $env, $cmdline, $loadlist]); 652 641 } 653 642 } else { … … 655 644 } 656 645 } 657 close(IN) or die("Error creating recipe ");646 close(IN) or die("Error creating recipe from $filename"); 658 647 return @ret; 659 648 } … … 671 660 $ENV{SELFTEST_INTERFACES} = ""; 672 661 } 673 if ($opt_verbose) {674 $ENV{SELFTEST_VERBOSE} = "1";675 } else {676 $ENV{SELFTEST_VERBOSE} = "";677 }678 662 if ($opt_quick) { 679 663 $ENV{SELFTEST_QUICK} = "1"; … … 681 665 $ENV{SELFTEST_QUICK} = ""; 682 666 } 683 $ENV{SELFTEST_TARGET} = $opt_target;684 667 $ENV{SELFTEST_MAXTIME} = $torture_maxtime; 685 668 … … 728 711 if ($match) { 729 712 if (defined($skipreason)) { 713 if (not $opt_list) { 730 714 Subunit::skip_testsuite($name, $skipreason); 715 } 731 716 } else { 732 717 push(@todo, $testsuite); … … 734 719 } 735 720 } elsif (defined($skipreason)) { 736 Subunit::skip_testsuite($name, $skipreason); 721 if (not $opt_list) { 722 Subunit::skip_testsuite($name, $skipreason); 723 } 737 724 } else { 738 725 push(@todo, $testsuite); … … 753 740 my $suitestotal = $#todo + 1; 754 741 755 Subunit::progress($suitestotal); 756 Subunit::report_time(time()); 742 unless ($opt_list) { 743 Subunit::progress($suitestotal); 744 Subunit::report_time(time()); 745 } 757 746 758 747 my $i = 0; … … 777 766 "REALM", 778 767 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 779 778 # domain controller stuff 780 779 "DC_SERVER", 781 780 "DC_SERVER_IP", 781 "DC_SERVER_IPV6", 782 782 "DC_NETBIOSNAME", 783 783 "DC_NETBIOSALIAS", … … 786 786 "MEMBER_SERVER", 787 787 "MEMBER_SERVER_IP", 788 "MEMBER_SERVER_IPV6", 788 789 "MEMBER_NETBIOSNAME", 789 790 "MEMBER_NETBIOSALIAS", … … 792 793 "RPC_PROXY_SERVER", 793 794 "RPC_PROXY_SERVER_IP", 795 "RPC_PROXY_SERVER_IPV6", 794 796 "RPC_PROXY_NETBIOSNAME", 795 797 "RPC_PROXY_NETBIOSALIAS", … … 798 800 "VAMPIRE_DC_SERVER", 799 801 "VAMPIRE_DC_SERVER_IP", 802 "VAMPIRE_DC_SERVER_IPV6", 800 803 "VAMPIRE_DC_NETBIOSNAME", 801 804 "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", 802 811 803 812 # server stuff 804 813 "SERVER", 805 814 "SERVER_IP", 815 "SERVER_IPV6", 806 816 "NETBIOSNAME", 807 817 "NETBIOSALIAS", … … 814 824 "DC_PASSWORD", 815 825 826 # UID/GID for rfc2307 mapping tests 827 "UID_RFC2307TEST", 828 "GID_RFC2307TEST", 829 816 830 # misc stuff 817 831 "KRB5_CONFIG", 818 " WINBINDD_SOCKET_DIR",832 "SELFTEST_WINBINDD_SOCKET_DIR", 819 833 "WINBINDD_PRIV_PIPE_DIR", 820 834 "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", 822 847 ); 823 848 824 $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub { 849 sub sighandler($) 850 { 825 851 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"; 826 859 teardown_env($_) foreach(keys %running_envs); 827 die("Received signal $signame"); 860 system("pstree -p $$"); 861 print "$0: PID[$$]: Exiting...\n"; 862 exit(1); 828 863 }; 864 865 $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = $SIG{PIPE} = \&sighandler; 829 866 830 867 sub setup_env($$) … … 843 880 $option = "client" if $option eq ""; 844 881 845 if ($envname eq "none") { 846 $testenv_vars = {}; 847 } elsif (defined(get_running_env($envname))) { 882 if (defined(get_running_env($envname))) { 848 883 $testenv_vars = get_running_env($envname); 849 884 if (not $testenv_vars->{target}->check_env($testenv_vars)) { … … 853 888 } else { 854 889 $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'"); 857 897 } 858 898 } … … 908 948 { 909 949 my ($envname) = @_; 910 return 1 if ($envname eq "none");911 950 my $env = get_running_env($envname); 912 951 return $env->{target}->check_env($env); … … 917 956 my ($envname) = @_; 918 957 return if ($envname eq "none"); 958 print STDERR "teardown_env($envname)\n"; 919 959 my $env = get_running_env($envname); 920 960 $env->{target}->teardown_env($env); … … 924 964 # This 'global' file needs to be empty when we start 925 965 unlink("$prefix_abs/dns_host_file"); 966 unlink("$prefix_abs/hosts"); 967 968 if ($opt_random_order) { 969 require List::Util; 970 my @newtodo = List::Util::shuffle(@todo); 971 @todo = @newtodo; 972 } 926 973 927 974 if ($opt_testenv) { … … 931 978 my $testenv_vars = setup_env($testenv_name, $prefix); 932 979 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 } 934 983 935 984 $ENV{PIDDIR} = $testenv_vars->{PIDDIR}; … … 938 987 my $envvarstr = exported_envvars_str($testenv_vars); 939 988 940 my $term = ($ENV{TERMINAL} or "xterm -e"); 941 system("$term 'echo -e \" 989 my @term_args = ("echo -e \" 942 990 Welcome to the Samba4 Test environment '$testenv_name' 943 991 … … 950 998 951 999 $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 953 1011 teardown_env($testenv_name); 954 1012 } elsif ($opt_list) { 955 1013 foreach (@todo) { 956 my $cmd = $$_[2];957 1014 my $name = $$_[0]; 958 1015 my $envname = $$_[1]; 959 960 unless($cmd =~ /\$LISTOPT/) { 1016 my $cmd = $$_[2]; 1017 my $listcmd = $$_[3]; 1018 1019 unless (defined($listcmd)) { 961 1020 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"; 962 1024 next; 963 1025 } 964 1026 965 $cmd =~ s/\$LISTOPT/--list/g; 966 967 system($cmd); 1027 system($listcmd); 968 1028 969 1029 if ($? == -1) { 970 die("Unable to run $ cmd: $!");1030 die("Unable to run $listcmd: $!"); 971 1031 } elsif ($? & 127) { 972 die(s nprintf("%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')); 973 1033 } 974 1034 … … 990 1050 Subunit::end_testsuite($name, "error", 991 1051 "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"); 992 1057 next; 993 1058 } … … 1002 1067 } 1003 1068 $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."); 1007 1071 } 1008 1072 }
Note:
See TracChangeset
for help on using the changeset viewer.