3 // ============================================================================
7 * This file factors out common macros and other utilities used by the
8 * ACE automated regression tests. It also shows how to redirect ACE_DEBUG/ACE_ERROR
11 * @author Prashant Jain <pjain@cs.wustl.edu>
12 * @author Tim Harrison <harrison@cs.wustl.edu>
13 * @author David Levine <levine@cs.wustl.edu>
15 // ============================================================================
17 #ifndef ACE_TEST_CONFIG_H
18 #define ACE_TEST_CONFIG_H
20 // This first #undef protects against command-line definitions.
23 #include "ace/config-all.h"
25 #if !defined (ACE_LACKS_PRAGMA_ONCE)
27 #endif /* ACE_LACKS_PRAGMA_ONCE */
29 #if defined (ACE_NLOGGING)
30 // ACE_NLOGGING must not be set if the tests are to produce any output.
32 #endif /* ACE_NLOGGING */
34 #include "ace/OS_NS_errno.h"
35 #include "ace/OS_NS_stdio.h"
36 #include "ace/Log_Msg.h"
38 #if defined (ACE_WIN32)
39 # define ACE_LOG_DIRECTORY ACE_TEXT ("log\\")
40 # define ACE_LOG_DIRECTORY_FOR_MKDIR ACE_TEXT ("log\\")
41 # define MAKE_PIPE_NAME(X) ACE_TEXT ("\\\\.\\pipe\\"#X)
42 #elif defined (ANDROID)
43 # define ACE_LOG_DIRECTORY_FOR_MKDIR ACE_TEXT ("/sdcard/log/")
44 # define ACE_LOG_DIRECTORY ACE_TEXT ("/sdcard/log/")
45 # define MAKE_PIPE_NAME(X) ACE_TEXT (X)
47 # define ACE_LOG_DIRECTORY_FOR_MKDIR ACE_TEXT ("log/")
48 # define ACE_LOG_DIRECTORY ACE_TEXT ("log/")
49 # define MAKE_PIPE_NAME(X) ACE_TEXT (X)
50 #endif /* ACE_WIN32 */
52 #if !defined (ACE_DEFAULT_TEST_DIR)
53 # define ACE_DEFAULT_TEST_DIR ACE_TEXT ("")
56 #if !defined (ACE_LOG_FILE_EXT_NAME)
57 # define ACE_LOG_FILE_EXT_NAME ACE_TEXT (".log")
58 #endif /* ACE_LOG_FILE_EXT_NAME */
60 size_t const ACE_MAX_CLIENTS
= 30;
61 size_t const ACE_NS_MAX_ENTRIES
= 1000;
62 size_t const ACE_DEFAULT_USECS
= 1000;
63 size_t const ACE_MAX_TIMERS
= 4;
64 size_t const ACE_MAX_DELAY
= 10;
65 size_t const ACE_MAX_INTERVAL
= 0;
66 size_t const ACE_MAX_ITERATIONS
= 10;
67 size_t const ACE_MAX_PROCESSES
= 10;
68 size_t const ACE_MAX_THREADS
= 4;
70 #if defined ACE_HAS_CONSOLE_TEST_OUTPUT
71 #ifndef ACE_START_TEST
72 # define ACE_START_TEST(NAME) const ACE_TCHAR *program = NAME; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Starting %s test at %D\n"), NAME))
73 #endif /* ACE_START_TEST */
76 # define ACE_END_TEST ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Ending %s test %D\n"), program));
77 #endif /* ACE_END_TEST */
78 #endif /* ACE_HAS_CONSOLE_TEST_OUTPUT */
80 #ifdef ACE_TEST_LOG_TO_STDERR
81 # define ACE_TEST_LOG_MSG_FLAGS ACE_Log_Msg::STDERR | ACE_Log_Msg::VERBOSE_LITE
82 # define ACE_TEST_SET_OUTPUT(APPEND)
83 # define ACE_CLOSE_TEST_LOG
85 # define ACE_TEST_LOG_MSG_FLAGS ACE_Log_Msg::OSTREAM | ACE_Log_Msg::VERBOSE_LITE
86 # define ACE_TEST_SET_OUTPUT(APPEND) \
87 if (ace_file_stream::instance ()->set_output (program, APPEND) != 0) \
88 ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("set_output failed")), -1);
89 # define ACE_CLOSE_TEST_LOG ace_file_stream::instance ()->close ()
92 #define ACE_START_TEST_TEMPLATE(NAME, APPEND) \
93 const ACE_TCHAR *program = NAME; \
94 if (ACE_LOG_MSG->open (program, ACE_TEST_LOG_MSG_FLAGS) != 0) \
95 ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open log_msg failed")), -1); \
96 ACE_TEST_SET_OUTPUT (APPEND); \
97 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Starting %s test at %D\n"), program))
99 #ifndef ACE_START_TEST
100 # define ACE_START_TEST(NAME) ACE_START_TEST_TEMPLATE (NAME, 0)
101 #endif /* ACE_START_TEST */
104 #define ACE_END_TEST \
105 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Ending %s test at %D\n"), program)); \
107 #endif /* ACE_END_TEST */
109 #ifndef ACE_APPEND_LOG
110 # define ACE_APPEND_LOG(NAME) ACE_START_TEST_TEMPLATE (NAME, 1)
111 #endif /* ACE_APPEND_LOG */
113 #define ACE_END_LOG \
114 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Ending %s test at %D\n\n"), program)); \
115 ACE_LOG_MSG->set_flags(ACE_Log_Msg::SILENT); \
118 #if defined (ACE_VXWORKS)
119 // This is the only way I could figure out to avoid an error
120 // about attempting to unlink a non-existent file.
122 #include "ace/OS_NS_fcntl.h"
124 #define ACE_INIT_LOG(NAME) \
125 ACE_TCHAR temp[MAXPATHLEN]; \
126 ACE_OS::sprintf (temp, ACE_TEXT ("%s%s%s"), \
128 ACE::basename (NAME, ACE_DIRECTORY_SEPARATOR_CHAR), \
129 ACE_LOG_FILE_EXT_NAME); \
130 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Deleting old log file %s (if any)\n\n"), temp)); \
132 if ((fd_init_log = ACE_OS::open (temp, \
134 S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) != ERROR) \
136 ACE_OS::close (fd_init_log); \
137 ACE_OS::unlink (temp); \
140 #else /* ! VXWORKS */
141 #define ACE_INIT_LOG(NAME) \
142 ACE_TCHAR temp[MAXPATHLEN]; \
143 ACE_OS::sprintf (temp, \
144 ACE_TEXT ("%") ACE_TEXT_PRIs \
145 ACE_TEXT ("%") ACE_TEXT_PRIs \
146 ACE_TEXT ("%") ACE_TEXT_PRIs, \
148 ACE::basename (NAME, ACE_DIRECTORY_SEPARATOR_CHAR), \
149 ACE_LOG_FILE_EXT_NAME); \
150 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Deleting old log file %s (if any)\n\n"), temp)); \
151 ACE_OS::unlink (temp);
152 #endif /* ! VXWORKS */
154 #if defined (ACE_LACKS_IOSTREAM_TOTALLY)
155 #define OFSTREAM FILE
157 #define OFSTREAM ofstream
158 #endif /* ACE_LACKS_IOSTREAM_TOTALLY */
160 #include "Test_Output_Export.h"
162 class Test_Output_Export ACE_Test_Output
167 static ACE_Test_Output
*instance ();
168 int set_output (const ACE_TCHAR
*filename
, int append
= 0);
169 OFSTREAM
*output_file ();
171 const ACE_TCHAR
*dll_name ();
172 const ACE_TCHAR
*name ();
173 static void close_singleton ();
176 static ACE_Test_Output
*instance_
;
178 OFSTREAM
*output_file_
;
181 typedef ACE_Test_Output ace_file_stream
;
183 #endif /* ACE_TEST_CONFIG_H */