Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / tests / DII_Collocation_Tests / oneway / Collocated_Test.cpp
blob98685324a0fa1eccaf75fa07fecc6930507353ea
1 #include "Server_Task.h"
2 #include "Client_Task.h"
3 #include "ace/Get_Opt.h"
4 #include "ace/Argv_Type_Converter.h"
5 #include "ace/SString.h"
6 #include "ace/Manual_Event.h"
8 const ACE_TCHAR *output = ACE_TEXT("server.ior");
9 const ACE_TCHAR *input = ACE_TEXT("file://server.ior");
10 const ACE_TCHAR *simple_test_output = ACE_TEXT("simple_test.ior");
11 const ACE_TCHAR *simple_test_input = ACE_TEXT("file://simple_test.ior");
12 // static int named_orbs = 0;
13 ACE_CString server_orb;
14 ACE_CString client_orb;
16 CORBA::Boolean debug = 0;
18 int
19 parse_args (int argc, ACE_TCHAR *argv[])
21 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:o:nd"));
22 int c;
24 while ((c = get_opts ()) != -1)
25 switch (c)
27 case 'o':
28 output = get_opts.opt_arg ();
29 break;
30 case 'k':
31 input = get_opts.opt_arg ();
32 break;
33 case 'n':
34 // named_orbs = 1;
35 server_orb.set ("server_orb");
36 client_orb.set ("client_orb");
37 break;
38 case 'd':
39 debug = 1;
40 break;
41 case '?':
42 default:
43 // This is a hack but that is okay!
44 return 0;
46 // Indicates successful parsing of the command line
47 return 0;
50 int
51 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
53 if (parse_args (argc,
54 argv) == -1)
55 return -1;
57 try
59 ACE_Argv_Type_Converter satc (argc, argv);
60 CORBA::ORB_var sorb =
61 CORBA::ORB_init (satc.get_argc (),
62 satc.get_TCHAR_argv (),
63 server_orb.c_str ());
65 ACE_Manual_Event me;
66 Server_Task server_task (output,
67 simple_test_output,
68 sorb.in (),
69 me,
70 ACE_Thread_Manager::instance ());
72 if (server_task.activate (THR_NEW_LWP | THR_JOINABLE,
74 1) == -1)
76 ACE_ERROR ((LM_ERROR, "Error activating server task\n"));
79 // Wait for the server thread to do some processing
80 me.wait ();
82 ACE_Argv_Type_Converter catc (argc, argv);
83 CORBA::ORB_var corb =
84 CORBA::ORB_init (catc.get_argc (),
85 catc.get_TCHAR_argv (),
86 client_orb.c_str ());
88 Client_Task client_task (input,
89 simple_test_input,
90 corb.in (),
91 ACE_Thread_Manager::instance ());
93 if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
95 1) == -1)
97 ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
100 // Wait for the client and server to finish
101 ACE_Thread_Manager::instance ()->wait ();
103 // Now that all threads have completed we can destroy the ORB
104 sorb->destroy ();
105 if (server_orb != client_orb)
107 corb->destroy ();
110 CORBA::ULong errors = client_task.error_count () + server_task.error_count ();
111 if (errors == 0)
113 ACE_DEBUG((LM_DEBUG, "(%P|%t) test passed\n"));
115 else
117 ACE_DEBUG((LM_DEBUG, "(%P|%t) test failed - error_count=%u\n", errors));
118 return 1;
121 catch (const CORBA::Exception&)
123 // Ignore exceptions..
125 return 0;