Commit | Line | Data |
---|---|---|
a6b151f1 | 1 | # This testcase is part of GDB, the GNU debugger. |
ecd75fc8 | 2 | # Copyright 2007-2014 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 | ||
19 | load_lib gdbserver-support.exp | |
20 | ||
b0963d73 | 21 | standard_testfile server.c |
a6b151f1 DJ |
22 | |
23 | if { [skip_gdbserver_tests] } { | |
24 | return 0 | |
25 | } | |
26 | ||
b0963d73 | 27 | if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { |
a6b151f1 DJ |
28 | return -1 |
29 | } | |
30 | ||
a1999d40 PA |
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 | ||
a6b151f1 DJ |
35 | gdbserver_run "" |
36 | ||
37 | proc test_file_transfer { filename description } { | |
479c8d68 TT |
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" \ | |
a6b151f1 | 46 | "Successfully sent .*" "put $description" |
479c8d68 | 47 | gdb_test "remote get $down_server $up_server" \ |
a6b151f1 DJ |
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. | |
479c8d68 | 53 | set result [remote_exec host "cmp -s $filename $down_server"] |
a6b151f1 DJ |
54 | if { [lindex $result 0] == 0 } { |
55 | pass "compare intermediate $description" | |
56 | } else { | |
57 | fail "compare intermediate $description" | |
58 | } | |
59 | } | |
60 | ||
479c8d68 | 61 | set result [remote_exec host "cmp -s $filename $up_server"] |
a6b151f1 DJ |
62 | if { [lindex $result 0] == 0 } { |
63 | pass "compare $description" | |
64 | } else { | |
65 | fail "compare $description" | |
66 | } | |
67 | ||
479c8d68 | 68 | gdb_test "remote delete $down_server" \ |
a6b151f1 DJ |
69 | "Successfully deleted .*" "deleted $description" |
70 | ||
71 | if { ![is_remote target] } { | |
479c8d68 | 72 | if { ! [remote_file target exists $down_server] } { |
a6b151f1 DJ |
73 | pass "verified deleted $description" |
74 | } else { | |
75 | fail "verified deleted $description" | |
76 | } | |
77 | } | |
78 | ||
479c8d68 | 79 | catch { file delete $up_server } |
a6b151f1 DJ |
80 | } |
81 | ||
82 | test_file_transfer "$binfile" "binary file" | |
83 | test_file_transfer "$srcdir/$subdir/transfer.txt" "text file" |