my $singletest_bufferedrunner; # runner ID which is buffering logs
my %runnerids; # runner IDs by number
my @runnersidle; # runner IDs idle and ready to execute a test
-my %runnerfortest; # runner IDs by testnum
-my %countfortest; # test count by testnum
+my %countforrunner; # test count by runner ID
my %runnersrunning; # tests currently running by runner ID
#######################################################################
# some pattern that is allowed to differ, output test results
#
sub compare {
- my ($testnum, $testname, $subject, $firstref, $secondref)=@_;
+ my ($runnerid, $testnum, $testname, $subject, $firstref, $secondref)=@_;
my $result = compareparts($firstref, $secondref);
if(!$short) {
logmsg "\n $testnum: $subject FAILED:\n";
- my $logdir = getlogdir($testnum);
+ my $logdir = getrunnerlogdir($runnerid);
logmsg showdiff($logdir, $firstref, $secondref);
}
elsif(!$automakestyle) {
#######################################################################
-# Return the log directory for the given test
-# There is only one directory for the moment
-sub getlogdir {
- my $testnum = $_[0];
+# Return the log directory for the given test runner ID
+sub getrunnerlogdir {
+ my $runnerid = $_[0];
return $LOGDIR;
}
return -2;
}
- my $logdir = getlogdir($testnum);
+ my $logdir = getrunnerlogdir($runnerid);
my @err = getpart("verify", "errorcode");
my $errorcode = $err[0] || "0";
my $ok="";
subnewlines(0, \$_) for @validstdout;
}
- $res = compare($testnum, $testname, "stdout", \@actual, \@validstdout);
+ $res = compare($runnerid, $testnum, $testname, "stdout", \@actual, \@validstdout);
if($res) {
return -1;
}
chomp($validstderr[-1]);
}
- $res = compare($testnum, $testname, "stderr", \@actual, \@validstderr);
+ $res = compare($runnerid, $testnum, $testname, "stderr", \@actual, \@validstderr);
if($res) {
return -1;
}
return -1;
}
- $res = compare($testnum, $testname, "protocol", \@out, \@protocol);
+ $res = compare($runnerid, $testnum, $testname, "protocol", \@out, \@protocol);
if($res) {
return -1;
}
if(!$replyattr{'nocheck'} && (@reply || $replyattr{'sendzero'})) {
# verify the received data
my @out = loadarray($CURLOUT);
- $res = compare($testnum, $testname, "data", \@out, \@reply);
+ $res = compare($runnerid, $testnum, $testname, "data", \@out, \@reply);
if ($res) {
return -1;
}
}
}
- $res = compare($testnum, $testname, "upload", \@out, \@upload);
+ $res = compare($runnerid, $testnum, $testname, "upload", \@out, \@upload);
if ($res) {
return -1;
}
subnewlines(0, \$_) for @proxyprot;
}
- $res = compare($testnum, $testname, "proxy", \@out, \@proxyprot);
+ $res = compare($runnerid, $testnum, $testname, "proxy", \@out, \@proxyprot);
if($res) {
return -1;
}
@generated = @newgen;
}
- $res = compare($testnum, $testname, "output ($filename)",
+ $res = compare($runnerid, $testnum, $testname, "output ($filename)",
\@generated, \@outfile);
if($res) {
return -1;
if(@socksprot) {
# Verify the sent SOCKS proxy details
my @out = loadarray("$logdir/$SOCKSIN");
- $res = compare($testnum, $testname, "socks", \@out, \@socksprot);
+ $res = compare($runnerid, $testnum, $testname, "socks", \@out, \@socksprot);
if($res) {
return -1;
}
}
if($singletest_state{$runnerid} == ST_INIT) {
- my $logdir = getlogdir($testnum);
+ my $logdir = getrunnerlogdir($runnerid);
# first, remove all lingering log files
if(!cleardir($logdir) && $clearlocks) {
runnerac_clearlocks($runnerid, $logdir);
} elsif($singletest_state{$runnerid} == ST_CLEARLOCKS) {
my ($rid, $logs) = runnerar($runnerid);
logmsg $logs;
- my $logdir = getlogdir($testnum);
+ my $logdir = getrunnerlogdir($runnerid);
cleardir($logdir);
$singletest_state{$runnerid} = ST_INITED;
# Recursively call the state machine again because there is no
if($postmortem) {
# Error indicates an actual problem starting the server, so
# display the server logs
- displaylogs($testnum);
+ displaylogs($rid, $testnum);
}
}
#######################################################################
# Load test file for this test number
- my $logdir = getlogdir($testnum);
+ my $logdir = getrunnerlogdir($runnerid);
loadtest("${logdir}/test${testnum}");
#######################################################################
# Verify that the test succeeded
#
# Load test file for this test number
- my $logdir = getlogdir($testnum);
+ my $logdir = getrunnerlogdir($runnerid);
loadtest("${logdir}/test${testnum}");
readtestkeywords();
cleardir($LOGDIR);
mkdir($LOGDIR, 0777);
$runnerids{$runnernum} = runner_init($LOGDIR, $jobs);
+ my $dir = getrunnerlogdir($runnerids{$runnernum});
runnerready($runnerids{$runnernum});
}
}
sub displaylogs {
- my ($testnum)=@_;
- my $logdir = getlogdir($testnum);
+ my ($runnerid, $testnum)=@_;
+ my $logdir = getrunnerlogdir($runnerid);
opendir(DIR, "$logdir") ||
die "can't open dir: $!";
my @logs = readdir(DIR);
# pick a runner for this new test
my $runnerid = pickrunner($testnum);
- exists $runnerfortest{$testnum} && die "Internal error: test already running";
- $runnerfortest{$testnum} = $runnerid;
- $countfortest{$testnum} = $count;
+ $countforrunner{$runnerid} = $count;
# Start the test
- my $rid = $runnerfortest{$testnum};
- my ($error, $again) = singletest($rid, $testnum, $countfortest{$testnum}, $totaltests);
+ my ($error, $again) = singletest($runnerid, $testnum, $countforrunner{$runnerid}, $totaltests);
if($again) {
# this runner is busy running a test
- $runnersrunning{$rid} = $testnum;
+ $runnersrunning{$runnerid} = $testnum;
} else {
# We make this assumption to avoid having to handle $error here
die "Internal error: test must not complete on first call";
# This runner is ready to be serviced
my $testnum = $runnersrunning{$ridready};
delete $runnersrunning{$ridready};
- my ($error, $again) = singletest($ridready, $testnum, $countfortest{$testnum}, $totaltests);
+ my ($error, $again) = singletest($ridready, $testnum, $countforrunner{$ridready}, $totaltests);
if($again) {
# this runner is busy running a test
$runnersrunning{$ridready} = $testnum;
}
if($postmortem) {
# display all files in $LOGDIR/ in a nice way
- displaylogs($testnum);
+ displaylogs($ridready, $testnum);
}
if($error==2) {
$ign++; # ignored test result counter