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
12class TestGuiExpandThreadsTree(PExpectTest):
13
14    mydir = TestBase.compute_mydir(__file__)
15
16    # PExpect uses many timeouts internally and doesn't play well
17    # under ASAN on a loaded machine..
18    @skipIfAsan
19    @skipIfCursesSupportMissing
20    @skipIf(oslist=["linux"], archs=["arm", "aarch64"])
21    def test_gui(self):
22        self.build()
23
24        self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,500))
25        self.expect("breakpoint set -n break_here", substrs=["Breakpoint 1", "address ="])
26        self.expect("run", substrs=["stop reason ="])
27
28        escape_key = chr(27).encode()
29
30        # Start the GUI and close the welcome window.
31        self.child.sendline("gui")
32        self.child.send(escape_key)
33        self.child.expect_exact("Threads")
34
35        # The thread running thread_start_routine should be expanded.
36        self.child.expect_exact("#0: break_here")
37
38        # Exit GUI.
39        self.child.send(escape_key)
40        self.expect_prompt()
41
42        # Select the main thread.
43        self.child.sendline("thread select 1")
44
45        # Start the GUI.
46        self.child.sendline("gui")
47        self.child.expect_exact("Threads")
48
49        # The main thread should be expanded.
50        self.child.expect("#\d+: main")
51
52        # Quit the GUI
53        self.child.send(escape_key)
54
55        self.expect_prompt()
56        self.quit()
57