More tests update
[ACE_TAO.git] / TAO / tests / DSI_AMH / client.cpp
blob74f23dad92b3b5c1c852f82855b74ccc1c63920e
1 #include "TestC.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/High_Res_Timer.h"
4 #include "tao/debug.h"
6 const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
7 int niterations = 100;
8 int do_shutdown = 1;
10 int
11 parse_args (int argc, ACE_TCHAR *argv[])
13 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("xk:i:"));
14 int c;
16 while ((c = get_opts ()) != -1)
17 switch (c)
19 case 'x':
20 do_shutdown = 0;
21 break;
23 case 'k':
24 ior = get_opts.opt_arg ();
25 break;
27 case 'i':
28 niterations = ACE_OS::atoi (get_opts.opt_arg ());
29 break;
31 case '?':
32 default:
33 ACE_ERROR_RETURN ((LM_ERROR,
34 "usage: %s "
35 "-k <ior> "
36 "-i <niterations> "
37 "-x (disable shutdown) "
38 "\n",
39 argv [0]),
40 -1);
42 // Indicates successful parsing of the command line
43 return 0;
46 int
47 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
50 try
52 CORBA::ORB_var orb =
53 CORBA::ORB_init (argc, argv);
55 if (parse_args (argc, argv) != 0)
56 return 1;
58 CORBA::Object_var object =
59 orb->string_to_object (ior);
61 Test::Roundtrip_var roundtrip =
62 Test::Roundtrip::_narrow (object.in ());
64 if (CORBA::is_nil (roundtrip.in ()))
66 ACE_ERROR_RETURN ((LM_ERROR,
67 "Nil Test::Roundtrip reference <%s>\n",
68 ior),
69 1);
72 for (int i = 0; i < niterations; ++i)
74 ACE_hrtime_t start = ACE_OS::gethrtime ();
75 ACE_hrtime_t retval = roundtrip->test_method (start);
77 if (TAO_debug_level > 0)
78 ACE_DEBUG ((LM_DEBUG, "test return value: %Q\n", retval));
82 ACE_DEBUG ((LM_DEBUG, "test finished\n"));
85 if (do_shutdown)
87 roundtrip->shutdown ();
90 catch (const CORBA::Exception& ex)
92 ex._tao_print_exception ("Exception caught:");
93 return 1;
96 return 0;