]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/c/blocks/TestBlocks.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / c / blocks / TestBlocks.py
1 """Test that lldb can invoke blocks and access variables inside them"""
2
3 from __future__ import print_function
4
5
6
7 import unittest2
8 import os, time
9 import lldb
10 from lldbsuite.test.lldbtest import *
11 import lldbsuite.test.lldbutil as lldbutil
12
13 class BlocksTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16     lines = []
17
18     def setUp(self):
19         # Call super's setUp().
20         TestBase.setUp(self)
21         # Find the line numbers to break at.
22         self.lines.append(line_number('main.c', '// Set breakpoint 0 here.'))
23         self.lines.append(line_number('main.c', '// Set breakpoint 1 here.'))
24     
25     @unittest2.expectedFailure("rdar://problem/10413887 - Call blocks in expressions")
26     def test_expr(self):
27         self.build()
28         exe = os.path.join(os.getcwd(), "a.out")
29         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
30
31         self.is_started = False
32
33         # Break inside the foo function which takes a bar_ptr argument.
34         for line in self.lines:
35             lldbutil.run_break_set_by_file_and_line (self, "main.c", line, num_expected_locations=1, loc_exact=True)
36
37         self.wait_for_breakpoint()
38
39         self.expect("expression a + b", VARIABLES_DISPLAYED_CORRECTLY,
40             substrs = ["= 7"])
41
42         self.expect("expression c", VARIABLES_DISPLAYED_CORRECTLY,
43             substrs = ["= 1"])
44
45         self.wait_for_breakpoint()
46
47         # This should display correctly.
48         self.expect("expression (int)neg (-12)", VARIABLES_DISPLAYED_CORRECTLY,
49             substrs = ["= 12"])
50     
51     def wait_for_breakpoint(self):
52         if self.is_started == False:
53             self.is_started = True
54             self.runCmd("process launch", RUN_SUCCEEDED)
55         else:
56             self.runCmd("process continue", RUN_SUCCEEDED)
57
58         # The stop reason of the thread should be breakpoint.
59         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
60             substrs = ['stopped',
61                        'stop reason = breakpoint'])