2004-07-13 Andrew Cagney <cagney@gnu.org>

* gdb.gdb/observer.exp: Update copyright.
	(setup_test): Use gdb_test_multiple.
	(attach_first_observer, attach_second_observer)
	(attach_third_observer, detach_first_observer)
	(detach_second_observer, detach_third_observer)
	(reset_counters, check_counters): Make $message a prefix.
	(test_normal_stop_notifications): Add "args" parameter - a list of
	init functions to be called.  Make $message a prefix,
	(test_observer_normal_stop): Change the message prefixes so that
	they are unique, pass the attach / detach procedures to
	test_normal_stop_notifications.
This commit is contained in:
Andrew Cagney
2004-07-13 14:36:44 +00:00
parent ec58997a7b
commit ab89363a82
2 changed files with 70 additions and 62 deletions

View File

@ -1,5 +1,17 @@
2004-07-13 Andrew Cagney <cagney@gnu.org> 2004-07-13 Andrew Cagney <cagney@gnu.org>
* gdb.gdb/observer.exp: Update copyright.
(setup_test): Use gdb_test_multiple.
(attach_first_observer, attach_second_observer)
(attach_third_observer, detach_first_observer)
(detach_second_observer, detach_third_observer)
(reset_counters, check_counters): Make $message a prefix.
(test_normal_stop_notifications): Add "args" parameter - a list of
init functions to be called. Make $message a prefix,
(test_observer_normal_stop): Change the message prefixes so that
they are unique, pass the attach / detach procedures to
test_normal_stop_notifications.
* gdb.base/signull.exp (test_segv): Prefix all tests with * gdb.base/signull.exp (test_segv): Prefix all tests with
"${name}". Clean up test messages. "${name}". Clean up test messages.

View File

