]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.hp/sized-enum.exp
import gdb-19990422 snapshot
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.hp / sized-enum.exp
1 # Copyright (C) 1997, 1998 Free Software Foundation, Inc.
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
29 if $tracelevel then {
30 strace $tracelevel
31 }
32
33 #
34 # test running programs
35 #
36 set prms_id 0
37 set bug_id 0
38
39 if { [skip_hp_tests] } then { continue }
40
41 set testfile "sized-enum"
42 set srcfile ${testfile}.c
43 set binfile ${objdir}/${subdir}/${testfile}
44
45 if [get_compiler_info ${binfile}] {
46 return -1
47 }
48
49 if { $gcc_compiled } then { continue }
50
51 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
52 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
53 }
54
55 gdb_exit
56 gdb_start
57 gdb_reinitialize_dir $srcdir/$subdir
58 gdb_load ${binfile}
59
60 #
61 # set it up at a breakpoint so we can play with the variable values
62 #
63
64 if ![runto_main] then {
65 perror "couldn't run to breakpoint"
66 continue
67 }
68
69 # set a breakpoint and go there
70 send_gdb "break 34\n"
71 gdb_expect {
72 -re "Breakpoint \[0-9\] at.*$gdb_prompt $" { pass "set break 34" }
73 -re "$gdb_prompt $" { fail "set break 34" }
74 timeout { fail "(timeout) set break 34" }
75 }
76 send_gdb "continue\n"
77 gdb_expect {
78 -re "Continuing\\.\r\n\r\nBreakpoint \[0-9\]*, main....at.*sized-enum\\.c:34\r\n34.*\r\n$gdb_prompt $" { pass "continue" }
79 -re "$gdb_prompt $" { fail "continue" }
80 timeout { fail "(timeout) continue" }
81 }
82
83 # print stuff
84 send_gdb "print normal\n"
85 gdb_expect {
86 -re "\\$\[0-9\]* = \\{red, blue, green\\}.*$gdb_prompt $" { pass "print normal" }
87 -re "$gdb_prompt $" { fail "print normal" }
88 timeout { fail "(timeout) print normal" }
89 }
90 send_gdb "print small\n"
91 gdb_expect {
92 -re "\\$\[0-9\]* = \\{pink, cyan, grey\\}.*$gdb_prompt $" { pass "print small" }
93 -re "$gdb_prompt $" { fail "print small" }
94 timeout { fail "(timeout) print small" }
95 }
96 send_gdb "print tiny\n"
97 gdb_expect {
98 -re "\\$\[0-9\]* = \\{orange, yellow, brown\\}.*$gdb_prompt $" { pass "print tiny" }
99 -re "$gdb_prompt $" { fail "print tiny" }
100 timeout { fail "(timeout) print tiny" }
101 }
102
103 # print type sizes
104 send_gdb "print sizeof (Normal)\n"
105 gdb_expect {
106 -re "\\$\[0-9\]* = 4.*$gdb_prompt $" { pass "print sizeof (Normal)" }
107 -re "$gdb_prompt $" { fail "print sizeof (Normal)" }
108 timeout { fail "(timeout) print sizeof (Normal)" }
109 }
110 send_gdb "print sizeof (Small)\n"
111 gdb_expect {
112 -re "\\$\[0-9\]* = 2.*$gdb_prompt $" { pass "print sizeof (Small)" }
113 -re "$gdb_prompt $" { fail "print sizeof (Small)" }
114 timeout { fail "(timeout) print sizeof (Small)" }
115 }
116 send_gdb "print sizeof (Tiny)\n"
117 gdb_expect {
118 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print sizeof (Tiny)" }
119 -re "$gdb_prompt $" { fail "print sizeof (Tiny)" }
120 timeout { fail "(timeout) print sizeof (Tiny)" }
121 }
122
123 # print types
124 send_gdb "ptype normal\n"
125 gdb_expect {
126 -re "type = enum Normal \\{red, blue, green\\} \\\[3\\\].*$gdb_prompt $" { pass "ptype normal" }
127 -re "$gdb_prompt $" { fail "ptype normal" }
128 timeout { fail "(timeout) ptype normal" }
129 }
130 send_gdb "ptype small\n"
131 gdb_expect {
132 -re "type = short enum Small \\{pink, cyan, grey\\} \\\[3\\\].*$gdb_prompt $" { pass "ptype small" }
133 -re "$gdb_prompt $" { fail "ptype small" }
134 timeout { fail "(timeout) ptype small" }
135 }
136 send_gdb "ptype tiny\n"
137 gdb_expect {
138 -re "type = char enum Tiny \\{orange, yellow, brown\\} \\\[3\\\].*$gdb_prompt $" { pass "ptype tiny" }
139 -re "$gdb_prompt $" { fail "ptype tiny" }
140 timeout { fail "(timeout) ptype tiny" }
141 }
142
143 # convert to int
144 send_gdb "print (int) blue\n"
145 gdb_expect {
146 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print (int) blue" }
147 -re "$gdb_prompt $" { fail "print (int) blue" }
148 timeout { fail "(timeout) print (int) blue" }
149 }
150 send_gdb "print (int) cyan\n"
151 gdb_expect {
152 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print (int) cyan" }
153 -re "$gdb_prompt $" { fail "print (int) cyan" }
154 timeout { fail "(timeout) print (int) cyan" }
155 }
156 send_gdb "print (int) yellow\n"
157 gdb_expect {
158 -re "\\$\[0-9\]* = 1.*$gdb_prompt $" { pass "print (int) yellow" }
159 -re "$gdb_prompt $" { fail "print (int) yellow" }
160 timeout { fail "(timeout) print (int) yellow" }
161 }
162
163
164