Make gdb.base/call-strs.exp use gdb_test_stdio
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / call-strs.exp
1 # Copyright 1998-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 Elena Zannoni (ezannoni@cygnus.com)
17
18 # This test deals with calling functions which have strings as parameters.
19 # it plays around with constant strings.
20 # the corresponding source file is call-strs.c
21 #
22
23 #debug strarg
24
25
26 standard_testfile
27
28 # Test depends on printf, which the sparclet stub doesn't support.
29 if { [istarget "sparclet-*-*"] } {
30 return 0
31 }
32
33 # Some targets can't call functions, so don't even bother with this
34 # test.
35 if [target_info exists gdb,cannot_call_functions] {
36 setup_xfail "*-*-*" 2416
37 fail "This target can not call functions"
38 continue
39 }
40
41
42 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
43 untested $testfile.exp
44 return -1
45 }
46
47 gdb_test_no_output "set print sevenbit-strings"
48 gdb_test_no_output "set print address off"
49 gdb_test_no_output "set print symbol off"
50 gdb_test_no_output "set width 0"
51
52 if ![runto_main] then {
53 perror "couldn't run to breakpoint"
54 continue
55 }
56
57 set prev_timeout $timeout
58 set timeout 120
59
60 #step
61 gdb_test "step" \
62 "strcpy\\(buf, \"test string\"\\);" \
63 "step after assignment to s"
64
65 #next
66 gdb_test "next" \
67 "str_func\\(\"abcd\", \"efgh\", \"ijkl\", \"mnop\", \"qrst\", \"uvwx\", \"yz12\"\\);" \
68 "next over strcpy"
69
70 #print buf
71 gdb_test "print buf" \
72 "\"test string\",.*repeats 88 times.*"
73
74 #print s
75 gdb_test "print s" \
76 " = \"test string\".*"
77
78 #print str_func1(s)
79 if ![gdb_skip_stdio_test "print str_func1(s)"] {
80 gdb_test_stdio "print str_func1(s)" \
81 "first string arg is: test string" \
82 "\"test string\".*"
83 }
84
85 #print str_func1("test string")
86 if ![gdb_skip_stdio_test "print str_func1(teststring)"] {
87 gdb_test_stdio "print str_func1(\"test string\")" \
88 "first string arg is: test string" \
89 "\"test string\".*"
90 }
91
92 #call str_func1(s)
93 if ![gdb_skip_stdio_test "call str_func1(s)"] {
94 gdb_test_stdio "call str_func1(s)" \
95 "first string arg is: test string" \
96 "\"test string\".*"
97 }
98
99 #call str_func1("test string")
100 if ![gdb_skip_stdio_test "call str_func1 (...)"] {
101 gdb_test_stdio "call str_func1(\"test string\")" \
102 "first string arg is: test string" \
103 "\"test string\".*"
104 }
105
106 #print str_func1(buf)
107 if ![gdb_skip_stdio_test "print str_func1(buf)"] {
108 gdb_test_stdio "print str_func1(buf)" \
109 "first string arg is: test string" \
110 "\"test string\".*"
111 }
112
113 #call str_func1(buf)
114 if ![gdb_skip_stdio_test "call str_func1(buf)"] {
115 gdb_test_stdio "call str_func1(buf)" \
116 "first string arg is: test string" \
117 "\"test string\".*"
118 }
119
120 #print str_func("a","b","c","d","e","f","g")
121 if ![gdb_skip_stdio_test "print str_func(a,b,c,d,e,f,g)"] {
122 gdb_test_stdio "print str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
123 "first string arg is: a\[ \t\r\n\]+second string arg is: b\[ \t\r\n\]+third string arg is: c\[ \t\r\n\]+fourth string arg is: d\[ \t\r\n\]+fifth string arg is: e\[ \t\r\n\]+sixth string arg is: f\[ \t\r\n\]+seventh string arg is: g\[ \t\r\n\]+" \
124 "= \"abcdefg\".*"
125 }
126
127 #call str_func("a","b","c","d","e","f","g")
128 if ![gdb_skip_stdio_test "call str_func(a,b,c,d,e,f,g)"] {
129 gdb_test_stdio "call str_func(\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\")" \
130 "first string arg is: a\[ \t\r\n\]+second string arg is: b\[ \t\r\n\]+third string arg is: c\[ \t\r\n\]+fourth string arg is: d\[ \t\r\n\]+fifth string arg is: e\[ \t\r\n\]+sixth string arg is: f\[ \t\r\n\]+seventh string arg is: g\[ \t\r\n\]+" \
131 "= \"abcdefg\".*"
132 }
133
134 #print str_func(s,s,s,s,s,s,s)
135 if ![gdb_skip_stdio_test "print str_func(s,s,s,s,s,s,s,s)"] {
136 gdb_test_stdio "print str_func(s,s,s,s,s,s,s)" \
137 "first string arg is: test string\[ \t\r\n\]+second string arg is: test string\[ \t\r\n\]+third string arg is: test string\[ \t\r\n\]+fourth string arg is: test string\[ \t\r\n\]+fifth string arg is: test string\[ \t\r\n\]+sixth string arg is: test string\[ \t\r\n\]+seventh string arg is: test string\[ \t\r\n\]+" \
138 "\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*"
139 }
140
141 #call str_func(s,s,s,s,s,s,s)
142 if ![gdb_skip_stdio_test "call str_func(s,s,s,s,s,s,s,s)"] {
143 gdb_test_stdio "call str_func(s,s,s,s,s,s,s)" \
144 "first string arg is: test string\[ \t\r\n\]+second string arg is: test string\[ \t\r\n\]+third string arg is: test string\[ \t\r\n\]+fourth string arg is: test string\[ \t\r\n\]+fifth string arg is: test string\[ \t\r\n\]+sixth string arg is: test string\[ \t\r\n\]+seventh string arg is: test string\[ \t\r\n\]+" \
145 "\"test stringtest stringtest stringtest stringtest stringtest stringtest string\".*"
146 }
147
148 gdb_exit
149
150 set timeout $prev_timeout
151
This page took 0.032331 seconds and 4 git commands to generate.