From: Andrew Bartlett Date: Thu, 14 Nov 2019 00:49:48 +0000 (+1300) Subject: selftest: Test fix for ndrdump of structures by number X-Git-Tag: talloc-2.3.1~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3bdb17a35380237f7b46cc2b453b6b6b7c7a4f8;p=thirdparty%2Fsamba.git selftest: Test fix for ndrdump of structures by number This requires that misc.GUID not move in the IDL, so a comment is added. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14191 Signed-off-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/librpc/idl/misc.idl b/librpc/idl/misc.idl index 0b59ce5c96c..a705b53b5f3 100644 --- a/librpc/idl/misc.idl +++ b/librpc/idl/misc.idl @@ -11,6 +11,12 @@ ] interface misc { + /* + * While structures are not normally known by their order, + * please keep this as the first struct, we use this for a + * test of 'ndrdump misc 0 struct' (this helps debug failures + * from our NDR fuzzing tool, which doesn't use string names) + */ typedef [public,noprint,gensize] struct { uint32 time_low; uint16 time_mid; diff --git a/python/samba/tests/blackbox/ndrdump.py b/python/samba/tests/blackbox/ndrdump.py index b8f467f8e82..8ec138bacb3 100644 --- a/python/samba/tests/blackbox/ndrdump.py +++ b/python/samba/tests/blackbox/ndrdump.py @@ -94,3 +94,19 @@ class NdrDumpTests(BlackboxTestCase): self.assertEqual(actual[:len(expected)], expected.encode('utf-8')) self.assertTrue(actual.endswith(b"dump OK\n")) + + def test_ndrdump_with_binary_struct_number(self): + expected = '''pull returned NT_STATUS_OK + 0 : 33323130-3534-3736-3839-616263646566 +dump OK +''' + try: + actual = self.check_output( + "ndrdump misc 0 struct %s" % + self.data_path("misc-GUID.dat")) + except BlackboxProcessError as e: + self.fail(e) + + # check_output will return bytes + # convert expected to bytes for python 3 + self.assertEqual(actual, expected.encode('utf-8')) diff --git a/source4/librpc/tests/misc-GUID.dat b/source4/librpc/tests/misc-GUID.dat new file mode 100644 index 00000000000..454f6b314bf --- /dev/null +++ b/source4/librpc/tests/misc-GUID.dat @@ -0,0 +1 @@ +0123456789abcdef \ No newline at end of file