summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1996-11-18 03:56:19 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1996-11-18 03:56:19 +0000
commit8825d290d8873c6ee96e27dcba1f1c8bf59d2236 (patch)
treef8913a7ba038ec752e3d98e49b18950a374a85a9 /tests
parente1b089abb1df9b1c7a5f6eabf1100b6c21ec1fe8 (diff)
downloadATCD-8825d290d8873c6ee96e27dcba1f1c8bf59d2236.tar.gz
ywhoopie!!
More new stuff, more things will break!! I have no idea about this file. Heck, I am not even Doug!
Diffstat (limited to 'tests')
-rw-r--r--tests/Barrier_Test.cpp18
-rw-r--r--tests/Buffer_Stream_Test.cpp27
-rw-r--r--tests/CPP_Test.cpp15
-rw-r--r--tests/Future_Test.cpp44
-rw-r--r--tests/Handle_Set_Test.cpp18
-rw-r--r--tests/Map_Manager_Test.cpp3
-rw-r--r--tests/Mem_Map_Test.cpp45
-rw-r--r--tests/Message_Queue_Test.cpp12
-rw-r--r--tests/Mutex_Test.cpp49
-rw-r--r--tests/Naming_Test.cpp5
-rw-r--r--tests/Priority_Buffer_Test.cpp15
-rw-r--r--tests/Reactor_Timer_Test.cpp2
-rw-r--r--tests/Reactors_Test.cpp42
-rw-r--r--tests/Reader_Writer_Test.cpp28
-rw-r--r--tests/Recursive_Mutex_Test.cpp28
-rw-r--r--tests/SPIPE_Test.cpp17
-rw-r--r--tests/SString_Test.cpp2
-rw-r--r--tests/SV_Shared_Memory_Test.cpp2
-rw-r--r--tests/Shared_Memory_MM_Test.cpp12
-rw-r--r--tests/Shared_Memory_SV_Test.cpp2
-rw-r--r--tests/TSS_Test.cpp33
-rw-r--r--tests/Task_Test.cpp22
-rw-r--r--tests/Thread_Manager_Test.cpp22
-rw-r--r--tests/Thread_Pool_Test.cpp17
-rw-r--r--tests/Time_Value_Test.cpp4
-rw-r--r--tests/Tokens_Test.cpp59
-rw-r--r--tests/UPIPE_SAP_Test.cpp21
-rw-r--r--tests/test_config.h107
28 files changed, 352 insertions, 319 deletions
diff --git a/tests/Barrier_Test.cpp b/tests/Barrier_Test.cpp
index 958411d29cf..8acf3ce62e0 100644
--- a/tests/Barrier_Test.cpp
+++ b/tests/Barrier_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -63,11 +63,14 @@ tester (Tester_Args *args)
return 0;
}
+#endif /* ACE_HAS_THREADS */
+
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("Barrier_Test.cpp");
+#if defined (ACE_HAS_THREADS)
ACE_Service_Config daemon (argv[0]);
int n_threads = ACE_MAX_THREADS;
@@ -84,15 +87,10 @@ main (int argc, char *argv[])
// Wait for all the threads to reach their exit point.
ACE_Service_Config::thr_mgr ()->wait ();
-
- ACE_END_TEST;
- return 0;
-}
#else
-int
-main (int, char *[])
-{
ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n"));
+#endif /* ACE_HAS_THREADS */
+ ACE_END_TEST;
return 0;
}
-#endif /* ACE_HAS_THREADS */
+
diff --git a/tests/Buffer_Stream_Test.cpp b/tests/Buffer_Stream_Test.cpp
index efa87d3e9f3..3b83d0cc539 100644
--- a/tests/Buffer_Stream_Test.cpp
+++ b/tests/Buffer_Stream_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -126,7 +126,8 @@ Producer::svc (void)
d[0] = c;
d[1] = '\0';
- ACE_Message_Block *mb = new ACE_Message_Block (2);
+ ACE_Message_Block *mb;
+ ACE_NEW_RETURN (mb, ACE_Message_Block (2), -1);
ACE_OS::strcpy (mb->rd_ptr (), d);
mb->wr_ptr (2);
@@ -192,19 +193,25 @@ Consumer::svc (void)
return 0;
}
+#endif /* ACE_HAS_THREADS */
+
// Main driver function.
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("Buffer_Stream_Test.cpp");
+#if defined (ACE_HAS_THREADS)
ACE_Service_Config daemon (argv[0]);
// Control hierachically-related active objects
MT_Stream stream;
- MT_Module *cm = new MT_Module ("Consumer", new Consumer);
- MT_Module *pm = new MT_Module ("Producer", new Producer);
+ MT_Module *cm;
+ MT_Module *pm;
+
+ ACE_NEW_RETURN (cm, MT_Module ("Consumer", new Consumer), -1);
+ ACE_NEW_RETURN (pm, MT_Module ("Producer", new Producer), -1);
// Create Producer and Consumer Modules and push them onto the
// STREAM. All processing is performed in the STREAM.
@@ -217,18 +224,12 @@ main (int argc, char *argv[])
// Barrier synchronization: wait for the threads to exit, then exit
// ourselves.
ACE_Service_Config::thr_mgr ()->wait ();
-
- ACE_END_TEST;
- return 0;
-}
#else
-int
-main (int, char *[])
-{
ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n"));
+#endif /* ACE_HAS_THREADS */
+ ACE_END_TEST;
return 0;
}
-#endif /* ACE_HAS_THREADS */
diff --git a/tests/CPP_Test.cpp b/tests/CPP_Test.cpp
index 79d9c112f03..41c21f23cd7 100644
--- a/tests/CPP_Test.cpp
+++ b/tests/CPP_Test.cpp
@@ -137,15 +137,16 @@ server (void *)
for (;;)
{
char buf[BUFSIZ];
- int result = 0;
char t = 'a';
handle_set.reset ();
handle_set.set_bit (peer_acceptor.get_handle ());
- if ((result = ACE_OS::select (int (peer_acceptor.get_handle ()) + 1,
- handle_set,
- 0, 0, &tv)) == -1)
+ int result = ACE_OS::select (int (peer_acceptor.get_handle ()) + 1,
+ handle_set,
+ 0, 0, &tv);
+
+ if (result == -1)
ACE_ERROR ((LM_ERROR, "%p\n", "select"));
else if (result == 0)
{
@@ -154,7 +155,7 @@ server (void *)
}
// Create a new ACE_SOCK_Stream endpoint (note automatic restart
- // if errno == EINTR).
+ // if errno == EINTR).
while ((result = peer_acceptor.accept (new_stream, &cli_addr)) != -1)
{
@@ -196,7 +197,7 @@ server (void *)
if (errno == EWOULDBLOCK)
ACE_DEBUG ((LM_DEBUG, "no input available, going back to reading\n"));
else
- ACE_ERROR ((LM_ERROR, "%p\n", "ACE::write"));
+ ACE_ERROR ((LM_ERROR, "%p\n", "recv_n"));
}
if (new_stream.send_n ("", 1) != 1)
@@ -213,7 +214,7 @@ server (void *)
if (errno == EWOULDBLOCK)
ACE_DEBUG ((LM_DEBUG, "no connections available, going back to accepting\n"));
else
- ACE_ERROR ((LM_ERROR, "%p\n", "ACE::write"));
+ ACE_ERROR ((LM_ERROR, "%p\n", "accept"));
}
}
return 0;
diff --git a/tests/Future_Test.cpp b/tests/Future_Test.cpp
index 878154fe35b..eb9eccea6a9 100644
--- a/tests/Future_Test.cpp
+++ b/tests/Future_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -72,7 +72,6 @@ private:
const char *name_;
ACE_Activation_Queue activation_queue_;
Scheduler *scheduler_;
-
};
class Method_Object_work : public ACE_Method_Object
@@ -181,7 +180,7 @@ Scheduler::~Scheduler (void)
// open
int
-Scheduler::open (void *args)
+Scheduler::open (void *)
{
task_count++;
ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s open\n", this->name_));
@@ -190,7 +189,7 @@ Scheduler::open (void *args)
// close
int
-Scheduler::close (u_long flags)
+Scheduler::close (u_long)
{
ACE_DEBUG ((LM_DEBUG, "(%t) Scheduler %s close\n", this->name_));
task_count--;
@@ -199,7 +198,7 @@ Scheduler::close (u_long flags)
// put... ??
int
-Scheduler::put (ACE_Message_Block *mb, ACE_Time_Value *tv)
+Scheduler::put (ACE_Message_Block *, ACE_Time_Value *)
{
return 0;
}
@@ -258,7 +257,7 @@ Scheduler::name_i (void)
{
char *the_name;
- the_name = new char[ACE_OS::strlen (this->name_) + 1];
+ ACE_NEW_RETURN (the_name, char[ACE_OS::strlen (this->name_) + 1], 0);
ACE_OS::strcpy (the_name, this->name_);
return the_name;
@@ -305,25 +304,32 @@ static int n_iterations = 50000;
// Total number of loops.
static int n_loops = 100;
+#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION)
+template class ACE_Atomic_Op<ACE_Thread_Mutex, u_long>;
+#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */
+
+#endif /* ACE_HAS_THREADS */
+
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("Future_Test.cpp");
+#if defined (ACE_HAS_THREADS)
Scheduler *andres, *peter, *helmut, *matias;
// Create active objects..
// @@ Should "open" be subsumed within the constructor of
// Scheduler()?
- andres = new Scheduler ("andres");
+ ACE_NEW_RETURN (andres, Scheduler ("andres"), -1);
andres->open ();
- peter = new Scheduler ("peter");
+ ACE_NEW_RETURN (peter, Scheduler ("peter"), -1);
peter->open ();
- helmut = new Scheduler ("helmut");
+ ACE_NEW_RETURN (helmut, Scheduler ("helmut"), -1);
helmut->open ();
// Matias passes all asynchronous method calls on to Andres...
- matias = new Scheduler ("matias", andres);
+ ACE_NEW_RETURN (matias, Scheduler ("matias", andres), -1);
matias->open ();
for (int i = 0; i < n_loops; i++)
@@ -408,20 +414,10 @@ main (int argc, char *argv[])
ACE_DEBUG ((LM_DEBUG,"(%t) th' that's all folks!\n"));
ACE_OS::sleep (5);
- ACE_END_TEST;
-
- return 0;
-}
-
-#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION)
-template class ACE_Atomic_Op<ACE_Thread_Mutex, u_long>;
-#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */
-
#else
-int
-main (int, char *[])
-{
ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n"));
+#endif /* ACE_HAS_THREADS */
+ ACE_END_TEST;
return 0;
}
-#endif /* ACE_HAS_THREADS */
+
diff --git a/tests/Handle_Set_Test.cpp b/tests/Handle_Set_Test.cpp
index 7232fa85ebf..94b467b692e 100644
--- a/tests/Handle_Set_Test.cpp
+++ b/tests/Handle_Set_Test.cpp
@@ -24,12 +24,12 @@
#define IS_ODD(X) (((X) & 1) != 0)
-void
+static void
run_test (int count)
{
int duplicates = 0;
- int sets = 0;
- int clears = 0;
+ int sets = 0;
+ int clears = 0;
ACE_Handle_Set handle_set;
@@ -37,22 +37,22 @@ run_test (int count)
for (int i = 0; i < count; i++)
{
- int i = int (ACE_OS::rand () % ACE_Handle_Set::MAXSIZE);
+ int j = int (ACE_OS::rand () % ACE_Handle_Set::MAXSIZE);
- if (IS_ODD (i))
+ if (IS_ODD (j))
{
- if (handle_set.is_set ((ACE_HANDLE) i))
+ if (handle_set.is_set ((ACE_HANDLE) j))
duplicates++;
- handle_set.set_bit ((ACE_HANDLE) i);
+ handle_set.set_bit ((ACE_HANDLE) j);
sets++;
}
else
{
- if (handle_set.is_set ((ACE_HANDLE) i))
+ if (handle_set.is_set ((ACE_HANDLE) j))
duplicates--;
- handle_set.clr_bit ((ACE_HANDLE) i);
+ handle_set.clr_bit ((ACE_HANDLE) j);
clears++;
}
}
diff --git a/tests/Map_Manager_Test.cpp b/tests/Map_Manager_Test.cpp
index d58b6b7d6c0..96574af66cd 100644
--- a/tests/Map_Manager_Test.cpp
+++ b/tests/Map_Manager_Test.cpp
@@ -19,6 +19,7 @@
#include "ace/Map_Manager.h"
#include "ace/Synch.h"
+#include "test_config.h"
typedef ACE_Null_Mutex MUTEX;
typedef int KEY;
@@ -30,7 +31,7 @@ typedef ACE_Map_Reverse_Iterator <KEY, VALUE, MUTEX> REVERSE_ITERATOR;
typedef ACE_Map_Entry <KEY, VALUE> ENTRY;
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("Map_Manager_Test.cpp");
diff --git a/tests/Mem_Map_Test.cpp b/tests/Mem_Map_Test.cpp
index 1a414e5a986..cf2eff7ab60 100644
--- a/tests/Mem_Map_Test.cpp
+++ b/tests/Mem_Map_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -23,8 +23,8 @@
#include "ace/Mem_Map.h"
#include "test_config.h"
-static int size = 10;
-static int num_lines = 15;
+static const int FILE_SIZE = 10;
+static const int NUM_LINES = 15;
static void
reverse_file (ACE_HANDLE file_handle,
@@ -51,17 +51,20 @@ reverse_file (ACE_HANDLE file_handle,
ACE_OS::write (file_handle, array, count+1);
}
-int
-create_test_file ()
+static int
+create_test_file (int size, int num_lines)
{
- ACE_HANDLE file_handle;
- char *mybuf = new char[size+1];
+ char *mybuf;
+
+ ACE_NEW_RETURN (mybuf, char[size + 1], -1);
char c = 'a';
char d = c;
- if ((file_handle = ACE_OS::open (ACE_DEFAULT_TEST_FILE,
- O_RDWR | O_CREAT | O_TRUNC,
- 0666)) == 0)
+ ACE_HANDLE file_handle = ACE_OS::open (ACE_DEFAULT_TEST_FILE,
+ O_RDWR | O_CREAT | O_TRUNC,
+ 0666);
+
+ if (file_handle == ACE_INVALID_HANDLE)
ACE_ERROR_RETURN ((LM_ERROR, "Open failed\n"), -1);
for (int j = 0; j < num_lines; j++)
@@ -71,8 +74,11 @@ create_test_file ()
mybuf[i] = c;
c++;
}
+
mybuf[size] = '\0';
+
c = ++d;
+
if (ACE_OS::write (file_handle, mybuf, size) != size)
ACE_ERROR_RETURN ((LM_ERROR, "write to file failed\n"), -1);
@@ -89,12 +95,8 @@ main (int, char **argv)
{
ACE_START_TEST ("Mem_Map_Test.cpp");
- ACE_LOG_MSG->open (argv[0]);
-
- ACE_HANDLE temp_file_handle;
-
// First create a test file to work on
- if (create_test_file () != 0)
+ if (create_test_file (FILE_SIZE, NUM_LINES) != 0)
ACE_ERROR_RETURN ((LM_ERROR, "Create test file failed\n"), -1);
ACE_Mem_Map mmap;
@@ -103,14 +105,16 @@ main (int, char **argv)
if (mmap.map (ACE_DEFAULT_TEST_FILE) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%n: %p\n%a", "mmap"), -1);
+ ACE_HANDLE temp_file_handle = ACE_OS::open (ACE_TEMP_FILE_NAME,
+ O_RDWR | O_TRUNC | O_CREAT,
+ 0666);
+
// Now create a temporary file for intermediate processing
- if ((temp_file_handle = ACE_OS::open (ACE_TEMP_FILE_NAME,
- O_RDWR | O_TRUNC | O_CREAT,
- 0666)) == 0)
+ if (temp_file_handle == ACE_INVALID_HANDLE)
ACE_ERROR_RETURN ((LM_ERROR, "Open failed\n"), -1);
// Reverse the original file and write the output to the temporary
- // file
+ // file.
reverse_file (temp_file_handle,
(char *) mmap.addr (),
mmap.size ());
@@ -134,7 +138,7 @@ main (int, char **argv)
ACE_ERROR_RETURN ((LM_ERROR, "Open failed\n"), -1);
// Now reverse the temporary file and write everything to the second
- // temporary file
+ // temporary file.
reverse_file (temp_file_handle,
(char *) temp_mmap.addr (),
temp_mmap.size ());
@@ -143,6 +147,7 @@ main (int, char **argv)
// Memory map the second temporary file
ACE_Mem_Map temp_mmap2;
+
if (temp_mmap2.map (temp_file_name) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%n: %p\n%a", "mmap"), -1);
diff --git a/tests/Message_Queue_Test.cpp b/tests/Message_Queue_Test.cpp
index a73784125d3..5431734cfc4 100644
--- a/tests/Message_Queue_Test.cpp
+++ b/tests/Message_Queue_Test.cpp
@@ -19,13 +19,14 @@
#include "ace/Message_Queue.h"
#include "ace/Synch.h"
+#include "test_config.h"
typedef ACE_Message_Queue <ACE_NULL_SYNCH> QUEUE;
typedef ACE_Message_Queue_Iterator <ACE_NULL_SYNCH> ITERATOR;
typedef ACE_Message_Queue_Reverse_Iterator <ACE_NULL_SYNCH> REVERSE_ITERATOR;
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("Message_Queue_Test.cpp");
@@ -34,9 +35,14 @@ main (int argc, char *argv[])
for (int i = 1; i <= ITERATIONS; i++)
{
- char *buffer = new char[BUFSIZ];
+ char *buffer;
+ ACE_NEW_RETURN (buffer, char[BUFSIZ], -1);
sprintf (buffer, "%d", i);
- ACE_Message_Block *entry = new ACE_Message_Block (buffer, sizeof buffer);
+
+ ACE_Message_Block *entry;
+
+ ACE_NEW_RETURN (entry, ACE_Message_Block (buffer, sizeof buffer), -1);
+
if (queue.enqueue (entry) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "QUEUE::enqueue\n"), -1);
}
diff --git a/tests/Mutex_Test.cpp b/tests/Mutex_Test.cpp
index a8fbc3a966e..6885778aad6 100644
--- a/tests/Mutex_Test.cpp
+++ b/tests/Mutex_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -22,12 +22,10 @@
#include "ace/Log_Msg.h"
#include "test_config.h"
-int
-main (int argc, char *argv[])
+static void
+test (void)
{
- ACE_START_TEST ("Mutex_Test.cpp");
-
- char *name = argc == 1 ? "hello" : argv[1];
+ char *name = "hello";
ACE_Process_Mutex pm (name);
@@ -42,6 +40,45 @@ main (int argc, char *argv[])
ACE_ASSERT (pm.release () == 0);
ACE_DEBUG ((LM_DEBUG, "(%P|%t) = released\n"));
}
+}
+
+static void
+spawn (void)
+{
+#if !defined (ACE_WIN32)
+ switch (ACE_OS::fork ())
+ {
+ case -1:
+ ACE_ERROR ((LM_ERROR, "%p\n%a", "fork failed"));
+ exit (-1);
+ case 0:
+ test ();
+ default:
+ test ();
+ }
+#elif defined (ACE_HAS_THREADS)
+ if (thr_mgr.spawn (ACE_THR_FUNC (test),
+ (void *) 0,
+ THR_NEW_LWP | THR_DETACHED) == -1)
+ ACE_ERROR ((LM_ERROR, "%p\n%a", "thread create failed"));
+
+ if (thr_mgr.spawn (ACE_THR_FUNC (test),
+ (void *) 0,
+ THR_NEW_LWP | THR_DETACHED) == -1)
+ ACE_ERROR ((LM_ERROR, "%p\n%a", "thread create failed"));
+ thr_mgr.wait ();
+#else
+ ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n%a", 1));
+#endif /* ACE_HAS_THREADS */
+}
+
+int
+main (int, char *argv[])
+{
+ ACE_START_TEST ("Mutex_Test.cpp");
+
+ spawn ();
+
ACE_END_TEST;
return 0;
}
diff --git a/tests/Naming_Test.cpp b/tests/Naming_Test.cpp
index 414c9c1f338..df4cce8410a 100644
--- a/tests/Naming_Test.cpp
+++ b/tests/Naming_Test.cpp
@@ -117,8 +117,11 @@ main (int argc, char *argv[])
{
ACE_START_TEST ("Naming_Test.cpp");
- ACE_Naming_Context *ns_context = new ACE_Naming_Context ();
+ ACE_Naming_Context *ns_context;
+ ACE_NEW_RETURN (ns_context, ACE_Naming_Context, -1);
+
ACE_Name_Options *name_options = ns_context->name_options ();
+
name_options->parse_args (argc, argv);
name_options->database (ACE::basename (name_options->process_name (),
ACE_DIRECTORY_SEPARATOR_CHAR));
diff --git a/tests/Priority_Buffer_Test.cpp b/tests/Priority_Buffer_Test.cpp
index cf0804d8713..857b57d8aff 100644
--- a/tests/Priority_Buffer_Test.cpp
+++ b/tests/Priority_Buffer_Test.cpp
@@ -125,14 +125,17 @@ producer (ACE_Message_Queue<ACE_MT_SYNCH> *msg_queue)
return 0;
}
+#endif /* ACE_HAS_THREADS */
+
// Spawn off one thread that copies stdin to stdout in order of the
// size of each line.
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("Priority_Buffer_Test.cpp");
+#if defined (ACE_HAS_THREADS)
// Message queue.
ACE_Message_Queue<ACE_MT_SYNCH> msg_queue (max_queue);
@@ -143,15 +146,9 @@ main (int argc, char *argv[])
// Wait for producer and consumer threads to exit.
ACE_Service_Config::thr_mgr ()->wait ();
-
- ACE_END_TEST;
- return 0;
-}
#else
-int
-main (int, char *[])
-{
ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n"));
+#endif /* ACE_HAS_THREADS */
+ ACE_END_TEST;
return 0;
}
-#endif /* ACE_HAS_THREADS */
diff --git a/tests/Reactor_Timer_Test.cpp b/tests/Reactor_Timer_Test.cpp
index d24c2acb0e6..e8cd10449eb 100644
--- a/tests/Reactor_Timer_Test.cpp
+++ b/tests/Reactor_Timer_Test.cpp
@@ -99,7 +99,5 @@ main (int, char *argv[])
reactor.handle_events ();
ACE_END_TEST;
-
return 0;
}
-
diff --git a/tests/Reactors_Test.cpp b/tests/Reactors_Test.cpp
index 937d3f28a5f..07a38573a76 100644
--- a/tests/Reactors_Test.cpp
+++ b/tests/Reactors_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -85,7 +85,7 @@ Test_Task::open (void *args)
}
int
-Test_Task::close (u_long flags)
+Test_Task::close (u_long)
{
ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, reclock_, -1);
@@ -97,8 +97,7 @@ Test_Task::close (u_long flags)
}
int
-Test_Task::put (ACE_Message_Block *mb,
- ACE_Time_Value *tv)
+Test_Task::put (ACE_Message_Block *, ACE_Time_Value *)
{
return 0;
}
@@ -120,14 +119,13 @@ Test_Task::svc (void)
}
int
-Test_Task::handle_close (ACE_HANDLE fd,
- ACE_Reactor_Mask close_mask)
+Test_Task::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
{
return 0;
}
int
-Test_Task::handle_input (ACE_HANDLE fd)
+Test_Task::handle_input (ACE_HANDLE)
{
this->handled_++;
@@ -171,13 +169,23 @@ worker (void *args)
return 0;
}
+#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION)
+template class ACE_Atomic_Op<ACE_Thread_Mutex, u_long>;
+#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */
+
+#endif /* ACE_HAS_THREADS */
+
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("Reactors_Test.cpp");
+#if defined (ACE_HAS_THREADS)
ACE_Reactor *react1 = ACE_Service_Config::reactor ();
- ACE_Reactor *react2 = new ACE_Reactor ();
+ ACE_Reactor *react2;
+
+ ACE_NEW_RETURN (react2, ACE_Reactor, -1);
+
Test_Task tt1[MAX_TASKS];
Test_Task tt2[MAX_TASKS];
@@ -196,20 +204,10 @@ main (int argc, char *argv[])
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1);
ACE_Service_Config::thr_mgr ()->wait ();
-
- ACE_END_TEST;
- return 0;
-}
-
-#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION)
-template class ACE_Atomic_Op<ACE_Thread_Mutex, u_long>;
-#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */
-
#else
-int
-main (int, char *[])
-{
ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n"));
+#endif /* ACE_HAS_THREADS */
+ ACE_END_TEST;
return 0;
}
-#endif /* ACE_HAS_THREADS */
+
diff --git a/tests/Reader_Writer_Test.cpp b/tests/Reader_Writer_Test.cpp
index dda0841511c..cfc420bbbbf 100644
--- a/tests/Reader_Writer_Test.cpp
+++ b/tests/Reader_Writer_Test.cpp
@@ -46,7 +46,7 @@ volatile static int shared_data;
static ACE_RW_Mutex rw_mutex;
// Count of the number of readers and writers.
-ACE_Atomic_Op<ACE_Thread_Mutex, int> current_readers, current_writers;
+static ACE_Atomic_Op<ACE_Thread_Mutex, int> current_readers, current_writers;
// Explain usage and exit.
static void
@@ -58,6 +58,7 @@ print_usage_and_die (void)
}
// Parse the command-line arguments and set options.
+
static void
parse_args (int argc, char *argv[])
{
@@ -167,14 +168,19 @@ writer (void *)
return 0;
}
+#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION)
+template class ACE_Atomic_Op<ACE_Thread_Mutex, int>;
+#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */
+
+#endif /* ACE_HAS_THREADS */
+
// Spawn off threads.
-int main (int argc, char *argv[])
+int main (int, char *argv[])
{
ACE_START_TEST ("Reader_Writer_Test.cpp");
- ACE_LOG_MSG->open (argv[0]);
-
+#if defined (ACE_HAS_THREADS)
current_readers = 0; // Possibly already done
current_writers = 0; // Possibly already done
@@ -194,20 +200,10 @@ int main (int argc, char *argv[])
ACE_Service_Config::thr_mgr ()->wait ();
ACE_DEBUG ((LM_DEBUG, "(%t) exiting main thread\n"));
- ACE_END_TEST;
- return 0;
-}
-
-#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION)
-template class ACE_Atomic_Op<ACE_Thread_Mutex, int>;
-#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */
-
#else
-int
-main (int, char *[])
-{
ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n"));
+#endif /* ACE_HAS_THREADS */
+ ACE_END_TEST;
return 0;
}
-#endif /* ACE_HAS_THREADS */
diff --git a/tests/Recursive_Mutex_Test.cpp b/tests/Recursive_Mutex_Test.cpp
index 3ae7bafb8d2..4e7a17dbe3e 100644
--- a/tests/Recursive_Mutex_Test.cpp
+++ b/tests/Recursive_Mutex_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -17,15 +17,15 @@
// Prashant Jain and Doug C. Schmidt
//
// ============================================================================
-#include "ace/Log_Msg.h"
-
-#if defined (ACE_HAS_THREADS)
+#include "ace/Log_Msg.h"
#include "ace/Service_Config.h"
#include "ace/Get_Opt.h"
#include "ace/Synch.h"
#include "test_config.h"
+#if defined (ACE_HAS_THREADS)
+
// Total number of iterations.
static size_t n_iterations = 100;
static size_t n_threads = ACE_MAX_THREADS;
@@ -61,28 +61,24 @@ worker (void *arg)
return 0;
}
+#endif /* ACE_HAS_THREADS */
+
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("Recursive_Mutex_Test.cpp");
+#if defined (ACE_HAS_THREADS)
ACE_Service_Config daemon (argv[0]);
ACE_Recursive_Thread_Mutex rm;
ACE_Service_Config::thr_mgr ()->spawn_n (n_threads,
ACE_THR_FUNC (worker),
(void *) &rm);
-
ACE_Service_Config::thr_mgr ()->wait ();
-
+#else
+ ACE_ERROR ((LM_ERROR,
+ "ACE doesn't support support process mutexes on this platform (yet)\n"));
+#endif /* ACE_WIN32 */
ACE_END_TEST;
return 0;
}
-#else
-int
-main (void)
-{
- ACE_ERROR_RETURN ((LM_ERROR,
- "ACE doesn't support support process mutexes on this platform (yet)\n"),
- -1);
-}
-#endif /* ACE_WIN32 */
diff --git a/tests/SPIPE_Test.cpp b/tests/SPIPE_Test.cpp
index 2e8960ce829..3ee7b607508 100644
--- a/tests/SPIPE_Test.cpp
+++ b/tests/SPIPE_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -31,7 +31,7 @@
#include "test_config.h"
// pipe name to use
-static char *pipe_name = "acepipe";
+static const char *PIPE_NAME = "ace_pipe_name";
// Global thread manager.
static ACE_Thread_Manager thr_mgr;
@@ -43,7 +43,7 @@ client (void *)
ACE_Thread_Control thread_control (&thr_mgr); // Insert thread into thr_mgr
ACE_NEW_THREAD;
#endif
- char *rendezvous = "ace_pipe_name";
+ const char *rendezvous = PIPE_NAME;
ACE_SPIPE_Stream cli_stream;
ACE_SPIPE_Connector con;
@@ -78,9 +78,9 @@ server (void *)
int n;
char t = 'a';
- char *rendezvous = "ace_pipe_name";
+ const char *rendezvous = PIPE_NAME;
- // Initialize named pipe listener
+ // Initialize named pipe listener.
if (acceptor.open (ACE_SPIPE_Addr (rendezvous)) == -1)
ACE_ERROR ((LM_ERROR, "%p\n", "open"));
@@ -138,9 +138,12 @@ main (int, char *argv[])
{
ACE_START_TEST ("SPIPE_Test.cpp");
+#if defined (ACE_HAS_STREAM_PIPES) || defined (ACE_WIN32)
spawn ();
-
+#else
+ ACE_ERROR ((LM_ERROR,
+ "SPIPE is not supported on this platform\n"));
+#endif /* defined (ACE_HAS_STREAM_PIPES) || defined (ACE_WIN32) */
ACE_END_TEST;
return 0;
}
-
diff --git a/tests/SString_Test.cpp b/tests/SString_Test.cpp
index 680eed95da6..efd1792ee56 100644
--- a/tests/SString_Test.cpp
+++ b/tests/SString_Test.cpp
@@ -22,7 +22,7 @@
#include "test_config.h"
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("SString_Test.cpp");
diff --git a/tests/SV_Shared_Memory_Test.cpp b/tests/SV_Shared_Memory_Test.cpp
index 8baa4fe414a..262b4af2291 100644
--- a/tests/SV_Shared_Memory_Test.cpp
+++ b/tests/SV_Shared_Memory_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
diff --git a/tests/Shared_Memory_MM_Test.cpp b/tests/Shared_Memory_MM_Test.cpp
index 3752fdd76dc..6453e62833c 100644
--- a/tests/Shared_Memory_MM_Test.cpp
+++ b/tests/Shared_Memory_MM_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -26,7 +26,7 @@
#include "ace/Thread_Manager.h"
#include "test_config.h"
-#define SHMSZ 27
+const int SHMSZ = 27;
static char shm_key[] = "/tmp/fooXXXXXX";
// Global thread manager.
@@ -39,7 +39,7 @@ client (void *)
// Insert thread into thr_mgr
ACE_Thread_Control thread_control (&thr_mgr);
ACE_NEW_THREAD;
-#endif
+#endif /* ACE_WIN32 */
ACE_OS::sleep (3);
char t = 'a';
@@ -66,7 +66,7 @@ server (void *)
// Insert thread into thr_mgr
ACE_Thread_Control thread_control (&thr_mgr);
ACE_NEW_THREAD;
-#endif
+#endif /* ACE_WIN32 */
ACE_Shared_Memory *shm_server;
ACE_NEW_RETURN (shm_server, ACE_Shared_Memory_MM (shm_key, SHMSZ), 0);
@@ -90,7 +90,7 @@ server (void *)
}
static void
-spawn ()
+spawn (void)
{
#if !defined (ACE_WIN32)
switch (ACE_OS::fork ())
@@ -120,7 +120,7 @@ spawn ()
}
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("Shared_Memory_MM_Test.cpp");
diff --git a/tests/Shared_Memory_SV_Test.cpp b/tests/Shared_Memory_SV_Test.cpp
index 72bc2d6f8af..d2fe9c96258 100644
--- a/tests/Shared_Memory_SV_Test.cpp
+++ b/tests/Shared_Memory_SV_Test.cpp
@@ -60,7 +60,7 @@ server (void)
}
int
-main (int argc, char *argv [])
+main (int, char *argv [])
{
ACE_START_TEST ("Shared_Memory_SV_Test.cpp");
diff --git a/tests/TSS_Test.cpp b/tests/TSS_Test.cpp
index 966b4e45024..a73aef5e9ef 100644
--- a/tests/TSS_Test.cpp
+++ b/tests/TSS_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -25,7 +25,9 @@
#include "ace/Log_Msg.h"
#include "test_config.h"
-static int iterations = 100;
+#if defined (ACE_HAS_THREADS)
+
+static const int ITERATIONS = 100;
class Errno
{
@@ -110,7 +112,7 @@ worker (void *c)
if (ACE_OS::thr_keycreate (&key, cleanup) == -1)
ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate"));
- ip = new int;
+ ACE_NEW_RETURN (ip, int, 0);
if (ACE_OS::thr_setspecific (key, (void *) ip) == -1)
ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_setspecific"));
@@ -120,7 +122,7 @@ worker (void *c)
if (ACE_OS::thr_keycreate (&key, cleanup) == -1)
ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate"));
- ip = new int;
+ ACE_NEW_RETURN (ip, int, 0);
ACE_DEBUG ((LM_DEBUG, "(%t) in worker 1, key = %d, ip = %x\n", key, ip));
@@ -152,14 +154,14 @@ worker (void *c)
{
// Use the guard to serialize access
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, lock, 0));
- ACE_ASSERT (TSS_Error->flags () == iterations);
+ ACE_ASSERT (TSS_Error->flags () == ITERATIONS);
}
key = 0;
if (ACE_OS::thr_keycreate (&key, cleanup) == -1)
ACE_ERROR ((LM_ERROR, "(%t) %p\n", "ACE_OS::thr_keycreate"));
- ip = new int;
+ ACE_NEW_RETURN (ip, int, 0);
ACE_DEBUG ((LM_DEBUG, "(%t) in worker 2, key = %d, ip = %x\n", key, ip));
@@ -187,32 +189,35 @@ handler (int signum)
ACE_Service_Config::thr_mgr ()->exit (0);
}
+#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION)
+template class ACE_TSS<Errno>;
+#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */
+
+#endif /* ACE_HAS_THREADS */
+
int
main (int, char *argv[])
{
ACE_START_TEST ("TSS_Test.cpp");
+#if defined (ACE_MT_SAFE)
ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ());
ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
-#if defined (ACE_HAS_THREADS)
int threads = ACE_MAX_THREADS;
if (ACE_Service_Config::thr_mgr ()->spawn_n (threads,
ACE_THR_FUNC (&worker),
- (void *) iterations,
+ (void *) ITERATIONS,
THR_BOUND | THR_DETACHED) == -1)
ACE_OS::perror ("ACE_Thread_Manager::spawn_n");
ACE_Service_Config::thr_mgr ()->wait ();
#else
- worker ((void *) iterations);
-#endif /* ACE_HAS_THREADS */
-
+ ACE_ERROR ((LM_ERROR,
+ "threads are not supported on this platform\n"));
+#endif /* defined (ACE_MT_SAFE) */
ACE_END_TEST;
return 0;
}
-#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION)
-template class ACE_TSS<Errno>;
-#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */
diff --git a/tests/Task_Test.cpp b/tests/Task_Test.cpp
index 32b21e09082..186f76e5e25 100644
--- a/tests/Task_Test.cpp
+++ b/tests/Task_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -19,13 +19,12 @@
// ============================================================================
#include "ace/Log_Msg.h"
-
-#if defined (ACE_HAS_THREADS)
-
#include "ace/Service_Config.h"
#include "ace/Task.h"
#include "test_config.h"
+#if defined (ACE_HAS_THREADS)
+
class Barrier_Task : public ACE_Task<ACE_MT_SYNCH>
{
public:
@@ -89,11 +88,14 @@ Barrier_Task::svc (void)
return 0;
}
+#endif /* ACE_HAS_THREADS */
+
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("Task_Test.cpp");
+#if defined (ACE_HAS_THREADS)
int n_threads = ACE_MAX_THREADS;
int n_iterations = ACE_MAX_ITERATIONS;
@@ -103,15 +105,9 @@ main (int argc, char *argv[])
// Wait for all the threads to reach their exit point.
ACE_Service_Config::thr_mgr ()->wait ();
-
- ACE_END_TEST;
- return 0;
-}
#else
-int
-main (int, char *[])
-{
ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n"));
+#endif /* ACE_HAS_THREADS */
+ ACE_END_TEST;
return 0;
}
-#endif /* ACE_HAS_THREADS */
diff --git a/tests/Thread_Manager_Test.cpp b/tests/Thread_Manager_Test.cpp
index 48c163efd0a..0df6f757d31 100644
--- a/tests/Thread_Manager_Test.cpp
+++ b/tests/Thread_Manager_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -20,13 +20,12 @@
// ============================================================================
#include "ace/Log_Msg.h"
-
-#if defined (ACE_HAS_THREADS)
-
#include "ace/Service_Config.h"
#include "ace/Thread_Manager.h"
#include "test_config.h"
+#if defined (ACE_HAS_THREADS)
+
static void
handler (int signum)
{
@@ -60,13 +59,15 @@ worker (int iterations)
static const int DEFAULT_THREADS = ACE_MAX_THREADS;
static const int DEFAULT_ITERATIONS = 100000;
+#endif /* ACE_HAS_THREADS */
+
int
main (int argc, char *argv[])
{
ACE_START_TEST ("Thread_Manager_Test.cpp");
+#if defined (ACE_HAS_THREADS)
ACE_Service_Config daemon;
-
daemon.open (argv[0]);
// Register a signal handler
@@ -110,14 +111,9 @@ main (int argc, char *argv[])
// Perform a barrier wait until all the threads have shut down.
thr_mgr->wait ();
-
+#else
+ ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n"));
+#endif /* ACE_HAS_THREADS */
ACE_END_TEST;
return 0;
}
-#else
-int
-main (int, char *[])
-{
- ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1);
-}
-#endif /* ACE_HAS_THREADS */
diff --git a/tests/Thread_Pool_Test.cpp b/tests/Thread_Pool_Test.cpp
index 764871ee15b..437c7d8daea 100644
--- a/tests/Thread_Pool_Test.cpp
+++ b/tests/Thread_Pool_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -130,7 +130,8 @@ produce (Thread_Pool &thread_pool)
for (int n;;)
{
// Allocate a new message.
- ACE_Message_Block *mb = new ACE_Message_Block (BUFSIZ);
+ ACE_Message_Block *mb;
+ ACE_NEW (mb, ACE_Message_Block (BUFSIZ));
#if defined (manual)
ACE_DEBUG ((LM_DEBUG,
@@ -186,10 +187,13 @@ produce (Thread_Pool &thread_pool)
}
}
+#endif /* ACE_HAS_THREADS */
+
int
main (int argc, char *argv[])
{
ACE_START_TEST ("Thread_Pool_Test.cpp");
+#if defined (ACE_HAS_THREADS)
int n_threads = ACE_MAX_THREADS;
ACE_DEBUG ((LM_DEBUG, "(%t) argc = %d, threads = %d\n",
@@ -208,14 +212,9 @@ main (int argc, char *argv[])
ACE_Service_Config::thr_mgr ()->wait ();
ACE_DEBUG ((LM_DEBUG, "(%t) destroying worker tasks and exiting...\n"));
- ACE_END_TEST;
- return 0;
-}
#else
-int
-main (int, char *[])
-{
ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n"));
+#endif /* ACE_HAS_THREADS */
+ ACE_END_TEST;
return 0;
}
-#endif /* ACE_HAS_THREADS */
diff --git a/tests/Time_Value_Test.cpp b/tests/Time_Value_Test.cpp
index 4278ccf97d0..ac9064bba41 100644
--- a/tests/Time_Value_Test.cpp
+++ b/tests/Time_Value_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -22,7 +22,7 @@
#include "test_config.h"
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("Time_Value_Test.cpp");
diff --git a/tests/Tokens_Test.cpp b/tests/Tokens_Test.cpp
index 5690a39f872..3d44ad697f1 100644
--- a/tests/Tokens_Test.cpp
+++ b/tests/Tokens_Test.cpp
@@ -1,6 +1,6 @@
-// ============================================================================
// $Id$
+// ============================================================================
//
// = LIBRARY
// tests
@@ -37,12 +37,12 @@
#include "ace/Token_Invariants.h"
#include "test_config.h"
-typedef ACE_Token_Invariant_Manager TOKEN_INVARIANTS;
-
#if defined (ACE_HAS_THREADS)
-static char *server_host = "localhost";
-static int server_port = 23456;
+typedef ACE_Token_Invariant_Manager TOKEN_INVARIANTS;
+
+static const char *server_host = "localhost";
+static const int server_port = 23456;
struct Test_Params
{
@@ -123,12 +123,6 @@ run_thread (void *vp)
return 0;
}
-#if defined (ACE_HAS_PTHREADS)
-#define SUSPEND 0
-#else
-#define SUSPEND THR_SUSPENDED
-#endif
-
static int
run_test (ACE_Token_Proxy *A,
ACE_Token_Proxy *B,
@@ -156,15 +150,15 @@ run_test (ACE_Token_Proxy *A,
ACE_Thread_Manager *mgr = ACE_Service_Config::thr_mgr ();
if (mgr->spawn (ACE_THR_FUNC (run_thread),
- (void *) &tp1, THR_BOUND | SUSPEND) == -1)
+ (void *) &tp1, THR_BOUND | THR_SUSPENDED) == -1)
ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 1 failed"), -1);
if (mgr->spawn (ACE_THR_FUNC (run_thread),
- (void *) &tp2, THR_BOUND | SUSPEND) == -1)
+ (void *) &tp2, THR_BOUND | THR_SUSPENDED) == -1)
ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 2 failed"), -1);
if (mgr->spawn (ACE_THR_FUNC (run_thread),
- (void *) &tp3, THR_BOUND | SUSPEND) == -1)
+ (void *) &tp3, THR_BOUND | THR_SUSPENDED) == -1)
ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn 3 failed"), -1);
#if ! defined (ACE_HAS_PTHREADS)
@@ -178,17 +172,19 @@ run_test (ACE_Token_Proxy *A,
ACE_DEBUG ((LM_DEBUG, "Test finished.\n"));
return 0;
}
+#endif /* ACE_HAS_THREADS */
int
-main (int argc, char* argv[])
+main (int, char* argv[])
{
ACE_START_TEST ("Tokens_Test.cpp");
+#if defined (ACE_HAS_THREADS)
ACE_Token_Proxy *A, *B, *R, *W;
- A = new ACE_Local_Mutex ("L Mutex A", 0, 0);
- B = new ACE_Local_Mutex ("L Mutex B", 0, 0);
- R = new ACE_Local_RLock ("L Reader Lock", 0, 0);
- W = new ACE_Local_WLock ("L Writer Lock", 0, 0);
+ ACE_NEW_RETURN (A, ACE_Local_Mutex ("L Mutex A", 0, 0), -1);
+ ACE_NEW_RETURN (B, ACE_Local_Mutex ("L Mutex B", 0, 0), -1);
+ ACE_NEW_RETURN (R, ACE_Local_RLock ("L Reader Lock", 0, 0), -1);
+ ACE_NEW_RETURN (W, ACE_Local_WLock ("L Writer Lock", 0, 0), -1);
run_test (A,B,R,W);
@@ -220,12 +216,13 @@ main (int argc, char* argv[])
ACE_DEBUG ((LM_DEBUG, "Using Token Server on %s at port %d.\n", server_host, server_port));
ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host));
- A = new ACE_Remote_Mutex ("R Mutex A", 0, 1);
- B = new ACE_Remote_Mutex ("R Mutex B", 0, 1);
- R = new ACE_Remote_RLock ("R Reader Lock", 0, 1);
- W = new ACE_Remote_WLock ("R Writer Lock", 0, 1);
- run_test (A,B,R,W);
+ ACE_NEW_RETURN (A, ACE_Remote_Mutex ("R Mutex A", 0, 1), -1);
+ ACE_NEW_RETURN (B, ACE_Remote_Mutex ("R Mutex B", 0, 1), -1);
+ ACE_NEW_RETURN (R, ACE_Remote_RLock ("R Reader Lock", 0, 1), -1);
+ ACE_NEW_RETURN (W, ACE_Remote_WLock ("R Writer Lock", 0, 1), -1);
+
+ run_test (A, B, R, W);
// Wait for the server to finish.
ACE_OS::sleep (3);
@@ -235,16 +232,10 @@ main (int argc, char* argv[])
ACE_ERROR_RETURN ((LM_ERROR, "Kill failed.\n"), -1);
ACE_DEBUG ((LM_DEBUG, "(%t) main thread exiting.\n"));
-
+#else
+ ACE_ERROR ((LM_ERROR,
+ "threads not supported on this platform\n"));
+#endif /* ACE_HAS_THREADS */
ACE_END_TEST;
return 0;
}
-
-#else
-int
-main (int, char *[])
-{
- ACE_ERROR_RETURN ((LM_ERROR,
- "threads not supported on this platform\n"), -1);
-}
-#endif /* ACE_HAS_THREADS */
diff --git a/tests/UPIPE_SAP_Test.cpp b/tests/UPIPE_SAP_Test.cpp
index 7934c31e26c..72bbc80871c 100644
--- a/tests/UPIPE_SAP_Test.cpp
+++ b/tests/UPIPE_SAP_Test.cpp
@@ -46,7 +46,10 @@ peer1 (void *)
if (con.connect (c_stream, addr) == -1)
ACE_DEBUG ((LM_DEBUG, "(%t) peer1 ACE_UPIPE_Connector failed\n"));
- ACE_Message_Block *mb = new ACE_Message_Block (20);
+ ACE_Message_Block *mb;
+
+ ACE_NEW_RETURN (mb, ACE_Message_Block (20), 0);
+
mb->copy ("hello", 6);
if (c_stream.send (mb) == -1)
@@ -141,11 +144,14 @@ peer2 (void *)
return 0;
}
+#endif /* ACE_HAS_THREADS */
+
int
-main (int argc, char *argv[])
+main (int, char *argv[])
{
ACE_START_TEST ("UPIPE_SAP_Test.cpp");
+#if defined (ACE_HAS_THREADS)
// Spawn a peer2 thread.
if (ACE_Service_Config::thr_mgr ()->spawn (ACE_THR_FUNC (peer2),
(void *) 0,
@@ -154,14 +160,9 @@ main (int argc, char *argv[])
// Wait for peer2 and peer1 threads to exit.
ACE_Service_Config::thr_mgr ()->wait ();
-
+#else
+ ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n"));
+#endif /* ACE_HAS_THREADS */
ACE_END_TEST;
return 0;
}
-#else
-int
-main (int, char *[])
-{
- ACE_ERROR_RETURN ((LM_ERROR, "threads not supported on this platform\n"), -1);
-}
-#endif /* ACE_HAS_THREADS */
diff --git a/tests/test_config.h b/tests/test_config.h
index 44e99d56bd2..04d1c339d5d 100644
--- a/tests/test_config.h
+++ b/tests/test_config.h
@@ -28,6 +28,24 @@
#define MAKE_PIPE_NAME(X) X
#endif /* ACE_WIN32 */
+#define ACE_START_TEST(NAME) \
+ const char *program = argv ? argv[0] : NAME; \
+ ACE_LOG_MSG->open (program, ACE_Log_Msg::OSTREAM); \
+ if (ace_file_stream.set_output (program) != 0) \
+ ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "set_output failed"), -1); \
+ ACE_DEBUG ((LM_DEBUG, "starting %s test at %T\n", program));
+
+#define ACE_END_TEST \
+ ACE_DEBUG ((LM_DEBUG, "Ending %s test at %T\n", program)); \
+ ace_file_stream.flush ();
+
+#define ACE_NEW_THREAD \
+do {\
+ ACE_Log_Msg::instance()->msg_ostream (ace_file_stream.output_file ()); \
+ ACE_Log_Msg::instance()->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER ); \
+ ACE_Log_Msg::instance()->set_flags (ACE_Log_Msg::OSTREAM); \
+} while (0)
+
const int ACE_NS_MAX_ENTRIES = 2000;
const int ACE_MAX_TIMERS = 4;
const int ACE_MAX_THREADS = 4;
@@ -38,42 +56,11 @@ const int ACE_MAX_ITERATIONS = 10;
class ACE_Test_Output
{
public:
- ACE_Test_Output (void): output_file_ (0)
- {
- }
-
- ~ACE_Test_Output (void)
- {
- delete this->output_file_;
- }
-
- int set_output (const char *filename)
- {
- char temp[BUFSIZ];
- // Ignore the error value since the directory may already exist.
- ACE_OS::mkdir (ACE_LOG_DIRECTORY);
- ACE_OS::sprintf (temp, "%s%s%s",
- ACE_LOG_DIRECTORY,
- ACE::basename (filename, ACE_DIRECTORY_SEPARATOR_CHAR),
- ".log");
-
- ACE_NEW_RETURN (this->output_file_, ofstream (temp), -1);
-
- ACE_Log_Msg::instance()->msg_ostream (this->output_file_);
- ACE_Log_Msg::instance()->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER);
- ACE_Log_Msg::instance()->set_flags (ACE_Log_Msg::OSTREAM);
- return 0;
- }
-
- ofstream *output_file (void)
- {
- return this->output_file_;
- }
-
- void flush (void)
- {
- this->output_file_->flush ();
- }
+ ACE_Test_Output (void);
+ ~ACE_Test_Output (void);
+ int set_output (const char *filename);
+ ofstream *output_file (void);
+ void flush (void);
private:
ofstream *output_file_;
@@ -81,19 +68,41 @@ private:
static ACE_Test_Output ace_file_stream;
-#define ACE_START_TEST(NAME) \
- const char *program = argv ? argv[0] : NAME; \
- if (ace_file_stream.set_output (program) == -1) \
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "set_output failed"), -1); \
- ACE_DEBUG ((LM_DEBUG, "starting %s test at %T\n", program));
+ACE_Test_Output::ACE_Test_Output (void)
+ : output_file_ (0)
+{
+}
-#define ACE_END_TEST \
- ACE_DEBUG ((LM_DEBUG, "Ending %s test at %T\n", program)); \
- ace_file_stream.flush ();
-
-#define ACE_NEW_THREAD \
- ACE_Log_Msg::instance()->msg_ostream (ace_file_stream.output_file ()); \
- ACE_Log_Msg::instance()->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER ); \
- ACE_Log_Msg::instance()->set_flags (ACE_Log_Msg::OSTREAM);
+ACE_Test_Output::~ACE_Test_Output (void)
+{
+ delete this->output_file_;
+}
+int
+ACE_Test_Output::set_output (const char *filename)
+{
+ char temp[BUFSIZ];
+ // Ignore the error value since the directory may already exist.
+ ACE_OS::mkdir (ACE_LOG_DIRECTORY);
+ ACE_OS::sprintf (temp, "%s%s%s",
+ ACE_LOG_DIRECTORY,
+ ACE::basename (filename, ACE_DIRECTORY_SEPARATOR_CHAR),
+ ".log");
+
+ ACE_NEW_RETURN (this->output_file_, ofstream (temp), -1);
+ ACE_NEW_THREAD;
+ return 0;
+}
+
+ofstream *
+ACE_Test_Output::output_file (void)
+{
+ return this->output_file_;
+}
+
+void
+ACE_Test_Output::flush (void)
+{
+ this->output_file_->flush ();
+}
#endif /* ACE_TEST_CONFIG_H */