]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/objc/modules/TestObjCModules.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / objc / modules / TestObjCModules.py
1 """Test that importing modules in Objective-C works as expected."""
2
3 from __future__ import print_function
4
5
6
7 import unittest2
8 import os, time
9 import lldb
10 import platform
11 import lldbsuite.test.lldbutil as lldbutil
12
13 from distutils.version import StrictVersion
14
15 from lldbsuite.test.lldbtest import *
16
17 class ObjCModulesTestCase(TestBase):
18
19     mydir = TestBase.compute_mydir(__file__)
20
21     def setUp(self):
22         # Call super's setUp().
23         TestBase.setUp(self)
24         # Find the line number to break inside main().
25         self.line = line_number('main.m', '// Set breakpoint 0 here.')
26
27     @skipUnlessDarwin
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+")
30     def test_expr(self):
31         if not self.applies():
32             return
33
34         self.build()
35         exe = os.path.join(os.getcwd(), "a.out")
36         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
37
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)
40
41         self.runCmd("run", RUN_SUCCEEDED)
42
43         # The stop reason of the thread should be breakpoint.
44         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
45             substrs = ['stopped',
46                        'stop reason = breakpoint'])
47
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'])
51
52         self.expect("expr @import Darwin; 3", VARIABLES_DISPLAYED_CORRECTLY,
53             substrs = ["int", "3"])
54
55         self.expect("expr getpid()", VARIABLES_DISPLAYED_CORRECTLY,
56             substrs = ["pid_t"])
57
58         self.expect("expr @import Foundation; 4", VARIABLES_DISPLAYED_CORRECTLY,
59             substrs = ["int", "4"])
60
61         self.expect("expr string.length", VARIABLES_DISPLAYED_CORRECTLY,
62             substrs = ["NSUInteger", "5"])
63
64         self.expect("expr array.count", VARIABLES_DISPLAYED_CORRECTLY,
65             substrs = ["NSUInteger", "3"])
66
67         self.expect("p *[NSURL URLWithString:@\"http://lldb.llvm.org\"]", VARIABLES_DISPLAYED_CORRECTLY,
68             substrs = ["NSURL", "isa", "_urlString"])
69
70         self.expect("p [NSURL URLWithString:@\"http://lldb.llvm.org\"].scheme", VARIABLES_DISPLAYED_CORRECTLY,
71             substrs = ["http"])