1# Copyright 2011-2020 Free Software Foundation, Inc.
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# with a remotehost and gdbserver using stdio for communicating through
18# ssh. Certain firewalls prevent gdbserver from using the usual mechanism of
19# listening on a remote port, so use stdio via ssh instead.
20#
21# To use this file:
22# bash$ cd ${build_dir}/gdb
23# bash$ make check RUNTESTFLAGS="--target_board=remote-stdio-gdbserver \
24#    REMOTE_USERNAME=... REMOTE_HOSTNAME=... REMOTE_PORTNUM=... \
25#    [REMOTE_TMPDIR=${remote_dir}] [GDBSERVER=${remote_gdbserver}]"
26
27load_board_description "stdio-gdbserver-base"
28
29# Test machine info. The generic_config gdbserver reads some of these
30# values from board_info, so this file must set them there.
31if [info exists REMOTE_USERNAME] {
32    set_board_info username $REMOTE_USERNAME
33} else {
34    set_board_info username unspecified_username
35}
36if [info exists REMOTE_HOSTNAME] {
37    set_board_info hostname $REMOTE_HOSTNAME
38} else {
39    set_board_info hostname unspecified_hostname
40}
41
42# The two programs have different syntax to set the remote port, so
43# set it as part of the program name rather than in get_remote_login.
44
45if [info exists REMOTE_PORTNUM] {
46    set_board_info portnum $REMOTE_PORTNUM
47    set_board_info rsh_prog "/usr/bin/ssh -p$REMOTE_PORTNUM"
48    set_board_info rcp_prog "/usr/bin/scp -P$REMOTE_PORTNUM"
49} else {
50    set_board_info rsh_prog /usr/bin/ssh
51    set_board_info rcp_prog /usr/bin/scp
52}
53
54# Some remote machines don't have writable home directories.
55if [info exists REMOTE_TMPDIR] {
56    set_board_info remotedir $REMOTE_TMPDIR
57}
58
59proc get_remote_login { } {
60    set result ""
61    if {[board_info [target_info name] exists username]} {
62	append result "[board_info [target_info name] username]@"
63    }
64    if {[board_info [target_info name] exists hostname]} {
65	append result "[board_info [target_info name] hostname]"
66    }
67    return $result
68}
69
70proc get_target_remote_pipe_cmd { } {
71    set target_exec [gdbserver_download_current_prog]
72    set rsh_cmd "[board_info [target_info name] rsh_prog] [get_remote_login]"
73    return "$rsh_cmd /usr/bin/gdbserver --once stdio $target_exec"
74}
75
76proc ${board}_file { dest op args } {
77    if { $op == "delete" } {
78	return [remote_exec target "rm -f $args"]
79    }
80    return [eval [list standard_file $dest $op] $args]
81}
82