From: Andrew Cagney Date: Tue, 13 Jul 2004 14:36:44 +0000 (+0000) Subject: 2004-07-13 Andrew Cagney X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab89363a823945b2a88a600011184ec20cefa832;p=binutils-gdb.git 2004-07-13 Andrew Cagney * 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. --- diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 2550ca5bad4..4db1f80b095 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,17 @@ 2004-07-13 Andrew Cagney + * 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 "${name}". Clean up test messages. diff --git a/gdb/testsuite/gdb.gdb/observer.exp b/gdb/testsuite/gdb.gdb/observer.exp index c36d46126d4..5b466e62bc0 100644 --- a/gdb/testsuite/gdb.gdb/observer.exp +++ b/gdb/testsuite/gdb.gdb/observer.exp @@ -1,5 +1,4 @@ -# Copyright 2003 -# Free Software Foundation, Inc. +# Copyright 2003, 2004 Free Software Foundation, Inc. # 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 @@ -15,9 +14,6 @@ # along with this program; if not, write to the Free Software # 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 # from xfullpath.exp. @@ -69,8 +65,7 @@ proc setup_test { executable } { set timeout 600 set description "run until breakpoint at captured_main" - send_gdb "run -nw\n" - gdb_expect { + gdb_test_multiple "run -nw" "$description" { -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" { pass "$description" } @@ -89,9 +84,6 @@ proc setup_test { executable } { verbose "Timeout is now $timeout seconds" 2 return -1 } - timeout { - fail "$description (timeout)" - } } set timeout $oldtimeout @@ -100,64 +92,68 @@ proc setup_test { executable } { 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)" \ - "" "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)" \ - "" "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)" \ - "" "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)" \ - "" "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)" \ - "" "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)" \ - "" "detach third observer" + "" "$message; detach third observer" } proc check_counters { first second third message } { gdb_test "print observer_test_first_observer" \ - ".\[0-9\]+ =.*$first" \ - "check first observer counter value ($message)" + ".\[0-9\]+ =.*$first" \ + "$message; check first observer counter value" gdb_test "print observer_test_second_observer" \ - ".\[0-9\]+ =.*$second" \ - "check second observer counter value ($message)" + ".\[0-9\]+ =.*$second" \ + "$message; check second observer counter value" gdb_test "print observer_test_third_observer" \ - ".\[0-9\]+ =.*$third" \ - "check third observer counter value ($message)" + ".\[0-9\]+ =.*$third" \ + "$message; check third observer counter value" } -proc reset_counters { } { +proc reset_counters { message } { 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" "" \ - "reset second observer counter" + "$message; reset second observer counter" 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 } { - reset_counters +proc test_normal_stop_notifications { first second third message args } { + # 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 # takes one argument, but this argument is ignored by the observer # callbacks we have installed. So we just pass an arbitrary value. gdb_test "call observer_notify_normal_stop (0)" "" \ - "sending notification ($message)" + "$message; sending notification" 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. - 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. - attach_second_observer - test_normal_stop_notifications 0 1 0 "one observer" + test_normal_stop_notifications 0 1 0 "second observer attached" \ + attach_second_observer # Remove the observer, and send a notification. - detach_second_observer - test_normal_stop_notifications 0 0 0 "no observer" + test_normal_stop_notifications 0 0 0 "second observer detached" \ + detach_second_observer # With a new observer. - attach_first_observer - test_normal_stop_notifications 1 0 0 "a new observer" + test_normal_stop_notifications 1 0 0 "1st observer added" \ + attach_first_observer # With 2 observers. - attach_second_observer - test_normal_stop_notifications 1 1 0 "2 observers" + test_normal_stop_notifications 1 1 0 "2nd observer added" \ + attach_second_observer # With 3 observers. - attach_third_observer - test_normal_stop_notifications 1 1 1 "3 observers" + test_normal_stop_notifications 1 1 1 "3rd observer added" \ + attach_third_observer # Remove middle observer. - detach_second_observer - test_normal_stop_notifications 1 0 1 "middle observer removed" + test_normal_stop_notifications 1 0 1 "2nd observer removed" \ + detach_second_observer # Remove first observer. - detach_first_observer - test_normal_stop_notifications 0 0 1 "first observer removed" + test_normal_stop_notifications 0 0 1 "1st observer removed" \ + detach_first_observer # Remove last observer. - detach_third_observer - test_normal_stop_notifications 0 0 0 "last observer removed" + test_normal_stop_notifications 0 0 0 "3rd observer removed" \ + detach_third_observer # Go back to 3 observers, and remove them in a different order... - attach_first_observer - attach_second_observer - attach_third_observer - test_normal_stop_notifications 1 1 1 "3 observers again" + test_normal_stop_notifications 1 1 1 "three observers added" \ + attach_first_observer \ + attach_second_observer \ + attach_third_observer # Remove the third observer. - detach_third_observer - test_normal_stop_notifications 1 1 0 "third observer removed" + test_normal_stop_notifications 1 1 0 "third observer removed" \ + detach_third_observer # Remove the second observer. - detach_second_observer - test_normal_stop_notifications 1 0 0 "second observer removed" + test_normal_stop_notifications 1 0 0 "second observer removed" \ + detach_second_observer # Remove the first observer, no more observers. - detach_first_observer - test_normal_stop_notifications 0 0 0 "last observer removed" + test_normal_stop_notifications 0 0 0 "first observer removed" \ + detach_first_observer return 0 }