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 (
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
):
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
):
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
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}'))
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
):
62 abi_write_vscript(f
, "MYLIB", "1.0", [], {
65 self
.assertEqual(f
.getvalue(), """\
76 def test_simple(self
):
79 abi_write_vscript(f
, "MYLIB", "1.0", ["0.1"], {
82 self
.assertEqual(f
.getvalue(), """\
98 def test_exclude(self
):
100 abi_write_vscript(f
, "MYLIB", "1.0", [], {
103 "new": "1.0"}, ["!exc_*"])
104 self
.assertEqual(f
.getvalue(), """\
116 def test_excludes_and_includes(self
):
118 abi_write_vscript(f
, "MYLIB", "1.0", [], {
122 }, ["pub_*", "!exc_*"])
123 self
.assertEqual(f
.getvalue(), """\