xref: /llvm-project/lldb/test/API/macosx/version_zero/TestGetVersionZeroVersion.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Read in a library with a version number of 0.0.0, make sure we produce a good version.
3"""
4
5
6import lldb
7from lldbsuite.test.decorators import *
8import lldbsuite.test.lldbutil as lldbutil
9from lldbsuite.test.lldbtest import *
10
11
12class TestGetVersionForZero(TestBase):
13    # If your test case doesn't stress debug info, then
14    # set this to true.  That way it won't be run once for
15    # each debug info format.
16    NO_DEBUG_INFO_TESTCASE = True
17
18    def test_get_version_zero(self):
19        """Read in a library with a version of 0.0.0.  Test SBModule::GetVersion"""
20        self.yaml2obj("libDylib.dylib.yaml", self.getBuildArtifact("libDylib.dylib"))
21        self.do_test()
22
23    def do_test(self):
24        lib_name = "libDylib.dylib"
25        target = lldbutil.run_to_breakpoint_make_target(self, exe_name=lib_name)
26        module = target.FindModule(lldb.SBFileSpec(lib_name))
27        self.assertTrue(module.IsValid(), "Didn't find the libDylib.dylib module")
28        # For now the actual version numbers are wrong for a library of 0.0.0
29        # but the previous code would crash iterating over the resultant
30        # list.  So we are testing that that doesn't happen.
31        did_iterate = False
32        for elem in module.GetVersion():
33            did_iterate = True
34        self.assertTrue(did_iterate, "Didn't get into the GetVersion loop")
35