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