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