Commit dd1f8cdf authored by Jamie McClymont's avatar Jamie McClymont Committed by Andreas Schneider

selftest: consistently produce high-res UTC time

Currently some subunit reporters throughout the codebase provide low-res time,
meaning timestamps jump back and forth in the subunit file. Also, some subunit
reporters produce UTC timestamps while others produce local time. UTC was chosen
as the standard for this commit since all of the timestamps end with a Z (= Zulu
= UTC).
Signed-off-by: default avatarJamie McClymont <jamiemcclymont@catalyst.net.nz>
Reviewed-by: default avatarAndrew Bartlett <abartlet@samba.org>
Reviewed-by: default avatarAndreas Schneider <asn@samba.org>

Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Mar 22 13:26:44 CET 2018 on sn-devel-144
parent ba805dcd
......@@ -62,9 +62,9 @@ static void torture_subunit_report_time(struct torture_context *tctx)
return;
}
tmp = localtime(&tp.tv_sec);
tmp = gmtime(&tp.tv_sec);
if (!tmp) {
perror("localtime");
perror("gmtime");
return;
}
......
......@@ -16,6 +16,7 @@
package Subunit;
use POSIX;
use Time::HiRes;
require Exporter;
@ISA = qw(Exporter);
......@@ -43,10 +44,11 @@ sub end_test($$;$)
}
}
sub report_time($)
sub report_time()
{
my ($time) = @_;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($time);
$time = Time::HiRes::time() unless (defined($time));
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime($time);
$sec = ($time - int($time) + $sec);
my $msg = sprintf("%f", $sec);
if (substr($msg, 1, 1) eq ".") {
......
......@@ -28,6 +28,7 @@ use lib "$RealBin";
use Subunit;
use SocketWrapper;
use target::Samba;
use Time::HiRes qw(time);
eval {
require Time::HiRes;
......@@ -150,9 +151,9 @@ sub run_testsuite($$$$$)
Subunit::start_testsuite($name);
Subunit::progress_push();
Subunit::report_time(time());
Subunit::report_time();
system($cmd);
Subunit::report_time(time());
Subunit::report_time();
Subunit::progress_pop();
if ($? == -1) {
......@@ -781,7 +782,7 @@ my $suitestotal = $#todo + 1;
unless ($opt_list) {
Subunit::progress($suitestotal);
Subunit::report_time(time());
Subunit::report_time();
}
my $i = 0;
......
......@@ -790,9 +790,9 @@ static void torture_subunit_report_time(struct torture_context *tctx)
return;
}
tmp = localtime(&tp.tv_sec);
tmp = gmtime(&tp.tv_sec);
if (!tmp) {
torture_comment(tctx, "failed to call localtime");
torture_comment(tctx, "failed to call gmtime");
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment