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