mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-18 21:38:49 +00:00
[gdb/testsuite] Set remotedir by default in some boards
When doing a gdb_simple_compile, and downloading the resulting exec $obj to target the result $target_obj may be a relative file path, which may give problems when trying to do: ... remote_exec target $target_obj ... Fix/workaround this on some target boards by setting remotedir by default, and add a corresponding test in gdb.testsuite/board-sanity.exp. This doesn't work for host/target board local-remote-host-native, so xfail this. Tested on x86_64-linux.
This commit is contained in:
@@ -37,22 +37,35 @@ if { [info exists REMOTE_TARGET_USERNAME] } {
|
|||||||
}
|
}
|
||||||
set_board_info hostname localhost
|
set_board_info hostname localhost
|
||||||
|
|
||||||
# Handle separate test account.
|
save_vars {rsh_cmd res} {
|
||||||
if { [board_info $board username] != $env(USER) } {
|
set rsh_cmd \
|
||||||
# We're pretending that some local user account is remote target.
|
[join \
|
||||||
# Make things a bit more realistic by restricting file permissions.
|
[list \
|
||||||
|
[board_info $board rsh_prog] \
|
||||||
|
-l [board_info $board username] \
|
||||||
|
[board_info $board hostname]]]
|
||||||
|
|
||||||
# Make sure remote target can't see files on build.
|
# Handle separate test account.
|
||||||
remote_exec build "chmod go-rx $objdir"
|
if { [board_info $board username] != $env(USER) } {
|
||||||
|
# We're pretending that some local user account is remote target.
|
||||||
|
# Make things a bit more realistic by restricting file permissions.
|
||||||
|
|
||||||
# Make sure build can't see files on remote target. We can't use
|
# Make sure remote target can't see files on build.
|
||||||
# remote_exec target, because we're in the middle of parsing the
|
remote_exec build "chmod go-rx $objdir"
|
||||||
# target board.
|
|
||||||
remote_exec build \
|
# Make sure build can't see files on remote target. We can't use
|
||||||
"[board_info $board rsh_prog] \
|
# remote_exec target, because we're in the middle of parsing the
|
||||||
-l [board_info $board username] \
|
# target board.
|
||||||
[board_info $board hostname] \
|
remote_exec build $rsh_cmd chmod go-rx ."
|
||||||
chmod go-rx ."
|
}
|
||||||
|
|
||||||
|
# Set remotedir by default, to force remote_download target to give an
|
||||||
|
# absolute file name.
|
||||||
|
set res [remote_exec build $rsh_cmd pwd]
|
||||||
|
if { [lindex $res 0] != 0 } {
|
||||||
|
error "Couldn't set remotedir using pwd"
|
||||||
|
}
|
||||||
|
set_board_info remotedir [string trim [lindex $res 1]]
|
||||||
}
|
}
|
||||||
|
|
||||||
proc ${board}_file { dest op args } {
|
proc ${board}_file { dest op args } {
|
||||||
|
|||||||
@@ -45,6 +45,22 @@ set_board_info rcp_prog /usr/bin/scp
|
|||||||
# Some remote machines don't have writable home directories.
|
# Some remote machines don't have writable home directories.
|
||||||
if [info exists REMOTE_TMPDIR] {
|
if [info exists REMOTE_TMPDIR] {
|
||||||
set_board_info remotedir $REMOTE_TMPDIR
|
set_board_info remotedir $REMOTE_TMPDIR
|
||||||
|
} else {
|
||||||
|
# Set remotedir by default, to force remote_download target to give an
|
||||||
|
# absolute file name.
|
||||||
|
save_vars {rsh_cmd res} {
|
||||||
|
set rsh_cmd \
|
||||||
|
[join \
|
||||||
|
[list \
|
||||||
|
[board_info $board rsh_prog] \
|
||||||
|
-l [board_info $board username] \
|
||||||
|
[board_info $board hostname]]]
|
||||||
|
set res [remote_exec build $rsh_cmd pwd]
|
||||||
|
if { [lindex $res 0] != 0 } {
|
||||||
|
error "Couldn't set remotedir using pwd"
|
||||||
|
}
|
||||||
|
set_board_info remotedir [string trim [lindex $res 1]]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if [info exists GDBSERVER] {
|
if [info exists GDBSERVER] {
|
||||||
|
|||||||
@@ -120,3 +120,35 @@ foreach_with_prefix remote {host target} {
|
|||||||
test_remote $remote $host_is_target
|
test_remote $remote $host_is_target
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc_with_prefix gdb_simple_compile_and_run {} {
|
||||||
|
set src {
|
||||||
|
int main() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set test "compile"
|
||||||
|
if {![gdb_simple_compile board-sanity $src executable]} {
|
||||||
|
fail $test
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pass $test
|
||||||
|
|
||||||
|
set target_obj [gdb_remote_download target $obj]
|
||||||
|
set result [remote_exec target $target_obj]
|
||||||
|
set status [lindex $result 0]
|
||||||
|
set output [lindex $result 1]
|
||||||
|
|
||||||
|
if { [host_info name] == "local-remote-host-native"
|
||||||
|
&& [target_info name] == "local-remote-host-native" } {
|
||||||
|
# Setting remotedir on this board has effect on both host and
|
||||||
|
# target, and it seems to broken for host. Xfail this for now.
|
||||||
|
setup_xfail *-*-*
|
||||||
|
}
|
||||||
|
gdb_assert { $status == 0 && $output == "" }
|
||||||
|
|
||||||
|
remote_file build delete $obj
|
||||||
|
}
|
||||||
|
|
||||||
|
gdb_simple_compile_and_run
|
||||||
|
|||||||
Reference in New Issue
Block a user