1 # Copyright 2023-2024 Free Software Foundation, Inc.
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 3 of the License, or
5 # (at your option) any later version.
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
12 # You should have received a copy of the GNU General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 # The purpose of this test-case is to test the sanity of the used host/target
18 proc test_remote { remote host_is_target } {
21 set file board-sanity.exp
27 if { $host_is_target } {
28 if { $remote == "host" } {
29 set other_remote "target"
31 set other_remote "host"
35 with_test_prefix cleanup-remote {
36 set res [remote_file $remote delete $file]
37 gdb_assert { [lindex $res 0] == $delete_ok } \
38 "remove $remote copy "
40 set res [remote_file $remote exists $file]
41 gdb_assert { $res != $exists_ok } \
42 "$remote copy does not exist"
44 if { $host_is_target } {
45 set res [remote_file $other_remote exists $file]
46 gdb_assert { $res != $exists_ok } \
47 "$other_remote copy does not exist"
51 with_test_prefix copy-to-remote {
52 set remote_file [remote_download $remote $srcdir/$subdir/$file]
53 gdb_assert { [string equal [file tail $remote_file] $file] == 1} \
54 "remote_download returns valid value"
56 set res [remote_file $remote exists $file]
57 gdb_assert { $res == $exists_ok } \
60 if { $host_is_target } {
61 set res [remote_file $other_remote exists $file]
62 gdb_assert { $res == $exists_ok } \
63 "$other_remote copy exists"
67 with_test_prefix cleanup-build {
68 # Note: we're not comparing with delete_ok, return value seems to be
69 # different for build.
70 set res [remote_file build delete $file]
71 gdb_assert { [string equal $res ""] } \
74 set res [remote_file build exists $file]
75 gdb_assert { $res != $exists_ok } \
76 "build copy does not exist"
79 with_test_prefix copy-from-remote {
80 set build_file [remote_upload $remote $file]
81 gdb_assert { [string equal [file tail $build_file] $file] == 1 } \
82 "remote_upload returns valid value"
84 set res [remote_file $remote delete $file]
85 gdb_assert { [string equal $res $delete_ok] == 1 } \
88 set res [remote_file $remote exists $file]
89 gdb_assert { $res != $exists_ok } \
90 "$remote copy does not exist"
92 if { $host_is_target } {
93 set res [remote_file $other_remote exists $file]
94 gdb_assert { $res != $exists_ok } \
95 "$other_remote copy does not exist"
98 set res [remote_file build exists $file]
99 gdb_assert { $res == $exists_ok } \
102 set res [remote_file $remote delete $file]
103 gdb_assert { $res == $delete_ok } \
108 # Host_is_target == 1 for local-remote-host-native.exp, if as intended specified
109 # with both --target_board and --host_board.
110 if { [info exists host_board] } {
111 set host_is_target [string equal $host_board [target_info name]]
116 foreach_with_prefix remote {host target} {
117 if { [is_remote $remote] } {
118 test_remote $remote $host_is_target
122 proc_with_prefix gdb_simple_compile_and_run {} {
130 if {![gdb_simple_compile board-sanity $src executable]} {
136 set target_obj [gdb_remote_download target $obj]
137 set result [remote_exec target $target_obj]
138 set status [lindex $result 0]
139 set output [lindex $result 1]
140 gdb_assert { $status == 0 && $output == "" }
142 remote_file build delete $obj
145 gdb_simple_compile_and_run