2 #include "ace/Get_Opt.h"
3 #include "ace/Log_Msg.h"
4 #include "ace/OS_NS_stdio.h"
7 const ACE_TCHAR
* log_file_
;
10 parse_args (int argc
, ACE_TCHAR
* argv
[])
12 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT ("l:"));
16 while ((c
= get_opts()) != -1)
21 log_file_
= get_opts
.opt_arg();
33 FILE* fp
= ACE_OS::fopen (log_file_
,
39 ACE_TEXT ("error opening log file %s\n"),
45 while (ACE_OS::fgets (buf
, sizeof (buf
), fp
) != 0)
47 ///When verbose is on, a line contains a timestamp and a @ character
48 if (ACE_OS::strchr (buf
, ACE_TEXT('@')) != 0)
51 ACE_TEXT ("Test OK, a timestamp was found\n")));
52 (void) ACE_OS::fclose (fp
);
57 ACE_TEXT ("Test failed, no timestamp found in log\n")));
58 (void) ACE_OS::fclose (fp
);
63 check_flags (const u_long
& flags
, const int& verbose
)
69 /// Both VERBOSE and VERBOSE_LITE shouldn't be set
70 if ((flags
& ACE_Log_Msg::VERBOSE
) != 0 &&
71 (flags
& ACE_Log_Msg::VERBOSE_LITE
) != 0)
74 ACE_TEXT ("Test failed: Verbose flag not set properly when verbose=0\n")));
79 /// VERBOSE_LITE should be set
80 if ((flags
& ACE_Log_Msg::VERBOSE_LITE
) == 0)
83 ACE_TEXT ("Test failed: Verbose flag not set properly when verbose=1\n")));
88 /// VERBOSE should be set
89 if ((flags
& ACE_Log_Msg::VERBOSE
) == 0)
92 ACE_TEXT ("Test failed: Verbose flag not set properly when verbose=unknown\n")));
101 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
108 if (parse_args(argc
, argv
) != 0)
111 ACE_TEXT ("Usage:\n\n")
112 ACE_TEXT ("OPTIONS:\n\n")
113 ACE_TEXT ("\t[-l Log file]\n\n")));
117 for (int verbose
= 0; verbose
< 3; verbose
++)
119 ACE_DEBUG ((LM_DEBUG
,
120 ACE_TEXT ("Start ORB_init with ORBVerboseLogging=%d\n"),
123 ACE_TCHAR
**extra
= 0;
124 ACE_NEW_RETURN (extra
, ACE_TCHAR
*[extra_argc
], -1);
125 extra
[0] = ACE::strnew (ACE_TEXT ("-ORBCDRTradeoff"));
126 extra
[1] = ACE::strnew (ACE_TEXT ("2048"));
127 extra
[2] = ACE::strnew (ACE_TEXT ("-ORBCollocation"));
128 extra
[3] = ACE::strnew (ACE_TEXT ("per-orb"));
129 extra
[4] = ACE::strnew (ACE_TEXT ("-ORBDebug"));
130 extra
[5] = ACE::strnew (ACE_TEXT ("-ORBDebugLevel"));
131 extra
[6] = ACE::strnew (ACE_TEXT ("10"));
132 extra
[7] = ACE::strnew (ACE_TEXT ("-ORBDefaultInitRef"));
133 extra
[8] = ACE::strnew (ACE_TEXT ("corbaloc::localhost:4177"));
134 extra
[9] = ACE::strnew (ACE_TEXT ("-ORBDottedDecimalAddresses"));
135 extra
[10] = ACE::strnew (ACE_TEXT ("1"));
136 extra
[11] = ACE::strnew (ACE_TEXT ("-ORBId"));
137 extra
[12] = ACE::strnew (ACE_TEXT ("Client"));
138 extra
[13] = ACE::strnew (ACE_TEXT ("-ORBListenEndpoints"));
139 extra
[14] = ACE::strnew (ACE_TEXT ("iiop://:4178"));
140 extra
[15] = ACE::strnew (ACE_TEXT ("-ORBLogFile"));
141 ACE_NEW_RETURN (extra
[16],
142 ACE_TCHAR
[ACE_OS::strlen(log_file_
) + 1],
144 ACE_OS::sprintf (extra
[16], ACE_TEXT("%s"), log_file_
);
145 extra
[17] = ACE::strnew (ACE_TEXT ("-ORBNegotiateCodesets"));
146 extra
[18] = ACE::strnew (ACE_TEXT ("0"));
147 extra
[19] = ACE::strnew (ACE_TEXT ("-ORBNodelay"));
148 extra
[20] = ACE::strnew (ACE_TEXT ("1"));
149 extra
[21] = ACE::strnew (ACE_TEXT ("-ORBSvcConfDirective"));
150 extra
[22] = ACE::strnew (ACE_TEXT ("\"static Client_Strategy_Factory '-ORBWaitStrategy mt_noupcall'\""));
151 extra
[23] = ACE::strnew (ACE_TEXT ("-ORBVerboseLogging"));
152 ACE_NEW_RETURN (extra
[24],
155 ACE_OS::sprintf (extra
[24], ACE_TEXT ("%d"), verbose
);
157 ACE_TCHAR
**largv
= new ACE_TCHAR
*[argc
+extra_argc
];
158 for (int i
= 0; i
< argc
; i
++)
161 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("server adding args: ")));
162 for (int i
= 0; i
< extra_argc
; i
++)
164 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%s "), extra
[i
]));
165 largv
[argc
+i
] = extra
[i
];
167 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("\n")));
171 ACE_TCHAR orb_name
[25];
172 ACE_OS::sprintf (orb_name
, ACE_TEXT ("VERBOSE_LOGGING_TEST_%d"), verbose
);
174 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, largv
, orb_name
);
176 u_long log_flags
= ACE_LOG_MSG
->flags();
178 ACE_DEBUG ((LM_DEBUG
,
179 ACE_TEXT ("log flags %d verbose: %d\n"),
180 log_flags
, verbose
));
182 result
+= check_flags (log_flags
, verbose
);
185 orb
= CORBA::ORB::_nil ();
186 ACE_LOG_MSG
->restart ();
188 for (int i
= 0; i
< extra_argc
; i
++)
189 ACE::strdelete (extra
[i
]);
194 catch (const CORBA::Exception
& ex
)
196 ex
._tao_print_exception ("Exception caught:");
200 result
+= check_logging ();
203 ACE_DEBUG ((LM_DEBUG
,
204 ACE_TEXT ("Test passed!")));
206 ACE_ERROR ((LM_ERROR
,
207 ACE_TEXT ("Test failed. Result: %d\n"),