51 lines · python
1"""2Test that 'gui' does not crash when adding new threads, which3populate TreeItem's children and may be reallocated elsewhere.4"""5 6import lldb7from lldbsuite.test.decorators import *8from lldbsuite.test.lldbtest import *9from lldbsuite.test.lldbpexpect import PExpectTest10 11import sys12 13 14class TestGuiSpawnThreadsTest(PExpectTest):15 # PExpect uses many timeouts internally and doesn't play well16 # under ASAN on a loaded machine..17 @skipIfAsan18 @skipIfCursesSupportMissing19 def test_gui(self):20 self.build()21 22 self.launch(executable=self.getBuildArtifact("a.out"), dimensions=(100, 500))23 self.expect(24 'breakpoint set -f main.cpp -p "break here"',25 substrs=["Breakpoint 1", "address ="],26 )27 self.expect(28 'breakpoint set -f main.cpp -p "before join"',29 substrs=["Breakpoint 2", "address ="],30 )31 self.expect("run", substrs=["stop reason ="])32 33 escape_key = chr(27).encode()34 35 # Start the GUI36 self.child.sendline("gui")37 self.child.expect_exact("Threads")38 self.child.expect_exact(f"thread #1: tid =")39 40 for i in range(5):41 # Stopped at the breakpoint, continue over the thread creation42 self.child.send("c")43 # Check the newly created thread44 self.child.expect_exact(f"thread #{i + 2}: tid =")45 46 # Exit GUI.47 self.child.send(escape_key)48 self.expect_prompt()49 50 self.quit()51