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