diff options
-rw-r--r-- | ChangeLog-99b | 29 | ||||
-rw-r--r-- | tests/Process_Manager_Test.cpp | 62 |
2 files changed, 71 insertions, 20 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b index 55992904665..36f3e513bbb 100644 --- a/ChangeLog-99b +++ b/ChangeLog-99b @@ -1,12 +1,29 @@ +Thu Oct 14 14:30:06 1999 David L. Levine <levine@cs.wustl.edu> + + * tests/Process_Manager_Test.cpp: use u_int instead of + bool. Make ~Exit_Handler () public so that g++ doesn't + complain about a private destructor with no friends. + Commented out unused local variable child7. + +Thu Oct 14 14:25:44 1999 Dave Madden <dhm@mersenne.com> + + * tests/Process_Manager_Test.cpp: fixed the memory leaks, and + most of the "unused variable" warnings should be gone. + I've added, but left commented out, ASSERTs for the child + process' exit codes. The reason is that, on Unix, the exit + code contains extra information (exited, traced, stopped, + signaled, etc.) that causes the exit code from wait() to be + different from what the child's main() returned. + Wed Oct 13 20:23:58 1999 Nanbor Wang <nanbor@cs.wustl.edu> - * ace/config-WinCE.h: Added ACE_LACKS_ACE_TOKEN and - ACE_LACKS_ACE_OTHER to reduce CE dll's footprint. + * ace/config-WinCE.h: Added ACE_LACKS_ACE_TOKEN and + ACE_LACKS_ACE_OTHER to reduce CE dll's footprint. - * ace/Memory_Pool.cpp (ACE_Pagefile_Memory_Pool::map): The - SECURITY_DESCRIPTOR and its management routines are only - supported on NT. Changed to pass a NULL security attribute on - non-NT platforms (95, 98, CE.) + * ace/Memory_Pool.cpp (ACE_Pagefile_Memory_Pool::map): The + SECURITY_DESCRIPTOR and its management routines are only + supported on NT. Changed to pass a NULL security attribute on + non-NT platforms (95, 98, CE.) Wed Oct 13 10:50:39 1999 David L. Levine <levine@cs.wustl.edu> diff --git a/tests/Process_Manager_Test.cpp b/tests/Process_Manager_Test.cpp index b290dc77ee7..7063e75780b 100644 --- a/tests/Process_Manager_Test.cpp +++ b/tests/Process_Manager_Test.cpp @@ -38,14 +38,22 @@ USELIB("..\ace\aced.lib"); #if !defined (ACE_LACKS_FORK) && defined (ACE_HAS_THREADS) -static bool debug_test = false; +static u_int debug_test = 0; -class Exit_Handler : public ACE_Event_Handler +class Exit_Handler : public ACE_Event_Handler { public: Exit_Handler (const char *msg): msg_ (msg) { } - virtual int handle_exit (ACE_Process *proc) + virtual ~Exit_Handler (void) { } + + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask) + { + delete this; + return 0; + } + + virtual int handle_exit (ACE_Process *proc) { if (debug_test) ACE_DEBUG ((LM_DEBUG, @@ -95,21 +103,21 @@ main (int argc, ASYS_TCHAR *argv[]) ACE_Get_Opt args (argc, argv, "d"); for (int arg = args (); arg != EOF; arg = args ()) - switch (arg) + switch (arg) { case 'd': - debug_test = true; + debug_test = 1u; break; default: usage (argv[0]); break; } - if (args.optind == argc - 1) + if (args.optind == argc - 1) { // child process: sleep & exit int secs = atoi (argv[args.optind]); ACE_OS::sleep (secs ? secs : 1); - if (debug_test) + if (debug_test) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) about to exit with code %d\n"), secs)); @@ -119,14 +127,18 @@ main (int argc, ASYS_TCHAR *argv[]) if (args.optind != argc) // incorrect usage usage (argv[0]); + ACE_START_TEST (ASYS_TEXT ("Process_Manager_Test")); + // Try the explicit <ACE_Process_Manager::wait> functions + int result = 0; ACE_Process_Manager mgr; mgr.register_handler (new Exit_Handler ("default")); - + ACE_exitcode exitcode; + // -------------------------------------------------- // wait for a specific PID pid_t child1 = spawn_child (argv[0], mgr, @@ -134,12 +146,16 @@ main (int argc, ASYS_TCHAR *argv[]) pid_t result1 = mgr.wait (child1, &exitcode); + ACE_ASSERT (result1 == child1); + // ACE_ASSERT (exitcode == 1); + if (debug_test) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) waited for child %d: %d\n"), child1, exitcode)); + // -------------------------------------------------- // wait for a specific PID; another should finish first pid_t child2 = spawn_child (argv[0], mgr, @@ -150,6 +166,9 @@ main (int argc, ASYS_TCHAR *argv[]) pid_t result2 = mgr.wait (child3, &exitcode); + ACE_ASSERT (result2 == child3); + // ACE_ASSERT (exitcode == 4); + if (debug_test) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) waited for child %d: %d\n"), @@ -161,11 +180,15 @@ main (int argc, ASYS_TCHAR *argv[]) pid_t result3 = mgr.wait (0, &exitcode); + ACE_ASSERT (result3 == child2); + // ACE_ASSERT (exitcode == 1); + if (debug_test) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) waited for any child: %d\n"), exitcode)); + // -------------------------------------------------- // Try the timed wait functions // This one shouldn't timeout: @@ -176,6 +199,9 @@ main (int argc, ASYS_TCHAR *argv[]) ACE_Time_Value (4), &exitcode); + ACE_ASSERT (result4 == child4); + // ACE_ASSERT (exitcode == 1); + if (debug_test) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) waited for any child: %d\n"), @@ -188,7 +214,10 @@ main (int argc, ASYS_TCHAR *argv[]) pid_t result5 = mgr.wait (0, ACE_Time_Value (1), &exitcode); - if (debug_test) + + ACE_ASSERT (result5 == 0); // should have timed out + + if (debug_test) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) waited for any child: %d\n"), exitcode)); @@ -197,11 +226,15 @@ main (int argc, ASYS_TCHAR *argv[]) result5 = mgr.wait (0, &exitcode); + ACE_ASSERT (result5 == child5); + // ACE_ASSERT (exitcode == 4); + if (debug_test) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) waited for child 5 again: %d\n"), exitcode)); + // -------------------------------------------------- // Finally, try the reactor stuff... mgr.open (ACE_Process_Manager::DEFAULT_SIZE, ACE_Reactor::instance ()); @@ -209,9 +242,9 @@ main (int argc, ASYS_TCHAR *argv[]) pid_t child6 = spawn_child (argv[0], mgr, 5); - pid_t child7 = spawn_child (argv[0], - mgr, - 6); + /* pid_t child7 = */ spawn_child (argv[0], + mgr, + 6); mgr.register_handler (new Exit_Handler ("specific"), child6); @@ -224,11 +257,12 @@ main (int argc, ASYS_TCHAR *argv[]) ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) done!\n") )); - return 0; + ACE_END_TEST; + return result; } #else -int +int main (int, ASYS_TCHAR *[]) { ACE_START_TEST (ASYS_TEXT ("Process_Manager_Test")); |