6
6
from lldbsuite.test.lldbpexpect import PExpectTest
7
7
8
8
9
+ # PExpect uses many timeouts internally and doesn't play well
10
+ # under ASAN on a loaded machine..
11
+ @skipIfAsan
9
12
class TestStatusline(PExpectTest):
13
+ # Change this value to something smaller to make debugging this test less
14
+ # tedious.
15
+ TIMEOUT = 60
16
+
17
+ TERMINAL_HEIGHT = 10
18
+ TERMINAL_WIDTH = 60
19
+
10
20
def do_setup(self):
11
21
# Create a target and run to a breakpoint.
12
22
exe = self.getBuildArtifact("a.out")
@@ -15,36 +25,34 @@ def do_setup(self):
15
25
)
16
26
self.expect('breakpoint set -p "Break here"', substrs=["Breakpoint 1"])
17
27
self.expect("run", substrs=["stop reason"])
28
+ self.resize()
29
+
30
+ def resize(self):
31
+ # Change the terminal dimensions. When we launch the tests, we reset
32
+ # all the settings, leaving the terminal dimensions unset.
33
+ self.child.setwinsize(self.TERMINAL_HEIGHT, self.TERMINAL_WIDTH)
18
34
19
- # PExpect uses many timeouts internally and doesn't play well
20
- # under ASAN on a loaded machine..
21
- @skipIfAsan
22
35
def test(self):
23
36
"""Basic test for the statusline."""
24
37
self.build()
25
- self.launch()
38
+ self.launch(timeout=self.TIMEOUT )
26
39
self.do_setup()
27
40
28
- # Change the terminal dimensions.
29
- terminal_height = 10
30
- terminal_width = 60
31
- self.child.setwinsize(terminal_height, terminal_width)
32
-
33
41
# Enable the statusline and check for the control character and that we
34
42
# can see the target, the location and the stop reason.
35
43
self.expect('set set separator "| "')
36
44
self.expect(
37
45
"set set show-statusline true",
38
46
[
39
- "\x1b[0;{}r".format(terminal_height - 1),
47
+ "\x1b[0;{}r".format(self.TERMINAL_HEIGHT - 1),
40
48
"a.out | main.c:2:11 | breakpoint 1.1 ",
41
49
],
42
50
)
43
51
44
52
# Change the terminal dimensions and make sure it's reflected immediately.
45
- self.child.setwinsize(terminal_height , 25)
53
+ self.child.setwinsize(self.TERMINAL_HEIGHT , 25)
46
54
self.child.expect(re.escape("a.out | main.c:2:11 | bre"))
47
- self.child.setwinsize(terminal_height, terminal_width )
55
+ self.child.setwinsize(self.TERMINAL_HEIGHT, self.TERMINAL_WIDTH )
48
56
49
57
# Change the separator.
50
58
self.expect('set set separator "S "', ["a.out S main.c:2:11"])
@@ -58,23 +66,15 @@ def test(self):
58
66
59
67
# Hide the statusline and check or the control character.
60
68
self.expect(
61
- "set set show-statusline false", ["\x1b[0;{}r".format(terminal_height )]
69
+ "set set show-statusline false", ["\x1b[0;{}r".format(self.TERMINAL_HEIGHT )]
62
70
)
63
71
64
- # PExpect uses many timeouts internally and doesn't play well
65
- # under ASAN on a loaded machine..
66
- @skipIfAsan
67
72
def test_no_color(self):
68
73
"""Basic test for the statusline with colors disabled."""
69
74
self.build()
70
- self.launch(use_colors=False)
75
+ self.launch(use_colors=False, timeout=self.TIMEOUT )
71
76
self.do_setup()
72
77
73
- # Change the terminal dimensions.
74
- terminal_height = 10
75
- terminal_width = 60
76
- self.child.setwinsize(terminal_height, terminal_width)
77
-
78
78
# Enable the statusline and check for the "reverse video" control character.
79
79
self.expect(
80
80
"set set show-statusline true",
@@ -87,15 +87,20 @@ def test_deadlock(self):
87
87
"""Regression test for lock inversion between the statusline mutex and
88
88
the output mutex."""
89
89
self.build()
90
- self.launch(extra_args=["-o", "settings set use-color false"])
90
+ self.launch(
91
+ extra_args=["-o", "settings set use-color false"], timeout=self.TIMEOUT
92
+ )
91
93
self.child.expect("(lldb)")
92
-
93
- # Change the terminal dimensions.
94
- terminal_height = 10
95
- terminal_width = 60
96
- self.child.setwinsize(terminal_height, terminal_width)
94
+ self.resize()
97
95
98
96
exe = self.getBuildArtifact("a.out")
99
97
100
98
self.expect("file {}".format(exe), ["Current executable"])
101
99
self.expect("help", ["Debugger commands"])
100
+
101
+ def test_no_target(self):
102
+ """Test that we print "no target" when launched without a target."""
103
+ self.launch(timeout=self.TIMEOUT)
104
+ self.resize()
105
+
106
+ self.expect("set set show-statusline true", ["no target"])
0 commit comments