diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2012-03-20 02:31:02 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2012-03-26 18:28:06 +0200 |
commit | acd63fdb86769ff4328ccb6a4096181e65e4d30f (patch) | |
tree | 1107b503c8ab6c22dc6e9ebb573e582c0c3dc475 /buildtools/wafsamba | |
parent | 9c5723ab7aa0db9c239027b4783bb1f3986b1dbf (diff) | |
download | samba-acd63fdb86769ff4328ccb6a4096181e65e4d30f.tar.gz samba-acd63fdb86769ff4328ccb6a4096181e65e4d30f.tar.bz2 samba-acd63fdb86769ff4328ccb6a4096181e65e4d30f.zip |
wafsamba: Cope with slight differences in gdb output regarding incomplete sequences.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=8820
Diffstat (limited to 'buildtools/wafsamba')
-rw-r--r-- | buildtools/wafsamba/samba_abi.py | 4 | ||||
-rw-r--r-- | buildtools/wafsamba/tests/__init__.py | 1 | ||||
-rw-r--r-- | buildtools/wafsamba/tests/test_abi.py | 53 |
3 files changed, 58 insertions, 0 deletions
diff --git a/buildtools/wafsamba/samba_abi.py b/buildtools/wafsamba/samba_abi.py index 990e1e5fdf..76c2d8b0d4 100644 --- a/buildtools/wafsamba/samba_abi.py +++ b/buildtools/wafsamba/samba_abi.py @@ -18,6 +18,7 @@ def normalise_signature(sig): sig = re.sub('^\$[0-9]+\s=\s\{*', '', sig) sig = re.sub('\}(\s0x[0-9a-f]+\s<\w+>)?$', '', sig) sig = re.sub('0x[0-9a-f]+', '0xXXXX', sig) + sig = re.sub('", <incomplete sequence (\\\\[a-z0-9]+)>', r'\1"', sig) for t in abi_type_maps: # we need to cope with non-word characters in mapped types @@ -30,11 +31,13 @@ def normalise_signature(sig): sig = re.sub(m, abi_type_maps[t], sig) return sig + def normalise_varargs(sig): '''cope with older versions of gdb''' sig = re.sub(',\s\.\.\.', '', sig) return sig + def parse_sigs(sigs, abi_match): '''parse ABI signatures file''' abi_match = samba_utils.TO_LIST(abi_match) @@ -54,6 +57,7 @@ def parse_sigs(sigs, abi_match): break if not matched: continue + print "%s -> %s" % (sa[1], normalise_signature(sa[1])) ret[sa[0]] = normalise_signature(sa[1]) return ret diff --git a/buildtools/wafsamba/tests/__init__.py b/buildtools/wafsamba/tests/__init__.py index 76788802ab..c9f2fb64d7 100644 --- a/buildtools/wafsamba/tests/__init__.py +++ b/buildtools/wafsamba/tests/__init__.py @@ -23,6 +23,7 @@ from unittest import ( def test_suite(): names = [ + 'abi', 'utils', ] module_names = ['wafsamba.tests.test_' + name for name in names] diff --git a/buildtools/wafsamba/tests/test_abi.py b/buildtools/wafsamba/tests/test_abi.py new file mode 100644 index 0000000000..0aa0d56182 --- /dev/null +++ b/buildtools/wafsamba/tests/test_abi.py @@ -0,0 +1,53 @@ +# Copyright (C) 2012 Jelmer Vernooij <jelmer@samba.org> + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +from wafsamba.tests import TestCase + +from wafsamba.samba_abi import ( + normalise_signature, + ) + + +class NormaliseSignatureTests(TestCase): + + def test_function_simple(self): + self.assertEquals("int (const struct GUID *, const struct GUID *)", + normalise_signature("$2 = {int (const struct GUID *, const struct GUID *)} 0xe871 <GUID_compare>")) + + def test_maps_Bool(self): + # Some types have different internal names + self.assertEquals("bool (const struct GUID *)", + normalise_signature("$1 = {_Bool (const struct GUID *)} 0xe75b <GUID_all_zero>")) + + def test_function_keep(self): + self.assertEquals( + "enum ndr_err_code (struct ndr_push *, int, const union winreg_Data *)", + normalise_signature("enum ndr_err_code (struct ndr_push *, int, const union winreg_Data *)")) + + def test_struct_constant(self): + self.assertEquals( + 'uuid = {time_low = 0, time_mid = 0, time_hi_and_version = 0, clock_seq = "\\000", node = "\\000\\000\\000\\000\\000"}, if_version = 0', + normalise_signature('$239 = {uuid = {time_low = 0, time_mid = 0, time_hi_and_version = 0, clock_seq = "\\000", node = "\\000\\000\\000\\000\\000"}, if_version = 0}')) + + def test_incomplete_sequence(self): + # Newer versions of gdb insert these incomplete sequence elements + self.assertEquals( + 'uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\\237\\350", node = "\\b\\000+\\020H`"}, if_version = 2', + normalise_signature('$244 = {uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\\237", <incomplete sequence \\350>, node = "\\b\\000+\\020H`"}, if_version = 2}')) + self.assertEquals( + 'uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\\237\\350", node = "\\b\\000+\\020H`"}, if_version = 2', + normalise_signature('$244 = {uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\\237\\350", node = "\\b\\000+\\020H`"}, if_version = 2}')) + |