]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.hp/gdb.base-hp/sized-enum.exp
run copyright.sh for 2011.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.hp / gdb.base-hp / sized-enum.exp
CommitLineData
7b6bb8da 1# Copyright (C) 1997, 1998, 2007, 2008, 2009, 2010, 2011
4c38e0a4 2# Free Software Foundation, Inc.
7be570e7
JM
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
e22f8b7c 6# the Free Software Foundation; either version 3 of the License, or
7be570e7 7# (at your option) any later version.
e22f8b7c 8#
7be570e7
JM
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
e22f8b7c 13#
7be570e7 14# You should have received a copy of the GNU General Public License
e22f8b7c 15# along with this program. If not, see <http://www.gnu.org/licenses/>. */
7be570e7 16
7be570e7
JM
17# GDB tests for sized enumerations
18
19# This is aimed at HP-UX systems. The HP C compiler
20# allows specifying "char" or "short" for an enum, to
21# indicate that it is 1 or 2 bytes long.
22
23# This file was written by Satish Pai <pai@apollo.hp.com>
24# 1997-09-24
25
26if $tracelevel then {
27 strace $tracelevel
28 }
29
30#
31# test running programs
32#
7be570e7
JM
33
34if { [skip_hp_tests] } then { continue }
35
36set testfile "sized-enum"
37set srcfile ${testfile}.c
38set binfile ${objdir}/${subdir}/${testfile}
39
40if [get_compiler_info ${binfile}] {
41 return -1
42}
43
44if { $gcc_compiled } then { continue }
45if {$hp_aCC_compiler} {continue}
46
47if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
48 untested sized-enum.exp
49 return -1
7be570e7
JM
50}
51
52gdb_exit
53gdb_start
54gdb_reinitialize_dir $srcdir/$subdir
55gdb_load ${binfile}
56
57#
58# set it up at a breakpoint so we can play with the variable values
59#
60
61if ![runto_main] then {
62 perror "couldn't run to breakpoint"
63 continue
64}
65
66# set a breakpoint and go there
67send_gdb "break 34\n"
68gdb_expect {
69 -re "Breakpoint.*line 34.*$gdb_prompt $" { pass "set break 34" }
70 -re "$gdb_prompt $" { fail "set break 34" }
71 timeout { fail "(timeout) set break 34" }
72}
73send_gdb "continue\n"
74gdb_expect {
75 -re "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, main....at.*sized-enum\\.c:34\r\n34.*\r\n$gdb_prompt $" { pass "continue" }
76 -re "$gdb_prompt $" { fail "continue" }
77 timeout { fail "(timeout) continue" }
78}
79
80# print stuff
81send_gdb "print normal\n"
82gdb_expect {
83 -re "\\$\[0-9\]* = \\{red, blue, green\\}.*$gdb_prompt $" { pass "print normal" }
84 -re "$gdb_prompt $" { fail "print normal" }
85 timeout { fail "(timeout) print normal" }
86}
87send_gdb "print small\n"
88gdb_expect {
89 -re "\\$\[0-9\]* = \\{pink, cyan, grey\\}.*$gdb_prompt $" { pass "print small" }
90 -re "$gdb_prompt $" { fail "print small" }
91 timeout { fail "(timeout) print small" }
92}
93send_gdb "print tiny\n"
94gdb_expect {
95 -re "\\$\[0-9\]* = \\{orange, yellow, brown\\}.*$gdb_prompt $" { pass "print tiny" }
96 -re "$gdb_prompt $" { fail "print tiny" }
97 timeout { fail "(timeout) print tiny" }
98}
99
100# print type sizes
101send_gdb "print sizeof (Normal)\n"
102gdb_expect {
103 -re "\\$\[0-9\]* = 4.*$gdb_prompt $" { pass "print sizeof (Normal)" }
104 -re "$gdb_prompt $" { fail "print sizeof (Normal)" }
105 timeout { fail "(timeout) print sizeof (Normal)" }
106}
107send_gdb "print sizeof (Small)\n"
108gdb_expect {
109 -re "\\$\[0-9\]* = 2.*$gdb_prompt $" { pass "print sizeof (Small)" }
110 -re "$gdb_prompt $" { fail "print sizeof (Small)" }
111 timeout { fail "(timeout) print sizeof (Small)" }
112}
113send_gdb "print sizeof (Tiny)\n"
114gdb_expect {
115 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print sizeof (Tiny)" }
116 -re "$gdb_prompt $" { fail "print sizeof (Tiny)" }
117 timeout { fail "(timeout) print sizeof (Tiny)" }
118}
119
120# print types
121send_gdb "ptype normal\n"
122gdb_expect {
123 -re "type = enum Normal \\{red, blue, green\\} \\\[3\\\].*$gdb_prompt $" { pass "ptype normal" }
124 -re "$gdb_prompt $" { fail "ptype normal" }
125 timeout { fail "(timeout) ptype normal" }
126}
127send_gdb "ptype small\n"
128gdb_expect {
129 -re "type = short enum Small \\{pink, cyan, grey\\} \\\[3\\\].*$gdb_prompt $" { pass "ptype small" }
130 -re "$gdb_prompt $" { fail "ptype small" }
131 timeout { fail "(timeout) ptype small" }
132}
133send_gdb "ptype tiny\n"
134gdb_expect {
135 -re "type = char enum Tiny \\{orange, yellow, brown\\} \\\[3\\\].*$gdb_prompt $" { pass "ptype tiny" }
136 -re "$gdb_prompt $" { fail "ptype tiny" }
137 timeout { fail "(timeout) ptype tiny" }
138}
139
140# convert to int
141send_gdb "print (int) blue\n"
142gdb_expect {
143 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print (int) blue" }
144 -re "$gdb_prompt $" { fail "print (int) blue" }
145 timeout { fail "(timeout) print (int) blue" }
146}
147send_gdb "print (int) cyan\n"
148gdb_expect {
149 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print (int) cyan" }
150 -re "$gdb_prompt $" { fail "print (int) cyan" }
151 timeout { fail "(timeout) print (int) cyan" }
152}
153send_gdb "print (int) yellow\n"
154gdb_expect {
155 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print (int) yellow" }
156 -re "$gdb_prompt $" { fail "print (int) yellow" }
157 timeout { fail "(timeout) print (int) yellow" }
158}
159
160
161