From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 877 invoked by alias); 18 Mar 2003 02:09:04 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 655 invoked from network); 18 Mar 2003 02:09:03 -0000 Received: from unknown (HELO takamaka.act-europe.fr) (142.179.108.108) by sources.redhat.com with SMTP; 18 Mar 2003 02:09:03 -0000 Received: by takamaka.act-europe.fr (Postfix, from userid 507) id F06FDD34B8; Mon, 17 Mar 2003 18:09:05 -0800 (PST) Date: Tue, 18 Mar 2003 02:09:00 -0000 From: Joel Brobecker To: gdb-patches@sources.redhat.com Subject: [RFA] Add some code in observer.c to allow unit-testing Message-ID: <20030318020905.GL16507@gnat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="bajzpZikUji1w+G9" Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2003-03/txt/msg00385.txt.bz2 --bajzpZikUji1w+G9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 992 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 * 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 --bajzpZikUji1w+G9 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="observer.c.diff" Content-length: 1035 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++; + } + --bajzpZikUji1w+G9--