]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2014-2024 Free Software Foundation, Inc. |
666d413c YQ |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # This file is a dejagnu "board file" and is used to run the testsuite | |
17 | # against local host, in remote host mode. | |
18 | # | |
19 | # This board file is used to emulate the real remote host testing, in | |
20 | # which file system of host and build are not shared. This is achieved | |
21 | # by copying files from source directory to ${host_dir}. | |
22 | # | |
23 | # To use this file: | |
24 | # bash$ cd ${build_dir}/gdb | |
25 | # bash$ make check RUNTESTFLAGS="--host_board=local-remote-host-native --target_board=local-remote-host-native HOST_DIR=/tmp/foo/" | |
26 | # | |
27 | # We set both target board and host board together to test a native gdb | |
28 | # (host == target) on a remote host (host != build). $HOST_DIR is the | |
29 | # directory for copying files to, to avoid messing up your HOME. When | |
30 | # it is absent, files are copied to ./remote-host. | |
31 | ||
32 | if { $board_type == "target" } { | |
33 | set_board_info compiler gcc | |
34 | } | |
35 | ||
36 | # We have to explicitly specify GDB with the path to the copy in | |
37 | # the build directory because otherwise it will be set to the | |
38 | # result of "transform GDB" since the harness thinks we're using | |
39 | # a remote host. See lib/gdb.exp. | |
40 | set GDB [file join [pwd] "../gdb"] | |
41 | verbose -log "Overriding setting of GDB to $GDB" | |
42 | ||
6ad02613 | 43 | set_board_info hostname localhost |
666d413c YQ |
44 | |
45 | set_board_info username $env(USER) | |
46 | ||
7c872c90 TV |
47 | save_vars {rsh_cmd res} { |
48 | set rsh_cmd \ | |
49 | [join \ | |
50 | [list \ | |
51 | [board_info $board rsh_prog] \ | |
52 | -l [board_info $board username] \ | |
53 | [board_info $board hostname]]] | |
54 | ||
55 | if [info exists HOST_DIR] { | |
56 | set_board_info remotedir $HOST_DIR | |
57 | } else { | |
58 | # Set remotedir by default, to force remote_download target to give an | |
59 | # absolute file name. | |
60 | set res [remote_exec build $rsh_cmd pwd] | |
61 | if { [lindex $res 0] != 0 } { | |
62 | error "Couldn't set remotedir using pwd" | |
63 | } | |
64 | set_board_info remotedir [string trim [lindex $res 1]] | |
65 | } | |
66 | } | |
67 | ||
6ad02613 | 68 | # The ssh key should be correctly set up that you ssh to localhost |
666d413c YQ |
69 | # without having to type password. |
70 | set_board_info rsh_prog /usr/bin/ssh | |
71 | set_board_info rcp_prog /usr/bin/scp | |
72 | set_board_info file_transfer "rsh" | |
73 | ||
7c872c90 TV |
74 | if { $board_type == "host" } { |
75 | set_board_info gdb_opts "-d \"${HOST_DIR}\"" | |
76 | } | |
77 | ||
666d413c YQ |
78 | proc ${board}_spawn { board cmd } { |
79 | global board_info | |
80 | ||
81 | set remote [board_info $board hostname] | |
82 | set username [board_info $board username] | |
83 | set RSH [board_info $board rsh_prog] | |
84 | ||
85 | spawn $RSH -t -l $username $remote $cmd | |
9121a23f TV |
86 | |
87 | if { [string match "$::GDB*" $cmd] } { | |
88 | set board_info($board,fileid) $spawn_id | |
89 | } | |
90 | ||
666d413c YQ |
91 | return $spawn_id |
92 | } | |
93 | ||
1dc83674 TV |
94 | if { $board_type == "host" } { |
95 | set GDBFLAGS "${GDBFLAGS} -iex \"set style enabled off\"" | |
96 | } |