blob: 6abe9854ccf29d932b292f5e53199cf63d6d1797 [file] [log] [blame]
Sean Callanan974e9fd2013-04-30 22:05:15 +00001"""
2Tests calling a function by basename
3"""
4
5import lldb
6from lldbtest import *
7import lldbutil
8
9class CallCPPFunctionTestCase(TestBase):
10
11 mydir = os.path.join("lang", "cpp", "call-function")
12
13 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
14 @dsym_test
15 def test_with_dsym_and_run_command(self):
16 """Test calling a function by basename"""
17 self.buildDsym()
18 self.call_cpp_function()
19
Sean Callanand7bb1ba2013-04-30 23:52:02 +000020 @expectedFailureLinux # bugzilla 15854
Sean Callanan974e9fd2013-04-30 22:05:15 +000021 @dwarf_test
22 def test_with_dwarf_and_run_command(self):
23 """Test calling a function by basename"""
24 self.buildDwarf()
25 self.call_cpp_function()
26
27 def setUp(self):
28 TestBase.setUp(self)
29 self.line = line_number('main.cpp', '// breakpoint')
30
31 def call_cpp_function(self):
32 """Test calling a function by basename"""
33 self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
34
35 lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
36
37 self.runCmd("process launch", RUN_SUCCEEDED)
38
39 # The stop reason of the thread should be breakpoint.
40 self.expect("thread list",
41 STOPPED_DUE_TO_BREAKPOINT,
42 substrs = ['stopped', 'stop reason = breakpoint'])
43
44 self.expect("expression -- a_function_to_call()",
45 startstr = "(int) $0 = 0")
46
47if __name__ == '__main__':
48 import atexit
49 lldb.SBDebugger.Initialize()
50 atexit.register(lambda: lldb.SBDebugger.Terminate())
51 unittest2.main()