summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-12 03:04:42 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-12 03:04:42 +0000
commit611147bb623a367100006153bc82002fcf9edf29 (patch)
tree963b3ab23e724f088ef7fcb7e733833e5da08b6f /tests
parent3d7cc0a5bf912ca3027022823545e13df290c85b (diff)
downloadATCD-611147bb623a367100006153bc82002fcf9edf29.tar.gz
(main): kill children on Solaris/i386 instead of waiting for them. (acquire_release): added printout at top.
Diffstat (limited to 'tests')
-rw-r--r--tests/Process_Mutex_Test.cpp75
1 files changed, 45 insertions, 30 deletions
diff --git a/tests/Process_Mutex_Test.cpp b/tests/Process_Mutex_Test.cpp
index 67e948790b3..71e1ac19b6c 100644
--- a/tests/Process_Mutex_Test.cpp
+++ b/tests/Process_Mutex_Test.cpp
@@ -4,7 +4,7 @@
//
// = LIBRARY
// tests
-//
+//
// = FILENAME
// Process_Mutex_Test.cpp
//
@@ -13,7 +13,7 @@
//
// = AUTHOR
// Irfan Pyarali
-//
+//
// ============================================================================
#include "test_config.h"
@@ -31,11 +31,11 @@ static int child_process = 0;
static char *mutex_name = ACE_DEFAULT_MUTEX_A;
// Explain usage and exit.
-static void
+static void
print_usage_and_die (void)
{
- ACE_DEBUG ((LM_DEBUG,
- "usage: %n [-d (don't release mutex)] [-c (child process)] [-n mutex name] \n"));
+ ACE_DEBUG ((LM_DEBUG,
+ "usage: %n [-d (don't release mutex)] [-c (child process)] [-n mutex name] \n"));
ACE_OS::exit (1);
}
@@ -45,7 +45,7 @@ parse_args (int argc, char *argv[])
{
ACE_Get_Opt get_opt (argc, argv, "dcn:");
- int c;
+ int c;
while ((c = get_opt ()) != -1)
switch (c)
@@ -68,10 +68,12 @@ parse_args (int argc, char *argv[])
static void
acquire_release (void)
{
+ ACE_OS::fprintf (stderr, "acquire_release\n");
+ ACE_DEBUG ((LM_DEBUG, "acquire_release\n"));
ACE_Process_Mutex mutex (ACE_WIDE_STRING (mutex_name));
// Make sure the constructor succeeded
ACE_ASSERT (ACE_LOG_MSG->op_status () == 0);
- // Grab the lock
+ // Grab the lock
ACE_ASSERT (mutex.acquire () == 0);
ACE_DEBUG ((LM_DEBUG, "(%P) Mutex acquired %s\n", mutex_name));
ACE_DEBUG ((LM_DEBUG, "(%P) Working....\n"));
@@ -85,53 +87,66 @@ acquire_release (void)
}
}
-int
+int
main (int argc, char *argv[])
{
parse_args (argc, argv);
// Child process code
if (child_process)
- {
- ACE_APPEND_LOG ("Process_Mutex_Test-children");
+ {
+ ACE_APPEND_LOG ("Process_Mutex_Test-children");
acquire_release ();
ACE_END_LOG;
}
else
{
ACE_START_TEST ("Process_Mutex_Test");
- ACE_INIT_LOG ("Process_Mutex_Test-children");
+ ACE_INIT_LOG ("Process_Mutex_Test-children");
ACE_Process_Options options;
if (release_mutex == 0)
- options.command_line (__TEXT ("Process_Mutex_Test") ACE_PLATFORM_EXE_SUFFIX
- __TEXT (" -c -n %s -d"), ACE_WIDE_STRING (mutex_name));
+ options.command_line (__TEXT ("Process_Mutex_Test") ACE_PLATFORM_EXE_SUFFIX
+ __TEXT (" -c -n %s -d"), ACE_WIDE_STRING (mutex_name));
else
- options.command_line (__TEXT ("Process_Mutex_Test") ACE_PLATFORM_EXE_SUFFIX
- __TEXT (" -c -n %s"), ACE_WIDE_STRING (mutex_name));
-
+ options.command_line (__TEXT ("Process_Mutex_Test") ACE_PLATFORM_EXE_SUFFIX
+ __TEXT (" -c -n %s"), ACE_WIDE_STRING (mutex_name));
+
// Spawn ACE_MAX_PROCESSES processes that will contend for the
// lock.
ACE_Process servers[ACE_MAX_PROCESSES];
size_t i;
for (i = 0; i < ACE_MAX_PROCESSES; i++)
- {
- ACE_ASSERT (servers[i].spawn (options) != -1);
- ACE_DEBUG ((LM_DEBUG,
- "Server forked with pid = %d.\n",
- servers[i].getpid ()));
- }
+ {
+ ACE_ASSERT (servers[i].spawn (options) != -1);
+ ACE_DEBUG ((LM_DEBUG,
+ "Server forked with pid = %d.\n",
+ servers[i].getpid ()));
+ }
for (i = 0; i < ACE_MAX_PROCESSES; i++)
- {
- // Wait for the process we created to exit.
- ACE_ASSERT (servers[i].wait () != -1);
- ACE_DEBUG ((LM_DEBUG,
- "Server %d finished\n",
- servers[i].getpid ()));
- }
- ACE_END_TEST;
+ {
+#if defined (sun) && (defined (i386) || defined (__i386__))
+ // On g++/Solaris 2.6/i386 on a two-CPU machine, the test
+ // sometimes hangs because a child process hangs in either
+ // destruction of static objects (without
+ // ACE_HAS_NONSTATIC_OBJECT_MANAGER) or at the spawn above
+ // (with ACE_HAS_NONSTATIC_OBJECT_MANAGER). This hack masks
+ // that problem by killing each child process that is still
+ // alive.
+ ACE_OS::sleep (2);
+ ACE_OS::kill (servers[i].getpid (), 1);
+#else
+ // Wait for the process we created to exit.
+ ACE_ASSERT (servers[i].wait () != -1);
+#endif /* sun && (i386 || __i386__) */
+ ACE_DEBUG ((LM_DEBUG,
+ "Server %d finished\n",
+ servers[i].getpid ()));
+ }
+
+ ACE_END_TEST;
}
return 0;