Initial creation of sourceware repository
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / varargs.exp
CommitLineData
c906108c
SS
1# Copyright (C) 1997, 1998 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#
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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# This file was written by Elena Zannoni (ezannoni@cygnus.com)
21
22
23# this file tests command line calls with functions having variable
24# args list
25# corresponding source file: varargs.c
26
27#print find_max1(5,1,2,3,4,5)
28#print find_max1(1,3)
29#call find_max1(10,1,2,3,4,5,6,7,8,29,0)
30#print find_max2(3,1,2,3)
31#print find_max_double(5,1.0,17.0,2.0,3.0,4.0)
32#quit
33
34
35if $tracelevel then {
36 strace $tracelevel
37}
38
39set prms_id 0
40set bug_id 0
41
42set prototypes 0
43set testfile "varargs"
44set srcfile ${testfile}.c
45set binfile ${objdir}/${subdir}/${testfile}
46
47if [get_compiler_info ${binfile}] {
48 return -1
49}
50
51if {$gcc_compiled == 0} {
52 if [istarget "hppa*-hp-hpux*"] then {
53 set additional_flags "additional_flags=-Ae"
54 } else {
55 # don't know what the compiler is, hope for the best, maybe it's ANSI...
56 set additional_flags ""
57 }
58} else {
59 set additional_flags ""
60}
61
62# build the first test case
63#if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
64# gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
65#}
66
67if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
68 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
69}
70
71# Start with a fresh gdb.
72
73gdb_exit
74gdb_start
75gdb_reinitialize_dir $srcdir/$subdir
76gdb_load ${binfile}
77send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
78send_gdb "set print address off\n" ; gdb_expect -re "$gdb_prompt $"
79send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $"
80
81
82if ![runto_main] then {
83 perror "couldn't run to breakpoint"
84 continue
85}
86
87
88send_gdb "print find_max1(5,1,2,3,4,5)\n"
89gdb_expect {
90 -re ".*find_max\\(5, 1, 2, 3, 4, 5\\) returns 5\[ \r\n\]+.\[0-9\]+ = 5.*$gdb_prompt $" {
91 pass "print find_max1(5,1,2,3,4,5)"
92 }
93 -re ".*$gdb_prompt $" { fail "print find_max1(5,1,2,3,4,5)" }
94 timeout { fail "(timeout) print find_max1(5,1,2,3,4,5)" }
95 }
96
97
98
99
100send_gdb "print find_max1(1,3)\n"
101gdb_expect {
102 -re ".*find_max\\(1, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3.*$gdb_prompt $" {
103 pass "print find_max1(1,3)"
104 }
105 -re ".*$gdb_prompt $" { fail "print find_max1(1,3)" }
106 timeout { fail "(timeout) print find_max1(1,3)" }
107 }
108
109
110send_gdb "print find_max1(10,1,2,3,4,5,6,7,8,29,0)\n"
111gdb_expect {
112 -re ".*find_max\\(10, 1, 2, 3, 4, 5, 6, 7, 8, 29, 0\\) returns 29\[ \r\n\]+.\[0-9\]+ = 29.*$gdb_prompt $" {
113 pass "print find_max1(10,1,2,3,4,5,6,7,8,29,0)"
114 }
115 -re ".*$gdb_prompt $" { fail "print find_max1(10,1,2,3,4,5,6,7,8,29,0)" }
116 timeout { fail "(timeout) print find_max1(10,1,2,3,4,5,6,7,8,29,0)" }
117 }
118
119
120
121send_gdb "print find_max2(3,1,2,3)\n"
122gdb_expect {
123 -re ".*find_max\\(3, 1, 2, 3\\) returns 3\[ \r\n\]+.\[0-9\]+ = 3.*$gdb_prompt $" {
124 pass "print find_max2(3,1,2,3)"
125 }
126 -re ".*$gdb_prompt $" { fail "print find_max2(3,1,2,3)" }
127 timeout { fail "(timeout) print find_max2(3,1,2,3)" }
128 }
129
130
131send_gdb "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)\n"
132gdb_expect {
133 -re ".*find_max\\(.*\\) returns 17\\.000000\[ \r\n\]+.\[0-9\]+ = 17.*$gdb_prompt $" {
134 pass "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)"
135 }
136 -re ".*$gdb_prompt $" { fail "print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" }
137 timeout { fail "(timeout) print find_max_double(5,1.0,17.0,2.0,3.0,4.0)" }
138 }
139
This page took 0.027657 seconds and 4 git commands to generate.