]>
Commit | Line | Data |
---|---|---|
32d0add0 | 1 | # Copyright (C) 1997-2015 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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
7be570e7 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
7be570e7 JM |
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. | |
e22f8b7c | 12 | # |
7be570e7 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
7be570e7 | 15 | |
7be570e7 JM |
16 | # GDB tests for sized enumerations |
17 | ||
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. | |
21 | ||
22 | # This file was written by Satish Pai <pai@apollo.hp.com> | |
23 | # 1997-09-24 | |
24 | ||
7be570e7 JM |
25 | # |
26 | # test running programs | |
27 | # | |
7be570e7 JM |
28 | |
29 | if { [skip_hp_tests] } then { continue } | |
30 | ||
31 | set testfile "sized-enum" | |
32 | set srcfile ${testfile}.c | |
33 | set binfile ${objdir}/${subdir}/${testfile} | |
34 | ||
4c93b1db | 35 | if [get_compiler_info] { |
7be570e7 JM |
36 | return -1 |
37 | } | |
38 | ||
39 | if { $gcc_compiled } then { continue } | |
40 | if {$hp_aCC_compiler} {continue} | |
41 | ||
42 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
b60f0898 JB |
43 | untested sized-enum.exp |
44 | return -1 | |
7be570e7 JM |
45 | } |
46 | ||
47 | gdb_exit | |
48 | gdb_start | |
49 | gdb_reinitialize_dir $srcdir/$subdir | |
50 | gdb_load ${binfile} | |
51 | ||
52 | # | |
53 | # set it up at a breakpoint so we can play with the variable values | |
54 | # | |
55 | ||
56 | if ![runto_main] then { | |
57 | perror "couldn't run to breakpoint" | |
58 | continue | |
59 | } | |
60 | ||
61 | # set a breakpoint and go there | |
62 | send_gdb "break 34\n" | |
63 | gdb_expect { | |
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" } | |
67 | } | |
68 | send_gdb "continue\n" | |
69 | gdb_expect { | |
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" } | |
73 | } | |
74 | ||
75 | # print stuff | |
76 | send_gdb "print normal\n" | |
77 | gdb_expect { | |
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" } | |
81 | } | |
82 | send_gdb "print small\n" | |
83 | gdb_expect { | |
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" } | |
87 | } | |
88 | send_gdb "print tiny\n" | |
89 | gdb_expect { | |
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" } | |
93 | } | |
94 | ||
95 | # print type sizes | |
96 | send_gdb "print sizeof (Normal)\n" | |
97 | gdb_expect { | |
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)" } | |
101 | } | |
102 | send_gdb "print sizeof (Small)\n" | |
103 | gdb_expect { | |
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)" } | |
107 | } | |
108 | send_gdb "print sizeof (Tiny)\n" | |
109 | gdb_expect { | |
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)" } | |
113 | } | |
114 | ||
115 | # print types | |
116 | send_gdb "ptype normal\n" | |
117 | gdb_expect { | |
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" } | |
121 | } | |
122 | send_gdb "ptype small\n" | |
123 | gdb_expect { | |
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" } | |
127 | } | |
128 | send_gdb "ptype tiny\n" | |
129 | gdb_expect { | |
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" } | |
133 | } | |
134 | ||
135 | # convert to int | |
136 | send_gdb "print (int) blue\n" | |
137 | gdb_expect { | |
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" } | |
141 | } | |
142 | send_gdb "print (int) cyan\n" | |
143 | gdb_expect { | |
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" } | |
147 | } | |
148 | send_gdb "print (int) yellow\n" | |
149 | gdb_expect { | |
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" } | |
153 | } | |
154 | ||
155 | ||
156 |