local-remote-host-native.exp 2.8 KB

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