X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/97cfe3942f67200f77f6ae9b302409075e4e5792..47bc7a521803eaea0d6666c327f2e21e22eb920b:/test/runtest diff --git a/test/runtest b/test/runtest index c52afceaa..c9a07e0f8 100755 --- a/test/runtest +++ b/test/runtest @@ -32,7 +32,7 @@ use FindBin qw'$RealBin'; use lib "$RealBin/lib"; use Exim::Runtest; -use Exim::Utils qw(uniq numerically); +use Exim::Utils qw(uniq numerically cp); use if $ENV{DEBUG} && scalar($ENV{DEBUG} =~ /\bruntest\b/) => 'Smart::Comments' => '####'; use if $ENV{DEBUG} && scalar($ENV{DEBUG} =~ /\bruntest\b/) => 'Data::Dumper'; @@ -738,11 +738,10 @@ RESET_AFTER_EXTRA_LINE_READ: s/\bgid=\d+/gid=gggg/; s/\begid=\d+/egid=gggg/; - s/\b(pid=|PID: )\d+/$1pppp/; + s/\b(pid=|pid |PID: )\d+/$1pppp/; s/\buid=\d+/uid=uuuu/; s/\beuid=\d+/euid=uuuu/; s/set_process_info:\s+\d+/set_process_info: pppp/; - s/queue run pid \d+/queue run pid ppppp/; s/process \d+ running as transport filter/process pppp running as transport filter/; s/process \d+ writing to transport filter/process pppp writing to transport filter/; s/reading pipe for subprocess \d+/reading pipe for subprocess pppp/; @@ -1153,6 +1152,8 @@ RESET_AFTER_EXTRA_LINE_READ: # drop pdkim debugging header next if /^DKIM( <<<<<<<<<<<<<<<<<<<<<<<<<<<<<+|: no signatures)$/; + # Some platforms have TIOCOUTome do not + next if /\d+ bytes remain in socket output buffer$/; # Various other IPv6 lines must be omitted too next if /using host_fake_gethostbyname for \S+ \(IPv6\)/; @@ -1794,7 +1795,7 @@ if (-e $sf_current) if (-s $mf) { my $sf = /^u/i ? $sf_current : $sf_flavour; - tests_exit(-1, "Failed to cp $mf $sf") if system("cp '$mf' '$sf'") != 0; + copy($mf, $sf) or tests_exit(-1, "Failed to copy $mf $sf"); } else { @@ -2157,7 +2158,7 @@ if ($debug) $prcmd =~ s/; /;\n>> /; print ">> $prcmd\n"; } -system("$cmd"); +system($cmd); } @@ -2940,6 +2941,7 @@ GetOptions( 'valgrind' => \$valgrind, 'range=s{2}' => \my @range_wanted, 'test=i@' => \my @tests_wanted, + 'fail-any!' => \my $fail_any, 'flavor|flavour=s' => \$flavour, 'help' => sub { pod2usage(-exit => 0) }, 'man' => sub { @@ -3048,7 +3050,7 @@ my $eximinfo = "$parm_exim -d -C $parm_cwd/test-config -DDIR=$parm_cwd -bP exim_ chomp(my @eximinfo = `$eximinfo 2>&1`); die "$0: Can't run $eximinfo\n" if $? == -1; -warn 'Got ' . $?>>8 . " from $eximinfo\n" if $?; +warn 'Got ' . ($?>>8) . " from $eximinfo\n" if $?; foreach (@eximinfo) { if (my ($version) = /^Exim version (\S+)/) { @@ -3743,37 +3745,16 @@ system("sudo cp eximdir/exim eximdir/exim_exim;" . ($parm_exim_dir) = $parm_exim =~ m?^(.*)/exim?; $dbm_build_deleted = 0; -if (defined $parm_lookups{dbm} && - system("cp $parm_exim_dir/exim_dbmbuild eximdir") != 0) +if (defined $parm_lookups{dbm} && not cp("$parm_exim_dir/exim_dbmbuild", "eximdir/exim_dbmbuild")) { delete $parm_lookups{dbm}; $dbm_build_deleted = 1; } -if (system("cp $parm_exim_dir/exim_dumpdb eximdir") != 0) - { - tests_exit(-1, "Failed to make a copy of exim_dumpdb: $!"); - } - -if (system("cp $parm_exim_dir/exim_lock eximdir") != 0) - { - tests_exit(-1, "Failed to make a copy of exim_lock: $!"); - } - -if (system("cp $parm_exim_dir/exinext eximdir") != 0) - { - tests_exit(-1, "Failed to make a copy of exinext: $!"); - } - -if (system("cp $parm_exim_dir/exigrep eximdir") != 0) - { - tests_exit(-1, "Failed to make a copy of exigrep: $!"); - } - -if (system("cp $parm_exim_dir/eximstats eximdir") != 0) - { - tests_exit(-1, "Failed to make a copy of eximstats: $!"); - } +foreach my $tool (qw(exim_dumpdb exim_lock exinext exigrep eximstats)) { + cp("$parm_exim_dir/$tool" => "eximdir/$tool") + or tests_exit(-1, "Failed to make a copy of $tool: $!"); +} # Collect some version information print '-' x 78, "\n"; @@ -4166,6 +4147,7 @@ if (not $force_continue) { } +my $failures = 0; foreach $test (@test_list) { state $lasttestdir = ''; @@ -4212,15 +4194,15 @@ foreach $test (@test_list) # the test-mail directory for appendfile deliveries. system "sudo /bin/rm -rf spool test-*"; - system "mkdir test-mail 2>/dev/null"; + mkdir "test-mail"; # A privileged Exim will normally make its own spool directory, but some of # the tests run in unprivileged modes that don't always work if the spool # directory isn't already there. What is more, we want anybody to be able # to read it in order to find the daemon's pid. - system "mkdir spool; " . - "sudo chown $parm_eximuser:$parm_eximgroup spool; " . + mkdir "spool"; + system "sudo chown $parm_eximuser:$parm_eximgroup spool; " . "sudo chmod 0755 spool"; # Empty the cache that keeps track of things like message id mappings, and @@ -4399,10 +4381,12 @@ foreach $test (@test_list) print "\nshow stdErr, show stdOut, Retry, Continue (without file comparison), or Quit? [Q] "; $_ = $force_continue ? "c" : ; tests_exit(1) if /^q?$/i; - if (/^c$/ && $force_continue) { - log_failure($log_failed_filename, $testno, "exit code unexpected"); - log_test($log_summary_filename, $testno, 'F') - } + if (/^c$/ && $force_continue) + { + log_failure($log_failed_filename, $testno, "exit code unexpected"); + log_test($log_summary_filename, $testno, 'F'); + $failures++; + } if ($force_continue) { print "\nstdout tail:\n"; @@ -4455,7 +4439,7 @@ foreach $test (@test_list) { if (($? & 0xff) == 0) { printf("Server return code %d for test %d starting line %d", $?/256, - $testno, $subtest_startline); } + $testno, $subtest_startline); } elsif (($? & 0xff00) == 0) { printf("Server killed by signal %d", $? & 255); } else @@ -4466,10 +4450,12 @@ foreach $test (@test_list) print "\nShow server stdout, Retry, Continue, or Quit? [Q] "; $_ = $force_continue ? "c" : ; tests_exit(1) if /^q?$/i; - if (/^c$/ && $force_continue) { - log_failure($log_failed_filename, $testno, "exit code unexpected"); - log_test($log_summary_filename, $testno, 'F') - } + if (/^c$/ && $force_continue) + { + log_failure($log_failed_filename, $testno, "exit code unexpected"); + log_test($log_summary_filename, $testno, 'F'); + $failures++; + } print "... continue forced\n" if $force_continue; last if /^[rc]$/i; @@ -4504,7 +4490,14 @@ foreach $test (@test_list) { sleep 1 if $slow; my $rc = check_output($TEST_STATE->{munge}); - log_test($log_summary_filename, $testno, 'P') if ($rc == 0); + if ($rc == 0) + { + log_test($log_summary_filename, $testno, 'P'); + } + else + { + $failures++; + } if ($rc < 2) { print (" Script completed\n"); @@ -4523,7 +4516,7 @@ foreach $test (@test_list) ################################################## tests_exit(-1, "No runnable tests selected") if not @test_list; -tests_exit(0); +tests_exit($fail_any ? $failures : 0); __END__