Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Client_Leaks / client.cpp
blob87665d4fbc56c63cc44b601d79ac2a94bc2a2975
1 #include "Client_Task.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
5 int iterations = 100;
6 int threads = 12;
8 int
9 parse_args (int argc, ACE_TCHAR *argv[])
11 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:i:n:"));
12 int c;
14 while ((c = get_opts ()) != -1)
15 switch (c)
17 case 'k':
18 ior = get_opts.opt_arg ();
19 break;
21 case 'i':
22 iterations = ACE_OS::atoi (get_opts.opt_arg ());
23 break;
25 case 'n':
26 threads = ACE_OS::atoi (get_opts.opt_arg ());
27 break;
29 case '?':
30 default:
31 ACE_ERROR_RETURN ((LM_ERROR,
32 "usage: %s "
33 "-k <ior> "
34 "-i <iterations> "
35 "-i <threads> "
36 "\n",
37 argv [0]),
38 -1);
40 // Indicates successful parsing of the command line
41 return 0;
44 int
45 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
47 try
49 CORBA::ORB_var orb =
50 CORBA::ORB_init (argc, argv);
52 if (parse_args (argc, argv) != 0)
53 return 1;
55 CORBA::Object_var tmp =
56 orb->string_to_object (ior);
58 Test::Process_Factory_var process_factory =
59 Test::Process_Factory::_narrow(tmp.in ());
61 if (CORBA::is_nil (process_factory.in ()))
63 ACE_ERROR_RETURN ((LM_DEBUG,
64 "Nil process reference <%s>\n",
65 ior),
66 1);
69 Client_Task client_task (process_factory.in (),
70 iterations);
72 if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
73 threads, 1) == -1)
75 ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
77 ACE_Thread_Manager::instance ()->wait ();
79 process_factory->shutdown ();
81 orb->destroy ();
83 // Only pass the test if 90% of the calls worked
84 if (client_task.successful_calls () < 0.9 * iterations * threads)
86 ACE_ERROR ((LM_ERROR,
87 "ERROR: no calls were successful\n"));
90 catch (const CORBA::Exception& ex)
92 ex._tao_print_exception ("Exception caught:");
93 return 1;
96 return 0;