mirror of
https://github.com/curl/curl.git
synced 2026-07-29 02:13:05 +03:00
runtests: track only the current test timings in runner.pm
This avoids passing these data through through global variables, which soon won't be possible. Ref: #10818
This commit is contained in:
parent
c6e7f6c61f
commit
020cf1c117
3 changed files with 81 additions and 53 deletions
|
|
@ -62,12 +62,6 @@ BEGIN {
|
|||
%feature
|
||||
%keywords
|
||||
@protocols
|
||||
%timesrvrend
|
||||
%timesrvrini
|
||||
%timesrvrlog
|
||||
%timetoolend
|
||||
%timetoolini
|
||||
%timevrfyend
|
||||
);
|
||||
}
|
||||
use pathhelp qw(exe_ext);
|
||||
|
|
@ -117,11 +111,5 @@ our @protocols; # array of lowercase supported protocol servers
|
|||
our %feature; # hash of enabled features
|
||||
our $has_shared; # built as a shared library
|
||||
our %keywords; # hash of keywords from the test spec
|
||||
our %timesrvrini; # timestamp for each test required servers verification start
|
||||
our %timesrvrend; # timestamp for each test required servers verification end
|
||||
our %timetoolini; # timestamp for each test command run starting
|
||||
our %timetoolend; # timestamp for each test command run stopping
|
||||
our %timesrvrlog; # timestamp for each test server logs lock removal
|
||||
our %timevrfyend; # timestamp for each test result verification end
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -369,13 +369,13 @@ sub restore_test_env {
|
|||
#######################################################################
|
||||
# Start the servers needed to run this test case
|
||||
sub singletest_startservers {
|
||||
my ($testnum) = @_;
|
||||
my ($testnum, $testtimings) = @_;
|
||||
|
||||
# remove test server commands file before servers are started/verified
|
||||
unlink($FTPDCMD) if(-f $FTPDCMD);
|
||||
|
||||
# timestamp required servers verification start
|
||||
$timesrvrini{$testnum} = Time::HiRes::time();
|
||||
$$testtimings{"timesrvrini"} = Time::HiRes::time();
|
||||
|
||||
my $why;
|
||||
if (!$listonly) {
|
||||
|
|
@ -395,7 +395,7 @@ sub singletest_startservers {
|
|||
}
|
||||
|
||||
# timestamp required servers verification end
|
||||
$timesrvrend{$testnum} = Time::HiRes::time();
|
||||
$$testtimings{"timesrvrend"} = Time::HiRes::time();
|
||||
|
||||
# remove server output logfile after servers are started/verified
|
||||
unlink($SERVERIN);
|
||||
|
|
@ -566,7 +566,7 @@ sub singletest_prepare {
|
|||
#######################################################################
|
||||
# Run the test command
|
||||
sub singletest_run {
|
||||
my $testnum = $_[0];
|
||||
my ($testnum, $testtimings) = @_;
|
||||
|
||||
# get the command line options to use
|
||||
my ($cmd, @blaha)= getpart("client", "command");
|
||||
|
|
@ -740,7 +740,7 @@ sub singletest_run {
|
|||
$| = 1;
|
||||
|
||||
# timestamp starting of test command
|
||||
$timetoolini{$testnum} = Time::HiRes::time();
|
||||
$$testtimings{"timetoolini"} = Time::HiRes::time();
|
||||
|
||||
# run the command line we built
|
||||
if ($torture) {
|
||||
|
|
@ -759,7 +759,7 @@ sub singletest_run {
|
|||
}
|
||||
|
||||
# timestamp finishing of test command
|
||||
$timetoolend{$testnum} = Time::HiRes::time();
|
||||
$$testtimings{"timetoolend"} = Time::HiRes::time();
|
||||
|
||||
return (0, $cmdres, $dumped_core, $CURLOUT, $tool, use_valgrind() && !$disablevalgrind);
|
||||
}
|
||||
|
|
@ -768,7 +768,7 @@ sub singletest_run {
|
|||
#######################################################################
|
||||
# Clean up after test command
|
||||
sub singletest_clean {
|
||||
my ($testnum, $dumped_core)=@_;
|
||||
my ($testnum, $dumped_core, $testtimings)=@_;
|
||||
|
||||
if(!$dumped_core) {
|
||||
if(-r "core") {
|
||||
|
|
@ -832,7 +832,7 @@ sub singletest_clean {
|
|||
portable_sleep($postcommanddelay) if($postcommanddelay);
|
||||
|
||||
# timestamp removal of server logs advisor read lock
|
||||
$timesrvrlog{$testnum} = Time::HiRes::time();
|
||||
$$testtimings{"timesrvrlog"} = Time::HiRes::time();
|
||||
|
||||
# test definition might instruct to stop some servers
|
||||
# stop also all servers relative to the given one
|
||||
|
|
@ -843,8 +843,6 @@ sub singletest_clean {
|
|||
chomp $server;
|
||||
if(stopserver($server)) {
|
||||
logmsg " killserver FAILED\n";
|
||||
# timestamp test result verification end
|
||||
$timevrfyend{$testnum} = Time::HiRes::time();
|
||||
return 1; # normal error if asked to fail on unexpected alive
|
||||
}
|
||||
}
|
||||
|
|
@ -869,8 +867,6 @@ sub singletest_postcheck {
|
|||
# to clean up, but the result can't be relied upon.
|
||||
if($rc != 0 && !$torture) {
|
||||
logmsg " postcheck FAILED\n";
|
||||
# timestamp test result verification end
|
||||
$timevrfyend{$testnum} = Time::HiRes::time();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
@ -885,9 +881,11 @@ sub singletest_postcheck {
|
|||
sub runner_test_preprocess {
|
||||
my ($testnum)=@_;
|
||||
|
||||
my %testtimings;
|
||||
|
||||
###################################################################
|
||||
# Start the servers needed to run this test case
|
||||
my $why = singletest_startservers($testnum);
|
||||
my $why = singletest_startservers($testnum, \%testtimings);
|
||||
|
||||
if(!$why) {
|
||||
|
||||
|
|
@ -907,7 +905,7 @@ sub runner_test_preprocess {
|
|||
$why = singletest_precheck($testnum);
|
||||
}
|
||||
}
|
||||
return $why;
|
||||
return ($why, \%testtimings);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -919,6 +917,8 @@ sub runner_test_preprocess {
|
|||
sub runner_test_run {
|
||||
my ($testnum)=@_;
|
||||
|
||||
my %testtimings;
|
||||
|
||||
#######################################################################
|
||||
# Prepare the test environment to run this test case
|
||||
my $error = singletest_prepare($testnum);
|
||||
|
|
@ -933,30 +933,31 @@ sub runner_test_run {
|
|||
my $CURLOUT;
|
||||
my $tool;
|
||||
my $usedvalgrind;
|
||||
($error, $cmdres, $dumped_core, $CURLOUT, $tool, $usedvalgrind) = singletest_run($testnum);
|
||||
($error, $cmdres, $dumped_core, $CURLOUT, $tool, $usedvalgrind) = singletest_run($testnum, \%testtimings);
|
||||
if($error) {
|
||||
return -2;
|
||||
return (-2, \%testtimings);
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# Clean up after test command
|
||||
$error = singletest_clean($testnum, $dumped_core);
|
||||
$error = singletest_clean($testnum, $dumped_core, \%testtimings);
|
||||
if($error) {
|
||||
return $error;
|
||||
return ($error, \%testtimings);
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# Verify that the postcheck succeeded
|
||||
$error = singletest_postcheck($testnum);
|
||||
if($error) {
|
||||
return $error;
|
||||
return ($error, \%testtimings);
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
# restore environment variables that were modified
|
||||
restore_test_env(0);
|
||||
|
||||
return (0, $cmdres, $CURLOUT, $tool, $usedvalgrind);
|
||||
|
||||
return (0, \%testtimings, $cmdres, $CURLOUT, $tool, $usedvalgrind);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -143,6 +143,12 @@ my %ignored; # ignored results of test cases
|
|||
my $timestats; # time stamping and stats generation
|
||||
my $fullstats; # show time stats for every single test
|
||||
my %timeprepini; # timestamp for each test preparation start
|
||||
my %timesrvrini; # timestamp for each test required servers verification start
|
||||
my %timesrvrend; # timestamp for each test required servers verification end
|
||||
my %timetoolini; # timestamp for each test command run starting
|
||||
my %timetoolend; # timestamp for each test command run stopping
|
||||
my %timesrvrlog; # timestamp for each test server logs lock removal
|
||||
my %timevrfyend; # timestamp for each test result verification end
|
||||
|
||||
#######################################################################
|
||||
# variables that command line options may set
|
||||
|
|
@ -834,6 +840,28 @@ sub citest_finishtestrun {
|
|||
}
|
||||
|
||||
|
||||
# add one set of test timings from the runner to global set
|
||||
sub updatetesttimings {
|
||||
my ($testnum, %testtimings)=@_;
|
||||
|
||||
if(defined $testtimings{"timesrvrini"}) {
|
||||
$timesrvrini{$testnum} = $testtimings{"timesrvrini"};
|
||||
}
|
||||
if(defined $testtimings{"timesrvrend"}) {
|
||||
$timesrvrend{$testnum} = $testtimings{"timesrvrend"};
|
||||
}
|
||||
if(defined $testtimings{"timetoolini"}) {
|
||||
$timetoolini{$testnum} = $testtimings{"timetoolini"};
|
||||
}
|
||||
if(defined $testtimings{"timetoolend"}) {
|
||||
$timetoolend{$testnum} = $testtimings{"timetoolend"};
|
||||
}
|
||||
if(defined $testtimings{"timesrvrlog"}) {
|
||||
$timesrvrlog{$testnum} = $testtimings{"timesrvrlog"};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#######################################################################
|
||||
# Verify that this test case should be run
|
||||
sub singletest_shouldrun {
|
||||
|
|
@ -1575,7 +1603,9 @@ sub singletest {
|
|||
citest_starttest($testnum);
|
||||
|
||||
if(!$why) {
|
||||
$why = runner_test_preprocess($testnum);
|
||||
my $testtimings;
|
||||
($why, $testtimings) = runner_test_preprocess($testnum);
|
||||
updatetesttimings($testnum, %$testtimings);
|
||||
} else {
|
||||
|
||||
# set zero servers verification time when they aren't started
|
||||
|
|
@ -1597,17 +1627,24 @@ sub singletest {
|
|||
my $CURLOUT;
|
||||
my $tool;
|
||||
my $usedvalgrind;
|
||||
($error, $cmdres, $CURLOUT, $tool, $usedvalgrind) = runner_test_run($testnum);
|
||||
my $testtimings;
|
||||
($error, $testtimings, $cmdres, $CURLOUT, $tool, $usedvalgrind) = runner_test_run($testnum);
|
||||
updatetesttimings($testnum, %$testtimings);
|
||||
if($error == -1) {
|
||||
# return a test failure, either to be reported or to be ignored
|
||||
return $errorreturncode;
|
||||
# no further verification will occur
|
||||
$timevrfyend{$testnum} = Time::HiRes::time();
|
||||
# return a test failure, either to be reported or to be ignored
|
||||
return $errorreturncode;
|
||||
}
|
||||
elsif($error == -2) {
|
||||
timestampskippedevents($testnum);
|
||||
return $error;
|
||||
# fill in the missing timings on error
|
||||
timestampskippedevents($testnum);
|
||||
return $error;
|
||||
}
|
||||
elsif($error > 0) {
|
||||
return $error;
|
||||
# no further verification will occur
|
||||
$timevrfyend{$testnum} = Time::HiRes::time();
|
||||
return $error;
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
|
|
@ -1931,13 +1968,14 @@ while(@ARGV) {
|
|||
elsif($ARGV[0] eq "-r") {
|
||||
# run time statistics needs Time::HiRes
|
||||
if($Time::HiRes::VERSION) {
|
||||
keys(%timeprepini) = 1000;
|
||||
keys(%timesrvrini) = 1000;
|
||||
keys(%timesrvrend) = 1000;
|
||||
keys(%timetoolini) = 1000;
|
||||
keys(%timetoolend) = 1000;
|
||||
keys(%timesrvrlog) = 1000;
|
||||
keys(%timevrfyend) = 1000;
|
||||
# presize hashes appropriately to hold an entire test run
|
||||
keys(%timeprepini) = 2000;
|
||||
keys(%timesrvrini) = 2000;
|
||||
keys(%timesrvrend) = 2000;
|
||||
keys(%timetoolini) = 2000;
|
||||
keys(%timetoolend) = 2000;
|
||||
keys(%timesrvrlog) = 2000;
|
||||
keys(%timevrfyend) = 2000;
|
||||
$timestats=1;
|
||||
$fullstats=0;
|
||||
}
|
||||
|
|
@ -1945,13 +1983,14 @@ while(@ARGV) {
|
|||
elsif($ARGV[0] eq "-rf") {
|
||||
# run time statistics needs Time::HiRes
|
||||
if($Time::HiRes::VERSION) {
|
||||
keys(%timeprepini) = 1000;
|
||||
keys(%timesrvrini) = 1000;
|
||||
keys(%timesrvrend) = 1000;
|
||||
keys(%timetoolini) = 1000;
|
||||
keys(%timetoolend) = 1000;
|
||||
keys(%timesrvrlog) = 1000;
|
||||
keys(%timevrfyend) = 1000;
|
||||
# presize hashes appropriately to hold an entire test run
|
||||
keys(%timeprepini) = 2000;
|
||||
keys(%timesrvrini) = 2000;
|
||||
keys(%timesrvrend) = 2000;
|
||||
keys(%timetoolini) = 2000;
|
||||
keys(%timetoolend) = 2000;
|
||||
keys(%timesrvrlog) = 2000;
|
||||
keys(%timevrfyend) = 2000;
|
||||
$timestats=1;
|
||||
$fullstats=1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue