Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: gdb/testsuite/gdb.gdb/observer.exp

Issue 124383005: GDB 7.6.50 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@upstream
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/testsuite/gdb.gdb/complaints.exp ('k') | gdb/testsuite/gdb.gdb/python-selftest.exp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2003-2004, 2007-2012 Free Software Foundation, Inc. 1 # Copyright 2003-2013 Free Software Foundation, Inc.
2 2
3 # This program is free software; you can redistribute it and/or modify 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 4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or 5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version. 6 # (at your option) any later version.
7 # 7 #
8 # This program is distributed in the hope that it will be useful, 8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>. 14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 15
16 # This file was written by Joel Brobecker (brobecker@gnat.com), derived 16 # This file was written by Joel Brobecker (brobecker@gnat.com), derived
17 # from xfullpath.exp. 17 # from xfullpath.exp.
18 18
19 19 load_lib selftest-support.exp
20 # are we on a target board
21 if { [is_remote target] || ![isnative] } then {
22 return
23 }
24
25 proc setup_test { executable } {
26 global gdb_prompt
27 global timeout
28
29 # load yourself into the debugger
30 # This can take a relatively long time, particularly for testing where
31 # the executable is being accessed over a network, or where gdb does not
32 # support partial symbols for a particular target and has to load the
33 # entire symbol table. Set the timeout to 10 minutes, which should be
34 # adequate for most environments (it *has* timed out with 5 min on a
35 # SPARCstation SLC under moderate load, so this isn't unreasonable).
36 # After gdb is started, set the timeout to 30 seconds for the duration
37 # of this test, and then back to the original value.
38
39 set oldtimeout $timeout
40 set timeout 600
41 verbose "Timeout is now $timeout seconds" 2
42
43 global gdb_file_cmd_debug_info
44 set gdb_file_cmd_debug_info "unset"
45
46 set result [gdb_load $executable]
47 set timeout $oldtimeout
48 verbose "Timeout is now $timeout seconds" 2
49
50 if { $result != 0 } then {
51 » return -1
52 }
53
54 if { $gdb_file_cmd_debug_info != "debug" } then {
55 » untested "No debug information, skipping testcase."
56 » return -1
57 }
58
59 # Set a breakpoint at main
60 gdb_test "break captured_main" \
61 "Breakpoint.*at.* file.*, line.*" \
62 "breakpoint in captured_main"
63
64 # run yourself
65 # It may take a very long time for the inferior gdb to start (lynx),
66 # so we bump it back up for the duration of this command.
67 set timeout 600
68
69 set description "run until breakpoint at captured_main"
70 gdb_test_multiple "run -nw" "$description" {
71 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .* main.c:.*$gdb_prompt $" {
72 pass "$description"
73 }
74 -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.*$gdb_p rompt $" {
75 xfail "$description (line numbers scrambled?)"
76 }
77 -re "vfork: No more processes.*$gdb_prompt $" {
78 fail "$description (out of virtual memory)"
79 set timeout $oldtimeout
80 verbose "Timeout is now $timeout seconds" 2
81 return -1
82 }
83 -re ".*$gdb_prompt $" {
84 fail "$description"
85 set timeout $oldtimeout
86 verbose "Timeout is now $timeout seconds" 2
87 return -1
88 }
89 }
90
91 set timeout $oldtimeout
92 verbose "Timeout is now $timeout seconds" 2
93
94 return 0
95 }
96 20
97 proc attach_first_observer { message } { 21 proc attach_first_observer { message } {
98 gdb_test_no_output "set \$first_obs = observer_attach_test_notification (&ob server_test_first_notification_function)" \ 22 gdb_test_no_output "set \$first_obs = observer_attach_test_notification (&ob server_test_first_notification_function)" \
99 "$message; attach first observer" 23 "$message; attach first observer"
100 } 24 }
101 25
102 proc attach_second_observer { message } { 26 proc attach_second_observer { message } {
103 gdb_test_no_output "set \$second_obs = observer_attach_test_notification (&o bserver_test_second_notification_function)" \ 27 gdb_test_no_output "set \$second_obs = observer_attach_test_notification (&o bserver_test_second_notification_function)" \
104 "$message; attach second observer" 28 "$message; attach second observer"
105 } 29 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 76 }
153 reset_counters $message 77 reset_counters $message
154 # Call observer_notify_test_notification. Note that this procedure 78 # Call observer_notify_test_notification. Note that this procedure
155 # takes one argument, but this argument is ignored by the observer 79 # takes one argument, but this argument is ignored by the observer
156 # callbacks we have installed. So we just pass an arbitrary value. 80 # callbacks we have installed. So we just pass an arbitrary value.
157 gdb_test_no_output "call observer_notify_test_notification (0)" \ 81 gdb_test_no_output "call observer_notify_test_notification (0)" \
158 "$message; sending notification" 82 "$message; sending notification"
159 check_counters $first $second $third $message 83 check_counters $first $second $third $message
160 } 84 }
161 85
162 proc test_observer { executable } { 86 proc test_observer {} {
163
164 set setup_result [setup_test $executable]
165 if {$setup_result <0} then {
166 return -1
167 }
168
169 # First, try sending a notification without any observer attached. 87 # First, try sending a notification without any observer attached.
170 test_notifications 0 0 0 "no observer attached" 88 test_notifications 0 0 0 "no observer attached"
171 89
172 # Now, attach one observer, and send a notification. 90 # Now, attach one observer, and send a notification.
173 test_notifications 0 1 0 "second observer attached" \ 91 test_notifications 0 1 0 "second observer attached" \
174 attach_second_observer 92 attach_second_observer
175 93
176 # Remove the observer, and send a notification. 94 # Remove the observer, and send a notification.
177 test_notifications 0 0 0 "second observer detached" \ 95 test_notifications 0 0 0 "second observer detached" \
178 detach_second_observer 96 detach_second_observer
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 test_notifications 1 0 0 "second observer removed" \ 133 test_notifications 1 0 0 "second observer removed" \
216 detach_second_observer 134 detach_second_observer
217 135
218 # Remove the first observer, no more observers. 136 # Remove the first observer, no more observers.
219 test_notifications 0 0 0 "first observer removed" \ 137 test_notifications 0 0 0 "first observer removed" \
220 detach_first_observer 138 detach_first_observer
221 139
222 return 0 140 return 0
223 } 141 }
224 142
225 # Find a pathname to a file that we would execute if the shell was asked 143 do_self_tests captured_main test_observer
226 # to run $arg using the current PATH.
227
228 proc find_gdb { arg } {
229
230 # If the arg directly specifies an existing executable file, then
231 # simply use it.
232
233 if [file executable $arg] then {
234 » return $arg
235 }
236
237 set result [which $arg]
238 if [string match "/" [ string range $result 0 0 ]] then {
239 » return $result
240 }
241
242 # If everything fails, just return the unqualified pathname as default
243 # and hope for best.
244
245 return $arg
246 }
247
248 # Run the test with self.
249 # Copy the file executable file in case this OS doesn't like to edit its own
250 # text space.
251
252 set GDB_FULLPATH [find_gdb $GDB]
253
254 # Remove any old copy lying around.
255 remote_file host delete x$tool
256
257 gdb_start
258 set file [remote_download host $GDB_FULLPATH x$tool]
259 set result [test_observer $file];
260 gdb_exit;
261 catch "remote_file host delete $file";
262
263 if {$result <0} then {
264 warning "Couldn't test self"
265 return -1
266 }
OLDNEW
« no previous file with comments | « gdb/testsuite/gdb.gdb/complaints.exp ('k') | gdb/testsuite/gdb.gdb/python-selftest.exp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698