From 8a0c00861bffa7450a5f0e85c0610c3278f66945 Mon Sep 17 00:00:00 2001 From: schmidt Date: Sun, 17 Nov 1996 19:55:21 +0000 Subject: Jammer! --- ACE-INSTALL.html | 8 +- ChangeLog-96b | 138 ++++++++++++++++++++++ README | 3 + examples/Threads/Makefile | 3 +- examples/Threads/test_tss1.cpp | 155 ++++++++++++++++++++++++ examples/Threads/test_tss2.cpp | 253 ++++++++++++++++++++++++++++++++++++++++ netsvcs/ACE-netsvcs.html | 3 + tests/Barrier_Test.cpp | 2 +- tests/Buffer_Stream_Test.cpp | 2 +- tests/CPP_Test.cpp | 6 +- tests/Future_Test.cpp | 2 +- tests/Handle_Set_Test.cpp | 2 +- tests/Map_Manager_Test.cpp | 25 +++- tests/Mem_Map_Test.cpp | 2 +- tests/Message_Queue_Test.cpp | 25 +++- tests/Mutex_Test.cpp | 2 +- tests/Naming_Test.cpp | 2 +- tests/Priority_Buffer_Test.cpp | 13 +-- tests/Reactor_Timer_Test.cpp | 3 +- tests/Reactors_Test.cpp | 2 +- tests/Reader_Writer_Test.cpp | 29 +++-- tests/Recursive_Mutex_Test.cpp | 2 +- tests/SPIPE_Test.cpp | 6 +- tests/SString_Test.cpp | 2 +- tests/SV_Shared_Memory_Test.cpp | 4 +- tests/Shared_Memory_MM_Test.cpp | 4 +- tests/Shared_Memory_SV_Test.cpp | 4 +- tests/TSS_Test.cpp | 2 +- tests/Task_Test.cpp | 2 +- tests/Thread_Manager_Test.cpp | 2 +- tests/Thread_Pool_Test.cpp | 2 +- tests/Time_Service_Test.cpp | 11 +- tests/Time_Value_Test.cpp | 2 +- tests/Timer_Queue_Test.cpp | 2 +- tests/Tokens_Test.cpp | 3 +- tests/UPIPE_SAP_Test.cpp | 27 +++-- tests/test_config.h | 11 +- 37 files changed, 679 insertions(+), 87 deletions(-) create mode 100644 examples/Threads/test_tss1.cpp create mode 100644 examples/Threads/test_tss2.cpp diff --git a/ACE-INSTALL.html b/ACE-INSTALL.html index fc6dbb2ef34..3670d9ac6fc 100644 --- a/ACE-INSTALL.html +++ b/ACE-INSTALL.html @@ -506,8 +506,6 @@ files that have "-orbix" in them! Back to the ACE home page. - - - - - + + + diff --git a/ChangeLog-96b b/ChangeLog-96b index 2135d51996e..379cc3ce520 100644 --- a/ChangeLog-96b +++ b/ChangeLog-96b @@ -1,3 +1,135 @@ +Sun Nov 17 13:00:02 1996 Douglas C. Schmidt + + * tests/test_config.h: VxWorks passes in a NULL argv (arrghhh...). + Therefore, to work around this in the ./tests directory, I changed + the ACE_START_TEST macro to take a NAME parameter, and then I + added the following local variable: + + const char *program = argv ? argv[0] : NAME; + + Thanks to David Levine for this fix. + +Sat Nov 16 12:01:08 1996 Douglas C. Schmidt + + * examples/Threads/test_tss2.cpp: Added Detlef's new test for + ACE_TSS. + + * ace/Synch_T.cpp (ts_get): Added Detlef's changes to fix deadlock + problems with ACE_TSS on NT. + +Fri Nov 15 18:01:26 1996 Douglas C. Schmidt + + * ace/ACE_SOCK_Stream.cpp: NT will signal an abortive close + to the opposite party if a socket is closed before all of its + data has been sent out. According to the NT SDK-docs, you should + do a shutdown before the closesocket() in order to prepare a + graceful close. Thus, I've placed an + ACE_SOCK_Stream::close_writer() method just before the call to + ACE_SOCK::close() in the new close() of the ACE_SOCK_Stream + class. Thanks to Tilo Christ for + this suggestion. + + * ace/INET_Addr.cpp: The function ACE_INET_Addr::addr_to_string + was a virtual function that is also inline and defined in the .i + file. Some compilers have a problem with this, so I moved it + into the *.cpp file. In addition, its sister function was also + virtual and is defined as: + + ACE_INLINE int + ACE_INET_Addr::string_to_addr (const char s[]) + + in the .cpp file. I removed the ACE_INLINE directive. Thanks + to Fred LaBar for reporting this. + +Thu Nov 14 16:20:20 1996 Douglas C. Schmidt + + * ace/Malloc_T.cpp: Added a new method to ACE_Malloc that will + return the number of chunks available on the free list. Thanks + to Fred Labar for this. + +Wed Nov 13 01:22:16 1996 Douglas C. Schmidt + + * ace/ReactorEx.cpp (handle_events): I've changed siginfo_t on + Win32 (which was previously typedef'd to int) so that it has the + following structure: + + struct siginfo_t + { + siginfo_t (ACE_HANDLE handle); + + ACE_HANDLE si_handle_; + // Win32 HANDLE that has become signaled. + }; + + Then, I've changed the ACE_ReactorEx::handle_events() method to + look like this: + + // Assign the ``signaled'' HANDLE so that callers can get + // it. + siginfo_t sig (relative_handles[relative_index]); + + if (relative_handlers[relative_index]->handle_signal + (0, &sig) == -1) + + Thus, you can refer to the signaled handle as + + si_handle_ + + within the handle_signal() call back. Thanks to Matthias + Kerkhoff for suggesting this. + + * ace/System_Time.h: Made ACE_System_Time::get_local_time() a + static member function. Thanks to Matthias Kerkhoff + for suggesting this. + + * ace/Message_Queue.h: The internal variables for counting the + bytes stored in the queue were declared as of type int (in + Message_Queue.h). But they are set (e.g. with + ACE_Message_Queue::ACE_Message_Queue) with values of size_t. + + When running tests/Priority_Buffer_Test, the high_water_mark_ is + preset with the value LONG_MAX. While assigning this value from + size_t to int, this becomes -1 and the queue is always believed + to be full :-( The fix is to change the internal data structures + in Message_Queue.h from int to size_t. Thanks to Thilo Kielmann + for reporting this. + + * tests: Fixed problems with the following three tests: + + Priority_Buffer_Test.cpp + Reader_Writer_Test.cpp + UPIPE_SAP_Test.cpp + + When these are compiled with gcc on Digital UNIX 4.0a the static + ACE_Thread_Manager thr_mgr; was never getting initialized due to + gcc compiler bugs. The fix is to replace the static thread + manager with the ACE_Service_Config::thr_mgr() singleton. + Thanks to Thilo Kielmann for + pointing this out. + +Tue Nov 12 19:43:12 1996 Douglas C. Schmidt + + * ace/Thread_Manager.cpp (spawn_n): Was missing a 0 after ?. + Thanks to Thilo Kielmann for + reporting this. + + * ace/Log_Msg.h: Created a new macro call ACE_ERROR_BREAK(X) { + ACE_ERROR(X); break;} for use within switch and loop statements. + Thanks to Luca for this idea. + + * ace/Pipe.cpp: Enabled the "reuse addr" flag for accepting and + connecting the Win32 version of ACE_Pipe. Thanks to Luca for + reporting this problem. + + * ace/OS.i (thr_join): ACE_Thread::join () has a default second + parameter (the status) set to 0. This is not handled in + ACE_OS::thr_join(). To avoid getting a system error in NT we + handle this as we did with ACE_OS::thr_create() and the + thr_handle parameter. + + * ace/config-irix6.2-sgic++.h: Updated the set of patches required + for IRIX 6.2. Thanks to Amos Shapira for reporting this. + Sun Nov 10 15:40:17 1996 Tim H. Harrison * ace/Token_Invariants.cpp: Moved static data @@ -16,6 +148,11 @@ Sun Nov 10 13:22:03 1996 Douglas C. Schmidt assigned ACE_hthread_t's. Thanks to Thilo Kielmann for suggesting this. +Sun Nov 10 13:56:38 1996 Prashant Jain + + * tests/Reactors_Test.cpp (main): Fixed the test so that the + output of the test goes to a log file instead of STDOUT. + Sat Nov 9 11:23:13 1996 Douglas C. Schmidt * ace/Synch.i: Fixed a bug in ACE_Thread_Mutex_Guard. @@ -95,6 +232,7 @@ Sat Nov 9 01:44:15 1996 Irfan Pyarali typedefs does not break existing code. Tue Nov 5 14:26:32 1996 David Levine + * include/makeinclude/wrapper_macros.GNU: Changed LINK.{c,cc} commands to use LD instead of CXX. Changed all platform macros files (except for g++ on VxWorks) to correspond. diff --git a/README b/README index 95a6c8db734..b05cdd0578d 100644 --- a/README +++ b/README @@ -655,6 +655,9 @@ Alex Villazon David Artus Todd Barkalow Alexander Smundak +Thilo Kielmann +Matthias Kerkhoff +Fred LaBar I would particularly like to thank Paul Stephenson, who worked with me at Ericsson and is now at ObjectSpace. Paul devised the recursive diff --git a/examples/Threads/Makefile b/examples/Threads/Makefile index f1c4c630a27..8f5f808ccaa 100644 --- a/examples/Threads/Makefile +++ b/examples/Threads/Makefile @@ -25,7 +25,8 @@ BIN = test_auto_event \ test_thread_manager \ test_thread_pool \ test_thread_specific \ - test_tss \ + test_tss1 \ + test_tss2 \ test_token LSRC = $(addsuffix .cpp,$(BIN)) diff --git a/examples/Threads/test_tss1.cpp b/examples/Threads/test_tss1.cpp new file mode 100644 index 00000000000..8f1d7c81528 --- /dev/null +++ b/examples/Threads/test_tss1.cpp @@ -0,0 +1,155 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// tests +// +// = FILENAME +// TSS_Test.cpp +// +// = DESCRIPTION +// This program tests thread specific storage of data. The ACE_TSS +// wrapper transparently ensures that the objects of this class +// will be placed in thread-specific storage. All calls on +// ACE_TSS::operator->() are delegated to the appropriate method +// in the Errno class. +// +// = AUTHOR +// Detlef Becker +// +// ============================================================================ + +#include "ace/Service_Config.h" +#include "ace/Synch.h" +#include "ace/Log_Msg.h" +#include "ace/Task.h" +#include "test_config.h" + +static int iterations = 100; + +class Errno +{ +public: + int error (void) { return this->errno_; } + void error (int i) { this->errno_ = i; } + + int line (void) { return this->lineno_; } + void line (int l) { this->lineno_ = l; } + + // Errno::flags_ is a static variable, so we've got to protect it + // with a mutex since it isn't kept in thread-specific storage. + int flags (void) { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_Mon, Errno::lock_, -1)); + + return Errno::flags_; + } + int flags (int f) + { + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, Errno::lock_, -1)); + + Errno::flags_ = f; + return 0; + } + +private: + // = errno_ and lineno_ will be thread-specific data so they don't + // need a lock. + int errno_; + int lineno_; + + static int flags_; +#if defined (ACE_HAS_THREADS) + // flags_ needs a lock. + static ACE_Thread_Mutex lock_; +#endif /* ACE_HAS_THREADS */ +}; + +// Static variables. +ACE_MT (ACE_Thread_Mutex Errno::lock_); +int Errno::flags_; + +// This is our thread-specific error handler... +static ACE_TSS TSS_Error; + +#if defined (ACE_HAS_THREADS) +// Serializes output via cout. +static ACE_Thread_Mutex lock; + +typedef ACE_TSS_Guard GUARD; +#else +// Serializes output via cout. +static ACE_Null_Mutex lock; + +typedef ACE_Guard GUARD; +#endif /* ACE_HAS_THREADS */ + +// Keeps track of whether Tester::close () has started. +static int close_started = 0; + +template +class Tester: public ACE_Task +{ +public: + Tester (void) {} + ~Tester (void) {} + + virtual int open (void *theArgs = 0); + virtual int close (u_long theArg = 0); + virtual int put (ACE_Message_Block *theMsgBlock, + ACE_Time_Value *theTimeVal = 0); + virtual int svc (void); +}; + +template +int Tester::open (void *) +{ + this->activate (); + return 0; +} + +template +int Tester::close (u_long) +{ + ACE_DEBUG ((LM_DEBUG, close running\n!)); + close_started = 1; + ACE_OS::sleep (2); + ACE_DEBUG ((LM_DEBUG, "close: trying to log error code 7!"\n)); + TSS_Error->error (7); + ACE_DEBUG ((LM_DEBUG, "close: logging succeeded!"\n)); + return 0; +} + +template int +Tester::put (ACE_Message_Block *, ACE_Time_Value *) +{ + return 0; +} + +template int +Tester::svc (void) +{ + return 0; +} + +int +main (int argc, char *argv[]) +{ + Tester tester; + + tester.open (); + + while (!close_started) + continue; + + ACE_DEBUG ((LM_DEBUG, "main: trying to log error code 7!"\n)); + + TSS_Error->error (3); + + ACE_DEBUG ((LM_DEBUG, "main: logging succeeded!"\n)); + return 0; +} + +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_TSS; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/examples/Threads/test_tss2.cpp b/examples/Threads/test_tss2.cpp new file mode 100644 index 00000000000..0cdbc7fe029 --- /dev/null +++ b/examples/Threads/test_tss2.cpp @@ -0,0 +1,253 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// tests +// +// = FILENAME +// TSS_Test.cpp +// +// = DESCRIPTION +// This program tests thread specific storage of data. The ACE_TSS +// wrapper transparently ensures that the objects of this class +// will be placed in thread-specific storage. All calls on +// ACE_TSS::operator->() are delegated to the appropriate method +// in the Errno class. +// +// = AUTHOR +// Prashant Jain and Doug Schmidt +// +// ============================================================================ + +#include "ace/Task.h" +#include "ace/Token.h" + +#if defined (ACE_HAS_THREADS) + +class TSS_Obj +{ +public: + + TSS_Obj (void); + ~TSS_Obj (void); + +private: + static int count_; + static ACE_Thread_Mutex lock_; +}; + +int TSS_Obj::count_ = 0; +ACE_Thread_Mutex TSS_Obj::lock_; + +TSS_Obj::TSS_Obj (void) +{ + ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); + + count_++; + cout << "TO+ : " << count_ << endl; +} + +TSS_Obj::~TSS_Obj (void) +{ + ACE_GUARD (ACE_Thread_Mutex, ace_mon, lock_); + + count_--; + cout << "TO- : " << count_ << endl; +} + +class Test_Task +{ +public: + + Test_Task (void); + ~Test_Task (void); + + int open (void *arg); + + static void* svc (void *arg); + + static int wait_count_; + static int max_count_; + +private: + static int count_; +}; + +int Test_Task::count_ = 0; +int Test_Task::wait_count_ = 0; +int Test_Task::max_count_ = 0; +int num_threads_ = 0; + +ACE_Token token; + +Test_Task::Test_Task (void) +{ + ACE_GUARD (ACE_Token, ace_mon, token); + + count_++; + cout << "Test_Task+ : " + << count_ << " (" + << ACE_OS::thr_self () + << ")" << endl; +} + +Test_Task::~Test_Task (void) +{ + ACE_GUARD (ACE_Token, ace_mon, token); + + count_--; + cout << "Test_Task- : " + << count_ << " (" + << ACE_OS::thr_self () + << ")" << endl; + + wait_count_--; +} + +int Test_Task::open (void *arg) +{ + + ACE_Thread::spawn (Test_Task::svc, arg); + + return 0; +} + + +void * +Test_Task::svc (void *arg) +{ + ACE_TSS tss (new TSS_Obj); + + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); + + wait_count_++; + max_count_++; + cout << "svc: waiting (" << ACE_OS::thr_self () << ")" << endl; + } + + while (1) + { + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); + + if (max_count_ >= num_threads_) + break; + else + { + ace_mon.release (); + ACE_Thread::yield (); + ace_mon.acquire (); + } + } + + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, 0); + + cout << "svc: waiting (" << ACE_OS::thr_self () << ") finished" << endl; + } + } + + delete (Test_Task *) arg; + + return 0; +} + +int +main (int argc, char **argv) +{ + if (argc != 2) + { + cout << "Missing parameters!" << endl; + return 1; + } + + int num_Tasks = atoi (argv[1]); + + num_threads_ = num_Tasks; + + Test_Task **task_arr = (Test_Task**) new char[sizeof (Test_Task*) * num_Tasks]; + + while (1) + { + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); + + cout << "ReseTest_Tasking Test_Task::max_count_ from: " + << Test_Task::max_count_ << endl; + + Test_Task::max_count_ = 0; + } + + for (int i = 0; i < num_Tasks; i++) + { + task_arr[i] = new Test_Task; + task_arr[i]->open (task_arr[i]); + } + + cout << "Waiting for first thread started..." << endl; + + for (;;) + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); + + if (Test_Task::max_count_ != 0 ) + { + ace_mon.release (); + ACE_Thread::yield (); + ace_mon.acquire (); + break; + } + ace_mon.release (); + ACE_Thread::yield (); + ace_mon.acquire (); + } + + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); + + cout << "First thread started!" << endl + << "Waiting for all threads finished..." << endl; + } + + for (;;) + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); + + if (!(Test_Task::max_count_ == num_threads_ + && Test_Task::wait_count_ == 0)) + { + ace_mon.release (); + ACE_Thread::yield (); + ace_mon.acquire (); + continue; + } + + cout << "Test_Task::max_count_ = " + << Test_Task::max_count_ + << " Test_Task::wait_count_ = " + << Test_Task::wait_count_ + << endl; + break; + } + + { + ACE_GUARD_RETURN (ACE_Token, ace_mon, token, -1); + cout << "All threads finished..." << endl; + } + + ACE_OS::sleep (2); + } + + return 0; +} + +#else +int +main (int, char *[]) +{ + ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + return 0; +} +#endif /* ACE_HAS_THREADS */ diff --git a/netsvcs/ACE-netsvcs.html b/netsvcs/ACE-netsvcs.html index 1fef080dc3e..5b1200a15d4 100644 --- a/netsvcs/ACE-netsvcs.html +++ b/netsvcs/ACE-netsvcs.html @@ -893,3 +893,6 @@ to look for the shared object files or dlls.


Back to the ACE home page. + + + diff --git a/tests/Barrier_Test.cpp b/tests/Barrier_Test.cpp index c08e49f20b1..958411d29cf 100644 --- a/tests/Barrier_Test.cpp +++ b/tests/Barrier_Test.cpp @@ -66,7 +66,7 @@ tester (Tester_Args *args) int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Barrier_Test.cpp"); ACE_Service_Config daemon (argv[0]); diff --git a/tests/Buffer_Stream_Test.cpp b/tests/Buffer_Stream_Test.cpp index d1757c0c423..efa87d3e9f3 100644 --- a/tests/Buffer_Stream_Test.cpp +++ b/tests/Buffer_Stream_Test.cpp @@ -197,7 +197,7 @@ Consumer::svc (void) int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Buffer_Stream_Test.cpp"); ACE_Service_Config daemon (argv[0]); diff --git a/tests/CPP_Test.cpp b/tests/CPP_Test.cpp index b12d696c861..79d9c112f03 100644 --- a/tests/CPP_Test.cpp +++ b/tests/CPP_Test.cpp @@ -219,8 +219,8 @@ server (void *) return 0; } -void -spawn () +static void +spawn (void) { #if !defined (ACE_WIN32) switch (ACE_OS::fork ()) @@ -252,7 +252,7 @@ spawn () int main (int, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("CPP_Test.cpp"); ACE_DEBUG ((LM_DEBUG, "starting %s test at %u\n", argv[0], ACE_OS::time (0))); spawn (); diff --git a/tests/Future_Test.cpp b/tests/Future_Test.cpp index e09c7dbe4ac..878154fe35b 100644 --- a/tests/Future_Test.cpp +++ b/tests/Future_Test.cpp @@ -308,7 +308,7 @@ static int n_loops = 100; int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Future_Test.cpp"); Scheduler *andres, *peter, *helmut, *matias; diff --git a/tests/Handle_Set_Test.cpp b/tests/Handle_Set_Test.cpp index d41dec7d947..7232fa85ebf 100644 --- a/tests/Handle_Set_Test.cpp +++ b/tests/Handle_Set_Test.cpp @@ -67,7 +67,7 @@ run_test (int count) int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Handle_Set_Test.cpp"); int count = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_Handle_Set::MAXSIZE; run_test (count); diff --git a/tests/Map_Manager_Test.cpp b/tests/Map_Manager_Test.cpp index 417fa20771c..d58b6b7d6c0 100644 --- a/tests/Map_Manager_Test.cpp +++ b/tests/Map_Manager_Test.cpp @@ -1,6 +1,24 @@ +// ============================================================================ +// $Id$ + +// +// = LIBRARY +// tests +// +// = FILENAME +// Map_Manager_Test.cpp +// +// = DESCRIPTION +// This is a simple test of the ACE_Map_Manager that +// illustrates how to use the forward and reverse iterators. +// +// = AUTHOR +// Irfan Pyarali +// +// ============================================================================ + #include "ace/Map_Manager.h" #include "ace/Synch.h" -#include typedef ACE_Null_Mutex MUTEX; typedef int KEY; @@ -12,8 +30,10 @@ typedef ACE_Map_Reverse_Iterator REVERSE_ITERATOR; typedef ACE_Map_Entry ENTRY; int -main () +main (int argc, char *argv[]) { + ACE_START_TEST ("Map_Manager_Test.cpp"); + const int ITERATIONS = 5; MAP_MANAGER map; @@ -67,5 +87,6 @@ main () } } + ACE_END_TEST; return 0; } diff --git a/tests/Mem_Map_Test.cpp b/tests/Mem_Map_Test.cpp index 387f3e3da63..1a414e5a986 100644 --- a/tests/Mem_Map_Test.cpp +++ b/tests/Mem_Map_Test.cpp @@ -87,7 +87,7 @@ create_test_file () int main (int, char **argv) { - ACE_START_TEST; + ACE_START_TEST ("Mem_Map_Test.cpp"); ACE_LOG_MSG->open (argv[0]); diff --git a/tests/Message_Queue_Test.cpp b/tests/Message_Queue_Test.cpp index 6a57250e3ee..a73784125d3 100644 --- a/tests/Message_Queue_Test.cpp +++ b/tests/Message_Queue_Test.cpp @@ -1,14 +1,34 @@ +// ============================================================================ +// $Id$ + +// +// = LIBRARY +// tests +// +// = FILENAME +// Message_Queue_Test.cpp +// +// = DESCRIPTION +// This is a simple test of the ACE_Message_Queue that +// illustrates how to use the forward and reverse iterators. +// +// = AUTHOR +// Irfan Pyarali +// +// ============================================================================ + #include "ace/Message_Queue.h" #include "ace/Synch.h" -#include typedef ACE_Message_Queue QUEUE; typedef ACE_Message_Queue_Iterator ITERATOR; typedef ACE_Message_Queue_Reverse_Iterator REVERSE_ITERATOR; int -main () +main (int argc, char *argv[]) { + ACE_START_TEST ("Message_Queue_Test.cpp"); + const int ITERATIONS = 5; QUEUE queue; @@ -65,5 +85,6 @@ main () } } + ACE_END_TEST; return 0; } diff --git a/tests/Mutex_Test.cpp b/tests/Mutex_Test.cpp index d37083023a4..a8fbc3a966e 100644 --- a/tests/Mutex_Test.cpp +++ b/tests/Mutex_Test.cpp @@ -25,7 +25,7 @@ int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Mutex_Test.cpp"); char *name = argc == 1 ? "hello" : argv[1]; diff --git a/tests/Naming_Test.cpp b/tests/Naming_Test.cpp index ebc2a043ba1..414c9c1f338 100644 --- a/tests/Naming_Test.cpp +++ b/tests/Naming_Test.cpp @@ -115,7 +115,7 @@ find (ACE_Naming_Context *ns_context, int sign, int result) int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Naming_Test.cpp"); ACE_Naming_Context *ns_context = new ACE_Naming_Context (); ACE_Name_Options *name_options = ns_context->name_options (); diff --git a/tests/Priority_Buffer_Test.cpp b/tests/Priority_Buffer_Test.cpp index 1b436414603..cf0804d8713 100644 --- a/tests/Priority_Buffer_Test.cpp +++ b/tests/Priority_Buffer_Test.cpp @@ -21,14 +21,12 @@ #include "ace/Log_Msg.h" #include "ace/Message_Queue.h" -#include "ace/Thread_Manager.h" #include "ace/Service_Config.h" #include "test_config.h" #if defined (ACE_HAS_THREADS) // Global thread manager. -static ACE_Thread_Manager thr_mgr; static int count = 0; // Make the queue be capable of being *very* large. @@ -87,7 +85,7 @@ static void * producer (ACE_Message_Queue *msg_queue) { // Insert thread into thr_mgr. - ACE_Thread_Control thread_control (&thr_mgr); + ACE_Thread_Control thread_control (ACE_Service_Config::thr_mgr ()); ACE_NEW_THREAD; ACE_Message_Block *mb = 0; @@ -133,17 +131,18 @@ producer (ACE_Message_Queue *msg_queue) int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Priority_Buffer_Test.cpp"); // Message queue. ACE_Message_Queue msg_queue (max_queue); - if (thr_mgr.spawn (ACE_THR_FUNC (producer), (void *) &msg_queue, - THR_NEW_LWP | THR_DETACHED) == -1) + if (ACE_Service_Config::thr_mgr ()->spawn (ACE_THR_FUNC (producer), + (void *) &msg_queue, + THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 1); // Wait for producer and consumer threads to exit. - thr_mgr.wait (); + ACE_Service_Config::thr_mgr ()->wait (); ACE_END_TEST; return 0; diff --git a/tests/Reactor_Timer_Test.cpp b/tests/Reactor_Timer_Test.cpp index fe2a1aff668..d24c2acb0e6 100644 --- a/tests/Reactor_Timer_Test.cpp +++ b/tests/Reactor_Timer_Test.cpp @@ -52,7 +52,7 @@ public: int main (int, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Reactor_Timer_Test.cpp"); ACE_Reactor reactor; @@ -64,7 +64,6 @@ main (int, char *argv[]) t_id[i] = reactor.schedule_timer (&rt[i], (const void *) i, ACE_Time_Value (2 * i + 1)); - while (!done) reactor.handle_events (); diff --git a/tests/Reactors_Test.cpp b/tests/Reactors_Test.cpp index 4c171ebd71b..937d3f28a5f 100644 --- a/tests/Reactors_Test.cpp +++ b/tests/Reactors_Test.cpp @@ -174,7 +174,7 @@ worker (void *args) int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Reactors_Test.cpp"); ACE_Reactor *react1 = ACE_Service_Config::reactor (); ACE_Reactor *react2 = new ACE_Reactor (); diff --git a/tests/Reader_Writer_Test.cpp b/tests/Reader_Writer_Test.cpp index 160eba6de87..dda0841511c 100644 --- a/tests/Reader_Writer_Test.cpp +++ b/tests/Reader_Writer_Test.cpp @@ -21,7 +21,7 @@ #include "ace/Log_Msg.h" #include "ace/Synch.h" #include "ace/Thread.h" -#include "ace/Thread_Manager.h" +#include "ace/Service_Config.h" #include "ace/Get_Opt.h" #include "test_config.h" @@ -48,9 +48,6 @@ static ACE_RW_Mutex rw_mutex; // Count of the number of readers and writers. ACE_Atomic_Op current_readers, current_writers; -// Thread manager -static ACE_Thread_Manager thr_mgr; - // Explain usage and exit. static void print_usage_and_die (void) @@ -95,7 +92,7 @@ parse_args (int argc, char *argv[]) static void * reader (void *) { - ACE_Thread_Control tc (&thr_mgr); + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); ACE_NEW_THREAD; ACE_DEBUG ((LM_DEBUG, "(%t) reader starting\n")); @@ -134,7 +131,7 @@ reader (void *) static void * writer (void *) { - ACE_Thread_Control tc (&thr_mgr); + ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); ACE_NEW_THREAD; ACE_DEBUG ((LM_DEBUG, "(%t) writer starting\n")); @@ -174,7 +171,7 @@ writer (void *) int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Reader_Writer_Test.cpp"); ACE_LOG_MSG->open (argv[0]); @@ -183,18 +180,18 @@ int main (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, "(%t) main thread starting\n")); - if (thr_mgr.spawn_n (n_readers, - ACE_THR_FUNC (reader), - 0, - THR_NEW_LWP) == -1) + if (ACE_Service_Config::thr_mgr ()->spawn_n (n_readers, + ACE_THR_FUNC (reader), + 0, + THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); - else if (thr_mgr.spawn_n (n_writers, - ACE_THR_FUNC (writer), - 0, - THR_NEW_LWP) == -1) + else if (ACE_Service_Config::thr_mgr ()->spawn_n (n_writers, + ACE_THR_FUNC (writer), + 0, + THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); - thr_mgr.wait (); + ACE_Service_Config::thr_mgr ()->wait (); ACE_DEBUG ((LM_DEBUG, "(%t) exiting main thread\n")); ACE_END_TEST; diff --git a/tests/Recursive_Mutex_Test.cpp b/tests/Recursive_Mutex_Test.cpp index f19d8252210..3ae7bafb8d2 100644 --- a/tests/Recursive_Mutex_Test.cpp +++ b/tests/Recursive_Mutex_Test.cpp @@ -64,7 +64,7 @@ worker (void *arg) int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Recursive_Mutex_Test.cpp"); ACE_Service_Config daemon (argv[0]); ACE_Recursive_Thread_Mutex rm; diff --git a/tests/SPIPE_Test.cpp b/tests/SPIPE_Test.cpp index ef7fb564f67..2e8960ce829 100644 --- a/tests/SPIPE_Test.cpp +++ b/tests/SPIPE_Test.cpp @@ -103,8 +103,8 @@ server (void *) return 0; } -void -spawn () +static void +spawn (void) { #if !defined (ACE_WIN32) switch (ACE_OS::fork ()) @@ -136,7 +136,7 @@ spawn () int main (int, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("SPIPE_Test.cpp"); spawn (); diff --git a/tests/SString_Test.cpp b/tests/SString_Test.cpp index 4285d4fa90e..680eed95da6 100644 --- a/tests/SString_Test.cpp +++ b/tests/SString_Test.cpp @@ -24,7 +24,7 @@ int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("SString_Test.cpp"); ACE_CString s1 ("hello"); ACE_CString s2 ("world"); diff --git a/tests/SV_Shared_Memory_Test.cpp b/tests/SV_Shared_Memory_Test.cpp index 22eae95df7b..8baa4fe414a 100644 --- a/tests/SV_Shared_Memory_Test.cpp +++ b/tests/SV_Shared_Memory_Test.cpp @@ -69,7 +69,8 @@ server (void) int main (int, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("SV_Shared_Memory_Test.cpp"); + switch (ACE_OS::fork ()) { case -1: @@ -80,6 +81,7 @@ main (int, char *argv[]) default: server (); } + ACE_END_TEST; return 0; } diff --git a/tests/Shared_Memory_MM_Test.cpp b/tests/Shared_Memory_MM_Test.cpp index 9634e421a5c..3752fdd76dc 100644 --- a/tests/Shared_Memory_MM_Test.cpp +++ b/tests/Shared_Memory_MM_Test.cpp @@ -89,7 +89,7 @@ server (void *) return 0; } -void +static void spawn () { #if !defined (ACE_WIN32) @@ -122,7 +122,7 @@ spawn () int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Shared_Memory_MM_Test.cpp"); if (ACE_OS::mktemp (shm_key) == 0 || (ACE_OS::unlink (shm_key) == -1 && errno == EPERM)) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", shm_key), 1); diff --git a/tests/Shared_Memory_SV_Test.cpp b/tests/Shared_Memory_SV_Test.cpp index 5a481484e8e..72bc2d6f8af 100644 --- a/tests/Shared_Memory_SV_Test.cpp +++ b/tests/Shared_Memory_SV_Test.cpp @@ -62,7 +62,8 @@ server (void) int main (int argc, char *argv []) { - ACE_START_TEST; + ACE_START_TEST ("Shared_Memory_SV_Test.cpp"); + switch (ACE_OS::fork ()) { case -1: @@ -75,6 +76,7 @@ main (int argc, char *argv []) server (); break; } + ACE_END_TEST; return 0; } diff --git a/tests/TSS_Test.cpp b/tests/TSS_Test.cpp index 37a6d1428c0..966b4e45024 100644 --- a/tests/TSS_Test.cpp +++ b/tests/TSS_Test.cpp @@ -190,7 +190,7 @@ handler (int signum) int main (int, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("TSS_Test.cpp"); ACE_Thread_Control tc (ACE_Service_Config::thr_mgr ()); ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT); diff --git a/tests/Task_Test.cpp b/tests/Task_Test.cpp index d52eac6bba2..32b21e09082 100644 --- a/tests/Task_Test.cpp +++ b/tests/Task_Test.cpp @@ -92,7 +92,7 @@ Barrier_Task::svc (void) int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Task_Test.cpp"); int n_threads = ACE_MAX_THREADS; int n_iterations = ACE_MAX_ITERATIONS; diff --git a/tests/Thread_Manager_Test.cpp b/tests/Thread_Manager_Test.cpp index b49e3b85c6c..48c163efd0a 100644 --- a/tests/Thread_Manager_Test.cpp +++ b/tests/Thread_Manager_Test.cpp @@ -63,7 +63,7 @@ static const int DEFAULT_ITERATIONS = 100000; int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Thread_Manager_Test.cpp"); ACE_Service_Config daemon; diff --git a/tests/Thread_Pool_Test.cpp b/tests/Thread_Pool_Test.cpp index 00041e69701..764871ee15b 100644 --- a/tests/Thread_Pool_Test.cpp +++ b/tests/Thread_Pool_Test.cpp @@ -189,7 +189,7 @@ produce (Thread_Pool &thread_pool) int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Thread_Pool_Test.cpp"); int n_threads = ACE_MAX_THREADS; ACE_DEBUG ((LM_DEBUG, "(%t) argc = %d, threads = %d\n", diff --git a/tests/Time_Service_Test.cpp b/tests/Time_Service_Test.cpp index 5f54f9401f8..2121106433a 100644 --- a/tests/Time_Service_Test.cpp +++ b/tests/Time_Service_Test.cpp @@ -29,7 +29,7 @@ int main (int, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Time_Service_Test.cpp"); char app[BUFSIZ]; char server_conf[BUFSIZ]; @@ -48,6 +48,7 @@ main (int, char *argv[]) s_argv[3] = 0; ACE_Process server; + if (server.start (s_argv) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p.\n", "Server fork failed"), 0); else @@ -57,8 +58,9 @@ main (int, char *argv[]) s_argv[2] = clerk_conf; ACE_Process clerk; + if (clerk.start (s_argv) == -1) - ACE_ERROR_RETURN ((LM_DEBUG, "%p.\n", "Server fork failed"), 0); + ACE_ERROR_RETURN ((LM_DEBUG, "%p.\n", "Clerk fork failed"), 0); else ACE_DEBUG ((LM_DEBUG, "Server forked with pid = %d.\n", clerk.getpid ())); @@ -66,12 +68,11 @@ main (int, char *argv[]) ACE_OS::sleep (10); if (clerk.kill () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "Kill failed.\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "Kill failed for clerk.\n"), -1); if (server.kill () == -1) - ACE_ERROR_RETURN ((LM_ERROR, "Kill failed.\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "Kill failed for server.\n"), -1); ACE_END_TEST; - return 0; } diff --git a/tests/Time_Value_Test.cpp b/tests/Time_Value_Test.cpp index 7ee034e7c5d..4278ccf97d0 100644 --- a/tests/Time_Value_Test.cpp +++ b/tests/Time_Value_Test.cpp @@ -24,7 +24,7 @@ int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Time_Value_Test.cpp"); ACE_Time_Value tv1; ACE_Time_Value tv2 (2); diff --git a/tests/Timer_Queue_Test.cpp b/tests/Timer_Queue_Test.cpp index 956e4f38faa..820dad37475 100644 --- a/tests/Timer_Queue_Test.cpp +++ b/tests/Timer_Queue_Test.cpp @@ -37,7 +37,7 @@ public: int main (int, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("Timer_Queue_Test.cpp"); ACE_Timer_Queue tq; Example_Handler eh; diff --git a/tests/Tokens_Test.cpp b/tests/Tokens_Test.cpp index 341f84dc7f0..5690a39f872 100644 --- a/tests/Tokens_Test.cpp +++ b/tests/Tokens_Test.cpp @@ -182,8 +182,7 @@ run_test (ACE_Token_Proxy *A, int main (int argc, char* argv[]) { - ACE_DEBUG ((LM_DEBUG, "%s starting.\n", argv[0])); - ACE_START_TEST; + ACE_START_TEST ("Tokens_Test.cpp"); ACE_Token_Proxy *A, *B, *R, *W; A = new ACE_Local_Mutex ("L Mutex A", 0, 0); diff --git a/tests/UPIPE_SAP_Test.cpp b/tests/UPIPE_SAP_Test.cpp index b93cea88c96..7934c31e26c 100644 --- a/tests/UPIPE_SAP_Test.cpp +++ b/tests/UPIPE_SAP_Test.cpp @@ -21,13 +21,11 @@ #include "ace/Stream.h" #include "ace/UPIPE_Acceptor.h" #include "ace/UPIPE_Connector.h" +#include "ace/Service_Config.h" #include "test_config.h" #if defined (ACE_HAS_THREADS) -// Global thread manager. -static ACE_Thread_Manager thr_mgr; - // Global pattern static ACE_UPIPE_Addr addr ("pattern"); @@ -37,7 +35,7 @@ static void * peer1 (void *) { // Insert thread into thr_mgr. - ACE_Thread_Control thread_control (&thr_mgr); + ACE_Thread_Control thread_control (ACE_Service_Config::thr_mgr ()); ACE_NEW_THREAD; ACE_UPIPE_Stream c_stream; @@ -84,8 +82,8 @@ peer1 (void *) } conbuf[i] = '\0'; - ACE_ASSERT (ACE_OS::strcmp (conbuf, "this is the peer2 response!") - == 0); + ACE_DEBUG ((LM_DEBUG, "(%t) conbuf = %s", conbuf)); + ACE_ASSERT (ACE_OS::strcmp (conbuf, "this is the peer2 response!") == 0); c_stream.close (); return 0; } @@ -94,15 +92,16 @@ static void * peer2 (void *) { // Insert thread into thr_mgr. - ACE_Thread_Control thread_control (&thr_mgr); + ACE_Thread_Control thread_control (ACE_Service_Config::thr_mgr ()); ACE_NEW_THREAD; ACE_UPIPE_Acceptor acc (addr); ACE_UPIPE_Stream s_stream; // Spawn a peer1 thread. - if (thr_mgr.spawn (ACE_THR_FUNC (peer1), (void *) 0, - THR_NEW_LWP | THR_DETACHED) == -1) + if (ACE_Service_Config::thr_mgr ()->spawn (ACE_THR_FUNC (peer1), + (void *) 0, + THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) peer2 starting accept\n")); @@ -145,18 +144,18 @@ peer2 (void *) int main (int argc, char *argv[]) { - ACE_START_TEST; + ACE_START_TEST ("UPIPE_SAP_Test.cpp"); // Spawn a peer2 thread. - if (thr_mgr.spawn (ACE_THR_FUNC (peer2), (void *) 0, - THR_NEW_LWP | THR_DETACHED) == -1) + if (ACE_Service_Config::thr_mgr ()->spawn (ACE_THR_FUNC (peer2), + (void *) 0, + THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), 1); // Wait for peer2 and peer1 threads to exit. - thr_mgr.wait (); + ACE_Service_Config::thr_mgr ()->wait (); ACE_END_TEST; - return 0; } #else diff --git a/tests/test_config.h b/tests/test_config.h index 44d11017577..44e99d56bd2 100644 --- a/tests/test_config.h +++ b/tests/test_config.h @@ -47,7 +47,7 @@ public: delete this->output_file_; } - int set_output (char *filename) + int set_output (const char *filename) { char temp[BUFSIZ]; // Ignore the error value since the directory may already exist. @@ -81,13 +81,14 @@ private: static ACE_Test_Output ace_file_stream; -#define ACE_START_TEST \ - if (ace_file_stream.set_output (argv[0]) == -1) \ +#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", argv[0])); + 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", argv[0])); \ + ACE_DEBUG ((LM_DEBUG, "Ending %s test at %T\n", program)); \ ace_file_stream.flush (); #define ACE_NEW_THREAD \ -- cgit v1.2.1