]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.server/file-transfer.exp
run copyright.sh for 2011.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.server / file-transfer.exp
CommitLineData
a6b151f1 1# This testcase is part of GDB, the GNU debugger.
7b6bb8da 2# Copyright 2007, 2008, 2009, 2010, 2011 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
20
21set testfile "server"
22set srcfile ${testfile}.c
3788363d 23set binfile ${objdir}/${subdir}/file-transfer${EXEEXT}
a6b151f1
DJ
24
25if { [skip_gdbserver_tests] } {
26 return 0
27}
28
29if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
30 untested file-transfer.exp
31 return -1
32}
33
34gdb_exit
35gdb_start
36gdb_load $binfile
37gdb_reinitialize_dir $srcdir/$subdir
38
39gdbserver_run ""
40
41proc test_file_transfer { filename description } {
42 gdb_test "remote put \"$filename\" down-server" \
43 "Successfully sent .*" "put $description"
44 gdb_test "remote get down-server up-server" \
45 "Successfully fetched .*" "get $description"
46
47 if { ![is_remote target] } {
48 # If we can check the target copy of the file, do that too.
49 # This should catch symmetric errors in upload and download.
50 set result [remote_exec host "cmp -s $filename down-server"]
51 if { [lindex $result 0] == 0 } {
52 pass "compare intermediate $description"
53 } else {
54 fail "compare intermediate $description"
55 }
56 }
57
58 set result [remote_exec host "cmp -s $filename up-server"]
59 if { [lindex $result 0] == 0 } {
60 pass "compare $description"
61 } else {
62 fail "compare $description"
63 }
64
65 gdb_test "remote delete down-server" \
66 "Successfully deleted .*" "deleted $description"
67
68 if { ![is_remote target] } {
69 if { ! [remote_file target exists down-server] } {
70 pass "verified deleted $description"
71 } else {
72 fail "verified deleted $description"
73 }
74 }
75
76 catch { file delete up-server }
77}
78
79test_file_transfer "$binfile" "binary file"
80test_file_transfer "$srcdir/$subdir/transfer.txt" "text file"