1"""Test that importing modules in Objective-C works as expected."""
2
3
4
5import unittest2
6import lldb
7
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test import lldbutil
11
12
13class ObjCModulesAutoImportTestCase(TestBase):
14
15    mydir = TestBase.compute_mydir(__file__)
16
17    def setUp(self):
18        # Call super's setUp().
19        TestBase.setUp(self)
20        # Find the line number to break inside main().
21        self.line = line_number('main.m', '// Set breakpoint 0 here.')
22
23    @skipIf(macos_version=["<", "10.12"])
24    def test_expr(self):
25        self.build()
26        exe = self.getBuildArtifact("a.out")
27        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
28
29        # Break inside the foo function which takes a bar_ptr argument.
30        lldbutil.run_break_set_by_file_and_line(
31            self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
32
33        self.runCmd("run", RUN_SUCCEEDED)
34
35        # The stop reason of the thread should be breakpoint.
36        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
37                    substrs=['stopped',
38                             'stop reason = breakpoint'])
39
40        # The breakpoint should have a hit count of 1.
41        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
42                    substrs=[' resolved, hit count = 1'])
43
44        self.runCmd("settings set target.auto-import-clang-modules true")
45
46        self.expect("p getpid()", VARIABLES_DISPLAYED_CORRECTLY,
47                    substrs=["pid_t"])
48