xref: /llvm-project/lldb/test/API/commands/gui/viewlarge/TestGuiViewLarge.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1fc0e8fb7SLuboš Luňák"""
2fc0e8fb7SLuboš LuňákTest that the 'gui' displays long lines/names correctly without overruns.
3fc0e8fb7SLuboš Luňák"""
4fc0e8fb7SLuboš Luňák
5fc0e8fb7SLuboš Luňákimport lldb
6fc0e8fb7SLuboš Luňákfrom lldbsuite.test.decorators import *
7fc0e8fb7SLuboš Luňákfrom lldbsuite.test.lldbtest import *
8fc0e8fb7SLuboš Luňákfrom lldbsuite.test.lldbpexpect import PExpectTest
9fc0e8fb7SLuboš Luňák
10fc0e8fb7SLuboš Luňák
11*2238dcc3SJonas Devlieghereclass GuiViewLargeCommandTest(PExpectTest):
12fc0e8fb7SLuboš Luňák    # PExpect uses many timeouts internally and doesn't play well
13fc0e8fb7SLuboš Luňák    # under ASAN on a loaded machine..
14fc0e8fb7SLuboš Luňák    @skipIfAsan
15fc0e8fb7SLuboš Luňák    @skipIfCursesSupportMissing
16fc0e8fb7SLuboš Luňák    @skipIfRemote  # "run" command will not work correctly for remote debug
1799562332SMichał Górny    @expectedFailureNetBSD
18f2128abeSMuhammad Omair Javaid    @skipIf(oslist=["linux"], archs=["arm", "aarch64"])
19fc0e8fb7SLuboš Luňák    def test_gui(self):
20fc0e8fb7SLuboš Luňák        self.build()
21fc0e8fb7SLuboš Luňák
22fc0e8fb7SLuboš Luňák        # Limit columns to 80, so that long lines will not be displayed completely.
23fc0e8fb7SLuboš Luňák        self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100, 80))
24*2238dcc3SJonas Devlieghere        self.expect(
25*2238dcc3SJonas Devlieghere            'br set -f main.c -p "// Break here"', substrs=["Breakpoint 1", "address ="]
26*2238dcc3SJonas Devlieghere        )
27fc0e8fb7SLuboš Luňák        self.expect("run", substrs=["stop reason ="])
28fc0e8fb7SLuboš Luňák
29fc0e8fb7SLuboš Luňák        escape_key = chr(27).encode()
30*2238dcc3SJonas Devlieghere        left_key = chr(27) + "OD"  # for vt100 terminal (lldbexpect sets TERM=vt100)
31*2238dcc3SJonas Devlieghere        right_key = chr(27) + "OC"
32dcd4589aSLuboš Luňák        ctrl_l = chr(12)
33fc0e8fb7SLuboš Luňák
34aaca2acdSLuboš Luňák        # Start the GUI.
35fc0e8fb7SLuboš Luňák        self.child.sendline("gui")
36fc0e8fb7SLuboš Luňák
37fc0e8fb7SLuboš Luňák        # Check the sources window.
38fc0e8fb7SLuboš Luňák        self.child.expect_exact("Sources")
39fc0e8fb7SLuboš Luňák        # The string is copy&pasted from a 80-columns terminal. It will be followed by some
40fc0e8fb7SLuboš Luňák        # kind of an escape sequence (color, frame, etc.).
41*2238dcc3SJonas Devlieghere        self.child.expect_exact(
42*2238dcc3SJonas Devlieghere            "int a_variable_with_a_very_looooooooooooooooooooooooooo" + chr(27)
43*2238dcc3SJonas Devlieghere        )
44fc0e8fb7SLuboš Luňák        # The escape here checks that there's no content drawn by the previous line.
45fc0e8fb7SLuboš Luňák        self.child.expect_exact("int shortvar = 1;" + chr(27))
46fc0e8fb7SLuboš Luňák        # Check the triggered breakpoint marker on a long line.
47fc0e8fb7SLuboš Luňák        self.child.expect_exact("<<< Thread 1: breakpoint 1.1" + chr(27))
48fc0e8fb7SLuboš Luňák
49fc0e8fb7SLuboš Luňák        # Check the variable window.
50fc0e8fb7SLuboš Luňák        self.child.expect_exact("Variables")
51*2238dcc3SJonas Devlieghere        self.child.expect_exact(
52*2238dcc3SJonas Devlieghere            "(int) a_variable_with_a_very_looooooooooooooooooooooooooooooo" + chr(27)
53*2238dcc3SJonas Devlieghere        )
54fc0e8fb7SLuboš Luňák        self.child.expect_exact("(int) shortvar = 1" + chr(27))
55fc0e8fb7SLuboš Luňák
56dcd4589aSLuboš Luňák        # Scroll the sources view twice to the right.
57dcd4589aSLuboš Luňák        self.child.send(right_key)
58dcd4589aSLuboš Luňák        self.child.send(right_key)
59dcd4589aSLuboš Luňák        # Force a redraw, otherwise curses will optimize the drawing to not draw all 'o'.
60dcd4589aSLuboš Luňák        self.child.send(ctrl_l)
61dcd4589aSLuboš Luňák        # The source code is indented by two spaces, so there'll be just two extra 'o' on the right.
62*2238dcc3SJonas Devlieghere        self.child.expect_exact(
63*2238dcc3SJonas Devlieghere            "int a_variable_with_a_very_looooooooooooooooooooooooooooo" + chr(27)
64*2238dcc3SJonas Devlieghere        )
65dcd4589aSLuboš Luňák
66dcd4589aSLuboš Luňák        # And scroll back to the left.
67dcd4589aSLuboš Luňák        self.child.send(left_key)
68dcd4589aSLuboš Luňák        self.child.send(left_key)
69dcd4589aSLuboš Luňák        self.child.send(ctrl_l)
70*2238dcc3SJonas Devlieghere        self.child.expect_exact(
71*2238dcc3SJonas Devlieghere            "int a_variable_with_a_very_looooooooooooooooooooooooooo" + chr(27)
72*2238dcc3SJonas Devlieghere        )
73dcd4589aSLuboš Luňák
74fc0e8fb7SLuboš Luňák        # Press escape to quit the gui
75fc0e8fb7SLuboš Luňák        self.child.send(escape_key)
76fc0e8fb7SLuboš Luňák
77fc0e8fb7SLuboš Luňák        self.expect_prompt()
78fc0e8fb7SLuboš Luňák        self.quit()
79