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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
// $Id$
#include "TX_ObjectC.h"
#include "ace/OS_NS_stdlib.h"
#include "ace/OS_NS_string.h"
#include "ace/Get_Opt.h"
#include "ace/SString.h"
const ACE_TCHAR *ior = ACE_TEXT("file://test.ior");
const char *cert_file = "cacert.pem";
long number_iterations = 1;
long data_size = 3461724;
bool shutdown_server = false;
int
parse_args (int argc, ACE_TCHAR *argv[])
{
ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:i:d:x"));
int c;
while ((c = get_opts ()) != -1)
switch (c)
{
case 'k':
ior = get_opts.opt_arg ();
break;
case 'i':
number_iterations = ACE_OS::atoi (get_opts.opt_arg ());
break;
case 'd':
data_size = ACE_OS::atoi (get_opts.opt_arg ());
break;
case 'x':
shutdown_server = true;
break;
case '?':
default:
ACE_ERROR_RETURN ((LM_ERROR,
"Usage: %s "
"-k <ior> "
"-i <iterations> "
"-d <datasize> "
"-x shutdown "
"\n",
argv [0]),
-1);
}
// Indicates sucessful parsing of the command line
return 0;
}
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
ACE_CString env ("SSL_CERT_FILE=");
env += cert_file;
ACE_OS::putenv (env.c_str ());
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
if (::parse_args (argc, argv) != 0)
return 1;
CORBA::Object_var obj =
orb->string_to_object (ior);
if (CORBA::is_nil (obj.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Nil server object reference\n"),
-1);
TX_Object_var txObject =
TX_Object::_narrow (obj.in ());
DataSeq data_input;
CORBA::ULong const len = data_size;
data_input.length (len);
// Fill in some useless data.
for (CORBA::ULong i = 0; i < len; ++i)
{
data_input[i] = i % 9;
}
for (int iteration = 0; iteration < number_iterations; ++iteration)
{
ACE_DEBUG ((LM_DEBUG,
"Sending octet sequence of length:\t%u\n",
data_input.length ()));
txObject->send (data_input);
DataSeq_var data_output;
txObject->recv (data_output.out ());
ACE_DEBUG ((LM_DEBUG,
"Received octet sequence of length:\t%u\n",
data_output->length ()));
// Sanity check
if (data_output->length () != len
|| ACE_OS::memcmp (data_input.get_buffer (),
data_output->get_buffer (),
len) != 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"ERROR: Received octet sequence does not match "
"the one that was sent.\n"),
-1);
}
}
if (shutdown_server)
{
txObject->shutdown ();
}
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("ERROR");
return -1;
}
ACE_DEBUG ((LM_DEBUG,
"\n"
"SSLIOP Big_Request test passed.\n"));
return 0;
}
|