2 #include "ace/Get_Opt.h"
5 #include "ace/OS_NS_time.h"
6 #include "ace/OS_NS_string.h"
7 #include "ace/OS_NS_unistd.h"
9 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
11 unsigned int seed
= 0;
15 parse_args (int argc
, ACE_TCHAR
*argv
[])
17 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("vk:i:s:"));
20 while ((c
= get_opts ()) != -1)
24 ior
= get_opts
.opt_arg ();
28 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
32 seed
= ACE_OS::atoi (get_opts
.opt_arg ());
41 ACE_ERROR_RETURN ((LM_ERROR
,
51 // Indicates successful parsing of the command line
56 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
61 CORBA::ORB_init (argc
, argv
);
63 if (parse_args (argc
, argv
) != 0)
66 CORBA::Object_var object
=
67 orb
->string_to_object (ior
);
69 Test::Database_var server
=
70 Test::Database::_narrow (object
.in ());
72 if (CORBA::is_nil (server
.in ()))
74 ACE_ERROR_RETURN ((LM_ERROR
,
75 "Object reference <%s> is nil.\n",
80 #if (TAO_HAS_MINIMUM_CORBA == 0)
81 CORBA::String_var repository_id
=
82 server
->_repository_id ();
84 if (ACE_OS::strcmp (repository_id
.in (), "IDL:Test/Database:1.0") != 0)
86 ACE_ERROR_RETURN ((LM_ERROR
,
87 "Repository id is wrong <%C>\n",
91 #endif /* TAO_HAS_MINIMUM_CORBA == 0 */
95 seed
= static_cast<unsigned int> (ACE_OS::time (0));
96 ACE_DEBUG ((LM_DEBUG
, "Seed value is %d\n", seed
));
99 const int nelements
= 64; // @@ TODO
100 const int maxsize
= 1024;
101 Test::OctetSeq elements
[nelements
];
103 for (int i
= 0; i
!= niterations
; ++i
)
105 CORBA::ULong r
= ACE_OS::rand_r (&seed
);
106 Test::Index idx
= (r
% nelements
);
110 for (int j
= 0; j
!= nelements
; ++j
)
112 CORBA::ULong r
= ACE_OS::rand_r (&seed
);
113 CORBA::ULong l
= r
% maxsize
;
114 elements
[j
].length (l
);
115 CORBA::Double token
= 0;
116 for (CORBA::ULong k
= 0; k
!= l
; ++k
)
118 r
= ACE_OS::rand_r (&seed
);
119 elements
[j
][k
] = (r
% 128);
122 CORBA::Double returned_token
;
123 server
->set (Test::Index (j
),
128 if (!ACE::is_equal (token
, returned_token
))
130 ACE_ERROR ((LM_ERROR
,
131 "ERROR - invalid token <%f> returned,"
132 " expecting %f in (%d,%d)\n",
133 returned_token
, token
, i
, j
));
138 CORBA::ULong crc_remote
=
139 server
->get_crc (idx
);
141 CORBA::ULong crc_local
=
142 ACE::crc32 (elements
[idx
].get_buffer (),
143 elements
[idx
].length ());
145 if (crc_local
!= crc_remote
)
147 ACE_DEBUG ((LM_DEBUG
,
148 "CRC mismatch for element %d\n", idx
));
150 else if (verbose
== 1)
152 ACE_DEBUG ((LM_DEBUG
,
153 "CRC <%u> matched for element %d\n",
163 catch (const CORBA::Exception
& ex
)
165 ex
._tao_print_exception ("Caught exception:");