librpc: Shorten dcerpc_binding_handle_call a bit
[Samba/gebeck_regimport.git] / buildtools / wafsamba / tests / test_abi.py
blobbba78c1ba0745b37a59a50ee71d9c31b0c63ae7d
1 # Copyright (C) 2012 Jelmer Vernooij <jelmer@samba.org>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU Lesser General Public License as published by
5 # the Free Software Foundation; either version 2.1 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 from wafsamba.tests import TestCase
19 from wafsamba.samba_abi import (
20 abi_write_vscript,
21 normalise_signature,
24 from cStringIO import StringIO
27 class NormaliseSignatureTests(TestCase):
29 def test_function_simple(self):
30 self.assertEquals("int (const struct GUID *, const struct GUID *)",
31 normalise_signature("$2 = {int (const struct GUID *, const struct GUID *)} 0xe871 <GUID_compare>"))
33 def test_maps_Bool(self):
34 # Some types have different internal names
35 self.assertEquals("bool (const struct GUID *)",
36 normalise_signature("$1 = {_Bool (const struct GUID *)} 0xe75b <GUID_all_zero>"))
38 def test_function_keep(self):
39 self.assertEquals(
40 "enum ndr_err_code (struct ndr_push *, int, const union winreg_Data *)",
41 normalise_signature("enum ndr_err_code (struct ndr_push *, int, const union winreg_Data *)"))
43 def test_struct_constant(self):
44 self.assertEquals(
45 'uuid = {time_low = 0, time_mid = 0, time_hi_and_version = 0, clock_seq = "\\000", node = "\\000\\000\\000\\000\\000"}, if_version = 0',
46 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}'))
48 def test_incomplete_sequence(self):
49 # Newer versions of gdb insert these incomplete sequence elements
50 self.assertEquals(
51 'uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\\237\\350", node = "\\b\\000+\\020H`"}, if_version = 2',
52 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}'))
53 self.assertEquals(
54 'uuid = {time_low = 2324192516, time_mid = 7403, time_hi_and_version = 4553, clock_seq = "\\237\\350", node = "\\b\\000+\\020H`"}, if_version = 2',
55 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}'))
58 class WriteVscriptTests(TestCase):
60 def test_one(self):
61 f = StringIO()
62 abi_write_vscript(f, "MYLIB", "1.0", [], {
63 "old": "1.0",
64 "new": "1.0"}, ["*"])
65 self.assertEquals(f.getvalue(), """\
66 1.0 {
67 \tglobal:
68 \t\t*;
70 """)
72 def test_simple(self):
73 # No restrictions.
74 f = StringIO()
75 abi_write_vscript(f, "MYLIB", "1.0", ["0.1"], {
76 "old": "0.1",
77 "new": "1.0"}, ["*"])
78 self.assertEquals(f.getvalue(), """\
79 MYLIB_0.1 {
80 \tglobal:
81 \t\told;
84 1.0 {
85 \tglobal:
86 \t\t*;
88 """)
90 def test_exclude(self):
91 f = StringIO()
92 abi_write_vscript(f, "MYLIB", "1.0", [], {
93 "exc_old": "0.1",
94 "old": "0.1",
95 "new": "1.0"}, ["!exc_*"])
96 self.assertEquals(f.getvalue(), """\
97 1.0 {
98 \tglobal:
99 \t\t*;
100 \tlocal:
101 \t\texc_*;
103 """)
105 def test_excludes_and_includes(self):
106 f = StringIO()
107 abi_write_vscript(f, "MYLIB", "1.0", [], {
108 "pub_foo": "1.0",
109 "exc_bar": "1.0",
110 "other": "1.0"
111 }, ["pub_*", "!exc_*"])
112 self.assertEquals(f.getvalue(), """\
113 1.0 {
114 \tglobal:
115 \t\tpub_*;
116 \tlocal:
117 \t\texc_*;
118 \t\t*;
120 """)