1 # Copyright (C) 1997-2013 Free Software Foundation, Inc.
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.
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.
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/>. */
16 # GDB tests for sized enumerations
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.
22 # This file was written by Satish Pai <pai@apollo.hp.com>
26 # test running programs
29 if { [skip_hp_tests] } then { continue }
31 set testfile "sized-enum"
32 set srcfile ${testfile}.c
33 set binfile ${objdir}/${subdir}/${testfile}
35 if [get_compiler_info] {
39 if { $gcc_compiled } then { continue }
40 if {$hp_aCC_compiler} {continue}
42 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
43 untested sized-enum.exp
49 gdb_reinitialize_dir $srcdir/$subdir
53 # set it up at a breakpoint so we can play with the variable values
56 if ![runto_main] then {
57 perror "couldn't run to breakpoint"
61 # set a breakpoint and go there
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" }
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" }
76 send_gdb "print normal\n"
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" }
82 send_gdb "print small\n"
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" }
88 send_gdb "print tiny\n"
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" }
96 send_gdb "print sizeof (Normal)\n"
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)" }
102 send_gdb "print sizeof (Small)\n"
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)" }
108 send_gdb "print sizeof (Tiny)\n"
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)" }
116 send_gdb "ptype normal\n"
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" }
122 send_gdb "ptype small\n"
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" }
128 send_gdb "ptype tiny\n"
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" }
136 send_gdb "print (int) blue\n"
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" }
142 send_gdb "print (int) cyan\n"
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" }
148 send_gdb "print (int) yellow\n"
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" }