blob: 204bbf8a284da27992c947d6bd475307c7a45dde (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
// $Id$
#include "test_i.h"
#include "common.h"
#include "ace/Get_Opt.h"
#include "ace/OS_NS_stdio.h"
#include "ace/High_Res_Timer.h"
void parse_args(int argc, char * argv[]);
void write_ior_to_file(char const * ior);
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
// Fetching the high res timer's global scale factor ensures that it
// is calibrated (if necessary on this platform) at the beginning of
// the test. While the timer would otherwise be calibrated on first
// use, this introduces delay in the middle of the test's execution.
// This leads to failures due to timing assumptions (timeouts, etc.)
// within the test itself.
(void) ACE_High_Res_Timer::global_scale_factor();
try
{
CORBA::ORB_var orb = initialize_orb_and_poa(argc, argv);
parse_args(argc, argv);
test_i servant (orb.in());
CORBA::String_var ior =
servant.create_and_activate_server();
write_ior_to_file(ior.in());
orb->run();
}
catch(...)
{
report_exception();
return 1;
}
return 0;
}
namespace
{
const char *ior_output_file = "test.ior";
}
void
parse_args(int argc, char * argv[])
{
ACE_Get_Opt get_opts (argc, argv, "o:");
int c;
while ((c = get_opts ()) != -1)
{
switch (c)
{
case 'o':
ior_output_file = get_opts.opt_arg ();
break;
case '?':
default:
throw "Usage: server [-o iorfile]\n";
}
}
}
void write_ior_to_file(char const * ior)
{
if (ior_output_file == 0)
{
return;
}
FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
if (output_file == 0)
{
throw "Cannot open output file to write the IOR";
}
ACE_OS::fprintf (output_file, "%s", ior);
ACE_OS::fclose (output_file);
}
|