1 # This testcase is part of GDB, the GNU debugger.
2 # Copyright 2007-2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Test gdbserver monitor commands.
19 load_lib gdbserver-support.exp
20 load_lib mi-support.exp
23 if { [skip_gdbserver_tests] } {
27 standard_testfile basics.c
29 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
30 untested mi-file-transfer.exp
39 mi_gdb_reinitialize_dir $srcdir/$subdir
40 mi_gdb_file_cmd ${binfile}
42 proc mi_gdbserver_run { } {
43 mi_gdb_test "kill" ".*" ""
45 set res [gdbserver_spawn ""]
46 set protocol [lindex $res 0]
47 set gdbport [lindex $res 1]
49 if { [mi_gdb_target_cmd $protocol $gdbport] != 0 } {
56 proc test_file_transfer { filename description } {
57 mi_gdb_test "-target-file-put \"$filename\" \"down-server\"" \
58 "\\^done" "put $description"
59 mi_gdb_test "-target-file-get \"down-server\" \"up-server\"" \
60 "\\^done" "get $description"
62 if { ![is_remote target] } {
63 # If we can check the target copy of the file, do that too.
64 # This should catch symmetric errors in upload and download.
65 set result [remote_exec host "cmp -s $filename down-server"]
66 if { [lindex $result 0] == 0 } {
67 pass "compare intermediate $description"
69 fail "compare intermediate $description"
73 set result [remote_exec host "cmp -s $filename up-server"]
74 if { [lindex $result 0] == 0 } {
75 pass "compare $description"
77 fail "compare $description"
80 mi_gdb_test "-target-file-delete \"down-server\"" \
81 "\\^done" "deleted $description"
83 if { ![is_remote target] } {
84 if { ! [remote_file target exists down-server] } {
85 pass "verified deleted $description"
87 fail "verified deleted $description"
91 catch { file delete up-server }
96 test_file_transfer "$binfile" "binary file"