mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
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@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Tue Jun 26 06:09:46 CEST 2018 on sn-devel-144
This commit is contained in:
parent
120fe41073
commit
113da7ac67
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user