f61861790340605ab23aa16aa3aa7c074e3c31d5
[platform/upstream/gdb.git] / gdb / testsuite / gdb.base / all-bin.exp
1 # Copyright 1998-2014 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 file is part of the gdb testsuite
19 #
20 # tests for arithmetic, logical and relational operators
21 # with mixed types
22
23
24
25
26 #
27 # test running programs
28 #
29
30 standard_testfile all-types.c
31
32 if [get_compiler_info] {
33     return -1
34 }
35
36 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
37     untested $testfile.exp
38     return -1
39 }
40
41 #
42 # set it up at a breakpoint so we can play with the variable values
43 #
44
45 if ![runto_main] then {
46     perror "couldn't run to breakpoint"
47     continue
48 }
49
50 gdb_test "next" "return 0;" "continuing after dummy()"
51
52 gdb_test "print v_int+v_char" " = 71" "print value of v_int+v_char"
53
54 gdb_test "print v_int+v_short" " = 9" "print value of v_int+v_short"
55
56 gdb_test "print v_int+v_signed_char" " = 72" \
57     "print value of v_int+v_signed_char"
58
59 gdb_test "print v_int+v_unsigned_char" " = 73" \
60     "print value of v_int+v_unsigned_char"
61
62 gdb_test "print v_int+v_signed_short" " = 10" \
63     "print value of v_int+v_signed_short"
64
65 gdb_test "print v_int+v_unsigned_short" " = 11" \
66     "print value of v_int+v_unsigned_short"
67
68 gdb_test "print v_int+v_signed_int" " = 13" \
69     "print value of v_int+v_signed_int"
70
71 gdb_test "print v_int+v_unsigned_int" " = 14" \
72     "print value of v_int+v_unsigned_int"
73
74 gdb_test "print v_int+v_long" " = 15" "print value of v_int+v_long"
75
76 gdb_test "print v_int+v_signed_long" " = 16" \
77     "print value of v_int+v_signed_long"
78
79 gdb_test "print v_int+v_unsigned_long" " = 17" \
80     "print value of v_int+v_unsigned_long"
81
82 gdb_test "print v_int+v_float" " = 106.34343.*" \
83     "print value of v_int+v_float"
84
85 gdb_test "print v_int+v_double" " = 206.565.*" \
86     "print value of v_int+v_double"
87
88
89 #
90 # test the relational operators with mixed types
91 #
92
93 gdb_test "print v_int <= v_char" " = 1" "print value of v_int<=v_char"
94
95 gdb_test "print v_int <= v_short" " = $false" \
96     "print value of v_int<=v_short"
97
98 gdb_test "print v_int <= v_signed_char" " = 1" \
99     "print value of v_int<=v_signed_char"
100
101 gdb_test "print v_int <= v_unsigned_char" " = 1" \
102     "print value of v_int<=v_unsigned_char"
103
104 gdb_test "print v_int <= v_signed_short" " = $false" \
105     "print value of v_int<=v_signed_short"
106
107 gdb_test "print v_int <= v_unsigned_short" " = $false" \
108     "print value of v_int<=v_unsigned_short"
109
110 gdb_test "print v_int <= v_signed_int" " = $true" \
111     "print value of v_int<=v_signed_int"
112
113 gdb_test "print v_int <= v_unsigned_int" " = $true" \
114     "print value of v_int<=v_unsigned_int"
115
116 gdb_test "print v_int <= v_long" " = $true" "print value of v_int<=v_long"
117
118 gdb_test "print v_int <= v_signed_long" " = $true" \
119     "print value of v_int<=v_signed_long"
120
121 gdb_test "print v_int <= v_unsigned_long" " = $true" \
122     "print value of v_int<=v_unsigned_long"
123
124 gdb_test "print v_int <= v_float" " = $true" "print value of v_int<=v_float"
125
126 gdb_test "print v_int <= v_double" " = $true" \
127     "print value of v_int<=v_double"
128
129 #
130 # test the logical operators with mixed types
131 #
132
133 gdb_test_no_output "set variable v_char=0" "set v_char=0"
134 gdb_test_no_output "set variable v_double=0.0" "set v_double=0"
135 gdb_test_no_output "set variable v_unsigned_long=0" "set v_unsigned_long=0"
136
137 gdb_test "print v_int && v_char" " = $false" "print value of v_int&&v_char"
138
139 gdb_test "print v_int && v_short" " = $true" "print value of v_int&&v_short"
140
141 gdb_test "print v_int && v_signed_char" " = $true" \
142     "print value of v_int&&v_signed_char"
143
144 gdb_test "print v_int && v_unsigned_char" " = $true" \
145     "print value of v_int&&v_unsigned_char"
146
147 gdb_test "print v_int && v_signed_short" " = $true" \
148     "print value of v_int&&v_signed_short"
149
150 gdb_test "print v_int && v_unsigned_short" " = $true" \
151     "print value of v_int&&v_unsigned_short"
152
153 gdb_test "print v_int && v_signed_int" " = $true" \
154     "print value of v_int&&v_signed_int"
155
156 gdb_test "print v_int && v_unsigned_int" " = $true" \
157     "print value of v_int&&v_unsigned_int"
158
159 gdb_test "print v_int && v_long" " = $true" "print value of v_int&&v_long"
160
161 gdb_test "print v_int && v_signed_long" " = $true" \
162     "print value of v_int&&v_signed_long"
163
164 gdb_test "print v_int && v_unsigned_long" " = $false" \
165     "print value of v_int&&v_unsigned_long"
166
167 gdb_test "print v_int && v_float" " = $true" "print value of v_int&&v_float"
168
169 gdb_test "print v_int && v_double" " = $false" \
170     "print value of v_int&&v_double"
171
172
173
174
175