1 # Copyright 2024 Free Software Foundation, Inc. 2 3 # This program is free software; you can redistribute it and/or modify 4 # it under the terms of the GNU General Public License as published by 5 # the Free Software Foundation; either version 3 of the License, or 6 # (at your option) any later version. 7 # 8 # This program is distributed in the hope that it will be useful, 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # GNU General Public License for more details. 12 # 13 # You should have received a copy of the GNU General Public License 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 # Test cancellation of a "launch" command. 17 18 require allow_dap_tests 19 20 load_lib dap-support.exp 21 22 # Anything will work, we aren't going to run it. 23 standard_testfile sources.c 24 25 if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} { 26 return 27 } 28 29 if {[dap_initialize] == ""} { 30 return 31 } 32 33 set launch_id [dap_launch $testfile] 34 35 # Set a breakpoint. This is done to ensure that the launch request is 36 # definitely in the deferred state when we try to cancel it. 37 set line [gdb_get_line_number "Distinguishing comment"] 38 dap_check_request_and_response "set breakpoint by line number" \ 39 setBreakpoints \ 40 [format {o source [o path [%s]] breakpoints [a [o line [i %d]]]} \ 41 [list s $srcfile] $line] 42 43 set cancel_id [dap_send_request cancel \ 44 [format {o requestId [i %d]} $launch_id]] 45 46 dap_read_response cancel $cancel_id 47 48 # The cancellation isn't actually processed until configurationDone is 49 # sent. While this seems fine, it's unclear if gdb should be more 50 # eager here and try to cancel a deferred task before it is 51 # rescheduled. 52 dap_check_request_and_response "configurationDone" configurationDone 53 54 set resp [lindex [dap_read_response launch $launch_id] 0] 55 gdb_assert {[dict get $resp success] == "false"} \ 56 "launch failed" 57 gdb_assert {[dict get $resp message] == "cancelled"} \ 58 "launch cancelled" 59 60 dap_shutdown 61