1# Copyright 1988-2015 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 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16# This file was written by Rob Savoye. (rob@cygnus.com) 17 18# Can't do this test without stdio support. 19if [gdb_skip_stdio_test "a2run.exp"] { 20 return 21} 22 23# 24# test running programs 25# 26 27standard_testfile run.c 28 29if { [prepare_for_testing ${testfile}.exp $testfile $srcfile] } { 30 return -1 31} 32 33# Run with no arguments. 34gdb_run_cmd 35 36set test "run \"$testfile\" with no args" 37 38gdb_test_multiple "" $test { 39 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.\r\n$gdb_prompt $" { 40 pass $test 41 pass "no spurious messages at program exit" 42 } 43 -re ".*usage: factorial <number>.*$inferior_exited_re with code 01.*$gdb_prompt $" { 44 pass $test 45 fail "no spurious messages at program exit" 46 } 47 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.\r\n$gdb_prompt $" { 48 pass "$test (exit wrapper)" 49 pass "no spurious messages at program exit" 50 } 51 -re ".*usage: factorial <number>.* EXIT code 1.*$inferior_exited_re normally.*$gdb_prompt $" { 52 pass "$test (exit wrapper)" 53 fail "no spurious messages at program exit" 54 } 55} 56 57# The remaining tests don't work for targets can't take arguments... 58 59if [target_info exists noargs] then { 60 verbose "Skipping rest of a2-run.exp because of noargs." 61 return 62} 63 64# Now run with some arguments 65setup_xfail "arm-*-coff" 66gdb_run_cmd 5 67gdb_test "" "120.*" "run \"$testfile\" with arg" 68 69# Run again with same arguments. 70gdb_run_cmd 71 72setup_xfail "arm-*-coff" 73gdb_test "" "120.*" "run \"$testfile\" again with same args" 74 75# Use "set args" command to specify no arguments as default and run again. 76gdb_test_no_output "set args" 77 78gdb_run_cmd 79 80gdb_test "" "usage: factorial <number>.*" "run after setting args to nil" 81 82# Use "set args" command to specify an argument and run again. 83gdb_test_no_output "set args 6" 84 85gdb_run_cmd 86 87setup_xfail "arm-*-coff" 88gdb_test "" "720.*" "run \"$testfile\" again after setting args" 89 90# GOAL: Test that shell is being used with "run". For remote debugging 91# targets, there is no guarantee that a "shell" (whatever that is) is used. 92if ![is_remote target] then { 93 gdb_test "run `echo 8`" \ 94 "Starting program.*40320.*" \ 95 "run \"$testfile\" with shell" 96} 97