ndrdump tests: Make the tests less fragile
authorGary Lockyer <gary@catalyst.net.nz>
Tue, 3 Mar 2020 03:59:19 +0000 (16:59 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 7 Mar 2020 05:09:34 +0000 (05:09 +0000)
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@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/blackbox/ndrdump.py

index 22aa326e20156ffe7cfa6a632939ab5a0bf60de9..0b72684f2703cf0eaa931ccc9fe8c4922d15a3cd 100644 (file)
@@ -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