wafsamba.samba_abi: Add basic unit tests.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 5 Nov 2012 18:36:29 +0000 (19:36 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 5 Nov 2012 21:27:44 +0000 (08:27 +1100)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stephen Gallagher <sgallagh@redhat.com>
buildtools/wafsamba/samba_abi.py
buildtools/wafsamba/tests/test_abi.py

index eb53f8c69fac45cd034bc0bedd39386cd47f15c7..c325b3323e7a2d099ce2ba390b23c352d314cc23 100644 (file)
@@ -176,7 +176,7 @@ def abi_write_vscript(f, libname, current_version, versions, symmap, abi_match):
         if symver == current_version:
             break
         f.write("%s {\n" % symver)
-        if k in invmap:
+        if k in sorted(invmap.keys()):
             f.write("\tglobal:\n")
             for s in invmap.get(k, []):
                 f.write("\t\t%s;\n" % s);
index 0aa0d561823675b686cfd10bbbb24ed798611d4c..42c4697cde7ffd5e8e7f1f59abe0e71158523d6f 100644 (file)
 from wafsamba.tests import TestCase
 
 from wafsamba.samba_abi import (
+    abi_write_vscript,
     normalise_signature,
     )
 
+from cStringIO import StringIO
+
 
 class NormaliseSignatureTests(TestCase):
 
@@ -51,3 +54,50 @@ class NormaliseSignatureTests(TestCase):
             '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}'))
 
+
+class WriteVscriptTests(TestCase):
+
+    def test_one(self):
+        f = StringIO()
+        abi_write_vscript(f, "MYLIB", "1.0", [], {
+            "old": "1.0",
+            "new": "1.0"}, ["*"])
+        self.assertEquals(f.getvalue(), """\
+1.0 {
+\tglobal:
+\t\t*;
+};
+""")
+
+    def test_simple(self):
+        # No restrictions.
+        f = StringIO()
+        abi_write_vscript(f, "MYLIB", "1.0", ["0.1"], {
+            "old": "0.1",
+            "new": "1.0"}, ["*"])
+        self.assertEquals(f.getvalue(), """\
+MYLIB_0.1 {
+\tglobal:
+\t\told;
+};
+
+1.0 {
+\tglobal:
+\t\t*;
+};
+""")
+
+    def test_exclude(self):
+        f = StringIO()
+        abi_write_vscript(f, "MYLIB", "1.0", [], {
+            "exc_old": "0.1",
+            "old": "0.1",
+            "new": "1.0"}, ["!exc_*"])
+        self.assertEquals(f.getvalue(), """\
+1.0 {
+\tglobal:
+\t\t*;
+\tlocal:
+\t\texc_*;
+};
+""")