]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/types/TestRecursiveTypes.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / types / TestRecursiveTypes.py
1 """
2 Test that recursive types are handled correctly.
3 """
4
5 from __future__ import print_function
6
7
8 import lldb
9 import lldbsuite.test.lldbutil as lldbutil
10 import sys
11 from lldbsuite.test.lldbtest import *
12
13
14 class RecursiveTypesTestCase(TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     def setUp(self):
19         # Call super's setUp().
20         TestBase.setUp(self)
21         # disable "There is a running process, kill it and restart?" prompt
22         self.runCmd("settings set auto-confirm true")
23         self.addTearDownHook(
24             lambda: self.runCmd("settings clear auto-confirm"))
25         # Find the line number to break for main.c.
26         self.line = line_number('recursive_type_main.cpp',
27                                 '// Test at this line.')
28
29         self.d1 = {
30             'CXX_SOURCES': 'recursive_type_main.cpp recursive_type_1.cpp'}
31         self.d2 = {
32             'CXX_SOURCES': 'recursive_type_main.cpp recursive_type_2.cpp'}
33
34     def test_recursive_type_1(self):
35         """Test that recursive structs are displayed correctly."""
36         self.build(dictionary=self.d1)
37         self.setTearDownCleanup(dictionary=self.d1)
38         self.print_struct()
39
40     def test_recursive_type_2(self):
41         """Test that recursive structs are displayed correctly."""
42         self.build(dictionary=self.d2)
43         self.setTearDownCleanup(dictionary=self.d2)
44         self.print_struct()
45
46     def print_struct(self):
47         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
48
49         lldbutil.run_break_set_by_file_and_line(
50             self,
51             "recursive_type_main.cpp",
52             self.line,
53             num_expected_locations=-1,
54             loc_exact=True)
55
56         self.runCmd("run", RUN_SUCCEEDED)
57
58         self.expect("print tpi", RUN_SUCCEEDED)
59         self.expect("print *tpi", RUN_SUCCEEDED)