local-remote-host-native.exp revision 1.6
1243789Sdim# Copyright 2014-2019 Free Software Foundation, Inc. 2243789Sdim 3243789Sdim# This program is free software; you can redistribute it and/or modify 4243789Sdim# it under the terms of the GNU General Public License as published by 5243789Sdim# the Free Software Foundation; either version 3 of the License, or 6243789Sdim# (at your option) any later version. 7243789Sdim# 8243789Sdim# This program is distributed in the hope that it will be useful, 9243789Sdim# but WITHOUT ANY WARRANTY; without even the implied warranty of 10243789Sdim# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11243789Sdim# GNU General Public License for more details. 12243789Sdim# 13243789Sdim# You should have received a copy of the GNU General Public License 14243789Sdim# along with this program. If not, see <http://www.gnu.org/licenses/>. 15243789Sdim 16243789Sdim# This file is a dejagnu "board file" and is used to run the testsuite 17243789Sdim# against local host, in remote host mode. 18243789Sdim# 19243789Sdim# This board file is used to emulate the real remote host testing, in 20243789Sdim# which file system of host and build are not shared. This is achieved 21243789Sdim# by copying files from source directory to ${host_dir}. 22243789Sdim# 23243789Sdim# To use this file: 24243789Sdim# bash$ cd ${build_dir}/gdb 25243789Sdim# bash$ make check RUNTESTFLAGS="--host_board=local-remote-host-native --target_board=local-remote-host-native HOST_DIR=/tmp/foo/" 26243789Sdim# 27243789Sdim# We set both target board and host board together to test a native gdb 28243789Sdim# (host == target) on a remote host (host != build). $HOST_DIR is the 29243789Sdim# directory for copying files to, to avoid messing up your HOME. When 30243789Sdim# it is absent, files are copied to ./remote-host. 31243789Sdim 32243789Sdimif { $board_type == "target" } { 33243789Sdim set_board_info compiler gcc 34243789Sdim} 35243789Sdim 36243789Sdim# We have to explicitly specify GDB with the path to the copy in 37243789Sdim# the build directory because otherwise it will be set to the 38243789Sdim# result of "transform GDB" since the harness thinks we're using 39243789Sdim# a remote host. See lib/gdb.exp. 40243789Sdimset GDB [file join [pwd] "../gdb"] 41243789Sdimverbose -log "Overriding setting of GDB to $GDB" 42243789Sdim 43243789Sdimset_board_info hostname 127.0.0.1 44243789Sdim 45243789Sdimset_board_info username $env(USER) 46243789Sdim 47243789Sdim# The ssh key should be correctly set up that you ssh to 127.0.0.1 48243789Sdim# without having to type password. 49243789Sdimset_board_info rsh_prog /usr/bin/ssh 50243789Sdimset_board_info rcp_prog /usr/bin/scp 51243789Sdimset_board_info file_transfer "rsh" 52243789Sdim 53243789Sdimif { ![info exists HOST_DIR] } { 54243789Sdim set HOST_DIR [file join [pwd] "remote-host"] 55243789Sdim} 56243789Sdim 57243789Sdimif { $board_type == "host" } { 58243789Sdim set_board_info gdb_opts "-d \"${HOST_DIR}\"" 59243789Sdim} 60243789Sdim 61243789Sdimproc ${board}_spawn { board cmd } { 62243789Sdim global board_info 63243789Sdim 64243789Sdim set remote [board_info $board hostname] 65243789Sdim set username [board_info $board username] 66243789Sdim set RSH [board_info $board rsh_prog] 67243789Sdim 68243789Sdim spawn $RSH -t -l $username $remote $cmd 69243789Sdim set board_info($board,fileid) $spawn_id 70243789Sdim return $spawn_id 71243789Sdim} 72243789Sdim 73243789Sdimproc ${board}_download { board src dest } { 74243789Sdim global HOST_DIR 75243789Sdim 76243789Sdim if { ![file exists $HOST_DIR] } { 77243789Sdim file mkdir $HOST_DIR 78243789Sdim } 79243789Sdim 80243789Sdim set destfile [file join $HOST_DIR $dest] 81243789Sdim verbose -log "${board}_download: file copy -force $src $destfile" 82243789Sdim file copy -force $src $destfile 83243789Sdim 84243789Sdim return $destfile 85243789Sdim} 86243789Sdim