1 # Copyright (C) 1997, 1998, 2007, 2008, 2009, 2010
2 # Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 # GDB tests for sized enumerations
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.
23 # This file was written by Satish Pai <pai@apollo.hp.com>
31 # test running programs
36 if { [skip_hp_tests] } then { continue }
38 set testfile "sized-enum"
39 set srcfile ${testfile}.c
40 set binfile ${objdir}/${subdir}/${testfile}
42 if [get_compiler_info ${binfile}] {
46 if { $gcc_compiled } then { continue }
47 if {$hp_aCC_compiler} {continue}
49 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
50 untested sized-enum.exp
56 gdb_reinitialize_dir $srcdir/$subdir
60 # set it up at a breakpoint so we can play with the variable values
63 if ![runto_main] then {
64 perror "couldn't run to breakpoint"
68 # set a breakpoint and go there
71 -re "Breakpoint.*line 34.*$gdb_prompt $" { pass "set break 34" }
72 -re "$gdb_prompt $" { fail "set break 34" }
73 timeout { fail "(timeout) set break 34" }
77 -re "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, main....at.*sized-enum\\.c:34\r\n34.*\r\n$gdb_prompt $" { pass "continue" }
78 -re "$gdb_prompt $" { fail "continue" }
79 timeout { fail "(timeout) continue" }
83 send_gdb "print normal\n"
85 -re "\\$\[0-9\]* = \\{red, blue, green\\}.*$gdb_prompt $" { pass "print normal" }
86 -re "$gdb_prompt $" { fail "print normal" }
87 timeout { fail "(timeout) print normal" }
89 send_gdb "print small\n"
91 -re "\\$\[0-9\]* = \\{pink, cyan, grey\\}.*$gdb_prompt $" { pass "print small" }
92 -re "$gdb_prompt $" { fail "print small" }
93 timeout { fail "(timeout) print small" }
95 send_gdb "print tiny\n"
97 -re "\\$\[0-9\]* = \\{orange, yellow, brown\\}.*$gdb_prompt $" { pass "print tiny" }
98 -re "$gdb_prompt $" { fail "print tiny" }
99 timeout { fail "(timeout) print tiny" }
103 send_gdb "print sizeof (Normal)\n"
105 -re "\\$\[0-9\]* = 4.*$gdb_prompt $" { pass "print sizeof (Normal)" }
106 -re "$gdb_prompt $" { fail "print sizeof (Normal)" }
107 timeout { fail "(timeout) print sizeof (Normal)" }
109 send_gdb "print sizeof (Small)\n"
111 -re "\\$\[0-9\]* = 2.*$gdb_prompt $" { pass "print sizeof (Small)" }
112 -re "$gdb_prompt $" { fail "print sizeof (Small)" }
113 timeout { fail "(timeout) print sizeof (Small)" }
115 send_gdb "print sizeof (Tiny)\n"
117 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print sizeof (Tiny)" }
118 -re "$gdb_prompt $" { fail "print sizeof (Tiny)" }
119 timeout { fail "(timeout) print sizeof (Tiny)" }
123 send_gdb "ptype normal\n"
125 -re "type = enum Normal \\{red, blue, green\\} \\\[3\\\].*$gdb_prompt $" { pass "ptype normal" }
126 -re "$gdb_prompt $" { fail "ptype normal" }
127 timeout { fail "(timeout) ptype normal" }
129 send_gdb "ptype small\n"
131 -re "type = short enum Small \\{pink, cyan, grey\\} \\\[3\\\].*$gdb_prompt $" { pass "ptype small" }
132 -re "$gdb_prompt $" { fail "ptype small" }
133 timeout { fail "(timeout) ptype small" }
135 send_gdb "ptype tiny\n"
137 -re "type = char enum Tiny \\{orange, yellow, brown\\} \\\[3\\\].*$gdb_prompt $" { pass "ptype tiny" }
138 -re "$gdb_prompt $" { fail "ptype tiny" }
139 timeout { fail "(timeout) ptype tiny" }
143 send_gdb "print (int) blue\n"
145 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print (int) blue" }
146 -re "$gdb_prompt $" { fail "print (int) blue" }
147 timeout { fail "(timeout) print (int) blue" }
149 send_gdb "print (int) cyan\n"
151 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print (int) cyan" }
152 -re "$gdb_prompt $" { fail "print (int) cyan" }
153 timeout { fail "(timeout) print (int) cyan" }
155 send_gdb "print (int) yellow\n"
157 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print (int) yellow" }
158 -re "$gdb_prompt $" { fail "print (int) yellow" }
159 timeout { fail "(timeout) print (int) yellow" }