summaryrefslogtreecommitdiff
path: root/ACE/tests/Bug_2653_Regression_Test.cpp
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2007-04-03 22:33:08 +0000
committerSteve Huston <shuston@riverace.com>2007-04-03 22:33:08 +0000
commitb3a88803484927a4cebd70337d92c8108e03f6c7 (patch)
treeaf504657dacb98c0b2530e8971fdfe116cbe9930 /ACE/tests/Bug_2653_Regression_Test.cpp
parent7849a0f90e8bdbe11fefb3938b4fa9329afdb9c0 (diff)
downloadATCD-b3a88803484927a4cebd70337d92c8108e03f6c7.tar.gz
ChangeLogTag:Tue Apr 3 22:29:41 UTC 2007 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ACE/tests/Bug_2653_Regression_Test.cpp')
-rw-r--r--ACE/tests/Bug_2653_Regression_Test.cpp82
1 files changed, 50 insertions, 32 deletions
diff --git a/ACE/tests/Bug_2653_Regression_Test.cpp b/ACE/tests/Bug_2653_Regression_Test.cpp
index 74b87288894..6a86198f6f2 100644
--- a/ACE/tests/Bug_2653_Regression_Test.cpp
+++ b/ACE/tests/Bug_2653_Regression_Test.cpp
@@ -38,14 +38,18 @@ class Watchdog : public ACE_Task_Base
{
public:
int svc (void);
+ int my_grp_;
};
int
Watchdog::svc (void)
{
ACE_OS::sleep (5);
- // If we make it through the sleep, that means the process is hung
- ACE_ASSERT (0);
+ // If we make it through the sleep and haven't been canceled, that
+ // means the process is hung.
+ if (!this->thr_mgr ()->testcancel (ACE_Thread::self ()))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Watchdog slept without cancel - we're hung\n")));
return 0;
}
@@ -100,7 +104,6 @@ Handler::Handler (ACE_Reactor &reactor, bool close_other)
this->other_pipe_.close();
}
- ACE_ASSERT (ok);
}
Handler::~Handler (void)
@@ -131,13 +134,18 @@ Handler::handle_input (ACE_HANDLE fd)
char buffer[BUFSIZ];
ssize_t result = ACE::recv (fd, buffer, sizeof buffer);
- ACE_ASSERT (result == ssize_t (ACE_OS::strlen (message)));
+ if (result != ssize_t (ACE_OS::strlen (message)))
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Handler recv'd %b bytes; expected %B\n"),
+ result, ACE_OS::strlen (message)));
buffer[result] = '\0';
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Handler::handle_input: %C\n"), buffer));
- ACE_ASSERT (ACE_OS::strcmp (buffer,
- message) == 0);
+ if (ACE_OS::strcmp (buffer, message) != 0)
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("Handler text mismatch; received \"%C\"; ")
+ ACE_TEXT ("expected \"%C\"\n"),
+ buffer, message));
this->reactor ()->end_reactor_event_loop ();
return 0;
@@ -153,21 +161,25 @@ test_for_crash (ACE_Reactor &reactor)
ACE::send_n (handler.pipe_.write_handle (),
message,
ACE_OS::strlen (message));
- ACE_ASSERT (result == ssize_t (ACE_OS::strlen (message)));
+ if (result != ssize_t (ACE_OS::strlen (message)))
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Handler sent %b bytes; should be %B\n"),
+ result, ACE_OS::strlen (message)));
reactor.run_reactor_event_loop ();
- result =
- reactor.remove_handler (handler.pipe_.read_handle (),
- ACE_Event_Handler::ALL_EVENTS_MASK |
- ACE_Event_Handler::DONT_CALL);
- ACE_ASSERT (result == 0);
-
- result =
- reactor.remove_handler (handler.other_pipe_.write_handle (),
- ACE_Event_Handler::ALL_EVENTS_MASK |
- ACE_Event_Handler::DONT_CALL);
- ACE_ASSERT (result != 0);
+ if (0 != reactor.remove_handler (handler.pipe_.read_handle (),
+ ACE_Event_Handler::ALL_EVENTS_MASK |
+ ACE_Event_Handler::DONT_CALL))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("test_for_handler, remove pipe")));
+
+ if (0 == reactor.remove_handler (handler.other_pipe_.write_handle (),
+ ACE_Event_Handler::ALL_EVENTS_MASK |
+ ACE_Event_Handler::DONT_CALL))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("test_for_crash remove other_pipe succeeded ")
+ ACE_TEXT ("but shouldn't\n")));
}
static void
@@ -180,21 +192,25 @@ test_for_spin (ACE_Reactor &reactor)
ACE::send_n (handler.pipe_.write_handle (),
message,
ACE_OS::strlen (message));
- ACE_ASSERT (result == ssize_t (ACE_OS::strlen (message)));
+ if (result != ssize_t (ACE_OS::strlen (message)))
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("Handler sent %b bytes; should be %B\n"),
+ result, ACE_OS::strlen (message)));
reactor.run_reactor_event_loop ();
- result =
- reactor.remove_handler (handler.pipe_.read_handle (),
- ACE_Event_Handler::ALL_EVENTS_MASK |
- ACE_Event_Handler::DONT_CALL);
- ACE_ASSERT (result == 0);
-
- result =
- reactor.remove_handler (handler.other_pipe_.write_handle (),
- ACE_Event_Handler::ALL_EVENTS_MASK |
- ACE_Event_Handler::DONT_CALL);
- ACE_ASSERT (result != 0);
+ if (0 != reactor.remove_handler (handler.pipe_.read_handle (),
+ ACE_Event_Handler::ALL_EVENTS_MASK |
+ ACE_Event_Handler::DONT_CALL))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("test_for_spin, remove pipe")));
+
+ if (0 == reactor.remove_handler (handler.other_pipe_.write_handle (),
+ ACE_Event_Handler::ALL_EVENTS_MASK |
+ ACE_Event_Handler::DONT_CALL))
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("test_for_spin remove other_pipe succeeded ")
+ ACE_TEXT ("but shouldn't\n")));
}
int
@@ -208,9 +224,11 @@ run_main (int, ACE_TCHAR *[])
test_for_crash (tp_reactor);
// if that passes, start the watchdog. We don't need to wait
Watchdog wd;
- wd.activate (THR_DETACHED);
- test_for_spin(tp_reactor);
+ wd.activate ();
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing for spin\n")));
+ test_for_spin(tp_reactor);
+ // If test_for_spin returns, all is well.
+ wd.thr_mgr ()->cancel_grp (wd.grp_id ());
wd.wait ();
ACE_END_TEST;