Newer
Older
$string .= "\n" unless ($string =~ /\n$/);
$string =~ tr/\n//;
for my $line (split("\n", $string)) {
$line =~ s/\s*\!$//;
if ($truncate) {
push @tail, " $line\n";
} else {
logmsg " $line\n";
}
$linecount++;
$truncate = $linecount > 1000;
}
}
if (@tail) {
logmsg "=== File too long: lines here were removed\n";
# This won't work properly if time stamps are enabled in logmsg
logmsg join('',@tail[$#tail-200..$#tail]);
Daniel Stenberg
committed
}
}
sub displaylogs {
my ($testnum)=@_;
opendir(DIR, "$LOGDIR") ||
Daniel Stenberg
committed
die "can't open dir: $!";
my @logs = readdir(DIR);
closedir(DIR);
logmsg "== Contents of files in the $LOGDIR/ dir after test $testnum\n";
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
foreach my $log (sort @logs) {
if($log =~ /\.(\.|)$/) {
next; # skip "." and ".."
}
if($log =~ /^\.nfs/) {
next; # skip ".nfs"
}
if(($log eq "memdump") || ($log eq "core")) {
next; # skip "memdump" and "core"
}
if((-d "$LOGDIR/$log") || (! -s "$LOGDIR/$log")) {
next; # skip directory and empty files
}
if(($log =~ /^stdout\d+/) && ($log !~ /^stdout$testnum/)) {
next; # skip stdoutNnn of other tests
}
if(($log =~ /^stderr\d+/) && ($log !~ /^stderr$testnum/)) {
next; # skip stderrNnn of other tests
}
if(($log =~ /^upload\d+/) && ($log !~ /^upload$testnum/)) {
next; # skip uploadNnn of other tests
}
if(($log =~ /^curl\d+\.out/) && ($log !~ /^curl$testnum\.out/)) {
next; # skip curlNnn.out of other tests
}
if(($log =~ /^test\d+\.txt/) && ($log !~ /^test$testnum\.txt/)) {
next; # skip testNnn.txt of other tests
Daniel Stenberg
committed
}
if(($log =~ /^file\d+\.txt/) && ($log !~ /^file$testnum\.txt/)) {
next; # skip fileNnn.txt of other tests
}
if(($log =~ /^valgrind\d+/) && ($log !~ /^valgrind$testnum/)) {
next; # skip valgrindNnn of other tests
}
logmsg "=== Start of file $log\n";
displaylogcontent("$LOGDIR/$log");
logmsg "=== End of file $log\n";
Daniel Stenberg
committed
}
}
#######################################################################
# The main test-loop
#
my $ok=0;
my $total=0;
my $lasttest;
my @at = split(" ", $TESTCASES);
$start = time();
foreach $testnum (@at) {
$lasttest = $testnum if($testnum > $lasttest);
$count++;
my $error = singletest($testnum, $count, scalar(@at));
if($error < 0) {
# not a test we can run
$total++; # number of tests we've run
if($error>0) {
Daniel Stenberg
committed
if($postmortem) {
# display all files in log/ in a nice way
displaylogs($testnum);
Daniel Stenberg
committed
}
if(!$anyway) {
# a test failed, abort
logmsg "\n - abort tests\n";
elsif(!$error) {
$ok++; # successful test counter
#######################################################################
# Close command log
#
# Tests done, stop the servers
unlink($SOCKSPIDFILE);
Daniel Stenberg
committed
my $all = $total + $skipped;
if($total) {
logmsg sprintf("TESTDONE: $ok tests out of $total reported OK: %d%%\n",
$ok/$total*100);
if($ok != $total) {
logmsg "TESTFAIL: These test cases failed: $failed\n";
}
else {
logmsg "TESTFAIL: No tests were performed\n";
Daniel Stenberg
committed
if($all) {
my $sofar = time()-$start;
logmsg "TESTDONE: $all tests were considered during $sofar seconds.\n";
Daniel Stenberg
committed
}
my $s=0;
logmsg "TESTINFO: $skipped tests were skipped due to these restraints:\n";
for(keys %skipped) {
my $r = $_;
Daniel Stenberg
committed
printf "TESTINFO: \"%s\" %d times (", $r, $skipped{$_};
# now show all test case numbers that had this reason for being
# skipped
my $c=0;
for(0 .. scalar @teststat) {
my $t = $_;
if($teststat[$_] eq $r) {
logmsg ", " if($c);
logmsg $_;
$c++;
}
}
}
Daniel Stenberg
committed
}
if($total && ($ok != $total)) {
exit 1;
}