xref: /llvm-project/lldb/test/API/commands/gui/basic/TestGuiBasic.py (revision 8f30db8794125db2a768fbb3b20b0b1511ea211c)
1"""
2Test that the 'gui' displays the help window and basic UI.
3"""
4
5import lldb
6from lldbsuite.test.decorators import *
7from lldbsuite.test.lldbtest import *
8from lldbsuite.test.lldbpexpect import PExpectTest
9
10class BasicGuiCommandTest(PExpectTest):
11
12    mydir = TestBase.compute_mydir(__file__)
13
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    def test_gui(self):
20        self.build()
21
22        self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,500))
23        self.expect('br set -f main.c -p "// Break here"', substrs=["Breakpoint 1", "address ="])
24        self.expect("run", substrs=["stop reason ="])
25
26
27        escape_key = chr(27).encode()
28
29        # Start the GUI for the first time and check for the welcome window.
30        self.child.sendline("gui")
31        self.child.expect_exact("Welcome to the LLDB curses GUI.")
32
33        # Press escape to quit the welcome screen
34        self.child.send(escape_key)
35        # Press escape again to quit the gui
36        self.child.send(escape_key)
37        self.expect_prompt()
38
39        # Start the GUI a second time, this time we should have the normal GUI.
40        self.child.sendline("gui")
41        # Check for GUI elements in the menu bar.
42        self.child.expect_exact("Target")
43        self.child.expect_exact("Process")
44        self.child.expect_exact("Thread")
45        self.child.expect_exact("View")
46        self.child.expect_exact("Help")
47
48        # Check the sources window.
49        self.child.expect_exact("Sources")
50        self.child.expect_exact("main")
51        self.child.expect_exact("funky_var_name_that_should_be_rendered")
52
53        # Check the variable window.
54        self.child.expect_exact("Variables")
55        self.child.expect_exact("(int) funky_var_name_that_should_be_rendered = 22")
56
57        # Check the bar at the bottom.
58        self.child.expect_exact("Frame:")
59
60        # Press escape to quit the gui
61        self.child.send(escape_key)
62
63        self.expect_prompt()
64        self.quit()
65