]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.server/file-transfer.exp
d96dbcd3258e116470405745f27fbb04c76ad08b
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.server / file-transfer.exp
1 # This testcase is part of GDB, the GNU debugger.
2 # Copyright 2007-2016 Free Software Foundation, Inc.
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
19 load_lib gdbserver-support.exp
20
21 standard_testfile server.c
22
23 if { [skip_gdbserver_tests] } {
24 return 0
25 }
26
27 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
28 return -1
29 }
30
31 # Make sure we're disconnected, in case we're testing with an
32 # extended-remote board, therefore already connected.
33 gdb_test "disconnect" ".*"
34
35 gdbserver_run ""
36
37 proc test_file_transfer { filename description } {
38 set up_server up-server
39 set down_server down-server
40 if {![is_remote host] && ![is_remote target]} {
41 set up_server [standard_output_file $up_server]
42 set down_server [standard_output_file $down_server]
43 }
44
45 gdb_test "remote put \"$filename\" $down_server" \
46 "Successfully sent .*" "put $description"
47 gdb_test "remote get $down_server $up_server" \
48 "Successfully fetched .*" "get $description"
49
50 if { ![is_remote target] } {
51 # If we can check the target copy of the file, do that too.
52 # This should catch symmetric errors in upload and download.
53 set result [remote_exec host "cmp -s $filename $down_server"]
54 if { [lindex $result 0] == 0 } {
55 pass "compare intermediate $description"
56 } else {
57 fail "compare intermediate $description"
58 }
59 }
60
61 set result [remote_exec host "cmp -s $filename $up_server"]
62 if { [lindex $result 0] == 0 } {
63 pass "compare $description"
64 } else {
65 fail "compare $description"
66 }
67
68 gdb_test "remote delete $down_server" \
69 "Successfully deleted .*" "deleted $description"
70
71 if { ![is_remote target] } {
72 if { ! [remote_file target exists $down_server] } {
73 pass "verified deleted $description"
74 } else {
75 fail "verified deleted $description"
76 }
77 }
78
79 catch { file delete $up_server }
80 }
81
82 test_file_transfer "$binfile" "binary file"
83 test_file_transfer "$srcdir/$subdir/transfer.txt" "text file"