summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2007-11-30 21:55:06 +0000
committerSteve Huston <shuston@riverace.com>2007-11-30 21:55:06 +0000
commit2f8224491e1555a68d7ba46b80b5a34fd02134c4 (patch)
treec2af5afecedf3f8dc4a85e564ecc0cf781df7950
parent5ee4c584c49271d14920c4379b63b5223d3f71e4 (diff)
downloadATCD-2f8224491e1555a68d7ba46b80b5a34fd02134c4.tar.gz
ChangeLogTag:Fri Nov 30 21:53:15 UTC 2007 Steve Huston <shuston@riverace.com>
-rw-r--r--ACE/ChangeLog5
-rw-r--r--ACE/tests/Reactor_Notify_Test.cpp95
2 files changed, 94 insertions, 6 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog
index 4404701fb7d..a4b38549b5c 100644
--- a/ACE/ChangeLog
+++ b/ACE/ChangeLog
@@ -1,3 +1,8 @@
+Fri Nov 30 21:53:15 UTC 2007 Steve Huston <shuston@riverace.com>
+
+ * tests/Reactor_Notify_Test.cpp: Added a test to verify that a quiet
+ (e.g., no I/O occurring) event loop will be awoken by a notify().
+
Fri Nov 30 16:58:00 UTC 2007 Steve Huston <shuston@riverace.com>
* ace/CDR_Stream.{h cpp}:
diff --git a/ACE/tests/Reactor_Notify_Test.cpp b/ACE/tests/Reactor_Notify_Test.cpp
index 8c1af55294d..abaed28ff62 100644
--- a/ACE/tests/Reactor_Notify_Test.cpp
+++ b/ACE/tests/Reactor_Notify_Test.cpp
@@ -38,6 +38,82 @@ ACE_RCSID(tests, Reactor_Notify_Test, "$Id$")
static const time_t LONG_TIMEOUT = 10;
static const time_t SHORT_TIMEOUT = 2;
+// A class to run a quiet event loop in one thread, and a plain notify()
+// from the main thread to make sure a simple notify will wake up a quiet
+// reactor.
+class Quiet_Notify_Tester : public ACE_Task<ACE_NULL_SYNCH>
+{
+public:
+ Quiet_Notify_Tester (void) : result_ (0) {}
+ ~Quiet_Notify_Tester (void) { this->wait (); }
+
+ //FUZZ: disable check_for_lack_ACE_OS
+ virtual int open (void * = 0);
+ // Start the reactor event thread.
+
+ // Run the reactor event loop.
+ virtual int svc (void);
+
+ // Return the test result, 0 ok, -1 fail
+ int result (void) const { return this->result_; }
+
+private:
+ ACE_Reactor r_;
+ int result_;
+};
+
+int
+Quiet_Notify_Tester::open (void *)
+{
+ this->reactor (&this->r_);
+ return this->activate ();
+}
+
+int
+Quiet_Notify_Tester::svc (void)
+{
+ // Count on the main thread doing a notify in less than LONG_TIMEOUT
+ // seconds. If we don't get it, report a failure.
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Starting quiet event loop\n")));
+ this->r_.owner (ACE_Thread::self ());
+ ACE_Time_Value tmo (LONG_TIMEOUT);
+ int status = this->r_.handle_events (&tmo);
+ time_t remain = tmo.sec ();
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%t) event loop status %d, %: secs remain\n"),
+ status, remain));
+ if (remain == 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("(%t) Notify did not wake quiet event loop\n")));
+ this->result_ = -1;
+ }
+ else
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Notify woke quiet event loop\n")));
+ }
+ return 0;
+}
+
+static int
+run_quiet_notify_test (void)
+{
+ ACE_DEBUG ((LM_DEBUG, "(%t) Starting quiet notify test\n"));
+ Quiet_Notify_Tester t;
+ if (t.open () == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("Quiet notify activate")),
+ -1);
+ // Now sleep a bit, then do a simple, reactor wake-up
+ ACE_OS::sleep (SHORT_TIMEOUT);
+ t.reactor ()->notify ();
+ t.wait ();
+ ACE_DEBUG ((LM_DEBUG, "(%t) Quiet notify test done\n"));
+ return t.result ();
+}
+
+
class Supplier_Task : public ACE_Task<ACE_MT_SYNCH>
{
public:
@@ -458,12 +534,20 @@ run_main (int, ACE_TCHAR *[])
int test_result = 0; // Innocent until proven guilty
- test_result = run_notify_purge_test ();
- if (test_result == 0)
- ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("purge_pending_notifications test OK\n")));
+ if (0 != run_quiet_notify_test ())
+ test_result = 1;
+
+ if (0 == run_notify_purge_test ())
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("purge_pending_notifications test OK\n")));
+ }
else
- ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("purge_pending_notifications test FAIL\n")));
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("purge_pending_notifications test FAIL\n")));
+ test_result = 1;
+ }
#if defined (ACE_HAS_THREADS)
ACE_Time_Value timeout (SHORT_TIMEOUT);
@@ -495,4 +579,3 @@ run_main (int, ACE_TCHAR *[])
ACE_END_TEST;
return test_result;
}
-