xref: /llvm-project/lldb/test/API/lang/objc/modules-auto-import/TestModulesAutoImport.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
199451b44SJordan Rupprecht"""Test that importing modules in Objective-C works as expected."""
299451b44SJordan Rupprecht
399451b44SJordan Rupprecht
499451b44SJordan Rupprechtimport lldb
599451b44SJordan Rupprecht
699451b44SJordan Rupprechtfrom lldbsuite.test.decorators import *
799451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
899451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil
999451b44SJordan Rupprecht
1099451b44SJordan Rupprecht
1199451b44SJordan Rupprechtclass ObjCModulesAutoImportTestCase(TestBase):
1299451b44SJordan Rupprecht    def setUp(self):
1399451b44SJordan Rupprecht        # Call super's setUp().
1499451b44SJordan Rupprecht        TestBase.setUp(self)
1599451b44SJordan Rupprecht        # Find the line number to break inside main().
16*2238dcc3SJonas Devlieghere        self.line = line_number("main.m", "// Set breakpoint 0 here.")
1799451b44SJordan Rupprecht
1899451b44SJordan Rupprecht    @skipIf(macos_version=["<", "10.12"])
1999451b44SJordan Rupprecht    def test_expr(self):
2099451b44SJordan Rupprecht        self.build()
2199451b44SJordan Rupprecht        exe = self.getBuildArtifact("a.out")
2299451b44SJordan Rupprecht        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
2399451b44SJordan Rupprecht
2499451b44SJordan Rupprecht        # Break inside the foo function which takes a bar_ptr argument.
2599451b44SJordan Rupprecht        lldbutil.run_break_set_by_file_and_line(
26*2238dcc3SJonas Devlieghere            self, "main.m", self.line, num_expected_locations=1, loc_exact=True
27*2238dcc3SJonas Devlieghere        )
2899451b44SJordan Rupprecht
2999451b44SJordan Rupprecht        self.runCmd("run", RUN_SUCCEEDED)
3099451b44SJordan Rupprecht
3199451b44SJordan Rupprecht        # The stop reason of the thread should be breakpoint.
32*2238dcc3SJonas Devlieghere        self.expect(
33*2238dcc3SJonas Devlieghere            "thread list",
34*2238dcc3SJonas Devlieghere            STOPPED_DUE_TO_BREAKPOINT,
35*2238dcc3SJonas Devlieghere            substrs=["stopped", "stop reason = breakpoint"],
36*2238dcc3SJonas Devlieghere        )
3799451b44SJordan Rupprecht
3899451b44SJordan Rupprecht        # The breakpoint should have a hit count of 1.
399f0b5f9aSSYNOPSYS\georgiev        lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
4099451b44SJordan Rupprecht
4199451b44SJordan Rupprecht        self.runCmd("settings set target.auto-import-clang-modules true")
4299451b44SJordan Rupprecht
43*2238dcc3SJonas Devlieghere        self.expect(
44*2238dcc3SJonas Devlieghere            "expression getpid()", VARIABLES_DISPLAYED_CORRECTLY, substrs=["pid_t"]
45*2238dcc3SJonas Devlieghere        )
46