1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

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: Jamie McClymont <jamiemcclymont@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas 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
This commit is contained in:
Jamie McClymont 2018-01-25 17:23:06 +13:00 committed by Andreas Schneider
parent ba805dcd6f
commit dd1f8cdf6b
4 changed files with 12 additions and 9 deletions
lib/torture
selftest
source4/torture/rpc

View File

@ -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;
}

View File

@ -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 ".") {

View File

@ -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;

View File

@ -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;
}