Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tests / MT_Server / client.cpp
blobbae8827649ca99f3f6afeb5ad467018685f551e8
1 #include "ace/Get_Opt.h"
2 #include "ace/Task.h"
3 #include "testC.h"
5 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
6 int niterations = 5;
7 int do_shutdown = 0;
9 int
10 parse_args (int argc, ACE_TCHAR *argv[])
12 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("xk:i:"));
13 int c;
15 while ((c = get_opts ()) != -1)
16 switch (c)
18 case 'x':
19 do_shutdown = 1;
20 break;
22 case 'k':
23 ior = get_opts.opt_arg ();
24 break;
26 case 'i':
27 niterations = ACE_OS::atoi (get_opts.opt_arg ());
28 break;
30 case '?':
31 default:
32 ACE_ERROR_RETURN ((LM_ERROR,
33 "usage: %s "
34 "-k <ior> "
35 "-i <niterations> "
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 object =
56 orb->string_to_object (ior);
58 Simple_Server_var server =
59 Simple_Server::_narrow (object.in ());
61 if (CORBA::is_nil (server.in ()))
63 ACE_ERROR_RETURN ((LM_ERROR,
64 "Object reference <%s> is nil.\n",
65 ior),
66 1);
69 for (int i = 0; i != niterations; ++i)
71 CORBA::Long r =
72 server->test_method (i);
74 if (r != i)
76 ACE_DEBUG ((LM_DEBUG,
77 "(%P|%t) unexpected result = %d for %d",
78 r, i));
82 if (do_shutdown)
84 server->shutdown ();
87 catch (const CORBA::Exception& ex)
89 ex._tao_print_exception ("Exception caught:");
90 return 1;
93 return 0;