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