summaryrefslogtreecommitdiff
path: root/TAO/IIOP/test
diff options
context:
space:
mode:
authorChris Cleeland <chris.cleeland@gmail.com>1997-05-22 16:57:08 +0000
committerChris Cleeland <chris.cleeland@gmail.com>1997-05-22 16:57:08 +0000
commite453c1c3709ed13ef2a45e1b7f9e6de58ef63098 (patch)
tree519f3b3b42444b2fb825c4b001cbbc4533b43869 /TAO/IIOP/test
parent5082d18b5363fdd2a025a58d15e00d66ff6a6c5c (diff)
downloadATCD-e453c1c3709ed13ef2a45e1b7f9e6de58ef63098.tar.gz
duh
Diffstat (limited to 'TAO/IIOP/test')
-rw-r--r--TAO/IIOP/test/clnt.cpp376
-rw-r--r--TAO/IIOP/test/cubitS.cpp24
-rw-r--r--TAO/IIOP/test/method_db.i2
-rw-r--r--TAO/IIOP/test/svr.cpp21
4 files changed, 233 insertions, 190 deletions
diff --git a/TAO/IIOP/test/clnt.cpp b/TAO/IIOP/test/clnt.cpp
index 7a4211d4521..367d463de66 100644
--- a/TAO/IIOP/test/clnt.cpp
+++ b/TAO/IIOP/test/clnt.cpp
@@ -47,10 +47,8 @@ static void cube_union_dii(unsigned &, unsigned &,
CORBA_Object_ptr, CORBA_Environment &);
// Global variables
-CORBA_ORB_ptr orb_ptr;
+const char* TAO_arg_ior = 0;
unsigned loop_count = 1;
-CORBA_Object_ptr objref = CORBA_Object::_nil();
-CORBA_Environment env;
int exit_later = 0;
// = TITLE
@@ -76,12 +74,7 @@ int parse_args(int argc, char *argv[])
case 'O': // stringified objref
{
- objref = orb_ptr->string_to_object (
- (CORBA_String)opts.optarg, env);
- if (env.exception () != 0) {
- print_exception (env.exception (), "string2object");
- return 1;
- }
+ TAO_arg_ior = ACE_OS::strdup(opts.optarg);
}
continue;
@@ -106,258 +99,289 @@ int parse_args(int argc, char *argv[])
int
main (int argc, char *argv[])
- {
+{
+ CORBA_ORB_ptr orb_ptr;
+ CORBA_Object_ptr objref = CORBA_Object::_nil();
+ CORBA_Environment env;
#if defined (VXWORKS)
- // Work around VxWorks' lack of command line
+ // Work around VxWorks' lack of command line
- loop_count = 50;
- int dummy = 1;
- orb_ptr = CORBA_ORB_init (dummy, (char **)0, "internet", env);
- if (env.exception() != 0)
+ loop_count = 50;
+ int dummy = 1;
+ orb_ptr = CORBA_ORB_init (dummy, (char **)0, "internet", env);
+ if (env.exception() != 0)
{
- print_exception(env.exception(), "ORB initialization");
- return 1;
+ print_exception(env.exception(), "ORB initialization");
+ return 1;
}
- hostAdd( "mv2604d", "130.38.183.132" );
+ hostAdd( "mv2604d", "130.38.183.132" );
+
+ TAO_arg_ior = ACE_OS::strdup("iiop:1.0//mv2604d:1000/key0");
- objref = orb_ptr->string_to_object (
- (CORBA_String)"iiop:1.0//mv2604d:1000/key0", env);
#else
- orb_ptr = CORBA_ORB_init(argc, argv, "internet", env);
- if (env.exception() != 0)
+ orb_ptr = CORBA_ORB_init(argc, argv, "internet", env);
+ if (env.exception() != 0)
{
- print_exception(env.exception(), "ORB initialization");
- return 1;
+ print_exception(env.exception(), "ORB initialization");
+ return 1;
}
- //
- // Parse command line and verify parameters.
- //
- parse_args(argc, argv);
+ //
+ // Parse command line and verify parameters.
+ //
+ parse_args(argc, argv);
#endif
- if (CORBA_is_nil (objref) == CORBA_B_TRUE) {
- ACE_OS::fprintf (stderr, "%s: must identify non-null target objref\n",
- argv [0]);
- return 1;
+ if (TAO_arg_ior == 0)
+ ACE_ERROR_RETURN((LM_ERROR, "%s: must specify an object reference using -O <ior>\n", argv[0]), 1);
+
+ objref = orb_ptr->string_to_object ((CORBA_String)TAO_arg_ior, env);
+
+ ACE_OS::free(TAO_arg_ior);
+ TAO_arg_ior = 0;
+
+ if (env.exception () != 0)
+ {
+ print_exception (env.exception (), "string2object");
+ return 1;
}
- // Narrow the CORBA_Object reference to the stub object, checking
- // the type along the way using _is_a
- Cubit_ptr aCubit = Cubit::_narrow(objref);
+ if (CORBA_is_nil (objref) == CORBA_B_TRUE)
+ ACE_ERROR_RETURN((LM_ERROR, "%s: must identify non-null target objref\n", argv [0]), 1);
- //
- // Make the calls in a loop.
- //
- unsigned i;
- unsigned call_count, error_count;
+ // Narrow the CORBA_Object reference to the stub object, checking
+ // the type along the way using _is_a
+ Cubit_ptr aCubit = Cubit::_narrow(objref);
+ if (aCubit == 0)
+ ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to narrow object reference to a Cubit_ptr.\n"), 1);
- call_count = 0;
- error_count = 0;
+ //
+ // Make the calls in a loop.
+ //
+ unsigned i;
+ unsigned call_count, error_count;
- ACE_Time_Value before, after;
+ call_count = 0;
+ error_count = 0;
- before = ACE_OS::gettimeofday();
+ ACE_Time_Value before, after;
- for (i = 0; i < loop_count; i++) {
- //
- // Cube an octet.
- //
- CORBA_Octet arg_octet, ret_octet;
+ before = ACE_OS::gettimeofday();
+
+ for (i = 0; i < loop_count; i++)
+ {
+ //
+ // Cube an octet.
+ //
+ CORBA_Octet arg_octet, ret_octet;
- call_count++;
- ret_octet = aCubit->Cubit_cube_octet (arg_octet = func (i), env);
- if (env.exception () != 0) {
+ call_count++;
+ ret_octet = aCubit->Cubit_cube_octet (arg_octet = func (i), env);
+ if (env.exception () != 0)
+ {
print_exception (env.exception (), "from cube_octet");
error_count++;
- } else {
+ }
+ else
+ {
dmsg2 ("cube octet: %d --> %d\n", arg_octet, ret_octet);
arg_octet = arg_octet * arg_octet * arg_octet;
if (arg_octet != ret_octet) {
- ACE_OS::printf ("** cube_octet(%d) ERROR (--> %d)\n",
- (CORBA_Octet) func (i), ret_octet);
- error_count++;
+ ACE_OS::printf ("** cube_octet(%d) ERROR (--> %d)\n",
+ (CORBA_Octet) func (i), ret_octet);
+ error_count++;
}
- }
+ }
- //
- // Cube a short.
- //
- CORBA_Short arg_short, ret_short;
+ //
+ // Cube a short.
+ //
+ CORBA_Short arg_short, ret_short;
- call_count++;
- ret_short = aCubit->Cubit_cube_short (arg_short = func (i), env);
- if (env.exception () != 0) {
+ call_count++;
+ ret_short = aCubit->Cubit_cube_short (arg_short = func (i), env);
+ if (env.exception () != 0)
+ {
print_exception (env.exception (), "from cube_short");
error_count++;
- } else {
+ }
+ else
+ {
dmsg2 ("cube short: %d --> %d\n", arg_short, ret_short);
arg_short = arg_short * arg_short * arg_short;
- if (arg_short != ret_short) {
- ACE_OS::printf ("** cube_short(%d) ERROR (--> %d)\n",
- (CORBA_Short) func (i), ret_short);
- error_count++;
- }
- }
+ if (arg_short != ret_short)
+ {
+ ACE_OS::printf ("** cube_short(%d) ERROR (--> %d)\n",
+ (CORBA_Short) func (i), ret_short);
+ error_count++;
+ }
+ }
- //
- // Cube a long.
- //
- CORBA_Long arg_long, ret_long;
+ //
+ // Cube a long.
+ //
+ CORBA_Long arg_long, ret_long;
- call_count++;
- ret_long = aCubit->Cubit_cube_long (arg_long = func (i), env);
- if (env.exception () != 0) {
+ call_count++;
+ ret_long = aCubit->Cubit_cube_long (arg_long = func (i), env);
+ if (env.exception () != 0)
+ {
print_exception (env.exception (), "from cube_long");
error_count++;
- } else {
+ }
+ else
+ {
dmsg2 ("cube long: %d --> %d\n", arg_long, ret_long);
arg_long = arg_long * arg_long * arg_long;
if (arg_long != ret_long) {
- ACE_OS::printf ("** cube_long(%ld) ERROR (--> %ld)\n",
- (CORBA_Long) func (i), ret_long);
- error_count++;
+ ACE_OS::printf ("** cube_long(%ld) ERROR (--> %ld)\n",
+ (CORBA_Long) func (i), ret_long);
+ error_count++;
}
- }
+ }
- //
- // Cube a "struct" ...
- //
- Cubit_Many arg_struct, *ret_struct;
+ //
+ // Cube a "struct" ...
+ //
+ Cubit_Many arg_struct, *ret_struct;
- call_count++;
+ call_count++;
- arg_struct.l = func (i);
- arg_struct.s = func (i);
- arg_struct.o = func (i);
+ arg_struct.l = func (i);
+ arg_struct.s = func (i);
+ arg_struct.o = func (i);
- ret_struct = aCubit->Cubit_cube_struct (arg_struct, env);
- if (env.exception () != 0) {
+ ret_struct = aCubit->Cubit_cube_struct (arg_struct, env);
+ if (env.exception () != 0)
+ {
print_exception (env.exception (), "from cube_struct");
error_count++;
- } else {
+ }
+ else
+ {
dmsg ("cube struct ...");
arg_struct.l = arg_struct.l * arg_struct.l * arg_struct.l;
arg_struct.s = arg_struct.s * arg_struct.s * arg_struct.s;
arg_struct.o = arg_struct.o * arg_struct.o * arg_struct.o;
if (arg_struct.l != ret_struct->l
- || arg_struct.s != ret_struct->s
- || arg_struct.o != ret_struct->o) {
- ACE_OS::printf ("** cube_struct ERROR\n");
- error_count++;
- }
+ || arg_struct.s != ret_struct->s
+ || arg_struct.o != ret_struct->o)
+ {
+ ACE_OS::printf ("** cube_struct ERROR\n");
+ error_count++;
+ }
delete ret_struct;
- }
+ }
}
- after = ACE_OS::gettimeofday();
+ after = ACE_OS::gettimeofday();
- if (call_count > 0)
+ if (call_count > 0)
{
- if (error_count == 0)
- {
+ if (error_count == 0)
+ {
ACE_Time_Value diff = after - before;
unsigned long us = diff.sec() * 1000 * 1000 + diff.usec();
us /= call_count;
if (us > 0)
- ACE_OS::printf ("cube average call ACE_OS::time\t= %ld.%.03ldms, \t"
- "%ld calls/second\n",
- us / 1000, us % 1000,
- 1000000L / us);
- }
+ ACE_OS::printf ("cube average call ACE_OS::time\t= %ld.%.03ldms, \t"
+ "%ld calls/second\n",
+ us / 1000, us % 1000,
+ 1000000L / us);
+ }
- ACE_OS::printf ("%d calls, %d errors\n", call_count, error_count);
+ ACE_OS::printf ("%d calls, %d errors\n", call_count, error_count);
}
+ //
+ // Simple test for DII: call "cube_struct". (It's not timed
+ // since the copious mallocation of DII would bias numbers against
+ // typical stub-based calls.)
+ //
+ do {
//
- // Simple test for DII: call "cube_struct". (It's not timed
- // since the copious mallocation of DII would bias numbers against
- // typical stub-based calls.)
+ // Create the request ...
//
- do {
- //
- // Create the request ...
- //
- CORBA_Request_ptr req;
+ CORBA_Request_ptr req;
- req = objref->_request ((const CORBA_String) "cube_struct", env);
- if (env.exception () != 0) {
- print_exception (env.exception (), "DII request create");
- break;
- }
-
- //
- // ... initialise the argument list and result ...
- //
- Cubit_Many arg, *result;
+ req = objref->_request ((const CORBA_String) "cube_struct", env);
+ if (env.exception () != 0) {
+ print_exception (env.exception (), "DII request create");
+ break;
+ }
+
+ //
+ // ... initialise the argument list and result ...
+ //
+ Cubit_Many arg, *result;
- arg.o = 3; arg.l = 5; arg.s = -7;
+ arg.o = 3; arg.l = 5; arg.s = -7;
- CORBA_Any tmp_arg (TC_Cubit_Many, &arg, CORBA_B_FALSE);
+ CORBA_Any tmp_arg (TC_Cubit_Many, &arg, CORBA_B_FALSE);
- req->arguments ()->add_value (0, tmp_arg, CORBA_ARG_IN, env);
- if (env.exception () != 0) {
- print_exception (env.exception (), "DII request arg add");
- CORBA_release (req);
- break;
- }
+ req->arguments ()->add_value (0, tmp_arg, CORBA_ARG_IN, env);
+ if (env.exception () != 0) {
+ print_exception (env.exception (), "DII request arg add");
+ CORBA_release (req);
+ break;
+ }
- req->result ()->value ()
- ->replace (TC_Cubit_Many, 0, CORBA_B_TRUE, env);
- if (env.exception () != 0) {
- print_exception (env.exception (), "DII request result type");
- CORBA_release (req);
- break;
- }
-
- //
- // Make the invocation, verify the result
- //
- req->invoke ();
- if (req->env ()->exception () != 0) {
- print_exception (req->env ()->exception (), "DII invoke");
- CORBA_release (req);
- break;
- }
+ req->result ()->value ()
+ ->replace (TC_Cubit_Many, 0, CORBA_B_TRUE, env);
+ if (env.exception () != 0) {
+ print_exception (env.exception (), "DII request result type");
+ CORBA_release (req);
+ break;
+ }
+
+ //
+ // Make the invocation, verify the result
+ //
+ req->invoke ();
+ if (req->env ()->exception () != 0) {
+ print_exception (req->env ()->exception (), "DII invoke");
+ CORBA_release (req);
+ break;
+ }
- result = (Cubit_Many *) req->result ()->value ()->value ();
+ result = (Cubit_Many *) req->result ()->value ()->value ();
- if (result->o != 27 || result->l != 125 || result->s != -343)
- ACE_OS::fprintf (stderr, "DII cube_struct -- bad results\n");
- else
- dmsg ("DII cube_struct ... success!!");
+ if (result->o != 27 || result->l != 125 || result->s != -343)
+ ACE_OS::fprintf (stderr, "DII cube_struct -- bad results\n");
+ else
+ dmsg ("DII cube_struct ... success!!");
- CORBA_release (req);
+ CORBA_release (req);
- } while (0);
-
- //
- // Two more tests, using the "cube_union" function
- //
- cube_union_dii(call_count, error_count, objref, env);
- if (env.exception () != 0)
- error_count++;
+ } while (0);
+
+ //
+ // Two more tests, using the "cube_union" function
+ //
+ cube_union_dii(call_count, error_count, objref, env);
+ if (env.exception () != 0)
+ error_count++;
- cube_union_stub(i, call_count, error_count, objref, env);
- if (env.exception () != 0)
- error_count++;
+ cube_union_stub(i, call_count, error_count, objref, env);
+ if (env.exception () != 0)
+ error_count++;
- if (exit_later) {
- aCubit->Cubit_please_exit (env);
- dexc (env, "server, please ACE_OS::exit");
- }
+ if (exit_later) {
+ aCubit->Cubit_please_exit (env);
+ dexc (env, "server, please ACE_OS::exit");
+ }
- CORBA_release (objref);
+ CORBA_release (objref);
- return (error_count == 0) ? 0 : 1;
+ return (error_count == 0) ? 0 : 1;
}
diff --git a/TAO/IIOP/test/cubitS.cpp b/TAO/IIOP/test/cubitS.cpp
index 8e3e9864be9..b153b71db1b 100644
--- a/TAO/IIOP/test/cubitS.cpp
+++ b/TAO/IIOP/test/cubitS.cpp
@@ -16,10 +16,16 @@
#include "method_db.i"
#include "iiopobj.h"
+#if defined(CUBIT_USE_DYNAMIC_HASH)
TAO_Dynamic_Hash_OpTable tao_cubit_optable(7); // Dynamic Operation Table
+#else
+TAO_Linear_OpTable tao_cubit_optable(7);
+#endif
_skel_Cubit::_skel_Cubit(const char* obj_name)
{
+ const char* mn = "_skel_Cubit::_skel_Cubit()";
+
// Initialize Method Database
initialize_method_db (&tao_cubit_optable);
@@ -28,6 +34,14 @@ _skel_Cubit::_skel_Cubit(const char* obj_name)
IIOP_Object *data;
CORBA_BOA_ptr oa = TAO_OA_PARAMS::instance()->oa();
+ if (oa == 0)
+ {
+ // We just have to assume that oa will be good, or we have to
+ // throw an exception. For now we "assume", but we'll
+ ACE_ERROR((LM_ERROR, "(%P|%t) %s Unable to locate a valid object adapter\n", mn));
+ return;
+ }
+
this->optable_ = &tao_cubit_optable;
data = new IIOP_Object(type_id);
@@ -41,14 +55,16 @@ _skel_Cubit::_skel_Cubit(const char* obj_name)
ACE_OS::memcpy (data->profile.object_key.buffer,
obj_name,
- data->profile.object_key.length);
+ data->profile.object_key.length+1);
this->set_parent(data);
this->sub_ = this;
- if (oa)
- oa->bind(data->profile.object_key, this);
-
+ if (oa->bind(data->profile.object_key, this) == -1)
+ {
+ ACE_ERROR((LM_ERROR, "(%P|%t) %s Unable to bind object to key '%s': %p\n", mn, data->profile.object_key.buffer));
+ return;
+ }
}
void
diff --git a/TAO/IIOP/test/method_db.i b/TAO/IIOP/test/method_db.i
index b567d09b7af..6b77cdf040a 100644
--- a/TAO/IIOP/test/method_db.i
+++ b/TAO/IIOP/test/method_db.i
@@ -58,7 +58,7 @@ static const method_db cubit_operations[] = {
};
-void initialize_method_db (TAO_Dynamic_Hash_OpTable *the_optable)
+void initialize_method_db (TAO_Operation_Table *the_optable)
{
for (int ndx = 0; ndx < 7; ndx++)
the_optable->bind(cubit_operations[ndx].opname,
diff --git a/TAO/IIOP/test/svr.cpp b/TAO/IIOP/test/svr.cpp
index 4afe2c62cd8..e4659d52c92 100644
--- a/TAO/IIOP/test/svr.cpp
+++ b/TAO/IIOP/test/svr.cpp
@@ -10,12 +10,14 @@
// Modified version of Cubit Example written by Sun Microsystems Inc.
// Modified by: Brian Mendel
-#include "cubit_i.h"
-#include <ace/Get_Opt.h>
+#include "ace/Get_Opt.h"
+#include "ace/Log_Msg.h"
#include "corba/orb.h"
-#include <corba/debug.h>
-#include <connect.h>
+#include "corba/debug.h"
+#include "connect.h"
+
+#include "cubit_i.h"
extern void
print_exception (const CORBA_Exception *, const char *, FILE *f=stdout);
@@ -27,7 +29,7 @@ int
main (int argc, char *argv[])
{
CORBA_Environment env;
- CORBA_Object_ptr obj;
+ CORBA_Object_ptr obj = 0;
CORBA_ORB_ptr orb_ptr;
CORBA_BOA_ptr oa_ptr;
CORBA_String key = (CORBA_String) "key0";
@@ -55,6 +57,9 @@ main (int argc, char *argv[])
// Initialize the Basic Object Adapter
oa_ptr = orb_ptr->BOA_init(argc, argv, "ROA");
+ if (oa_ptr == 0)
+ ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to initialize the BOA.\n"), 1);
+
// Create implementation object with user specified key
Cubit_i_ptr my_cubit = new Cubit_i(key);
@@ -63,14 +68,12 @@ main (int argc, char *argv[])
{
// Why are we getting the BOA_ptr from here when we've already
// got it above?
- CORBA_BOA_ptr oa = TAO_OA_PARAMS::instance()->oa();
CORBA_OctetSeq obj_key;
obj_key.buffer = (CORBA_Octet *) key;
obj_key.length = obj_key.maximum = ACE_OS::strlen ((char *)key);
- if (oa)
- (void) oa->find(obj_key, obj);
-
+ if (oa_ptr->find(obj_key, obj) == -1)
+ ACE_ERROR_RETURN((LM_ERROR, "(%P|%t) Unable to locate object with key '%s', %p\n", key), 2);
//
// Stringify the objref we'll be implementing, and