Update copyright year in most headers.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.hp / gdb.base-hp / sized-enum.exp
1 # Copyright (C) 1997, 1998, 2007, 2008, 2009, 2010
2 # Free Software Foundation, Inc.
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
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
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.
13 #
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/>. */
16
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
26 if $tracelevel then {
27 strace $tracelevel
28 }
29
30 #
31 # test running programs
32 #
33 set prms_id 0
34 set bug_id 0
35
36 if { [skip_hp_tests] } then { continue }
37
38 set testfile "sized-enum"
39 set srcfile ${testfile}.c
40 set binfile ${objdir}/${subdir}/${testfile}
41
42 if [get_compiler_info ${binfile}] {
43 return -1
44 }
45
46 if { $gcc_compiled } then { continue }
47 if {$hp_aCC_compiler} {continue}
48
49 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
50 untested sized-enum.exp
51 return -1
52 }
53
54 gdb_exit
55 gdb_start
56 gdb_reinitialize_dir $srcdir/$subdir
57 gdb_load ${binfile}
58
59 #
60 # set it up at a breakpoint so we can play with the variable values
61 #
62
63 if ![runto_main] then {
64 perror "couldn't run to breakpoint"
65 continue
66 }
67
68 # set a breakpoint and go there
69 send_gdb "break 34\n"
70 gdb_expect {
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" }
74 }
75 send_gdb "continue\n"
76 gdb_expect {
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" }
80 }
81
82 # print stuff
83 send_gdb "print normal\n"
84 gdb_expect {
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" }
88 }
89 send_gdb "print small\n"
90 gdb_expect {
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" }
94 }
95 send_gdb "print tiny\n"
96 gdb_expect {
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" }
100 }
101
102 # print type sizes
103 send_gdb "print sizeof (Normal)\n"
104 gdb_expect {
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)" }
108 }
109 send_gdb "print sizeof (Small)\n"
110 gdb_expect {
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)" }
114 }
115 send_gdb "print sizeof (Tiny)\n"
116 gdb_expect {
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)" }
120 }
121
122 # print types
123 send_gdb "ptype normal\n"
124 gdb_expect {
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" }
128 }
129 send_gdb "ptype small\n"
130 gdb_expect {
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" }
134 }
135 send_gdb "ptype tiny\n"
136 gdb_expect {
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" }
140 }
141
142 # convert to int
143 send_gdb "print (int) blue\n"
144 gdb_expect {
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" }
148 }
149 send_gdb "print (int) cyan\n"
150 gdb_expect {
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" }
154 }
155 send_gdb "print (int) yellow\n"
156 gdb_expect {
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" }
160 }
161
162
163
This page took 0.034051 seconds and 4 git commands to generate.