Remove superfluous semicolons from testsuite throughout.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / args.exp
CommitLineData
28e7fd62 1# Copyright 2003-2013 Free Software Foundation, Inc.
8f9ab801
EZ
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
8f9ab801
EZ
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
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
8f9ab801 15
8f9ab801
EZ
16# This is a test for the gdb invocation option --args.
17
8f9ab801
EZ
18
19global GDBFLAGS
20
19ea9e73
MS
21# Skip test if target does not support argument passing.
22if [target_info exists noargs] {
4ec70201 23 return
19ea9e73
MS
24}
25
8f9ab801
EZ
26set testfile "args"
27set srcfile ${testfile}.c
28set binfile ${objdir}/${subdir}/${testfile}
29
fc91c6c2 30if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
b60f0898
JB
31 untested args.exp
32 return -1
8f9ab801
EZ
33}
34
ae018d1a
DJ
35proc args_test { name arglist } {
36 global srcdir
37 global subdir
38 global binfile
39 global hex
40 global decimal
41
42 gdb_exit
43 gdb_start
44 gdb_reinitialize_dir $srcdir/$subdir
45
46 # No loading needs to be done when the target is `exec'. Some targets
47 # require that the program be loaded, however, and it doesn't hurt
48 # for `exec'.
49 gdb_load $binfile
50
51 runto_main
52 gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
53 gdb_continue_to_breakpoint "breakpoint for $name"
54
55 set expected_len [expr 1 + [llength $arglist]]
56 gdb_test "print argc" "\\\$$decimal = $expected_len" "argc for $name"
57
58 set i 1
59 foreach arg $arglist {
60 gdb_test "print argv\[$i\]" "\\\$$decimal = $hex \"$arg\"" \
61 "argv\[$i\] for $name"
62 set i [expr $i + 1]
63 }
64}
65
8f9ab801
EZ
66#
67# Test that the --args are processed correctly.
68#
c362c33a 69set old_gdbflags $GDBFLAGS
6b8ce727
DE
70
71set GDBFLAGS "$old_gdbflags --args $binfile 1 3"
ae018d1a 72args_test basic {{1} {3}}
8f9ab801
EZ
73
74#
75# Test that the --args are processed correctly even if one of them is empty.
ae018d1a
DJ
76# The syntax needed is a little peculiar; DejaGNU treats the arguments as a
77# list and expands them itself, since no shell redirection is involved.
8f9ab801 78#
6b8ce727 79set GDBFLAGS "$old_gdbflags --args $binfile 1 {} 3"
ae018d1a 80args_test "one empty" {{1} {} {3}}
8f9ab801
EZ
81
82#
83# try with 2 empty args
84#
6b8ce727 85set GDBFLAGS "$old_gdbflags --args $binfile 1 {} {} 3"
ae018d1a
DJ
86args_test "two empty" {{1} {} {} 3}
87
88# Try with arguments containing literal single quotes.
89
6b8ce727 90set GDBFLAGS "$old_gdbflags --args $binfile 1 '' 3"
6f439c36 91args_test "one empty (with single quotes)" {{1} {''} {3}}
ae018d1a 92
6b8ce727 93set GDBFLAGS "$old_gdbflags --args $binfile 1 '' '' 3"
6f439c36 94args_test "two empty (with single quotes)" {{1} {''} {''} {3}}
8f9ab801 95
c2226152
AS
96# try with arguments containing literal newlines.
97
98set GDBFLAGS "-nx --args $binfile 1 {\n} 3"
99args_test "one newline" {{1} {\\n} {3}}
100
101set GDBFLAGS "-nx --args $binfile 1 {\n} {\n} 3"
102args_test "two newlines" {{1} {\\n} {\\n} {3}}
103
c362c33a 104set GDBFLAGS $old_gdbflags
This page took 1.048587 seconds and 4 git commands to generate.