[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Sat Mar 7 06:38:01 UTC 2020


The branch, master has been updated
       via  d2d2329b119 audit_logging tests: Fix timezone validation
       via  56e466b4b84 ndrdump tests: Make the tests less fragile
      from  b0ba7cd4f96 vfs_fruit: tmsize prevent overflow Force the type during arithmetic in order to prevent overflow when summing the Time Machine folder size. Increase the precision to off_t (used for file sizes), leave the overflow error traps but with more precise wording.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit d2d2329b11968c000b81b22909f6c4234fc8d101
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Mar 3 10:44:47 2020 +1300

    audit_logging tests: Fix timezone validation
    
    test_audit_get_timestamp used the "%Z" format specifier in strptime,
    this is non-portable.  Updated tests now explicitly set the time zone to
    "UTC".
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Sat Mar  7 06:37:09 UTC 2020 on sn-devel-184

commit 56e466b4b849b7269add03faebeb0a63f9cda827
Author: Gary Lockyer <gary at catalyst.net.nz>
Date:   Tue Mar 3 16:59:19 2020 +1300

    ndrdump tests: Make the tests less fragile
    
    Remove the C source file and line number from the expected output to
    make the tests less likely to break if ndr.c changes.
    
    Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/audit_logging/tests/audit_logging_test.c | 27 +++++++++++++++++++++++----
 python/samba/tests/blackbox/ndrdump.py       |  6 ++++++
 2 files changed, 29 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/audit_logging/tests/audit_logging_test.c b/lib/audit_logging/tests/audit_logging_test.c
index 1efb03b0b51..8c949e5f8fc 100644
--- a/lib/audit_logging/tests/audit_logging_test.c
+++ b/lib/audit_logging/tests/audit_logging_test.c
@@ -796,15 +796,35 @@ static void test_audit_get_timestamp(_UNUSED_ void **state)
 	time_t before;
 	time_t after;
 	time_t actual;
+	char *env_tz = NULL;
+	char *orig_tz = NULL;
 
 	TALLOC_CTX *ctx = talloc_new(NULL);
 
+	/*
+	 * Explicitly set the time zone to UTC to make the test easier
+	 */
+	env_tz = getenv("TZ");
+	if (env_tz != NULL) {
+		orig_tz = talloc_strdup(ctx, env_tz);
+	}
+	setenv("TZ", "UTC", 1);
+
 	before = time(NULL);
 	t = audit_get_timestamp(ctx);
 	after = time(NULL);
 
-
 	c = strptime(t, "%a, %d %b %Y %H:%M:%S", &tm);
+
+	/*
+	 * Restore the time zone if we changed it
+	 */
+	if (orig_tz != NULL) {
+		setenv("TZ", orig_tz, 1);
+		TALLOC_FREE(orig_tz);
+	}
+
+	assert_non_null(c);
 	tm.tm_isdst = -1;
 	if (c != NULL && *c == '.') {
 		char *e;
@@ -812,10 +832,9 @@ static void test_audit_get_timestamp(_UNUSED_ void **state)
 		c = e;
 	}
 	if (c != NULL && *c == ' ') {
-		struct tm tz;
-		c = strptime(c, " %Z", &tz);
+		assert_string_equal(" UTC", c);
+		c += 4;
 	}
-	assert_non_null(c);
 	assert_int_equal(0, strlen(c));
 
 	actual = mktime(&tm);
diff --git a/python/samba/tests/blackbox/ndrdump.py b/python/samba/tests/blackbox/ndrdump.py
index 22aa326e201..0b72684f270 100644
--- a/python/samba/tests/blackbox/ndrdump.py
+++ b/python/samba/tests/blackbox/ndrdump.py
@@ -22,6 +22,7 @@ from __future__ import print_function
 """Blackbox tests for ndrdump."""
 
 import os
+import re
 from samba.tests import BlackboxTestCase, BlackboxProcessError
 
 for p in ["../../../../../source4/librpc/tests",
@@ -436,6 +437,11 @@ dump OK
         except BlackboxProcessError as e:
             self.fail(e)
 
+        # Filter out the C source file and line number
+        regex = rb"\.\./\.\./librpc/ndr/ndr\.c:[0-9]+"
+        actual = re.sub(regex, b"", actual)
+        expected = re.sub(regex, b"", expected)
+
         self.assertEqual(actual, expected)
 
     # Test a print of NULL pointer in manually-written ndr_drsuapi.c


-- 
Samba Shared Repository



More information about the samba-cvs mailing list