summaryrefslogtreecommitdiff
path: root/ACE
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>2009-03-24 13:44:57 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>2009-03-24 13:44:57 +0000
commit2a2cc7a6bb7a8e2c9b75ea82baff24a0592cd56f (patch)
tree2f3706614da0dcb6c16f443bdadc7519e032a026 /ACE
parente2a88334b86d2fde7f550fb7ffa864feaef5164d (diff)
downloadATCD-2a2cc7a6bb7a8e2c9b75ea82baff24a0592cd56f.tar.gz
ChangeLogTag:Tue
Diffstat (limited to 'ACE')
-rw-r--r--ACE/ChangeLog7
-rw-r--r--ACE/tests/Sig_Handlers_Test.cpp130
2 files changed, 136 insertions, 1 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index 43bda3bfd0a..bb739d22444 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,8 @@
+Tue Mar 24 13:43:14 UTC 2009 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu>
+
+ * tests/Sig_Handlers_Test.cpp: Added a new test to ensure that the
+ ACE_Sig_Handlers class is working properly.
+
Tue Mar 24 11:45:22 UTC 2009 Johnny Willemsen <jwillemsen@remedy.nl>
* tests/Bug_3532_Regression_Test.cpp:
@@ -15,7 +20,7 @@ Mon Mar 23 23:11:49 UTC 2009 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu>
* ace/Sig_Handler.cpp: Fixed a silly bug in the use of
ACE_Fixed_Set_Iterator that was causing every other signal in
- ACE_Sig_Handlers to be skipped. Thanks to Andreas_Drescher <ace
+ ACE_Sig_Handlers to be skipped. Thanks to Andreas Drescher <ace
at anticat dot ch> for reporting this bug.
Sun Mar 22 19:21:06 UTC 2009 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu>
diff --git a/ACE/tests/Sig_Handlers_Test.cpp b/ACE/tests/Sig_Handlers_Test.cpp
new file mode 100644
index 00000000000..fbefcfa283c
--- /dev/null
+++ b/ACE/tests/Sig_Handlers_Test.cpp
@@ -0,0 +1,130 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// tests
+//
+// = FILENAME
+// Sig_Handlers_Test.cpp
+//
+// = DESCRIPTION
+// This is a simple program that tests whether the ACE_Sig_Handlers
+// class works properly. To run this test, start the application
+// and then type ^C. If everything is working properly the test
+// will shutdown gracefully.
+//
+// = AUTHOR
+// Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> and Andreas Drescher <ace at anticat dot ch>
+//
+// ============================================================================
+
+#include "test_config.h"
+#include "ace/Reactor.h"
+#include "ace/WFMO_Reactor.h"
+#include "ace/Select_Reactor.h"
+#include "ace/Log_Msg.h"
+#include "ace/Signal.h"
+#include "ace/Assert.h"
+#include <string>
+
+ACE_RCSID(tests, Reactor_Timer_Test, "$Id$")
+
+class Test_SIGINT_Handler : public ACE_Event_Handler
+{
+public:
+ Test_SIGINT_Handler (ACE_Reactor *reactor, const char *message)
+ : message_ (message)
+ {
+ int result = reactor->register_handler (SIGINT, this);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Main::Test_SIGINT_Handler (%u) - Result %i\n"),
+ this,
+ result));
+ Test_SIGINT_Handler::registration_count_++;
+ }
+
+ ~Test_SIGINT_Handler()
+ {
+ ACE_ASSERT (Test_SIGINT_Handler::handle_signal_count_ == Test_SIGINT_Handler::registration_count_);
+ }
+
+ virtual int handle_signal (int signal, siginfo_t *, ucontext_t *)
+ {
+ ACE_ASSERT (signal == SIGINT);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Main::Test_SIGINT_Handler (%u) - %s\n"),
+ this,
+ this->message_.c_str()));
+ Test_SIGINT_Handler::handle_signal_count_++;
+ return 0;
+ }
+
+private:
+ std::string message_;
+
+ static int handle_signal_count_;
+
+ static int registration_count_;
+};
+
+int Test_SIGINT_Handler::handle_signal_count_ = 0;
+int Test_SIGINT_Handler::registration_count_ = 0;
+
+class Test_SIGINT_Shutdown_Handler : public ACE_Event_Handler
+{
+public:
+ Test_SIGINT_Shutdown_Handler (ACE_Reactor *reactor)
+ {
+ int result = reactor->register_handler (SIGINT, this);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Main::Test_SIGINT_Shutdown_Handler (%u) - Result %i\n"),
+ this,
+ result));
+ }
+
+ virtual int handle_signal (int signal, siginfo_t *, ucontext_t *)
+ {
+ ACE_ASSERT (signal == SIGINT);
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Main::Test_SIGINT_Shutdown_Handler (%u)\n"),
+ this));
+ ACE_Reactor::instance ()->end_reactor_event_loop ();
+ return 0;
+ }
+};
+
+int
+run_main (int argc, ACE_TCHAR *[])
+{
+/ ACE_START_TEST (ACE_TEXT ("Sig_Handlers_Test"));
+
+ ACE_Sig_Handlers multi_handlers;
+ ACE_Select_Reactor reactor_impl (&multi_handlers);
+ ACE_Reactor reactor (&reactor_impl);
+ ACE_Reactor::instance (&reactor);
+
+ // Create a bevy of handlers.
+
+ Test_SIGINT_Handler h1 (ACE_Reactor::instance (), "h1");
+ Test_SIGINT_Handler h2 (ACE_Reactor::instance (), "h2");
+ Test_SIGINT_Handler h3 (ACE_Reactor::instance (), "h3");
+ Test_SIGINT_Handler h4 (ACE_Reactor::instance (), "h4");
+ Test_SIGINT_Handler h5 (ACE_Reactor::instance (), "h5");
+ Test_SIGINT_Handler h6 (ACE_Reactor::instance (), "h6");
+ Test_SIGINT_Handler h7 (ACE_Reactor::instance (), "h7");
+ Test_SIGINT_Handler h8 (ACE_Reactor::instance (), "h8");
+
+ Test_SIGINT_Shutdown_Handler h0 (ACE_Reactor::instance ());
+
+ // Wait for user to type SIGINT.
+ while (!ACE_Reactor::instance ()->reactor_event_loop_done ())
+ {
+ ACE_DEBUG ((LM_DEBUG,"\nwaiting for SIGINT\n"));
+ if (ACE_Reactor::instance ()->handle_events () == -1)
+ ACE_ERROR ((LM_ERROR,"%p\n","handle_events"));
+ }
+
+ ACE_END_TEST;
+ return 0;
+}