xref: /llvm-project/lldb/test/API/commands/gui/expand-threads-tree/TestGuiExpandThreadsTree.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test the 'gui' default thread tree expansion.
3The root process tree item and the tree item corresponding to the selected
4thread should be expanded by default.
5"""
6
7import lldb
8from lldbsuite.test.decorators import *
9from lldbsuite.test.lldbtest import *
10from lldbsuite.test.lldbpexpect import PExpectTest
11
12
13class TestGuiExpandThreadsTree(PExpectTest):
14    # PExpect uses many timeouts internally and doesn't play well
15    # under ASAN on a loaded machine..
16    @skipIfAsan
17    @skipIfCursesSupportMissing
18    @skipIf(oslist=["linux"], archs=["arm", "aarch64"])
19    @skipIf(bugnumber="rdar://97460266")
20    def test_gui(self):
21        self.build()
22
23        self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100, 500))
24        self.expect(
25            "breakpoint set -n break_here", substrs=["Breakpoint 1", "address ="]
26        )
27        self.expect("run", substrs=["stop reason ="])
28
29        escape_key = chr(27).encode()
30
31        # Start the GUI and close the welcome window.
32        self.child.sendline("gui")
33        self.child.send(escape_key)
34        self.child.expect_exact("Threads")
35
36        # The thread running thread_start_routine should be expanded.
37        self.child.expect_exact("#0: break_here")
38
39        # Exit GUI.
40        self.child.send(escape_key)
41        self.expect_prompt()
42
43        # Select the main thread.
44        self.child.sendline("thread select 1")
45
46        # Start the GUI.
47        self.child.sendline("gui")
48        self.child.expect_exact("Threads")
49
50        # The main thread should be expanded.
51        self.child.expect("#\d+: main")
52
53        # Quit the GUI
54        self.child.send(escape_key)
55
56        self.expect_prompt()
57        self.quit()
58