1 #include "Client_Task.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
9 parse_args (int argc
, ACE_TCHAR
*argv
[])
11 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:i:n:"));
14 while ((c
= get_opts ()) != -1)
18 ior
= get_opts
.opt_arg ();
22 iterations
= ACE_OS::atoi (get_opts
.opt_arg ());
26 threads
= ACE_OS::atoi (get_opts
.opt_arg ());
31 ACE_ERROR_RETURN ((LM_ERROR
,
40 // Indicates successful parsing of the command line
45 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
50 CORBA::ORB_init (argc
, argv
);
52 if (parse_args (argc
, argv
) != 0)
55 CORBA::Object_var tmp
=
56 orb
->string_to_object(ior
);
58 Test::Sleep_Service_var sleep_service
=
59 Test::Sleep_Service::_narrow(tmp
.in ());
61 if (CORBA::is_nil (sleep_service
.in ()))
63 ACE_ERROR_RETURN ((LM_DEBUG
,
64 "Nil process reference <%s>\n",
69 Client_Task
task0 (orb
.in (),
74 Client_Task
task1 (orb
.in (),
80 if (task0
.activate (THR_NEW_LWP
| THR_JOINABLE
, threads
, 1) == -1)
82 ACE_ERROR ((LM_ERROR
, "Error activating client task\n"));
84 if (task1
.activate (THR_NEW_LWP
| THR_JOINABLE
, threads
, 1) == -1)
86 ACE_ERROR ((LM_ERROR
, "Error activating client task\n"));
88 ACE_Thread_Manager::instance ()->wait ();
90 // Get back in sync with the server..
91 sleep_service
->go_to_sleep (0);
93 sleep_service
->shutdown ();
98 "Task 0: Successful calls = %d, timed out calls = %d\n",
99 task0
.successful_calls (),
100 task0
.timed_out_calls ()));
102 ACE_DEBUG ((LM_DEBUG
,
103 "Task 1: Successful calls = %d, timed out calls = %d\n",
104 task1
.successful_calls (),
105 task1
.timed_out_calls ()));
107 // No more than 5 % of the calls are allowed to have a too big
109 if (task0
.too_big_difference_calls () > iterations
/20
110 || task1
.too_big_difference_calls () > iterations
/20)
112 //FUZZ: disable check_for_lack_ACE_OS
113 ACE_DEBUG ((LM_DEBUG
,
114 "Warning: Too many calls have a too big difference between "
115 "timeout and elapsed time (task0: %d, task1: %d)\n",
116 task0
.too_big_difference_calls (),
117 task1
.too_big_difference_calls ()));
118 //FUZZ: enable check_for_lack_ACE_OS
120 else if (task0
.too_big_difference_calls () != 0
121 || task1
.too_big_difference_calls () != 0)
123 ACE_DEBUG ((LM_DEBUG
,
124 "Warning: some calls (task0: %d, task1: %d) "
125 "exceeded their expected elapsed times\n",
126 task0
.too_big_difference_calls (),
127 task1
.too_big_difference_calls ()));
130 if (task0
.timed_out_calls () == 0)
132 ACE_ERROR ((LM_ERROR
,
133 "ERROR: non-zero number of timeouts "
134 "expected for task 0\n"));
137 if (task1
.successful_calls () != 0)
139 ACE_ERROR ((LM_ERROR
,
140 "ERROR: zero successful calls "
141 "expected for task 1\n"));
144 catch (const CORBA::Exception
& ex
)
146 ex
._tao_print_exception ("Exception caught:");