libsmb: Make cli_qpathinfo_standard() static
[samba4-gss.git] / buildtools / wafsamba / tests / test_abi.py
blobffd5a568e1b5992391817bbd52eada271448f44c
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 io import StringIO
27 class NormaliseSignatureTests(TestCase):
29 def test_function_simple(self):
30 self.assertEqual("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.assertEqual("bool (const struct GUID *)",
36 normalise_signature("$1 = {_Bool (const struct GUID *)} 0xe75b <GUID_all_zero>"))
38 def test_function_keep(self):
39 self.assertEqual(
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.assertEqual(
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.assertEqual(
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.assertEqual(
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.assertEqual(f.getvalue(), """\
66 1.0 {
67 \tglobal:
68 \t\t*;
69 \tlocal:
70 \t\t_end;
71 \t\t__bss_start;
72 \t\t_edata;
74 """)
76 def test_simple(self):
77 # No restrictions.
78 f = StringIO()
79 abi_write_vscript(f, "MYLIB", "1.0", ["0.1"], {
80 "old": "0.1",
81 "new": "1.0"}, ["*"])
82 self.assertEqual(f.getvalue(), """\
83 MYLIB_0.1 {
84 \tglobal:
85 \t\told;
88 1.0 {
89 \tglobal:
90 \t\t*;
91 \tlocal:
92 \t\t_end;
93 \t\t__bss_start;
94 \t\t_edata;
96 """)
98 def test_exclude(self):
99 f = StringIO()
100 abi_write_vscript(f, "MYLIB", "1.0", [], {
101 "exc_old": "0.1",
102 "old": "0.1",
103 "new": "1.0"}, ["!exc_*"])
104 self.assertEqual(f.getvalue(), """\
105 1.0 {
106 \tglobal:
107 \t\t*;
108 \tlocal:
109 \t\texc_*;
110 \t\t_end;
111 \t\t__bss_start;
112 \t\t_edata;
114 """)
116 def test_excludes_and_includes(self):
117 f = StringIO()
118 abi_write_vscript(f, "MYLIB", "1.0", [], {
119 "pub_foo": "1.0",
120 "exc_bar": "1.0",
121 "other": "1.0"
122 }, ["pub_*", "!exc_*"])
123 self.assertEqual(f.getvalue(), """\
124 1.0 {
125 \tglobal:
126 \t\tpub_*;
127 \tlocal:
128 \t\texc_*;
129 \t\t_end;
130 \t\t__bss_start;
131 \t\t_edata;
132 \t\t*;
134 """)