diff options
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/tests/Param_Test/Makefile | 1 | ||||
-rw-r--r-- | TAO/tests/Param_Test/README | 1 | ||||
-rw-r--r-- | TAO/tests/Param_Test/driver.cpp | 17 | ||||
-rw-r--r-- | TAO/tests/Param_Test/objref_struct.cpp | 206 | ||||
-rw-r--r-- | TAO/tests/Param_Test/objref_struct.h | 82 | ||||
-rw-r--r-- | TAO/tests/Param_Test/options.cpp | 2 | ||||
-rw-r--r-- | TAO/tests/Param_Test/options.h | 1 | ||||
-rw-r--r-- | TAO/tests/Param_Test/param_test.idl | 10 | ||||
-rw-r--r-- | TAO/tests/Param_Test/param_test_i.cpp | 71 | ||||
-rw-r--r-- | TAO/tests/Param_Test/param_test_i.h | 6 | ||||
-rwxr-xr-x | TAO/tests/Param_Test/run_test.pl | 2 | ||||
-rw-r--r-- | TAO/tests/Param_Test/tests.h | 1 | ||||
-rw-r--r-- | TAO/tests/Param_Test/ub_objref_seq.cpp | 90 |
13 files changed, 455 insertions, 35 deletions
diff --git a/TAO/tests/Param_Test/Makefile b/TAO/tests/Param_Test/Makefile index 3da306e253b..a45a5317af4 100644 --- a/TAO/tests/Param_Test/Makefile +++ b/TAO/tests/Param_Test/Makefile @@ -44,6 +44,7 @@ CLI_FILES = param_testC \ fixed_array \ fixed_struct \ nested_struct \ + objref_struct \ objref \ short \ longlong \ diff --git a/TAO/tests/Param_Test/README b/TAO/tests/Param_Test/README index ad054e2cfef..acc3fb83095 100644 --- a/TAO/tests/Param_Test/README +++ b/TAO/tests/Param_Test/README @@ -59,6 +59,7 @@ To run the client, type bd_strseq for bounded sequences of strings var_struct for variable structs nested_struct for nested structs + objref_struct for object references inside structures ub_struct_seq for sequences of structs bd_struct_seq for bounded sequences of structs any for Any diff --git a/TAO/tests/Param_Test/driver.cpp b/TAO/tests/Param_Test/driver.cpp index ef179b7212b..271a9aff8a0 100644 --- a/TAO/tests/Param_Test/driver.cpp +++ b/TAO/tests/Param_Test/driver.cpp @@ -238,6 +238,21 @@ Driver::run (void) delete client; } break; + + case Options::TEST_OBJREF_STRUCT: + { + Param_Test_Client<Test_Objref_Struct> *client = new + Param_Test_Client<Test_Objref_Struct> (this->orb_.in (), + this->objref_.in(), + new Test_Objref_Struct); + if (opt->invoke_type () == Options::SII) + retstatus = client->run_sii_test (); + else + retstatus = client->run_dii_test (); + delete client; + } + break; + case Options::TEST_UB_STRUCT_SEQUENCE: { Param_Test_Client<Test_Struct_Sequence> *client = new @@ -439,6 +454,7 @@ template class Param_Test_Client<Test_String_Sequence>; template class Param_Test_Client<Test_Bounded_String_Sequence>; template class Param_Test_Client<Test_Var_Struct>; template class Param_Test_Client<Test_Nested_Struct>; +template class Param_Test_Client<Test_Objref_Struct>; template class Param_Test_Client<Test_Struct_Sequence>; template class Param_Test_Client<Test_Bounded_Struct_Sequence>; template class Param_Test_Client<Test_ObjRef>; @@ -463,6 +479,7 @@ template class Param_Test_Client<Test_Var_Array>; #pragma instantiate Param_Test_Client<Test_Bounded_String_Sequence> #pragma instantiate Param_Test_Client<Test_Var_Struct> #pragma instantiate Param_Test_Client<Test_Nested_Struct> +#pragma instantiate Param_Test_Client<Test_Objref_Struct> #pragma instantiate Param_Test_Client<Test_Struct_Sequence> #pragma instantiate Param_Test_Client<Test_Bounded_Struct_Sequence> #pragma instantiate Param_Test_Client<Test_ObjRef> diff --git a/TAO/tests/Param_Test/objref_struct.cpp b/TAO/tests/Param_Test/objref_struct.cpp new file mode 100644 index 00000000000..22e8a1260ec --- /dev/null +++ b/TAO/tests/Param_Test/objref_struct.cpp @@ -0,0 +1,206 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// objref_struct.cpp +// +// = DESCRIPTION +// test structures containing object references. +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#include "helper.h" +#include "objref_struct.h" + +ACE_RCSID(Param_Test, objref_struct, "$Id$") + +// ************************************************************************ +// Test_Objref_Struct +// ************************************************************************ + +Test_Objref_Struct::Test_Objref_Struct (void) + : opname_ (CORBA::string_dup ("test_objref_struct")), + inout_ (new Param_Test::Objref_Struct), + out_ (new Param_Test::Objref_Struct), + ret_ (new Param_Test::Objref_Struct) +{ +} + +Test_Objref_Struct::~Test_Objref_Struct (void) +{ + CORBA::string_free (this->opname_); + this->opname_ = 0; + // the other data members will be freed as they are "_var"s and objects + // (rather than pointers to objects) +} + +const char * +Test_Objref_Struct::opname (void) const +{ + return this->opname_; +} + +int +Test_Objref_Struct::init_parameters (Param_Test_ptr objref, + CORBA::Environment &env) +{ + Generator *gen = GENERATOR::instance (); // value generator + + // set the length of the sequence + this->in_.x = gen->gen_long (); + this->in_.y = objref->make_coffee (env); + if (env.exception () != 0) return -1; + Coffee::Desc d; + d.name = gen->gen_string (); + this->in_.y->description (d, env); + if (env.exception () != 0) return -1; + + return 0; +} + +int +Test_Objref_Struct::reset_parameters (void) +{ + this->inout_ = new Param_Test::Objref_Struct; // delete the previous ones + this->out_ = new Param_Test::Objref_Struct; + this->ret_ = new Param_Test::Objref_Struct; + return 0; +} + +int +Test_Objref_Struct::run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env) +{ + Param_Test::Objref_Struct_out out (this->out_.out ()); + this->ret_ = objref->test_objref_struct (this->in_, + this->inout_.inout (), + out, + env); + return (env.exception () ? -1:0); +} + +int +Test_Objref_Struct::add_args (CORBA::NVList_ptr param_list, + CORBA::NVList_ptr retval, + CORBA::Environment &env) +{ + CORBA::Any in_arg (Param_Test::_tc_Objref_Struct, + &this->in_, + CORBA::B_FALSE); + + CORBA::Any inout_arg (Param_Test::_tc_Objref_Struct, + &this->inout_.inout (), // .out () causes crash + CORBA::B_FALSE); + + CORBA::Any out_arg (Param_Test::_tc_Objref_Struct, + &this->out_.inout (), + CORBA::B_FALSE); + + // add parameters + param_list->add_value ("s1", + in_arg, + CORBA::ARG_IN, + env); + + param_list->add_value ("s2", + inout_arg, + CORBA::ARG_INOUT, + env); + + param_list->add_value ("s3", + out_arg, + CORBA::ARG_OUT, + env); + + // add return value + retval->item (0, env)->value ()->replace (Param_Test::_tc_Objref_Struct, + &this->ret_.inout (), // see above + CORBA::B_FALSE, // does not own + env); + return 0; +} + + +CORBA::Boolean +Test_Objref_Struct::check_validity (void) +{ + if (this->in_.x != this->inout_->x + || this->in_.x != this->out_->x + || this->in_.x != this->ret_->x) + return CORBA::B_FALSE; + + CORBA::Environment env; + if (CORBA::is_nil (this->in_.y.in ()) + || CORBA::is_nil (this->out_->y.in ()) + || CORBA::is_nil (this->ret_->y.in ()) + || CORBA::is_nil (this->inout_->y.in ()) ) + return CORBA::B_FALSE; + + Coffee::Desc_var s_in = this->in_.y->description (env); + if (env.exception () != 0) return CORBA::B_FALSE; + Coffee::Desc_var s_out = this->out_->y->description (env); + if (env.exception () != 0) return CORBA::B_FALSE; + Coffee::Desc_var s_inout = this->inout_->y->description (env); + if (env.exception () != 0) return CORBA::B_FALSE; + Coffee::Desc_var s_ret = this->ret_->y->description (env); + if (env.exception () != 0) return CORBA::B_FALSE; + + if (ACE_OS::strcmp (s_in->name, s_out->name) != 0 + || ACE_OS::strcmp (s_in->name, s_inout->name) != 0 + || ACE_OS::strcmp (s_in->name, s_ret->name) != 0 ) + return CORBA::B_FALSE; + + return CORBA::B_TRUE; +} + +CORBA::Boolean +Test_Objref_Struct::check_validity (CORBA::Request_ptr req) +{ + ACE_UNUSED_ARG (req); + return this->check_validity (); +} + +void +Test_Objref_Struct::print_values (void) +{ + ACE_DEBUG ((LM_DEBUG, + "\n*=*=*=*=*=*=*=*=*=*=\n" + "in_.x = %d\n" + "inout_.x = %d\n" + "out_.x = %d\n" + "ret_.x = %d\n", + this->in_.x, + this->inout_->x, + this->out_->x, + this->ret_->x )); + + CORBA::Environment env; + + Coffee::Desc_var s_in = this->in_.y->description (env); + if (env.exception () != 0) return; + Coffee::Desc_var s_out = this->out_->y->description (env); + if (env.exception () != 0) return; + Coffee::Desc_var s_inout = this->inout_->y->description (env); + if (env.exception () != 0) return; + Coffee::Desc_var s_ret = this->ret_->y->description (env); + if (env.exception () != 0) return; + + ACE_DEBUG ((LM_DEBUG, + "\n*=*=*=*=*=*=*=*=*=*=\n" + "in_ name = %s\n" + "inout_ name = %s\n" + "out_ name = %s\n" + "ret_ name = %s\n", + s_in->name.in (), + s_inout->name.in (), + s_out->name.in (), + s_ret->name.in () )); +} + diff --git a/TAO/tests/Param_Test/objref_struct.h b/TAO/tests/Param_Test/objref_struct.h new file mode 100644 index 00000000000..4de7a72d9a8 --- /dev/null +++ b/TAO/tests/Param_Test/objref_struct.h @@ -0,0 +1,82 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// objref_struct.h +// +// = DESCRIPTION +// Tests variable sized structures +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#if !defined (PARAM_TEST_OBJREF_STRUCT_H) +#define PARAM_TEST_OBJREF_STRUCT_H + +#include "param_testC.h" + +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// test variable sized structs +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +class Test_Objref_Struct +{ +public: + Test_Objref_Struct (void); + // ctor + + ~Test_Objref_Struct (void); + // dtor + + int run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env); + // run the SII test + + int add_args (CORBA::NVList_ptr nvlist, + CORBA::NVList_ptr retval, + CORBA::Environment &env); + // add args to NVList for DII + const char *opname (void) const; + // return operation name + + int init_parameters (Param_Test_ptr objref, + CORBA::Environment &env); + // set values for parameters + + int reset_parameters (void); + // reset values for CORBA + + CORBA::Boolean check_validity (void); + // check if results are valid + + CORBA::Boolean check_validity (CORBA::Request_ptr req); + // check if results are valid. This is used for DII results + + void print_values (void); + // print all the values + +private: + char *opname_; + // operation name + + Param_Test::Objref_Struct in_; + // in parameter + + // these need memory management + Param_Test::Objref_Struct_var inout_; + // inout parameter + + Param_Test::Objref_Struct_var out_; + // out parameter + + Param_Test::Objref_Struct_var ret_; + // return value +}; + +#endif /* PARAM_TEST_OBJREF_STRUCT_H */ diff --git a/TAO/tests/Param_Test/options.cpp b/TAO/tests/Param_Test/options.cpp index b8086ee7835..59c1176e3bd 100644 --- a/TAO/tests/Param_Test/options.cpp +++ b/TAO/tests/Param_Test/options.cpp @@ -104,6 +104,8 @@ Options::parse_args (int argc, char **argv) this->test_type_ = Options::TEST_VAR_STRUCT; else if (!ACE_OS::strcmp (get_opts.optarg, "nested_struct")) this->test_type_ = Options::TEST_NESTED_STRUCT; + else if (!ACE_OS::strcmp (get_opts.optarg, "objref_struct")) + this->test_type_ = Options::TEST_OBJREF_STRUCT; else if (!ACE_OS::strcmp (get_opts.optarg, "ub_struct_seq")) this->test_type_ = Options::TEST_UB_STRUCT_SEQUENCE; else if (!ACE_OS::strcmp (get_opts.optarg, "bd_struct_seq")) diff --git a/TAO/tests/Param_Test/options.h b/TAO/tests/Param_Test/options.h index 9e55764a057..22c0cebe754 100644 --- a/TAO/tests/Param_Test/options.h +++ b/TAO/tests/Param_Test/options.h @@ -38,6 +38,7 @@ public: TEST_BD_STRING_SEQUENCE, TEST_VAR_STRUCT, TEST_NESTED_STRUCT, + TEST_OBJREF_STRUCT, TEST_UB_STRUCT_SEQUENCE, TEST_BD_STRUCT_SEQUENCE, TEST_OBJREF, diff --git a/TAO/tests/Param_Test/param_test.idl b/TAO/tests/Param_Test/param_test.idl index 0a5caef70ab..813d32987c1 100644 --- a/TAO/tests/Param_Test/param_test.idl +++ b/TAO/tests/Param_Test/param_test.idl @@ -169,6 +169,16 @@ interface Param_Test // Anys. We try to pump in all kinds of data types thru these Anys any test_any (in any a1, inout any a2, out any a3); + struct Objref_Struct + { + long x; + Coffee y; + }; + Objref_Struct test_objref_struct (in Objref_Struct t1, + inout Objref_Struct t2, + out Objref_Struct t3); + // test structures that contain object references. + // arrays (fixed) const unsigned long DIM1 = 10; typedef long Fixed_Array [DIM1]; diff --git a/TAO/tests/Param_Test/param_test_i.cpp b/TAO/tests/Param_Test/param_test_i.cpp index 7af75d84b8d..5e395a41055 100644 --- a/TAO/tests/Param_Test/param_test_i.cpp +++ b/TAO/tests/Param_Test/param_test_i.cpp @@ -318,6 +318,31 @@ Param_Test::Coffee_Mix * Param_Test_i::test_coffe_mix ( *ret = new Param_Test::Coffee_Mix, *out = new Param_Test::Coffee_Mix; +#if 0 + ACE_DEBUG ((LM_DEBUG, + "maximum = %d\n" + "length = %d\n", + s1.maximum (), + s1.length ())); + ACE_DEBUG ((LM_DEBUG, "Elements -\n")); + for (CORBA::ULong i = 0; i < s1.length (); ++i) + { + Coffee_ptr c = s1[i]; + if (CORBA::is_nil (c)) + { + ACE_DEBUG ((LM_DEBUG, + "Element #%d is nil\n", i)); + continue; + } + ACE_DEBUG ((LM_DEBUG, + "Element #%d\n" + "\ttype = <%s>\n", + i, + c->_interface_repository_id ())); + } +#endif /* 0 */ + + s2 = s1; *out = s1; *ret = s1; @@ -336,6 +361,31 @@ Param_Test::Bounded_Coffee_Mix * Param_Test_i::test_bounded_coffe_mix ( *ret = new Param_Test::Bounded_Coffee_Mix, *out = new Param_Test::Bounded_Coffee_Mix; +#if 0 + ACE_DEBUG ((LM_DEBUG, + "maximum = %d\n" + "length = %d\n", + s1.maximum (), + s1.length ())); + ACE_DEBUG ((LM_DEBUG, "Elements -\n")); + for (CORBA::ULong i = 0; i < s1.length (); ++i) + { + Coffee_ptr c = s1[i]; + if (CORBA::is_nil (c)) + { + ACE_DEBUG ((LM_DEBUG, + "Element #%d is nil\n", i)); + continue; + } + ACE_DEBUG ((LM_DEBUG, + "Element #%d\n" + "\ttype = <%s>\n", + i, + c->_interface_repository_id ())); + } +#endif /* 0 */ + + s2 = s1; *out = s1; *ret = s1; @@ -410,6 +460,27 @@ Param_Test_i::test_nested_struct (const Param_Test::Nested_Struct &s1, return ret; } +Param_Test::Objref_Struct * +Param_Test_i::test_objref_struct (const Param_Test::Objref_Struct &s1, + Param_Test::Objref_Struct &s2, + Param_Test::Objref_Struct_out s3, + CORBA::Environment &env) +{ + ACE_UNUSED_ARG (env); + // we copy the "in" sequences into all the inout, out and return sequences. + + Param_Test::Objref_Struct + *ret = new Param_Test::Objref_Struct, + *out = new Param_Test::Objref_Struct; + + // now copy all elements of s1 into the others + s2 = s1; + *out = s1; + *ret = s1; + s3 = out; + return ret; +} + // make a Coffee object Coffee_ptr Param_Test_i::make_coffee (CORBA::Environment &env) diff --git a/TAO/tests/Param_Test/param_test_i.h b/TAO/tests/Param_Test/param_test_i.h index 0f8b2889a80..1d59b9f14d9 100644 --- a/TAO/tests/Param_Test/param_test_i.h +++ b/TAO/tests/Param_Test/param_test_i.h @@ -172,6 +172,12 @@ public: CORBA::Environment &env); // test for nested structs + virtual Param_Test::Objref_Struct * + test_objref_struct (const Param_Test::Objref_Struct &s1, + Param_Test::Objref_Struct &s2, + Param_Test::Objref_Struct_out s3, + CORBA::Environment &env); + virtual Coffee_ptr make_coffee (CORBA::Environment &env); // make a coffee object diff --git a/TAO/tests/Param_Test/run_test.pl b/TAO/tests/Param_Test/run_test.pl index 55d6e2a5df9..bdf512df0db 100755 --- a/TAO/tests/Param_Test/run_test.pl +++ b/TAO/tests/Param_Test/run_test.pl @@ -94,7 +94,7 @@ for ($i = 0; $i <= $#ARGV; $i++) "ub_strseq", "bd_strseq", "var_struct", "nested_struct", "ub_struct_seq", "bd_struct_seq", - "any", "objref", "objref_sequence", + "any", "objref", "objref_sequence", "objref_struct", "any_sequence", "ub_short_sequence", "ub_long_sequence", "bd_short_sequence", "bd_long_sequence", diff --git a/TAO/tests/Param_Test/tests.h b/TAO/tests/Param_Test/tests.h index 7f95cc79cf8..1a5b97bad94 100644 --- a/TAO/tests/Param_Test/tests.h +++ b/TAO/tests/Param_Test/tests.h @@ -28,6 +28,7 @@ #include "fixed_array.h" #include "fixed_struct.h" #include "nested_struct.h" +#include "objref_struct.h" #include "objref.h" #include "short.h" #include "longlong.h" diff --git a/TAO/tests/Param_Test/ub_objref_seq.cpp b/TAO/tests/Param_Test/ub_objref_seq.cpp index e050bec0686..17498a363e2 100644 --- a/TAO/tests/Param_Test/ub_objref_seq.cpp +++ b/TAO/tests/Param_Test/ub_objref_seq.cpp @@ -64,7 +64,7 @@ Test_ObjRef_Sequence::init_parameters (Param_Test_ptr objref, Generator *gen = GENERATOR::instance (); // value generator // get some sequence length (not more than 10) - CORBA::ULong len = (CORBA::ULong) (gen->gen_long () % 10) + 1; + CORBA::ULong len = (CORBA::ULong) (gen->gen_long () % 5) + 5; // set the length of the sequence this->in_.length (len); @@ -79,18 +79,18 @@ Test_ObjRef_Sequence::init_parameters (Param_Test_ptr objref, env.print_exception ("make_coffee"); return -1; } - // select a Coffee flavor at random - CORBA::ULong index = (CORBA::ULong) (gen->gen_long () % 6); - desc.name = Coffee_Flavor [index]; - // set the attribute for the in object - Coffee_ptr tmp = this->in_[i]; - tmp->description (desc, env); - - if (env.exception ()) - { - env.print_exception ("set coffee attribute"); - return -1; - } + // select a Coffee flavor at random + CORBA::ULong index = (CORBA::ULong) (gen->gen_long () % 6); + desc.name = Coffee_Flavor [index]; + // set the attribute for the in object + Coffee_ptr tmp = this->in_[i]; + tmp->description (desc, env); + + if (env.exception ()) + { + env.print_exception ("set coffee attribute"); + return -1; + } } return 0; } @@ -109,6 +109,8 @@ Test_ObjRef_Sequence::run_sii_test (Param_Test_ptr objref, CORBA::Environment &env) { Param_Test::Coffee_Mix_out out (this->out_.out ()); + // ACE_DEBUG ((LM_DEBUG, "test_coffe_mix (IN):\n")); + // this->print_sequence (this->in_); this->ret_ = objref->test_coffe_mix (this->in_, this->inout_.inout (), out, @@ -162,6 +164,15 @@ Test_ObjRef_Sequence::check_validity (void) { TAO_TRY { + // ACE_DEBUG ((LM_DEBUG, "IN: \n")); + // this->print_sequence (this->in_); + + // ACE_DEBUG ((LM_DEBUG, "INOUT: \n")); + // this->print_sequence (this->inout_.in ()); + + // ACE_DEBUG ((LM_DEBUG, "OUT: \n")); + // this->print_sequence (this->out_.in ()); + if (this->compare (this->in_, this->inout_.in (), TAO_TRY_ENV)) @@ -239,23 +250,29 @@ Test_ObjRef_Sequence::compare (const Param_Test::Coffee_Mix &s1, for (CORBA::ULong i=0; i < s1.length (); i++) { - const Coffee_ptr vs1 = s1[i]; - const Coffee_ptr vs2 = s2[i]; + Coffee_ptr vs1 = s1[i]; + Coffee_ptr vs2 = s2[i]; + + if (CORBA::is_nil (vs1) && CORBA::is_nil (vs2)) + continue; - char* n1 = vs1->description (env)->name; + if (CORBA::is_nil (vs1) || CORBA::is_nil (vs2)) + return 0; + + CORBA::String_var n1 = vs1->description (env)->name; if (env.exception ()) - { - env.print_exception ("retrieving description for vs1"); - return 0; - } - char* n2 = vs2->description (env)->name; - if (env.exception ()) - { - env.print_exception ("retrieving description for vs2"); - return 0; - } - if (!ACE_OS::strcmp(n1, n2)) - return 0; + { + env.print_exception ("retrieving description for vs1"); + return 0; + } + CORBA::String_var n2 = vs2->description (env)->name; + if (env.exception ()) + { + env.print_exception ("retrieving description for vs2"); + return 0; + } + if (ACE_OS::strcmp(n1.in (), n2.in ()) != 0) + return 0; } return 1; // success @@ -272,12 +289,17 @@ Test_ObjRef_Sequence::print_sequence (const Param_Test::Coffee_Mix &s) ACE_DEBUG ((LM_DEBUG, "Elements -\n")); for (CORBA::ULong i=0; i < s.length (); i++) { - /* const Coffee_ptr vs = s[i]; - + Coffee_ptr c = s[i]; + if (CORBA::is_nil (c)) + { + ACE_DEBUG ((LM_DEBUG, + "Element #%d is nil\n", i)); + continue; + } ACE_DEBUG ((LM_DEBUG, - "Element #%d\n" - "\tdesc = %d\n" - i, - vs.description(env).name)); */ + "Element #%d\n" + "\ttype = <%s>\n", + i, + c->_interface_repository_id ())); } } |