summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie McClymont <jamiemcclymont@catalyst.net.nz>2018-01-25 17:23:06 +1300
committerAndreas Schneider <asn@cryptomilk.org>2018-03-22 13:26:44 +0100
commitdd1f8cdf6bd1fb9c881d96957d709b0f517852bb (patch)
treeaad38b3302f0be02c47dff614b277f70ec82b1a9
parentba805dcd6f95748d77e24d5de7c31af2ff5848b1 (diff)
downloadsamba-dd1f8cdf6bd1fb9c881d96957d709b0f517852bb.tar.gz
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
-rw-r--r--lib/torture/subunit.c4
-rw-r--r--selftest/Subunit.pm6
-rwxr-xr-xselftest/selftest.pl7
-rw-r--r--source4/torture/rpc/witness.c4
4 files changed, 12 insertions, 9 deletions
diff --git a/lib/torture/subunit.c b/lib/torture/subunit.c
index 46f1b65053d..deb96ffa3a9 100644
--- a/lib/torture/subunit.c
+++ b/lib/torture/subunit.c
@@ -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;
}
diff --git a/selftest/Subunit.pm b/selftest/Subunit.pm
index 1cc0e721696..07f4b8ff97d 100644
--- a/selftest/Subunit.pm
+++ b/selftest/Subunit.pm
@@ -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 ".") {
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index a772613b8e1..995abd71a04 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -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;
diff --git a/source4/torture/rpc/witness.c b/source4/torture/rpc/witness.c
index 4b44e91dbcf..4e7c682a7ee 100644
--- a/source4/torture/rpc/witness.c
+++ b/source4/torture/rpc/witness.c
@@ -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;
}