91 lines · python
1"""2Test lldb-dap RestartRequest.3"""4 5from typing import Dict, Any, List6 7import lldbdap_testcase8from lldbsuite.test.decorators import *9from lldbsuite.test.lldbtest import line_number10 11 12@skipIfBuildType(["debug"])13class TestDAP_restart_console(lldbdap_testcase.DAPTestCaseBase):14 @skipIfAsan15 @skipIfWindows16 @skipIf(oslist=["linux"], archs=["arm$"]) # Always times out on buildbot17 def test_basic_functionality(self):18 """19 Test basic restarting functionality when the process is running in20 a terminal.21 """22 line_A = line_number("main.c", "// breakpoint A")23 line_B = line_number("main.c", "// breakpoint B")24 25 program = self.getBuildArtifact("a.out")26 self.build_and_launch(program, console="integratedTerminal")27 [bp_A, bp_B] = self.set_source_breakpoints("main.c", [line_A, line_B])28 29 # Verify we hit A, then B.30 self.dap_server.request_configurationDone()31 self.verify_breakpoint_hit([bp_A])32 self.dap_server.request_continue()33 self.verify_breakpoint_hit([bp_B])34 35 # Make sure i has been modified from its initial value of 0.36 self.assertEqual(37 int(self.dap_server.get_local_variable_value("i")),38 1234,39 "i != 1234 after hitting breakpoint B",40 )41 42 # Restart.43 self.dap_server.request_restart()44 45 # Finally, check we stop back at A and program state has been reset.46 self.verify_breakpoint_hit([bp_A])47 self.assertEqual(48 int(self.dap_server.get_local_variable_value("i")),49 0,50 "i != 0 after hitting breakpoint A on restart",51 )52 53 # Check breakpoint B54 self.dap_server.request_continue()55 self.verify_breakpoint_hit([bp_B])56 self.assertEqual(57 int(self.dap_server.get_local_variable_value("i")),58 1234,59 "i != 1234 after hitting breakpoint B",60 )61 self.continue_to_exit()62 63 @skipIfAsan64 @skipIfWindows65 @skipIf(oslist=["linux"], archs=["arm$"]) # Always times out on buildbot66 def test_stopOnEntry(self):67 """68 Check that stopOnEntry works correctly when using console.69 """70 program = self.getBuildArtifact("a.out")71 self.build_and_launch(program, console="integratedTerminal", stopOnEntry=True)72 [bp_main] = self.set_function_breakpoints(["main"])73 74 self.dap_server.request_configurationDone()75 self.verify_stop_on_entry()76 77 # Then, if we continue, we should hit the breakpoint at main.78 self.dap_server.request_continue()79 self.verify_breakpoint_hit([bp_main])80 81 # Restart and check that we still get a stopped event before reaching82 # main.83 self.dap_server.request_restart()84 self.verify_stop_on_entry()85 86 # continue to main87 self.dap_server.request_continue()88 self.verify_breakpoint_hit([bp_main])89 90 self.continue_to_exit()91