]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/audit_logging fix flapping test
authorGary Lockyer <gary@catalyst.net.nz>
Sat, 9 Jun 2018 12:58:51 +0000 (14:58 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 10 Jun 2018 17:02:19 +0000 (19:02 +0200)
Add an adjustment to the before and after values to cater for the
occasional differences between the calculated times.

The exact value of the time stamp is not important what is important is
that is correctly formatted and that the value is reasonable i.e. it's
close enough to the current time.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/audit_logging/tests/audit_logging_test.c

index 6be71f31dbe897e5e8a483aad2f229a3783fd17b..26875c98944445151249923c75b62373c5db8e43 100644 (file)
@@ -219,6 +219,7 @@ static void test_json_add_timestamp(void **state)
        time_t before;
        time_t after;
        time_t actual;
+       const int adjustment = 1;
 
 
        object = json_new_object();
@@ -255,7 +256,10 @@ static void test_json_add_timestamp(void **state)
 
        /*
         * The timestamp should be before <= actual <= after
+        * but we adjust the times to cater for any precision issues.
         */
+       before -= adjustment;
+       after += adjustment;
        assert_true(difftime(actual, before) >= 0);
        assert_true(difftime(after, actual) >= 0);