* [RFA] Add some code in observer.c to allow unit-testing
@ 2003-03-18 2:09 Joel Brobecker
2003-03-18 15:38 ` Andrew Cagney
0 siblings, 1 reply; 3+ messages in thread
From: Joel Brobecker @ 2003-03-18 2:09 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 992 bytes --]
Hello again,
Following a small discussion in gdb@, I have written a small regression
test for observer.c.
http://sources.redhat.com/ml/gdb/2003-03/msg00147.html
The test is done by doing inferior function calls to the normal_stop
observer routines. The sticky point is that the attach routine needs
to be provided with a function pointer (callback). This patch adds
3 static counters and 3 static functions that simply increment these
counters. These functions will be provided to the attach routine during
the test (See upcoming testsuite patch for more details)
2003-03-17 J. Brobecker <brobecker@gnat.com>
* observer.c (observer_test_first_observer): New static variable.
(observer_test_second_observer): Likewise.
(observer_test_third_observer): Likewise.
(observer_test_first_notification_function): New static function.
(observer_test_second_notification_function): Likewise.
(observer_test_third_notification_function): Likewise.
Ok to apply?
Thanks,
--
Joel
[-- Attachment #2: observer.c.diff --]
[-- Type: text/plain, Size: 1035 bytes --]
Index: observer.c
===================================================================
RCS file: /cvs/src/src/gdb/observer.c,v
retrieving revision 1.2
diff -c -3 -p -r1.2 observer.c
*** observer.c 28 Feb 2003 07:19:32 -0000 1.2
--- observer.c 18 Mar 2003 01:51:47 -0000
*************** observer_notify_normal_stop (void)
*** 190,192 ****
--- 190,218 ----
{
generic_observer_notify (normal_stop_subject, NULL);
}
+
+ /* The following code is only used to unit-test the observers from
+ our testsuite. DO NOT USE IT within observer.c! */
+
+ static int observer_test_first_observer = 0;
+ static int observer_test_second_observer = 0;
+ static int observer_test_third_observer = 0;
+
+ static void
+ observer_test_first_notification_function (void)
+ {
+ observer_test_first_observer++;
+ }
+
+ static void
+ observer_test_second_notification_function (void)
+ {
+ observer_test_second_observer++;
+ }
+
+ static void
+ observer_test_third_notification_function (void)
+ {
+ observer_test_third_observer++;
+ }
+
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Add some code in observer.c to allow unit-testing
2003-03-18 2:09 [RFA] Add some code in observer.c to allow unit-testing Joel Brobecker
@ 2003-03-18 15:38 ` Andrew Cagney
2003-03-18 18:07 ` Joel Brobecker
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2003-03-18 15:38 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
> Hello again,
>
> Following a small discussion in gdb@, I have written a small regression
> test for observer.c.
>
> http://sources.redhat.com/ml/gdb/2003-03/msg00147.html
>
> The test is done by doing inferior function calls to the normal_stop
> observer routines. The sticky point is that the attach routine needs
> to be provided with a function pointer (callback). This patch adds
> 3 static counters and 3 static functions that simply increment these
> counters. These functions will be provided to the attach routine during
> the test (See upcoming testsuite patch for more details)
>
> 2003-03-17 J. Brobecker <brobecker@gnat.com>
>
> * observer.c (observer_test_first_observer): New static variable.
> (observer_test_second_observer): Likewise.
> (observer_test_third_observer): Likewise.
> (observer_test_first_notification_function): New static function.
> (observer_test_second_notification_function): Likewise.
> (observer_test_third_notification_function): Likewise.
>
> Ok to apply?
Long term, it's going to run into -Wunused-function. Suggest adding a
disclaimer pointing out this limitation :-)
Otherwize (for want of any beter idea :-), ok.
Andrew
> Index: observer.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/observer.c,v
> retrieving revision 1.2
> diff -c -3 -p -r1.2 observer.c
> *** observer.c 28 Feb 2003 07:19:32 -0000 1.2
> --- observer.c 18 Mar 2003 01:51:47 -0000
> *************** observer_notify_normal_stop (void)
> *** 190,192 ****
> --- 190,218 ----
> {
> generic_observer_notify (normal_stop_subject, NULL);
> }
> +
> + /* The following code is only used to unit-test the observers from
> + our testsuite. DO NOT USE IT within observer.c! */
> +
> + static int observer_test_first_observer = 0;
> + static int observer_test_second_observer = 0;
> + static int observer_test_third_observer = 0;
> +
> + static void
> + observer_test_first_notification_function (void)
> + {
> + observer_test_first_observer++;
> + }
> +
> + static void
> + observer_test_second_notification_function (void)
> + {
> + observer_test_second_observer++;
> + }
> +
> + static void
> + observer_test_third_notification_function (void)
> + {
> + observer_test_third_observer++;
> + }
> +
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Add some code in observer.c to allow unit-testing
2003-03-18 15:38 ` Andrew Cagney
@ 2003-03-18 18:07 ` Joel Brobecker
0 siblings, 0 replies; 3+ messages in thread
From: Joel Brobecker @ 2003-03-18 18:07 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
> Long term, it's going to run into -Wunused-function. Suggest adding a
> disclaimer pointing out this limitation :-)
Sure, I added the following comment:
/* Since this code will not be used within GDB, it will trigger
a warning if we decide to compile with -Wunused-function.
This is ok for now. (brobecker 2003-03-18) */
> Otherwize (for want of any beter idea :-), ok.
Checked in, with the above addition.
Thanks,
--
Joel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-03-18 18:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-18 2:09 [RFA] Add some code in observer.c to allow unit-testing Joel Brobecker
2003-03-18 15:38 ` Andrew Cagney
2003-03-18 18:07 ` Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox