66from  lldbsuite .test .lldbpexpect  import  PExpectTest 
77
88
9+ # PExpect uses many timeouts internally and doesn't play well 
10+ # under ASAN on a loaded machine.. 
11+ @skipIfAsan  
912class  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+ 
1020    def  do_setup (self ):
1121        # Create a target and run to a breakpoint. 
1222        exe  =  self .getBuildArtifact ("a.out" )
@@ -15,36 +25,34 @@ def do_setup(self):
1525        )
1626        self .expect ('breakpoint set -p "Break here"' , substrs = ["Breakpoint 1" ])
1727        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 )
1834
19-     # PExpect uses many timeouts internally and doesn't play well 
20-     # under ASAN on a loaded machine.. 
21-     @skipIfAsan  
2235    def  test (self ):
2336        """Basic test for the statusline.""" 
2437        self .build ()
25-         self .launch ()
38+         self .launch (timeout = self . TIMEOUT )
2639        self .do_setup ()
2740
28-         # Change the terminal dimensions. 
29-         terminal_height  =  10 
30-         terminal_width  =  60 
31-         self .child .setwinsize (terminal_height , terminal_width )
32- 
3341        # Enable the statusline and check for the control character and that we 
3442        # can see the target, the location and the stop reason. 
3543        self .expect ('set set separator "| "' )
3644        self .expect (
3745            "set set show-statusline true" ,
3846            [
39-                 "\x1b [0;{}r" .format (terminal_height  -  1 ),
47+                 "\x1b [0;{}r" .format (self . TERMINAL_HEIGHT  -  1 ),
4048                "a.out | main.c:2:11 | breakpoint 1.1                        " ,
4149            ],
4250        )
4351
4452        # 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 )
4654        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 )
4856
4957        # Change the separator. 
5058        self .expect ('set set separator "S "' , ["a.out S main.c:2:11" ])
@@ -58,23 +66,15 @@ def test(self):
5866
5967        # Hide the statusline and check or the control character. 
6068        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 )]
6270        )
6371
64-     # PExpect uses many timeouts internally and doesn't play well 
65-     # under ASAN on a loaded machine.. 
66-     @skipIfAsan  
6772    def  test_no_color (self ):
6873        """Basic test for the statusline with colors disabled.""" 
6974        self .build ()
70-         self .launch (use_colors = False )
75+         self .launch (use_colors = False ,  timeout = self . TIMEOUT )
7176        self .do_setup ()
7277
73-         # Change the terminal dimensions. 
74-         terminal_height  =  10 
75-         terminal_width  =  60 
76-         self .child .setwinsize (terminal_height , terminal_width )
77- 
7878        # Enable the statusline and check for the "reverse video" control character. 
7979        self .expect (
8080            "set set show-statusline true" ,
@@ -87,15 +87,20 @@ def test_deadlock(self):
8787        """Regression test for lock inversion between the statusline mutex and 
8888        the output mutex.""" 
8989        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+         )
9193        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 ()
9795
9896        exe  =  self .getBuildArtifact ("a.out" )
9997
10098        self .expect ("file {}" .format (exe ), ["Current executable" ])
10199        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