OSDN Git Service

* gdb.base/return2.exp: return of long long and double fails for
[pf3gnuchains/pf3gnuchains4x.git] / gdb / testsuite / gdb.base / return2.exp
1 # Copyright 2000, 2001 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 Michael Snyder (msnyder@redhat.com)
21
22 if $tracelevel then {
23         strace $tracelevel
24 }
25
26 set prms_id 0
27 set bug_id 0
28
29 set testfile "return2"
30 set srcfile ${testfile}.c
31 set binfile ${objdir}/${subdir}/${testfile}
32 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
34 }
35
36 proc return_1 { type } {
37     global gdb_prompt
38
39     gdb_test "break ${type}_func" "Breakpoint \[0123456789\].*" \
40             "set break on ${type}_func"
41     gdb_test "continue" "Breakpoint.* ${type}_func.*" \
42             "continue to ${type}_func"
43     send_gdb "return testval.${type}_testval\n"
44     gdb_expect {
45         -re "Make ${type}_func return now.*y or n. $" {
46             send_gdb "y\n"
47             exp_continue
48         }
49         -re ".*${type}_resultval *= ${type}_func.*$gdb_prompt $" {
50             send_gdb "step\n"
51             exp_continue
52         }
53         -re ".*${type}_checkpoint.*$gdb_prompt $" {
54             pass "return from ${type}_func"
55         }
56         -re ".*$gdb_prompt $" {
57             fail "return from ${type}_func"
58         }
59         timeout {
60             fail "return from ${type}_func (timeout)"
61         }
62     }
63     gdb_test "print ${type}_resultval == testval.${type}_testval" ".* = 1" \
64             "${type} value returned successfully"
65     gdb_test "print ${type}_resultval != ${type}_returnval" ".* = 1" \
66             "validate result value not equal to program return value"
67 }
68
69 proc return_void { } {
70     global gdb_prompt
71
72     gdb_test "break void_func" "Breakpoint \[0123456789\].*" \
73             "set break on void_func"
74     gdb_test "continue" "Breakpoint.* void_func.*" \
75             "continue to void_func"
76     send_gdb "return \n"
77     gdb_expect {
78         -re "Make void_func return now.*y or n. $" {
79             send_gdb "y\n"
80             exp_continue
81         }
82         -re ".*void_func.*call to void_func.*$gdb_prompt $" {
83             send_gdb "step\n"
84             exp_continue
85         }
86         -re ".*void_checkpoint.*$gdb_prompt $" {
87             pass "return from void_func"
88         }
89         -re ".*$gdb_prompt $" {
90             fail "return from void_func"
91         }
92         timeout {
93             fail "return from void_func (timeout)"
94         }
95     }
96     gdb_test "print void_test == 0" ".* = 1" \
97             "void function returned successfully"
98 }
99
100 proc return2_tests { } {
101     global gdb_prompt
102
103     if { ! [ runto main ] } then {
104         gdb_suppress_entire_file "Run to main failed, so all tests in this file will automatically fail."
105     }
106
107     return_void
108     return_1 "char"
109     return_1 "short"
110     return_1 "int"
111     return_1 "long"
112     if { ! [istarget "m6811-*-*"] } then {
113         return_1 "long_long"
114     }
115     return_1 "float"
116     if { ! [istarget "m6811-*-*"] } then {
117         return_1 "double"
118     }
119 }
120
121 # Start with a fresh gdb.
122
123 gdb_exit
124 gdb_start
125 gdb_reinitialize_dir $srcdir/$subdir
126 gdb_load ${binfile}
127
128 set timeout 30
129 return2_tests