]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-file-transfer.exp
Rename to allow_gdbserver_tests
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-file-transfer.exp
CommitLineData
a6b151f1 1# This testcase is part of GDB, the GNU debugger.
213516ef 2# Copyright 2007-2023 Free Software Foundation, Inc.
a6b151f1
DJ
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17# Test gdbserver monitor commands.
18
19load_lib gdbserver-support.exp
20load_lib mi-support.exp
21set MIFLAGS "-i=mi"
22
cadfc59b 23require allow_gdbserver_tests
a6b151f1 24
298a9cf0
TT
25standard_testfile basics.c
26
a6b151f1 27if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
5b362f04 28 untested "failed to compile"
a6b151f1
DJ
29 return -1
30}
31
32gdb_exit
33if [mi_gdb_start] {
cdd42066 34 return
a6b151f1
DJ
35}
36mi_delete_breakpoints
37mi_gdb_reinitialize_dir $srcdir/$subdir
38mi_gdb_file_cmd ${binfile}
39
40proc mi_gdbserver_run { } {
41 mi_gdb_test "kill" ".*" ""
42
43 set res [gdbserver_spawn ""]
44 set protocol [lindex $res 0]
45 set gdbport [lindex $res 1]
46
47 if { [mi_gdb_target_cmd $protocol $gdbport] != 0 } {
48 return -1
49 }
50
51 return 0
52}
53
54proc test_file_transfer { filename description } {
84741506
TT
55 # If we are running everything locally, then we want to be sure to
56 # put the files into the test's standard output location. On the
57 # other hand, if the host or target is remote, then we need to
58 # continue with the "old-style" directory-less approach.
59 if {![is_remote host] && ![is_remote target]} {
60 set up_server [standard_output_file up-server]
61 set down_server [standard_output_file down-server]
62 } else {
63 set up_server up-server
64 set down_server down-server
65 }
66
67 mi_gdb_test "-target-file-put \"$filename\" \"${down_server}\"" \
a6b151f1 68 "\\^done" "put $description"
84741506 69 mi_gdb_test "-target-file-get \"${down_server}\" \"${up_server}\"" \
a6b151f1
DJ
70 "\\^done" "get $description"
71
72 if { ![is_remote target] } {
73 # If we can check the target copy of the file, do that too.
74 # This should catch symmetric errors in upload and download.
84741506 75 set result [remote_exec host "cmp -s $filename ${down_server}"]
a6b151f1
DJ
76 if { [lindex $result 0] == 0 } {
77 pass "compare intermediate $description"
78 } else {
79 fail "compare intermediate $description"
80 }
81 }
82
84741506 83 set result [remote_exec host "cmp -s $filename ${up_server}"]
a6b151f1
DJ
84 if { [lindex $result 0] == 0 } {
85 pass "compare $description"
86 } else {
87 fail "compare $description"
88 }
89
84741506 90 mi_gdb_test "-target-file-delete \"${down_server}\"" \
a6b151f1
DJ
91 "\\^done" "deleted $description"
92
93 if { ![is_remote target] } {
84741506 94 if { ! [remote_file target exists ${down_server}] } {
a6b151f1
DJ
95 pass "verified deleted $description"
96 } else {
97 fail "verified deleted $description"
98 }
99 }
100
84741506 101 catch { file delete ${up_server} }
a6b151f1
DJ
102}
103
104mi_gdbserver_run
105
106test_file_transfer "$binfile" "binary file"
107
108mi_gdb_exit