diff options
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/ChangeLog-98c | 14 | ||||
-rw-r--r-- | TAO/tests/Param_Test/driver.cpp | 12 | ||||
-rw-r--r-- | TAO/tests/Param_Test/helper.cpp | 9 | ||||
-rw-r--r-- | TAO/tests/Param_Test/helper.h | 4 | ||||
-rw-r--r-- | TAO/tests/Param_Test/param_test.idl | 22 | ||||
-rw-r--r-- | TAO/tests/Param_Test/param_test_i.cpp | 33 | ||||
-rw-r--r-- | TAO/tests/Param_Test/param_test_i.h | 6 | ||||
-rw-r--r-- | TAO/tests/Param_Test/ub_struct_seq.cpp | 199 | ||||
-rw-r--r-- | TAO/tests/Param_Test/ub_struct_seq.h | 65 |
9 files changed, 362 insertions, 2 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index 010e235db2e..006dd25e25f 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,3 +1,17 @@ +Wed Oct 14 12:05:37 1998 Matthew J Braun <mjb2@cec.wustl.edu> + + * tests/Param_Test/ub_struct_seq.h + * tests/Param_Test/ub_struct_seq.cpp + * tests/Param_Test/param_test_i.h + * tests/Param_Test/param_test_i.cpp + * tests/Param_Test/param_test.idl + * tests/Param_Test/helper.h + * tests/Param_Test/helper.cpp + * tests/Param_Test/driver.cpp + Added test for unbounded sequence of structs. This is in + response to a bug report from Mr. Hoon. Thanks to Andy and + Carlos for help. + Wed Oct 14 11:20:26 1998 Douglas C. Schmidt <schmidt@cs.wustl.edu> * TAO version 0.2.25 released. diff --git a/TAO/tests/Param_Test/driver.cpp b/TAO/tests/Param_Test/driver.cpp index cb97e726d34..01b9c037a22 100644 --- a/TAO/tests/Param_Test/driver.cpp +++ b/TAO/tests/Param_Test/driver.cpp @@ -264,6 +264,18 @@ Driver::run (void) else retstatus = client->run_dii_test (); delete client; + + Param_Test_Client<Test_Unbounded_Struct_Sequence> *client2 = new + Param_Test_Client<Test_Unbounded_Struct_Sequence> + (this->orb_.in (), + this->objref_.in(), + new Test_Unbounded_Struct_Sequence); + + if (opt->invoke_type () == Options::SII) + retstatus = client2->run_sii_test (); + else + retstatus = client2->run_dii_test (); + delete client2; } break; case Options::TEST_BD_STRUCT_SEQUENCE: diff --git a/TAO/tests/Param_Test/helper.cpp b/TAO/tests/Param_Test/helper.cpp index ccacbc4cb8f..ef81f429734 100644 --- a/TAO/tests/Param_Test/helper.cpp +++ b/TAO/tests/Param_Test/helper.cpp @@ -82,6 +82,15 @@ Generator::gen_fixed_struct (void) return this->fixed_struct_; } +const Param_Test::Step +Generator::gen_step (void) +{ + this->step_.name.id = this->gen_string (); + this->step_.name.kind = this->gen_string (); + this->step_.process = (CORBA::Boolean) ACE_OS::rand () % 2; + return this->step_; +} + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Singleton<Generator, ACE_SYNCH_RECURSIVE_MUTEX>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) diff --git a/TAO/tests/Param_Test/helper.h b/TAO/tests/Param_Test/helper.h index 9882706cef4..e76394ba6e1 100644 --- a/TAO/tests/Param_Test/helper.h +++ b/TAO/tests/Param_Test/helper.h @@ -42,8 +42,10 @@ public: CORBA::String gen_string (void); CORBA::String gen_string (int maxlength); const Param_Test::Fixed_Struct gen_fixed_struct (void); -private: + const Param_Test::Step gen_step (void); + private: Param_Test::Fixed_Struct fixed_struct_; + Param_Test::Step step_; }; typedef ACE_Singleton<Generator, ACE_SYNCH_RECURSIVE_MUTEX> GENERATOR; diff --git a/TAO/tests/Param_Test/param_test.idl b/TAO/tests/Param_Test/param_test.idl index 1ab300aabb5..87662defed7 100644 --- a/TAO/tests/Param_Test/param_test.idl +++ b/TAO/tests/Param_Test/param_test.idl @@ -10,7 +10,7 @@ // // = DESCRIPTION // This IDL description is used to test all the parameter passing modes (in, -// inout, out, and return) for a number of IDL data types. The goal is to +// inout, out, a0nd return) for a number of IDL data types. The goal is to // verify the correctness of the generated stubs and skeletons, and the // the marshaling engine of TAO. // @@ -75,7 +75,27 @@ interface Param_Test // = Sequences of long, strings, Var_Struct and Object // references... + + + struct NameComponent + { + string id; + string kind; + }; + + struct Step + { + NameComponent name; + boolean process; + }; + + typedef sequence<Step> PathSpec; + + PathSpec test_unbounded_struct_sequence (in PathSpec s1, + inout PathSpec s2, + out PathSpec s3); typedef sequence<short> Short_Seq; + Short_Seq test_short_sequence (in Short_Seq s1, inout Short_Seq s2, out Short_Seq s3); diff --git a/TAO/tests/Param_Test/param_test_i.cpp b/TAO/tests/Param_Test/param_test_i.cpp index 227f4b68c52..012ee472c93 100644 --- a/TAO/tests/Param_Test/param_test_i.cpp +++ b/TAO/tests/Param_Test/param_test_i.cpp @@ -312,6 +312,39 @@ Param_Test::Bounded_StructSeq * Param_Test_i::test_bounded_struct_sequence ( return ret; } + +Param_Test::PathSpec * Param_Test_i::test_unbounded_struct_sequence ( + const Param_Test::PathSpec & s1, + Param_Test::PathSpec & s2, + Param_Test::PathSpec_out s3, + CORBA::Environment & + ) +{ + Param_Test::PathSpec + *ret = new Param_Test::PathSpec, + *out = new Param_Test::PathSpec; + + + PathSpec_var rPathSpec = new Param_Test::PathSpec; + rPathSpec->length(2); + + rPathSpec[(unsigned long)0].name.id = CORBA::string_dup("staff"); + rPathSpec[(unsigned long)0].name.kind = CORBA::string_dup("staff"); + rPathSpec[(unsigned long)0].process = TRUE; + + rPathSpec[(unsigned long)1].name.id = CORBA::string_dup("john"); + rPathSpec[(unsigned long)1].name.kind = CORBA::string_dup("john"); + rPathSpec[(unsigned long)1].process = TRUE; + + s2 = s1; + *out = s1; + *ret = s1; + s3 = out; + + return ret; +} + + Param_Test::Coffee_Mix * Param_Test_i::test_coffe_mix ( const Param_Test::Coffee_Mix & s1, Param_Test::Coffee_Mix & s2, diff --git a/TAO/tests/Param_Test/param_test_i.h b/TAO/tests/Param_Test/param_test_i.h index 57c8f77f789..806018ca5c7 100644 --- a/TAO/tests/Param_Test/param_test_i.h +++ b/TAO/tests/Param_Test/param_test_i.h @@ -132,6 +132,12 @@ public: Param_Test::StructSeq_out s3, CORBA::Environment &env ); + virtual Param_Test::PathSpec * test_unbounded_struct_sequence ( + const Param_Test::PathSpec & s1, + Param_Test::PathSpec & s2, + Param_Test::PathSpec_out s3, + CORBA::Environment &env + ); virtual Param_Test::Bounded_StructSeq * test_bounded_struct_sequence ( const Param_Test::Bounded_StructSeq & s1, Param_Test::Bounded_StructSeq & s2, diff --git a/TAO/tests/Param_Test/ub_struct_seq.cpp b/TAO/tests/Param_Test/ub_struct_seq.cpp index 58d860b19c0..fe495ee7eb0 100644 --- a/TAO/tests/Param_Test/ub_struct_seq.cpp +++ b/TAO/tests/Param_Test/ub_struct_seq.cpp @@ -228,3 +228,202 @@ Test_Struct_Sequence::print_sequence (const Param_Test::StructSeq &s) } } + +// ************************************************************************ +// Test_Unbounded_Struct_Sequence +// ************************************************************************ + +Test_Unbounded_Struct_Sequence::Test_Unbounded_Struct_Sequence (void) + : opname_ (CORBA::string_dup ("test_unbounded_struct_sequence")), + inout_ (new Param_Test::PathSpec), + out_ (new Param_Test::PathSpec), + ret_ (new Param_Test::PathSpec) +{ +} + +Test_Unbounded_Struct_Sequence::~Test_Unbounded_Struct_Sequence (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_Unbounded_Struct_Sequence::opname (void) const +{ + return this->opname_; +} + +int +Test_Unbounded_Struct_Sequence::init_parameters (Param_Test_ptr objref, + CORBA::Environment &env) +{ + Generator *gen = GENERATOR::instance (); // value generator + + ACE_UNUSED_ARG (objref); + ACE_UNUSED_ARG (env); + + // get some sequence length (not more than 10) + CORBA::ULong len = (CORBA::ULong) (gen->gen_long () % 10) + 1; + + // set the length of the sequence + this->in_.length (len); + this->inout_->length (len); + // now set each individual element + + for (CORBA::ULong i = 0; i < this->in_.length (); i++) + { + // generate some arbitrary string to be filled into the ith location in + // the sequence + this->in_[i] = gen->gen_step (); + this->inout_[i] = gen->gen_step (); + } + return 0; +} + +int +Test_Unbounded_Struct_Sequence::reset_parameters (void) +{ + this->inout_ = new Param_Test::PathSpec; // delete the previous one + this->out_ = new Param_Test::PathSpec; + this->ret_ = new Param_Test::PathSpec; + return 0; +} + +int +Test_Unbounded_Struct_Sequence::run_sii_test (Param_Test_ptr objref, + CORBA::Environment &env) +{ + Param_Test::PathSpec_out out (this->out_.out ()); + this->ret_ = objref->test_unbounded_struct_sequence (this->in_, + this->inout_.inout (), + out, + env); + return (env.exception () ? -1:0); +} + +int +Test_Unbounded_Struct_Sequence::add_args (CORBA::NVList_ptr param_list, + CORBA::NVList_ptr retval, + CORBA::Environment &env) +{ + CORBA::Any in_arg (Param_Test::_tc_PathSpec, + &this->in_, + 0); + + CORBA::Any inout_arg (Param_Test::_tc_PathSpec, + &this->inout_.inout (), + 0); + + CORBA::Any out_arg (Param_Test::_tc_PathSpec, + &this->out_.inout (), + 0); + + // 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 type + retval->item (0, env)->value ()->replace (Param_Test::_tc_PathSpec, + &this->ret_.inout (), + 0, + env); + return 0; +} + +CORBA::Boolean +Test_Unbounded_Struct_Sequence::check_validity (void) +{ + if (this->compare (this->in_, this->inout_.in ()) && + this->compare (this->in_, this->out_.in ()) && + this->compare (this->in_, this->ret_.in ())) + return 1; + else + return 0; +} + +CORBA::Boolean +Test_Unbounded_Struct_Sequence::check_validity (CORBA::Request_ptr req) +{ + ACE_UNUSED_ARG (req); + return this->check_validity (); +} + +void +Test_Unbounded_Struct_Sequence::print_values (void) +{ + ACE_DEBUG ((LM_DEBUG, + "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" + "IN sequence\n")); + this->print_sequence (this->in_); + ACE_DEBUG ((LM_DEBUG, + "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" + "INOUT sequence\n")); + this->print_sequence (this->inout_.in ()); + ACE_DEBUG ((LM_DEBUG, + "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" + "OUT sequence\n")); + this->print_sequence (this->out_.in ()); + ACE_DEBUG ((LM_DEBUG, + "*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n" + "RET sequence\n")); + this->print_sequence (this->ret_.in ()); +} + +CORBA::Boolean +Test_Unbounded_Struct_Sequence::compare (const Param_Test::PathSpec &s1, + const Param_Test::PathSpec &s2) +{ + if (s1.maximum () != s2.maximum ()) + return 0; + if (s1.length () != s2.length ()) + return 0; + + for (CORBA::ULong i=0; i < s1.length (); i++) + { + const Param_Test::Step& vs1 = s1[i]; + const Param_Test::Step& vs2 = s2[i]; + + if (ACE_OS::strcmp (vs1.name.id.in (), vs2.name.id.in ()) + || ACE_OS:: strcmp (vs1.name.kind.in (), vs2.name.kind.in ()) + || vs1.process != vs2.process) + return 0; + } + return 1; // success +} + +void +Test_Unbounded_Struct_Sequence::print_sequence (const Param_Test::PathSpec &s) +{ + ACE_DEBUG ((LM_DEBUG, + "maximum = %d\n" + "length = %d\n", + s.maximum (), + s.length ())); + ACE_DEBUG ((LM_DEBUG, "Elements -\n")); + for (CORBA::ULong i=0; i < s.length (); i++) + { + const Param_Test::Step& vs = s[i]; + + ACE_DEBUG ((LM_DEBUG, + "Element #%d\n" + "\tname.id = %s\n" + "\tname.kind = %s\n" + "\tprocess = %d\n", + i, + vs.name.id.in (), vs.name.kind.in (), vs.process)); + } +} diff --git a/TAO/tests/Param_Test/ub_struct_seq.h b/TAO/tests/Param_Test/ub_struct_seq.h index 03b8c696896..0baf2d16787 100644 --- a/TAO/tests/Param_Test/ub_struct_seq.h +++ b/TAO/tests/Param_Test/ub_struct_seq.h @@ -87,4 +87,69 @@ private: // return value }; + + +class Test_Unbounded_Struct_Sequence +{ +public: + Test_Unbounded_Struct_Sequence (void); + // ctor + + ~Test_Unbounded_Struct_Sequence (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 + +protected: + CORBA::Boolean compare (const Param_Test::PathSpec &s1, + const Param_Test::PathSpec &s2); + // compare + + void print_sequence (const Param_Test::PathSpec &s); + // print individual sequence +private: + char *opname_; + // operation name + + Param_Test::PathSpec in_; + // in parameter + + // these need memory management + Param_Test::PathSpec_var inout_; + // inout parameter + + Param_Test::PathSpec_var out_; + // out parameter + + Param_Test::PathSpec_var ret_; + // return value +}; + + #endif /* PARAM_TEST_UNBOUNED_STRUCT_SEQUENCE_H */ |