Jonas Devlieghere d689570d7d [lldb] Make TestGuiBasicDebug more lenient
Matt's change to the register allocator in 89baeaef2fa9 changed where we
end up after the `finish`. Before we'd end up on line 4.

* thread #1, queue = 'com.apple.main-thread', stop reason = step out
Return value: (int) $0 = 1
    frame #0: 0x0000000100003f7d a.out`main(argc=1, argv=0x00007ffeefbff630) at main.c:4:3
   1    extern int func();
   2
   3    int main(int argc, char **argv) {
-> 4      func(); // Break here
   5      func(); // Second
   6      return 0;
   7    }

Now, we end up on line 5.

* thread #1, queue = 'com.apple.main-thread', stop reason = step out
Return value: (int) $0 = 1

    frame #0: 0x0000000100003f8d a.out`main(argc=1, argv=0x00007ffeefbff630) at main.c:5:3
   2
   3    int main(int argc, char **argv) {
   4      func(); // Break here
-> 5      func(); // Second
   6      return 0;
   7    }

Given that this is not expected stable to be stable I've made the test a
bit more lenient to accept both scenarios.
2020-09-30 17:06:47 -07:00

51 lines
1.7 KiB
Python

"""
Test the 'gui' shortcuts 's','n','f','u','d' (step in, step over, step out, up, down)
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test.lldbpexpect import PExpectTest
class TestGuiBasicDebugCommandTest(PExpectTest):
mydir = TestBase.compute_mydir(__file__)
# PExpect uses many timeouts internally and doesn't play well
# under ASAN on a loaded machine..
@skipIfAsan
@skipIfCursesSupportMissing
@expectedFailureAll(archs=["aarch64"], oslist=["linux"])
def test_gui(self):
self.build()
self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100,500))
self.expect('br set -f main.c -p "// Break here"', substrs=["Breakpoint 1", "address ="])
self.expect("run", substrs=["stop reason ="])
escape_key = chr(27).encode()
# Start the GUI and close the welcome window.
self.child.sendline("gui")
self.child.send(escape_key)
# Simulate a simple debugging session.
self.child.send("s") # step
self.child.expect("return 1; // In function[^\r\n]+<<< Thread 1: step in")
self.child.send("u") # up
self.child.expect_exact("func(); // Break here")
self.child.send("d") # down
self.child.expect_exact("return 1; // In function")
self.child.send("f") # finish
self.child.expect("<<< Thread 1: step out")
self.child.send("s") # move onto the second one
self.child.expect("<<< Thread 1: step in")
self.child.send("n") # step over
self.child.expect("<<< Thread 1: step over")
# Press escape to quit the gui
self.child.send(escape_key)
self.expect_prompt()
self.quit()