home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gdb-4.9 / gdb / testsuite / gdb.t01 / run.exp < prev    next >
Encoding:
Text File  |  1993-05-12  |  5.9 KB  |  223 lines

  1. #   Copyright (C) 1988, 1990, 1991, 1992 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-gdb@prep.ai.mit.edu
  17.  
  18. # This file was written by Rob Savoye. (rob@cygnus.com)
  19.  
  20. if $tracelevel then {
  21.     strace $tracelevel
  22.     }
  23.  
  24. #
  25. # test running programs
  26. #
  27. set prms_id 0
  28. set bug_id 0
  29.  
  30. set binfile "gdbme"
  31.  
  32. if ![file exists $objdir/$subdir/$binfile] then {
  33.     error "$objdir/$subdir/$binfile does not exist."
  34.     alldone
  35.     }
  36.  
  37. gdb_reinitialize_dir $srcdir/$subdir
  38. gdb_load $objdir/$subdir/$binfile
  39.  
  40. # Run with no arguments.
  41. # On VxWorks this justs make sure the program was run.
  42. send "run\n"
  43. expect -re "run\r\n" {}
  44. if [istarget "*-*-vxworks"] then {
  45.     set timeout 120
  46.     expect {
  47.         -i $shell_id -re "usage:  factorial <number>"\
  48.                 { pass "run $binfile" }
  49.         timeout        { fail "(timeout) run $binfile" }
  50.     }
  51.     set timeout 10
  52.     expect -re "$prompt $" {}
  53. } else {
  54.     expect {
  55.         -re "Starting program.*usage:  factorial <number>.*$prompt $"\
  56.                 { pass "run $binfile" }
  57.         -re ".*$prompt $"    { fail "run $binfile" }
  58.         timeout        { fail "(timeout) run $binfile" }
  59.     }
  60. }
  61.  
  62. # Now run with some arguments
  63. if [istarget "*-*-vxworks"] then {
  64.     send "run vxmain \"5\"\n"
  65.     expect -re "run vxmain \"5\"\r\n" {}
  66.     set timeout 120
  67.     expect {
  68.         -i $shell_id "120" { pass "run $binfile with arg" }
  69.         timeout { fail "(timeout) run $binfile with arg" }
  70.     }
  71.     set timeout 10
  72.     expect -re "$prompt $" {}
  73. } else {
  74.     if [istarget "a29k-*-udi"] then {
  75.     # FIXME: If PR 2415 is fixed, gdb_target_udi and gdb_load are
  76.     # not needed.
  77.     gdb_target_udi
  78.     gdb_load $objdir/$subdir/$binfile
  79.     send "run gdbme 5\n"
  80.     expect {
  81.         -re "Starting program.*120.*$prompt $"\
  82.                 { pass "run $binfile with arg" }
  83.         -re ".*$prompt $"    { fail "run $binfile with arg" }
  84.         timeout        { fail "(timeout) run $binfile with arg" }
  85.     }
  86.     } else {
  87.     setup_xfail "mips-idt-*"
  88.     send "run 5\n"
  89.     expect {
  90.         -re "Starting program.*$binfile.*120.*$prompt $"\
  91.                 { pass "run $binfile with arg" }
  92.         -re ".*$prompt $"    { fail "run $binfile with arg" }
  93.         timeout        { fail "(timeout) run $binfile with arg" }
  94.     }
  95.     }
  96. }
  97.  
  98. # Run again with same arguments.
  99. setup_xfail "mips-idt-*"
  100. if [istarget "a29k-*-udi"] then {
  101.     # FIXME: If PR 2415 is fixed, this is not needed.
  102.     gdb_target_udi
  103.     gdb_load $objdir/$subdir/$binfile
  104. }
  105. send "run\n"
  106. expect -re "run\r\n" {}
  107. if [istarget "*-*-vxworks"] then {
  108.     set timeout 120
  109.     expect {
  110.         -i $shell_id "120" { pass "run $binfile again" }
  111.         timeout { fail "(timeout) run $binfile again" }
  112.     }
  113.     set timeout 10
  114.     expect -re "$prompt $" {}
  115. } else {
  116.     expect {
  117.         -re "Starting program.*120.*$prompt $"\
  118.                 { pass "run $binfile again" }
  119.         -re ".*$prompt $"    { fail "run $binfile again" }
  120.         timeout        { fail "(timeout) run $binfile again" }
  121.     }
  122. }
  123.  
  124. # Use "set args" command to specify no arguments as default and run again.
  125. if [istarget "*-*-vxworks"] then {
  126.     send "set args main\n"
  127. } else {
  128.     send "set args\n"
  129. }
  130. expect -re "$prompt $"
  131.  
  132. if [istarget "a29k-*-udi"] then {
  133.     # FIXME: If PR 2415 is fixed, this is not needed.
  134.     gdb_target_udi
  135.     gdb_load $objdir/$subdir/$binfile
  136. }
  137. send "run\n"
  138. expect -re "run\r\n" {}
  139. if [istarget "*-*-vxworks"] then {
  140.     set timeout 120
  141.     expect {
  142.         -i $shell_id "usage:  factorial <number>"\
  143.                 { pass "set args to nil" }
  144.         timeout        { fail "(timeout) set args to nil" }
  145.     }
  146.     set timeout 10
  147.     expect -re "$prompt $" {}
  148. } else {
  149.     expect {
  150.         -re "Starting program.*usage:  factorial <number>.*$prompt $"\
  151.                 { pass "set args to nil" }
  152.         -re ".*$prompt $"    { fail "set args to nil" }
  153.         timeout        { fail "(timeout) set args to nil" }
  154.     }
  155. }
  156.  
  157. # Use "set args" command to specify an argument and run again.
  158. setup_xfail "mips-idt-*"
  159. if [istarget "*-*-vxworks"] then {
  160.    send "set args vxmain \"6\"\n"
  161. } else {
  162.     if [istarget "a29k-*-udi"] then {
  163.     send "set args gdbme 6\n"
  164.     } else {
  165.     send "set args 6\n"
  166.     }
  167. }
  168. expect -re "$prompt $"
  169. if [istarget "a29k-*-udi"] then {
  170.     # FIXME: If PR 2415 is fixed, this is not needed.
  171.     gdb_target_udi
  172.     gdb_load $objdir/$subdir/$binfile
  173. }
  174. send "run\n"
  175. expect -re "run\r\n" {}
  176. if [istarget "*-*-vxworks"] then {
  177.     set timeout 120
  178.     expect {
  179.         -i $shell_id "720" { pass "run $binfile again" }
  180.         timeout { fail "(timeout) run $binfile again" }
  181.     }
  182.     set timeout 10
  183.     expect -re "$prompt $" {}
  184. } else {
  185.     expect {
  186.         -re "Starting program.*720.*$prompt $"\
  187.                 { pass "set args" }
  188.         -re ".*$prompt $"    { fail "set args" }
  189.         timeout        { fail "(timeout) set args" }
  190.     }
  191. }
  192.  
  193. if [istarget "a29k-*-udi"] then {
  194.     # FIXME: If PR 2415 is fixed, this is not needed.
  195.     gdb_target_udi
  196.     gdb_load $objdir/$subdir/$binfile
  197. }
  198.  
  199. # GOAL: Test that shell is being used with "run".
  200. if ![istarget "*-*-vxworks"] then {
  201.     setup_xfail "mips-idt-*"
  202.     send "run `echo 8`\n"
  203.     expect {
  204.         -re "Starting program.*40320.*$prompt $"\
  205.                 { pass "run with shell" }
  206.         -re ".*$prompt $"    { fail "run with shell" }
  207.         timeout        { fail "(timeout) run with shell" }
  208.     }
  209. }
  210.  
  211. if [istarget "a29k-*-udi"] then {
  212.     # FIXME: If PR 2415 is fixed, this is not needed.
  213.     gdb_target_udi
  214. }
  215.  
  216. # Reset the default arguments for VxWorks
  217. if [istarget "*-*-vxworks"] then {
  218.     send "set args main\n"
  219.     expect -re ".*$prompt $" {}
  220. }
  221.