1 """Test that importing modules in Objective-C works as expected."""
3 from __future__ import print_function
11 import lldbsuite.test.lldbutil as lldbutil
13 from distutils.version import StrictVersion
15 from lldbsuite.test.lldbtest import *
17 class ObjCModulesTestCase(TestBase):
19 mydir = TestBase.compute_mydir(__file__)
22 # Call super's setUp().
24 # Find the line number to break inside main().
25 self.line = line_number('main.m', '// Set breakpoint 0 here.')
28 @unittest2.expectedFailure("rdar://20416388")
29 @unittest2.skipIf(platform.system() != "Darwin" or StrictVersion('12.0.0') > platform.release(), "Only supported on Darwin 12.0.0+")
31 if not self.applies():
35 exe = os.path.join(os.getcwd(), "a.out")
36 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
38 # Break inside the foo function which takes a bar_ptr argument.
39 lldbutil.run_break_set_by_file_and_line (self, "main.m", self.line, num_expected_locations=1, loc_exact=True)
41 self.runCmd("run", RUN_SUCCEEDED)
43 # The stop reason of the thread should be breakpoint.
44 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
46 'stop reason = breakpoint'])
48 # The breakpoint should have a hit count of 1.
49 self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
50 substrs = [' resolved, hit count = 1'])
52 self.expect("expr @import Darwin; 3", VARIABLES_DISPLAYED_CORRECTLY,
53 substrs = ["int", "3"])
55 self.expect("expr getpid()", VARIABLES_DISPLAYED_CORRECTLY,
58 self.expect("expr @import Foundation; 4", VARIABLES_DISPLAYED_CORRECTLY,
59 substrs = ["int", "4"])
61 self.expect("expr string.length", VARIABLES_DISPLAYED_CORRECTLY,
62 substrs = ["NSUInteger", "5"])
64 self.expect("expr array.count", VARIABLES_DISPLAYED_CORRECTLY,
65 substrs = ["NSUInteger", "3"])
67 self.expect("p *[NSURL URLWithString:@\"http://lldb.llvm.org\"]", VARIABLES_DISPLAYED_CORRECTLY,
68 substrs = ["NSURL", "isa", "_urlString"])
70 self.expect("p [NSURL URLWithString:@\"http://lldb.llvm.org\"].scheme", VARIABLES_DISPLAYED_CORRECTLY,