[PATCH] dsdb audit: Fix flapping test.
Gary Lockyer
gary at catalyst.net.nz
Mon Jun 25 22:40:23 UTC 2018
Fix flapping test:
[242(3560)/242 at 25m3s] samba4.dsdb.samdb.ldb_modules.audit_log
UNEXPECTED(failure):
samba4.dsdb.samdb.ldb_modules.audit_log.test_operation_json_empty(none)
REASON: Exception: Exception: difftime(after, actual) >= 0
../source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c:74: error: Failure!
FAILED (1 failures, 0 errors and 0 unexpected successes in 0 testsuites)
Review and possibly push appreciated
Thanks
Gary
-------------- next part --------------
From aa13dc4440cee69279d38b11dbbc47dc8a910667 Mon Sep 17 00:00:00 2001
From: Gary Lockyer <gary at catalyst.net.nz>
Date: Tue, 26 Jun 2018 09:39:56 +1200
Subject: [PATCH] dsdb audit: Fix timestamp tests
Fix flapping test:
[242(3560)/242 at 25m3s] samba4.dsdb.samdb.ldb_modules.audit_log
UNEXPECTED(failure):
samba4.dsdb.samdb.ldb_modules.audit_log.test_operation_json_empty(none)
REASON: Exception: Exception: difftime(after, actual) >= 0
../source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c:74: error:
The tests truncate the microsecond portion of the time, so the
difference could be less than 0.
Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
---
source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c b/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c
index 6ceea80..e48c239 100644
--- a/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c
+++ b/source4/dsdb/samdb/ldb_modules/tests/test_audit_log.c
@@ -28,6 +28,7 @@ int ldb_audit_log_module_init(const char *version);
#include "lib/ldb/include/ldb_private.h"
#include <regex.h>
+#include <float.h>
/*
* Test helper to check ISO 8601 timestamps for validity
@@ -40,6 +41,7 @@ static void check_timestamp(time_t before, const char* timestamp)
struct tm tm;
time_t after;
time_t actual;
+ const double lower = -1;
after = time(NULL);
@@ -69,9 +71,12 @@ static void check_timestamp(time_t before, const char* timestamp)
/*
* The timestamp should be before <= actual <= after
+ * Note: as the microsecond portion of the time is truncated we use
+ * a -1 as the lower bound for the time difference instead of
+ * zero
*/
- assert_true(difftime(actual, before) >= 0);
- assert_true(difftime(after, actual) >= 0);
+ assert_true(difftime(actual, before) >= lower);
+ assert_true(difftime(after, actual) >= lower);
}
static void test_has_password_changed(void **state)
--
2.7.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20180626/8ab5d466/signature.sig>
More information about the samba-technical
mailing list