aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/boards/local-remote-host-native.exp
blob: 72d88c45f4b93c2d82ecfa4f45666fead7a34235 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Copyright 2014-2016 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This file is a dejagnu "board file" and is used to run the testsuite
# against local host, in remote host mode.
#
# This board file is used to emulate the real remote host testing, in
# which file system of host and build are not shared.  This is achieved
# by copying files from source directory to ${host_dir}.
#
# To use this file:
# bash$ cd ${build_dir}/gdb
# bash$ make check RUNTESTFLAGS="--host_board=local-remote-host-native --target_board=local-remote-host-native HOST_DIR=/tmp/foo/"
#
# We set both target board and host board together to test a native gdb
# (host == target) on a remote host (host != build).  $HOST_DIR is the
# directory for copying files to, to avoid messing up your HOME.  When
# it is absent, files are copied to ./remote-host.

if { $board_type == "target" } {
    set_board_info compiler gcc
}

# We have to explicitly specify GDB with the path to the copy in
# the build directory because otherwise it will be set to the
# result of "transform GDB" since the harness thinks we're using
# a remote host.  See lib/gdb.exp.
set GDB [file join [pwd] "../gdb"]
verbose -log "Overriding setting of GDB to $GDB"

set_board_info hostname 127.0.0.1

set_board_info username $env(USER)

# The ssh key should be correctly set up that you ssh to 127.0.0.1
# without having to type password.
set_board_info rsh_prog /usr/bin/ssh
set_board_info rcp_prog /usr/bin/scp
set_board_info file_transfer "rsh"

if { ![info exists HOST_DIR] } {
    set HOST_DIR [file join [pwd] "remote-host"]
}

if { $board_type == "host" } {
    set_board_info gdb_opts "-d \"${HOST_DIR}\""
}

proc ${board}_spawn { board cmd } {
    global board_info

    set remote [board_info $board hostname]
    set username [board_info $board username]
    set RSH [board_info $board rsh_prog]

    spawn $RSH -t -l $username $remote $cmd
    set board_info($board,fileid) $spawn_id
    return $spawn_id
}

proc ${board}_download { board src dest } {
    global HOST_DIR

    if { ![file exists $HOST_DIR] } {
	file mkdir $HOST_DIR
    }

    set destfile [file join $HOST_DIR $dest]
    verbose -log "${board}_download: file copy -force $src $destfile"
    file copy -force $src $destfile

    return $destfile
}