home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-bin / lib / dejagnu / bug.exp next >
Encoding:
Text File  |  1996-10-12  |  2.7 KB  |  109 lines

  1. # Copyright (C) 1988, 1990, 1991, 1992, 1993 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 2 of the License, or
  6. # (at your option) any later version.
  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. # You should have received a copy of the GNU General Public License
  12. # along with this program; if not, write to the Free Software
  13. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  14.  
  15. # Please email any bugs, comments, and/or additions to this file to:
  16. # bug-dejagnu@prep.ai.mit.edu
  17.  
  18. # This file was written by Rob Savoye. (rob@cygnus.com)
  19.  
  20. #load_lib remote.exp
  21.  
  22. #
  23. # set target variables only if needed.
  24. #
  25. global targetname
  26. global connectmode
  27. global env
  28.  
  29. if ![info exists targetname] then {
  30.     if [info exists env(TARGETNAME)] then {
  31.     set targetname $env(TARGETNAME)
  32.     } else {
  33.     puts stderr "ERROR: Need a target name for the board."
  34.     puts stderr "       Use the --name option\n"
  35.     exit 1
  36.     }
  37. }
  38.  
  39. # the default connect program to use
  40. if ![info exists connectmode] then {
  41.     set connectmode    "tip"
  42.     warning "Using default of $connectmode for target communication."
  43. }        
  44.  
  45. #
  46. # bug_load -- load a file into the bug monitor
  47. #
  48. proc bug_load { shell_id file } {
  49.     global OBJCOPY
  50.  
  51.     if $shell_id<0 then {
  52.     warning "$file not executed because there is no target."
  53.     return -1
  54.     }
  55.  
  56.     # NOTE: this requires OBJCOPY to be tested first
  57.     catch "exec $OBJCOPY -O srec $file $file.srec" result
  58.     if ![string match "" $result] then {
  59.     perror "Couldn't convert to srecord for downloading"
  60.     return -1
  61.     }
  62.  
  63.     send -i $shell_id "lo 0\r"
  64.     expect {
  65.     -i $shell_id "lo 0*" {
  66.         verbose "Got load command echo" 0
  67.     }
  68.     -i $shell_id timeout {
  69.         perror "Load command didn't echo back"
  70.         return -1
  71.     }
  72.     }
  73.  
  74.     if [download $file.srec $shell_id]<0 then {
  75.     return -1
  76.     }
  77.     catch "exec rm -foreach  $file.srec"
  78.     return 0
  79. }
  80.  
  81. #
  82. # bug_execute -- execute a program
  83. #
  84. proc bug_execute { shell_id addr } {
  85.     global shell_prompt
  86.  
  87.     if $shell_id<0 then {
  88.     warning "$arg not executed because there is no target."
  89.     return -1
  90.     }
  91.     send -i $shell_id "go $addr\r"
  92.     verbose "Sent execute command"
  93.     expect {
  94.     -i $shell_id "*Effective address: $addr" {
  95.         exp_continue
  96.     }
  97.     -i $shell_id -re "$shell_prompt.*$" {
  98.         return 0
  99.     }
  100.     -i $shell_id timeout { 
  101.         error "Couldn't execute program (timed out)."
  102.         return 1
  103.     }
  104.     }
  105. }
  106.  
  107.