@ -1,5 +1,4 @@
# Copyright 2003 # Copyright 2003, 2004 Free Software Foundation, Inc.
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -15,9 +14,6 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu
# This file was written by Joel Brobecker (brobecker@gnat.com), derived # This file was written by Joel Brobecker (brobecker@gnat.com), derived
# from xfullpath.exp. # from xfullpath.exp.
@ -69,8 +65,7 @@ proc setup_test { executable } {
set timeout 600 set timeout 600
set description "run until breakpoint at captured_main" set description "run until breakpoint at captured_main"
send_gdb "run -nw\n" gdb_test_multiple "run -nw" "$description" {
gdb_expect {
-re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" { -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" {
pass "$description" pass "$description"
} }
@ -89,9 +84,6 @@ proc setup_test { executable } {
verbose "Timeout is now $timeout seconds" 2 verbose "Timeout is now $timeout seconds" 2
return -1 return -1
} }
timeout {
fail "$description (timeout)"
}
} }
set timeout $oldtimeout set timeout $oldtimeout
@ -100,64 +92,68 @@ proc setup_test { executable } {
return 0 return 0
} }
proc attach_first_observer { } { proc attach_first_observer { message } {
gdb_test "set \$first_obs = observer_attach_normal_stop (&observer_test_first_notification_function)" \ gdb_test "set \$first_obs = observer_attach_normal_stop (&observer_test_first_notification_function)" \
"" "attach first observer" "" "$message; attach first observer"
} }
proc attach_second_observer { } { proc attach_second_observer { message } {
gdb_test "set \$second_obs = observer_attach_normal_stop (&observer_test_second_notification_function)" \ gdb_test "set \$second_obs = observer_attach_normal_stop (&observer_test_second_notification_function)" \
"" "attach second observer" "" "$message; attach second observer"
} }
proc attach_third_observer { } { proc attach_third_observer { message } {
gdb_test "set \$third_obs = observer_attach_normal_stop (&observer_test_third_notification_function)" \ gdb_test "set \$third_obs = observer_attach_normal_stop (&observer_test_third_notification_function)" \
"" "attach third observer" "" "$message; attach third observer"
} }
proc detach_first_observer { } { proc detach_first_observer { message } {
gdb_test "call observer_detach_normal_stop (\$first_obs)" \ gdb_test "call observer_detach_normal_stop (\$first_obs)" \
"" "detach first observer" "" "$message; detach first observer"
} }
proc detach_second_observer { } { proc detach_second_observer { message } {
gdb_test "call observer_detach_normal_stop (\$second_obs)" \ gdb_test "call observer_detach_normal_stop (\$second_obs)" \
"" "detach second observer" "" "$message; detach second observer"
} }
proc detach_third_observer { } { proc detach_third_observer { message } {
gdb_test "call observer_detach_normal_stop (\$third_obs)" \ gdb_test "call observer_detach_normal_stop (\$third_obs)" \
"" "detach third observer" "" "$message; detach third observer"
} }
proc check_counters { first second third message } { proc check_counters { first second third message } {
gdb_test "print observer_test_first_observer" \ gdb_test "print observer_test_first_observer" \
".\[0-9\]+ =.*$first" \ ".\[0-9\]+ =.*$first" \
"check first observer counter value ($message)" "$message; check first observer counter value"
gdb_test "print observer_test_second_observer" \ gdb_test "print observer_test_second_observer" \
".\[0-9\]+ =.*$second" \ ".\[0-9\]+ =.*$second" \
"check second observer counter value ($message)" "$message; check second observer counter value"
gdb_test "print observer_test_third_observer" \ gdb_test "print observer_test_third_observer" \
".\[0-9\]+ =.*$third" \ ".\[0-9\]+ =.*$third" \
"check third observer counter value ($message)" "$message; check third observer counter value"
} }
proc reset_counters { } { proc reset_counters { message } {
gdb_test "set variable observer_test_first_observer = 0" "" \ gdb_test "set variable observer_test_first_observer = 0" "" \
"reset first observer counter" "$message; reset first observer counter"
gdb_test "set variable observer_test_second_observer = 0" "" \ gdb_test "set variable observer_test_second_observer = 0" "" \
"reset second observer counter" "$message; reset second observer counter"
gdb_test "set variable observer_test_third_observer = 0" "" \ gdb_test "set variable observer_test_third_observer = 0" "" \
"reset third observer counter" "$message; reset third observer counter"
} }
proc test_normal_stop_notifications { first second third message } { proc test_normal_stop_notifications { first second third message args } {
reset_counters # Do any initialization
for {set i 0} {$i < [llength $args]} {incr i} {
[lindex $args $i] $message
}
reset_counters $message
# Call observer_notify_normal_stop. Note that this procedure # Call observer_notify_normal_stop. Note that this procedure
# takes one argument, but this argument is ignored by the observer # takes one argument, but this argument is ignored by the observer
# callbacks we have installed. So we just pass an arbitrary value. # callbacks we have installed. So we just pass an arbitrary value.
gdb_test "call observer_notify_normal_stop (0)" "" \ gdb_test "call observer_notify_normal_stop (0)" "" \
"sending notification ($message)" "$message; sending notification"
check_counters $first $second $third $message check_counters $first $second $third $message
} }
@ -169,57 +165,57 @@ proc test_observer_normal_stop { executable } {
} }
# First, try sending a notification without any observer attached. # First, try sending a notification without any observer attached.
test_normal_stop_notifications 0 0 0 "no observer" test_normal_stop_notifications 0 0 0 "no observer attached"
# Now, attach one observer, and send a notification. # Now, attach one observer, and send a notification.
test_normal_stop_notifications 0 1 0 "second observer attached" \
attach_second_observer attach_second_observer
test_normal_stop_notifications 0 1 0 "one observer"
# Remove the observer, and send a notification. # Remove the observer, and send a notification.
test_normal_stop_notifications 0 0 0 "second observer detached" \
detach_second_observer detach_second_observer
test_normal_stop_notifications 0 0 0 "no observer"
# With a new observer. # With a new observer.
test_normal_stop_notifications 1 0 0 "1st observer added" \
attach_first_observer attach_first_observer
test_normal_stop_notifications 1 0 0 "a new observer"
# With 2 observers. # With 2 observers.
test_normal_stop_notifications 1 1 0 "2nd observer added" \
attach_second_observer attach_second_observer
test_normal_stop_notifications 1 1 0 "2 observers"
# With 3 observers. # With 3 observers.
test_normal_stop_notifications 1 1 1 "3rd observer added" \
attach_third_observer attach_third_observer
test_normal_stop_notifications 1 1 1 "3 observers"
# Remove middle observer. # Remove middle observer.
test_normal_stop_notifications 1 0 1 "2nd observer removed" \
detach_second_observer detach_second_observer
test_normal_stop_notifications 1 0 1 "middle observer removed"
# Remove first observer. # Remove first observer.
test_normal_stop_notifications 0 0 1 "1st observer removed" \
detach_first_observer detach_first_observer
test_normal_stop_notifications 0 0 1 "first observer removed"
# Remove last observer. # Remove last observer.
test_normal_stop_notifications 0 0 0 "3rd observer removed" \
detach_third_observer detach_third_observer
test_normal_stop_notifications 0 0 0 "last observer removed"
# Go back to 3 observers, and remove them in a different order... # Go back to 3 observers, and remove them in a different order...
attach_first_observer test_normal_stop_notifications 1 1 1 "three observers added" \
attach_second_observer attach_first_observer \
attach_second_observer \
attach_third_observer attach_third_observer
test_normal_stop_notifications 1 1 1 "3 observers again"
# Remove the third observer. # Remove the third observer.
test_normal_stop_notifications 1 1 0 "third observer removed" \
detach_third_observer detach_third_observer
test_normal_stop_notifications 1 1 0 "third observer removed"
# Remove the second observer. # Remove the second observer.
test_normal_stop_notifications 1 0 0 "second observer removed" \
detach_second_observer detach_second_observer
test_normal_stop_notifications 1 0 0 "second observer removed"
# Remove the first observer, no more observers. # Remove the first observer, no more observers.
test_normal_stop_notifications 0 0 0 "first observer removed" \
detach_first_observer detach_first_observer
test_normal_stop_notifications 0 0 0 "last observer removed"
return 0 return 0
} }