Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.server / reconnect-ctrl-c.exp
1 # This testcase is part of GDB, the GNU debugger.
2 #
3 # Copyright 2017-2020 Free Software Foundation, Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 # Test that Ctrl-C works after reconnecting.
19
20 load_lib gdbserver-support.exp
21
22 if { [skip_gdbserver_tests] } {
23 verbose "skipping gdbserver tests"
24 return -1
25 }
26
27 if [target_info exists gdb,nointerrupts] {
28 verbose "Skipping reconnect-ctrl-c.exp because of nointerrupts."
29 continue
30 }
31
32 standard_testfile
33 if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
34 return -1
35 }
36
37 # Make sure we're disconnected, in case we're testing with an
38 # extended-remote board, therefore already connected.
39 with_test_prefix "preparation" {
40 gdb_test "disconnect" ".*"
41 }
42
43 # Connect, continue, send Ctrl-C and expect a SIGINT stop.
44
45 proc connect_continue_ctrl_c {} {
46 global gdbserver_protocol gdbserver_gdbport
47
48 set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
49 if ![gdb_assert {$res == 0} "connect"] {
50 return
51 }
52
53 set test "continue for ctrl-c"
54 gdb_test_multiple "continue" $test {
55 -re "Continuing" {
56 pass $test
57 }
58 }
59
60 after 1000 {send_gdb "\003"}
61 gdb_test "" "Program received signal SIGINT.*" "stop with control-c"
62 }
63
64 with_test_prefix "first" {
65 # Start GDBserver.
66 set gdbserver_reconnect_p 1
67 set res [gdbserver_start "" $binfile]
68 set gdbserver_protocol [lindex $res 0]
69 set gdbserver_gdbport [lindex $res 1]
70
71 connect_continue_ctrl_c
72 }
73
74 with_test_prefix "second" {
75 gdb_test "disconnect" "Ending remote debugging."
76 connect_continue_ctrl_c
77 }
This page took 0.031088 seconds and 4 git commands to generate.