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