diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Alt_Mapping/alt_mapping.idl | 28 | ||||
-rw-r--r-- | tests/Alt_Mapping/alt_mapping.mpc | 2 | ||||
-rw-r--r-- | tests/Alt_Mapping/alt_mapping_i.cpp | 48 | ||||
-rw-r--r-- | tests/Alt_Mapping/alt_mapping_i.h | 10 | ||||
-rw-r--r-- | tests/Alt_Mapping/driver.cpp | 30 | ||||
-rw-r--r-- | tests/Alt_Mapping/nested_struct.cpp | 168 | ||||
-rw-r--r-- | tests/Alt_Mapping/nested_struct.h | 67 | ||||
-rw-r--r-- | tests/Alt_Mapping/options.cpp | 28 | ||||
-rw-r--r-- | tests/Alt_Mapping/options.h | 4 | ||||
-rwxr-xr-x | tests/Alt_Mapping/run_test.pl | 19 | ||||
-rw-r--r-- | tests/Alt_Mapping/tests.h | 2 | ||||
-rw-r--r-- | tests/Alt_Mapping/ub_long_seq.cpp | 2 | ||||
-rw-r--r-- | tests/Alt_Mapping/ub_octet_seq.cpp | 2 | ||||
-rw-r--r-- | tests/Alt_Mapping/ub_str_seq.cpp | 2 | ||||
-rw-r--r-- | tests/Alt_Mapping/ub_string.cpp | 4 | ||||
-rw-r--r-- | tests/Alt_Mapping/ub_struct_seq.cpp | 3 | ||||
-rw-r--r-- | tests/Alt_Mapping/var_struct.cpp | 248 | ||||
-rw-r--r-- | tests/Alt_Mapping/var_struct.h | 68 |
18 files changed, 696 insertions, 39 deletions
diff --git a/tests/Alt_Mapping/alt_mapping.idl b/tests/Alt_Mapping/alt_mapping.idl index 780007a0921..ed2dda70085 100644 --- a/tests/Alt_Mapping/alt_mapping.idl +++ b/tests/Alt_Mapping/alt_mapping.idl @@ -50,6 +50,34 @@ interface Alt_Mapping inout CORBA::OctetSeq s2, out CORBA::OctetSeq s3); + typedef string DUMMY; + + // Variable structure. + struct Var_Struct + { + double dbl; + DUMMY dummy1; + boolean boole; + DUMMY dummy2; + short shrt; + CORBA::StringSeq seq; + }; + + Var_Struct test_var_struct (in Var_Struct s1, + inout Var_Struct s2, + out Var_Struct s3); + + // Nested structs (We reuse the var_struct defn above to make a very + // complicated nested structure). + struct Nested_Struct + { + Var_Struct vs; + }; + + Nested_Struct test_nested_struct (in Nested_Struct s1, + inout Nested_Struct s2, + out Nested_Struct s3); + void shutdown (); // Shutdown the server: this is useful to check for memory leaks, // performance results and in general to verify that orderly diff --git a/tests/Alt_Mapping/alt_mapping.mpc b/tests/Alt_Mapping/alt_mapping.mpc index af71b0d4226..8451f327917 100644 --- a/tests/Alt_Mapping/alt_mapping.mpc +++ b/tests/Alt_Mapping/alt_mapping.mpc @@ -48,6 +48,7 @@ project(*Client): taoexe, codeset { client.cpp driver.cpp helper.cpp + nested_struct.cpp options.cpp results.cpp ub_octet_seq.cpp @@ -55,6 +56,7 @@ project(*Client): taoexe, codeset { ub_string.cpp ub_struct_seq.cpp ub_str_seq.cpp + var_struct.cpp } Header_Files { diff --git a/tests/Alt_Mapping/alt_mapping_i.cpp b/tests/Alt_Mapping/alt_mapping_i.cpp index 62bccdb9d4c..0d14e960a4c 100644 --- a/tests/Alt_Mapping/alt_mapping_i.cpp +++ b/tests/Alt_Mapping/alt_mapping_i.cpp @@ -64,9 +64,10 @@ Alt_Mapping_i::test_strseq ( } CORBA::LongSeq -Alt_Mapping_i::test_long_sequence (const CORBA::LongSeq & s1, - CORBA::LongSeq & s2, - CORBA::LongSeq & s3) +Alt_Mapping_i::test_long_sequence ( + const CORBA::LongSeq & s1, + CORBA::LongSeq & s2, + CORBA::LongSeq & s3) { s2 = s1; s3 = s1; @@ -76,9 +77,10 @@ Alt_Mapping_i::test_long_sequence (const CORBA::LongSeq & s1, } CORBA::OctetSeq -Alt_Mapping_i::test_octet_sequence (const CORBA::OctetSeq & s1, - CORBA::OctetSeq & s2, - CORBA::OctetSeq & s3) +Alt_Mapping_i::test_octet_sequence ( + const CORBA::OctetSeq & s1, + CORBA::OctetSeq & s2, + CORBA::OctetSeq & s3) { s2 = s1; s3 = s1; @@ -87,6 +89,40 @@ Alt_Mapping_i::test_octet_sequence (const CORBA::OctetSeq & s1, return ret; } +Alt_Mapping::Var_Struct * +Alt_Mapping_i::test_var_struct ( + const Alt_Mapping::Var_Struct & s1, + Alt_Mapping::Var_Struct & s2, + Alt_Mapping::Var_Struct_out s3) +{ + Alt_Mapping::Var_Struct + *ret = new Alt_Mapping::Var_Struct, + *out = new Alt_Mapping::Var_Struct; + + s2 = s1; + *out = s1; + *ret = s1; + s3 = out; + return ret; +} + +Alt_Mapping::Nested_Struct * +Alt_Mapping_i::test_nested_struct ( + const Alt_Mapping::Nested_Struct & s1, + Alt_Mapping::Nested_Struct & s2, + Alt_Mapping::Nested_Struct_out s3) +{ + Alt_Mapping::Nested_Struct + *ret = new Alt_Mapping::Nested_Struct, + *out = new Alt_Mapping::Nested_Struct; + + s2 = s1; + *out = s1; + *ret = s1; + s3 = out; + return ret; +} + void Alt_Mapping_i::shutdown (void) { diff --git a/tests/Alt_Mapping/alt_mapping_i.h b/tests/Alt_Mapping/alt_mapping_i.h index a9f3913f78d..6c96dbe120f 100644 --- a/tests/Alt_Mapping/alt_mapping_i.h +++ b/tests/Alt_Mapping/alt_mapping_i.h @@ -51,6 +51,16 @@ public: CORBA::OctetSeq & s2, CORBA::OctetSeq & s3); + virtual Alt_Mapping::Var_Struct * + test_var_struct (const Alt_Mapping::Var_Struct & s1, + Alt_Mapping::Var_Struct & s2, + Alt_Mapping::Var_Struct_out s3); + + virtual Alt_Mapping::Nested_Struct * + test_nested_struct (const Alt_Mapping::Nested_Struct & s1, + Alt_Mapping::Nested_Struct & s2, + Alt_Mapping::Nested_Struct_out s3); + void shutdown (void); private: diff --git a/tests/Alt_Mapping/driver.cpp b/tests/Alt_Mapping/driver.cpp index f492d165e2b..65a399de294 100644 --- a/tests/Alt_Mapping/driver.cpp +++ b/tests/Alt_Mapping/driver.cpp @@ -21,7 +21,7 @@ // This function runs the test (main program) int -ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { // get an instance of the driver object Driver drv; @@ -190,6 +190,34 @@ Driver::run (void) delete client; } break; + case Options::TEST_VAR_STRUCT: + { + Alt_Mapping_Client<Test_Var_Struct> *client = + new + Alt_Mapping_Client<Test_Var_Struct> ( + this->orb_.in (), + this->objref_.in(), + new Test_Var_Struct); + + retstatus = client->run_sii_test (); + + delete client; + } + break; + case Options::TEST_NESTED_STRUCT: + { + Alt_Mapping_Client<Test_Nested_Struct> *client = + new + Alt_Mapping_Client<Test_Nested_Struct> ( + this->orb_.in (), + this->objref_.in(), + new Test_Nested_Struct); + + retstatus = client->run_sii_test (); + + delete client; + } + break; default: break; } diff --git a/tests/Alt_Mapping/nested_struct.cpp b/tests/Alt_Mapping/nested_struct.cpp new file mode 100644 index 00000000000..0975e88d8bc --- /dev/null +++ b/tests/Alt_Mapping/nested_struct.cpp @@ -0,0 +1,168 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Alt_Mapping +// +// = FILENAME +// nested_struct.cpp +// +// = DESCRIPTION +// tests nested structs +// +// = AUTHORS +// Aniruddha Gokhale +// Jeff Parsons +// +// ============================================================================ + +#include "helper.h" +#include "nested_struct.h" + +// ************************************************************************ +// Test_Nested_Struct +// ************************************************************************ + +Test_Nested_Struct::Test_Nested_Struct (void) + : opname_ (CORBA::string_dup ("test_nested_struct")), + inout_ (new Alt_Mapping::Nested_Struct), + out_ (new Alt_Mapping::Nested_Struct), + ret_ (new Alt_Mapping::Nested_Struct) +{ +} + +Test_Nested_Struct::~Test_Nested_Struct (void) +{ + CORBA::string_free (this->opname_); + this->opname_ = 0; +} + +const char * +Test_Nested_Struct::opname (void) const +{ + return this->opname_; +} + +int +Test_Nested_Struct::init_parameters (Alt_Mapping_ptr) +{ + Generator *gen = GENERATOR::instance (); // value generator + + // get some sequence length (not more than 10) + CORBA::ULong len = (CORBA::ULong) (gen->gen_long () % 10) + 1; + + this->in_.vs.dbl = 0.0; + this->in_.vs.dummy1 = ""; + this->in_.vs.boole = 0; + this->in_.vs.dummy2 = ""; + this->in_.vs.shrt = 0; + // set the length of the sequence + this->in_.vs.seq.resize (len); + // now set each individual element + for (CORBA::ULong i = 0; i < len; ++i) + { + // generate some arbitrary string to be filled into the ith location in + // the sequence + char *str = gen->gen_string (); + this->in_.vs.seq[i] = str; + } + + this->inout_->vs.dbl = 0.0; + this->inout_->vs.dummy1 = ""; + this->inout_->vs.boole = 0; + this->inout_->vs.dummy2 = ""; + this->inout_->vs.shrt = 0; + // set the length of the sequence + this->inout_->vs.seq.resize (0); + + return 0; +} + +int +Test_Nested_Struct::reset_parameters (void) +{ + this->inout_ = new Alt_Mapping::Nested_Struct; + this->out_ = new Alt_Mapping::Nested_Struct; + this->ret_ = new Alt_Mapping::Nested_Struct; + + this->inout_->vs.dbl = 0.0; + this->inout_->vs.dummy1 = ""; + this->inout_->vs.boole = 0; + this->inout_->vs.dummy2 = ""; + this->inout_->vs.shrt = 0; + // set the length of the sequence + this->inout_->vs.seq.resize (0); + + return 0; +} + +int +Test_Nested_Struct::run_sii_test (Alt_Mapping_ptr objref) +{ + try + { + Alt_Mapping::Nested_Struct_out out (this->out_.out ()); + this->ret_ = objref->test_nested_struct (this->in_, + this->inout_.inout (), + this->out_); + + return 0; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Test_Nested_Struct::run_sii_test\n"); + + } + + return -1; +} + +CORBA::Boolean +Test_Nested_Struct::check_validity (void) +{ + CORBA::Boolean flag = false; + + if ((this->in_.vs.seq.size () == this->inout_->vs.seq.size ()) && + (this->in_.vs.seq.size () == this->out_->vs.seq.size ()) && + (this->in_.vs.seq.size () == this->ret_->vs.seq.size ())) + { + flag = true; // assume all are equal + + // lengths are same. Now compare the contents + for (CORBA::ULong i = 0; i < this->in_.vs.seq.size () && flag; ++i) + { + if (this->in_.vs.seq[i] != this->inout_->vs.seq[i] || + this->in_.vs.seq[i] != this->out_->vs.seq[i] || + this->in_.vs.seq[i] != this->ret_->vs.seq[i]) + // not equal + flag = false; + } + } + + return flag; +} + +void +Test_Nested_Struct::print_values (void) +{ + for (CORBA::ULong i = 0; i < this->in_.vs.seq.size (); ++i) + { + ACE_DEBUG ((LM_DEBUG, + "\n*=*=*=*=*=*=*=*=*=*=\n" + "Element # %d\n" + "in (len = %d): %s\n" + "inout (len = %d): %s\n" + "out (len = %d): %s\n" + "ret (len = %d): %s\n", + i, + this->in_.vs.seq.size (), + (this->in_.vs.seq.empty () ? this->in_.vs.seq[i].c_str () : "<nul>"), + this->inout_->vs.seq.size (), + (this->inout_->vs.seq.empty () ? this->inout_->vs.seq[i].c_str () : "<nul>"), + this->out_->vs.seq.size (), + (this->out_->vs.seq.empty () ? this->out_->vs.seq[i].c_str () : "<nul>"), + this->ret_->vs.seq.size (), + (this->ret_->vs.seq.empty () ? this->ret_->vs.seq[i].c_str () : "<nul>"))); + } +} diff --git a/tests/Alt_Mapping/nested_struct.h b/tests/Alt_Mapping/nested_struct.h new file mode 100644 index 00000000000..f7b6c3088fb --- /dev/null +++ b/tests/Alt_Mapping/nested_struct.h @@ -0,0 +1,67 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// nested_struct.h +// +// = DESCRIPTION +// Tests nested structures +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef ALT_MAPPING_TEST_NESTED_STRUCT_H +#define ALT_MAPPING_TEST_NESTED_STRUCT_H + +#include "alt_mappingC.h" + +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// test nested structs +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +class Test_Nested_Struct +{ +public: + Test_Nested_Struct (void); + // ctor + + ~Test_Nested_Struct (void); + // dtor + + int run_sii_test (Alt_Mapping_ptr objref); + // run the SII test + + const char *opname (void) const; + // return operation name + + int init_parameters (Alt_Mapping_ptr objref); + // set values for parameters + + int reset_parameters (void); + // reset values for CORBA + + CORBA::Boolean check_validity (void); + // check if results are valid + + void print_values (void); + // print all the values + +private: + char *opname_; + + Alt_Mapping::Nested_Struct in_; + + Alt_Mapping::Nested_Struct_var inout_; + + Alt_Mapping::Nested_Struct_var out_; + + Alt_Mapping::Nested_Struct_var ret_; +}; + +#endif /* ALT_MAPPING_TEST_NESTED_STRUCT_H */ diff --git a/tests/Alt_Mapping/options.cpp b/tests/Alt_Mapping/options.cpp index 4708d6003f2..a596d929555 100644 --- a/tests/Alt_Mapping/options.cpp +++ b/tests/Alt_Mapping/options.cpp @@ -3,7 +3,7 @@ // ============================================================================ // // = LIBRARY -// TAO/tests/Param_Test +// TAO/tests/Alt_Mapping // // = FILENAME // options.cpp @@ -44,7 +44,7 @@ Options::~Options (void) int Options::parse_args (int argc, ACE_TCHAR **argv) { - ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("xdn:f:i:t:k:")); + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("xdn:f:t:k:")); int c; int result; @@ -75,26 +75,25 @@ Options::parse_args (int argc, ACE_TCHAR **argv) break; - case 'k': - this->ior_ = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(get_opts.opt_arg ())); - break; - - case 'i': // invocation - if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT("dii"))) - this->invoke_type_ = Options::DII; + case 'k': + this->ior_ = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (get_opts.opt_arg ())); break; case 't': // data type - if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT("ubstring"))) + if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT ("ubstring"))) this->test_type_ = Options::TEST_UB_STRING; - else if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT("ub_struct_seq"))) + else if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT ("ub_struct_seq"))) this->test_type_ = Options::TEST_UB_STRUCT_SEQUENCE; - else if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT("ub_strseq"))) + else if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT ("ub_strseq"))) this->test_type_ = Options::TEST_UB_STRING_SEQUENCE; - else if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT("ub_long_seq"))) + else if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT ("ub_long_seq"))) this->test_type_ = Options::TEST_UB_LONG_SEQUENCE; - else if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT("ub_octet_seq"))) + else if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT ("ub_octet_seq"))) this->test_type_ = Options::TEST_UB_OCTET_SEQUENCE; + else if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT ("var_struct"))) + this->test_type_ = Options::TEST_VAR_STRUCT; + else if (!ACE_OS::strcmp (get_opts.opt_arg (), ACE_TEXT ("nested_struct"))) + this->test_type_ = Options::TEST_NESTED_STRUCT; break; case '?': @@ -104,7 +103,6 @@ Options::parse_args (int argc, ACE_TCHAR **argv) " [-d]" " [-n loopcount]" " [-f servant-IOR-file]" - " [-i invocation (sii/dii)]" " [-t data type]" "\n", argv [0]), diff --git a/tests/Alt_Mapping/options.h b/tests/Alt_Mapping/options.h index 45151630cba..8002cafc481 100644 --- a/tests/Alt_Mapping/options.h +++ b/tests/Alt_Mapping/options.h @@ -40,7 +40,9 @@ public: TEST_UB_STRUCT_SEQUENCE, TEST_UB_STRING_SEQUENCE, TEST_UB_LONG_SEQUENCE, - TEST_UB_OCTET_SEQUENCE + TEST_UB_OCTET_SEQUENCE, + TEST_VAR_STRUCT, + TEST_NESTED_STRUCT }; enum INVOKE_TYPE diff --git a/tests/Alt_Mapping/run_test.pl b/tests/Alt_Mapping/run_test.pl index 0271f212d35..72678201ada 100755 --- a/tests/Alt_Mapping/run_test.pl +++ b/tests/Alt_Mapping/run_test.pl @@ -17,26 +17,29 @@ my $client_iorfile = $client->LocalFile ($iorbase); $server->DeleteFile($iorbase); $client->DeleteFile($iorbase); -$invocation = "sii"; $num = 5; $debug = ""; $status = 0; # Parse the arguments -@types = ("ubstring", "ub_struct_seq", "ub_strseq", "ub_long_seq", "ub_octet_seq"); - +@types = ("ubstring", + "ub_struct_seq", + "ub_strseq", + "ub_long_seq", + "ub_octet_seq", + "var_struct", + "nested_struct"); for ($i = 0; $i <= $#ARGV; $i++) { if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?") { print "Run_Test Perl script for TAO Param Test\n\n"; - print "run_test [-n num] [-d] [-onewin] [-h] [-t type] [-i (dii|sii)] [-chorus <target>]\n"; + print "run_test [-n num] [-d] [-onewin] [-h] [-t type] [-chorus <target>]\n"; print "\n"; print "-n num -- runs the client num times\n"; print "-d -- runs each in debug mode\n"; print "-h -- prints this information\n"; print "-t type -- runs only one type of param test\n"; - print "-i (dii|sii) -- Changes the type of invocation\n"; print "-chorus <target> -- Run tests on chorus target\n"; exit 0; } @@ -51,10 +54,6 @@ for ($i = 0; $i <= $#ARGV; $i++) { @types = split (',', $ARGV[$i + 1]); $i++; } - elsif ($ARGV[$i] eq "-i") { - $invocation = $ARGV[$i + 1]; - $i++; - } } $SV = $server->CreateProcess ("server", "$debug -o $server_iorfile"); @@ -90,7 +89,7 @@ foreach $type (@types) { exit 1; } - $CL->Arguments ("$debug -f $client_iorfile -i $invocation -t $type -n $num -x"); + $CL->Arguments ("$debug -f $client_iorfile -t $type -n $num -x"); $client_status = $CL->SpawnWaitKill ($server->ProcessStartWaitInterval() + 45); if ($client_status != 0) { diff --git a/tests/Alt_Mapping/tests.h b/tests/Alt_Mapping/tests.h index c1635ad5e1e..24df56f20bb 100644 --- a/tests/Alt_Mapping/tests.h +++ b/tests/Alt_Mapping/tests.h @@ -21,5 +21,7 @@ #include "ub_str_seq.h" #include "ub_long_seq.h" #include "ub_octet_seq.h" +#include "nested_struct.h" +#include "var_struct.h" #endif /* if !defined */ diff --git a/tests/Alt_Mapping/ub_long_seq.cpp b/tests/Alt_Mapping/ub_long_seq.cpp index f9f1dd73384..e596ee23a45 100644 --- a/tests/Alt_Mapping/ub_long_seq.cpp +++ b/tests/Alt_Mapping/ub_long_seq.cpp @@ -3,7 +3,7 @@ // ============================================================================ // // = LIBRARY -// TAO/tests/Param_Test +// TAO/tests/Alt_Mapping // // = FILENAME // ub_long_seq.cpp diff --git a/tests/Alt_Mapping/ub_octet_seq.cpp b/tests/Alt_Mapping/ub_octet_seq.cpp index 6a3fca08f65..38c5ce372a8 100644 --- a/tests/Alt_Mapping/ub_octet_seq.cpp +++ b/tests/Alt_Mapping/ub_octet_seq.cpp @@ -3,7 +3,7 @@ // ============================================================================ // // = LIBRARY -// TAO/tests/Param_Test +// TAO/tests/Alt_Mapping // // = FILENAME // ub_octet_seq.cpp diff --git a/tests/Alt_Mapping/ub_str_seq.cpp b/tests/Alt_Mapping/ub_str_seq.cpp index a2e36b6c0f7..deee562d718 100644 --- a/tests/Alt_Mapping/ub_str_seq.cpp +++ b/tests/Alt_Mapping/ub_str_seq.cpp @@ -3,7 +3,7 @@ // ============================================================================ // // = LIBRARY -// TAO/tests/Param_Test +// TAO/tests/Alt_Mapping // // = FILENAME // ub_str_seq.cpp diff --git a/tests/Alt_Mapping/ub_string.cpp b/tests/Alt_Mapping/ub_string.cpp index cdf3746d71c..f37a20423fb 100644 --- a/tests/Alt_Mapping/ub_string.cpp +++ b/tests/Alt_Mapping/ub_string.cpp @@ -3,7 +3,7 @@ // ============================================================================ // // = LIBRARY -// TAO/tests/Param_Test +// TAO/tests/Alt_Mappings // // = FILENAME // ub_string.cpp @@ -68,7 +68,7 @@ Test_Unbounded_String::run_sii_test (Alt_Mapping_ptr objref) { this->ret_ = objref->test_unbounded_string (this->in_, this->inout_, - this->out_);//str_out); + this->out_); return 0; } diff --git a/tests/Alt_Mapping/ub_struct_seq.cpp b/tests/Alt_Mapping/ub_struct_seq.cpp index 456140f8fc6..946f29bbed3 100644 --- a/tests/Alt_Mapping/ub_struct_seq.cpp +++ b/tests/Alt_Mapping/ub_struct_seq.cpp @@ -3,7 +3,7 @@ // ============================================================================ // // = LIBRARY -// TAO/tests/Param_Test +// TAO/tests/Alt_Mapping // // = FILENAME // ub_struct_seq.cpp @@ -13,6 +13,7 @@ // // = AUTHORS // Aniruddha Gokhale +// Jeff Parsons // // ============================================================================ diff --git a/tests/Alt_Mapping/var_struct.cpp b/tests/Alt_Mapping/var_struct.cpp new file mode 100644 index 00000000000..3d9c324a932 --- /dev/null +++ b/tests/Alt_Mapping/var_struct.cpp @@ -0,0 +1,248 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Alt_Mapping +// +// = FILENAME +// var_struct.cpp +// +// = DESCRIPTION +// test variable sized structures +// +// = AUTHORS +// Aniruddha Gokhale +// Jeff Parsons +// +// ============================================================================ + +#include "helper.h" +#include "var_struct.h" + +// ************************************************************************ +// Test_Var_Struct +// ************************************************************************ + +Test_Var_Struct::Test_Var_Struct (void) + : opname_ (CORBA::string_dup ("test_var_struct")), + inout_ (new Alt_Mapping::Var_Struct), + out_ (new Alt_Mapping::Var_Struct), + ret_ (new Alt_Mapping::Var_Struct) +{ +} + +Test_Var_Struct::~Test_Var_Struct (void) +{ + CORBA::string_free (this->opname_); + this->opname_ = 0; +} + +const char * +Test_Var_Struct::opname (void) const +{ + return this->opname_; +} + +int +Test_Var_Struct::init_parameters (Alt_Mapping_ptr) +{ + Generator *gen = GENERATOR::instance (); // value generator + + // get some sequence length (not more than 10) + CORBA::ULong len = (CORBA::ULong) (gen->gen_long () % 10) + 1; + + this->in_.dbl = 3.14159; + this->in_.dummy1 = gen->gen_string (); + this->in_.boole = gen->gen_short () % 2; + this->in_.dummy2 = gen->gen_string (); + this->in_.shrt = gen->gen_short (); + + // set the length of the sequence + this->in_.seq.resize (len); + + // now set each individual element + for (CORBA::ULong i = 0; i < this->in_.seq.size (); i++) + { + // generate some arbitrary string to be filled into the ith location in + // the sequence + char *str = gen->gen_string (); + this->in_.seq[i] = str; + } + + this->inout_->dbl = 0.0; + this->inout_->dummy1 = ""; + this->inout_->boole = 0; + this->inout_->dummy2 = ""; + this->inout_->shrt = 0; + + // set the length of the sequence + this->inout_->seq.resize (0); + + return 0; +} + +int +Test_Var_Struct::reset_parameters (void) +{ + this->inout_ = new Alt_Mapping::Var_Struct; + this->out_ = new Alt_Mapping::Var_Struct; + this->ret_ = new Alt_Mapping::Var_Struct; + + this->inout_->dbl = 0.0; + this->inout_->dummy1 = ""; + this->inout_->boole = 0; + this->inout_->dummy2 = ""; + this->inout_->shrt = 0; + // set the length of the sequence + this->inout_->seq.resize (0); + + return 0; +} + +int +Test_Var_Struct::run_sii_test (Alt_Mapping_ptr objref) +{ + try + { + Alt_Mapping::Var_Struct_out out (this->out_.out ()); + this->ret_ = objref->test_var_struct (this->in_, + this->inout_.inout (), + out); + + return 0; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Test_Var_Struct::run_sii_test\n"); + + } + return -1; +} + +CORBA::Boolean +Test_Var_Struct::check_validity (void) +{ + CORBA::Boolean flag = false; + + if (this->in_.dbl == this->inout_->dbl && + this->in_.dbl == this->out_->dbl && + this->in_.dbl == this->ret_->dbl && + this->in_.dummy1 != this->inout_->dummy1 && + this->in_.dummy1 != this->out_->dummy1 && + this->in_.dummy1 != this->ret_->dummy1 && + this->in_.boole == this->inout_->boole && + this->in_.boole == this->out_->boole && + this->in_.boole == this->ret_->boole && + this->in_.dummy2 != this->inout_->dummy2 && + this->in_.dummy2 != this->out_->dummy2 && + this->in_.dummy2 != this->ret_->dummy2 && + this->in_.shrt == this->inout_->shrt && + this->in_.shrt == this->out_->shrt && + this->in_.shrt == this->ret_->shrt && + (this->in_.seq.size () == this->inout_->seq.size ()) && + (this->in_.seq.size () == this->out_->seq.size ()) && + (this->in_.seq.size () == this->ret_->seq.size ())) + { + flag = true; // assume all are equal + + // lengths are same. Now compare the contents + for (CORBA::ULong i = 0; i < this->in_.seq.size () && flag; ++i) + { + if (this->in_.seq[i] != this->inout_->seq[i] || + this->in_.seq[i] != this->out_->seq[i] || + this->in_.seq[i] != this->ret_->seq[i]) + // not equal + flag = false; + } + } + + return flag; +} + +void +Test_Var_Struct::print_values (void) +{ + ACE_DEBUG ((LM_DEBUG, + "\n*=*=*=*=*=*=*=*=*=*=\n" + "in_.dummy1 = %s\n" + "inout_.dummy1 = %s\n" + "out_.dummy1 = %s\n" + "ret_.dummy1 = %s\n", + this->in_.dummy1.in (), + this->inout_->dummy1.in (), + this->out_->dummy1.in (), + this->ret_->dummy1.in ())); + + ACE_DEBUG ((LM_DEBUG, + "\n*=*=*=*=*=*=*=*=*=*=\n" + "in_.dummy2 = %s\n" + "inout_.dummy2 = %s\n" + "out_.dummy2 = %s\n" + "ret_.dummy2 = %s\n", + this->in_.dummy2.in (), + this->inout_->dummy2.in (), + this->out_->dummy2.in (), + this->ret_->dummy2.in ())); + + CORBA::ULong i; + ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n")); + + for (i = 0; i < this->in_.seq.size (); ++i) + { + ACE_DEBUG ((LM_DEBUG, + "Element #%d\n" + "in.seq : %s\n", + i, + (this->in_.seq[i].empty () ? this->in_.seq[i].c_str () : "<nul>"))); + } + + ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n")); + + for (i = 0; this->inout_.ptr () && (i < this->inout_->seq.size ()); ++i) + { + ACE_DEBUG ((LM_DEBUG, + "Element #%d\n" + "inout : %s\n", + i, + (this->inout_->seq[i].empty () ? this->inout_->seq[i].c_str () : "<nul>"))); + } + + if (this->inout_.ptr () == 0) + { + ACE_DEBUG ((LM_DEBUG, "\ninout struct does not exist\n")); + } + + ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n")); + + for (i = 0; this->out_.ptr () && (i < this->out_->seq.size ()); ++i) + { + ACE_DEBUG ((LM_DEBUG, + "Element #%d\n" + "in : %s\n", + i, + (this->out_->seq[i].empty () ? this->out_->seq[i].c_str () : "<nul>"))); + } + + if (this->out_.ptr () == 0) + { + ACE_DEBUG ((LM_DEBUG, "\nout struct is NUL\n")); + } + + ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n")); + + for (i = 0; this->ret_.ptr () && (i < this->ret_->seq.size ()); ++i) + { + ACE_DEBUG ((LM_DEBUG, + "Element #%d\n" + "in : %s\n", + i, + (this->ret_->seq[i].empty () ? this->ret_->seq[i].c_str () : "<nul>"))); + } + if (this->ret_.ptr () == 0) + { + ACE_DEBUG ((LM_DEBUG, "\nret struct is NUL\n")); + } + + ACE_DEBUG ((LM_DEBUG, "\n*=*=*=*=*=*=*=*=*=*=\n")); +} diff --git a/tests/Alt_Mapping/var_struct.h b/tests/Alt_Mapping/var_struct.h new file mode 100644 index 00000000000..830407ff715 --- /dev/null +++ b/tests/Alt_Mapping/var_struct.h @@ -0,0 +1,68 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/Param_Test +// +// = FILENAME +// var_struct.h +// +// = DESCRIPTION +// Tests variable sized structures +// +// = AUTHORS +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef ALT_MAPPING_TEST_VAR_STRUCT_H +#define ALT_MAPPING_TEST_VAR_STRUCT_H + +#include "alt_mappingC.h" + +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// test variable sized structs +// =*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +class Test_Var_Struct +{ +public: + Test_Var_Struct (void); + // ctor + + ~Test_Var_Struct (void); + // dtor + + int run_sii_test (Alt_Mapping_ptr objref); + // run the SII test + + const char *opname (void) const; + // return operation name + + int init_parameters (Alt_Mapping_ptr objref); + // set values for parameters + + int reset_parameters (void); + // reset values for CORBA + + CORBA::Boolean check_validity (void); + // check if results are valid + + void print_values (void); + // print all the values + +private: + char *opname_; + // operation name + + Alt_Mapping::Var_Struct in_; + + Alt_Mapping::Var_Struct_var inout_; + + Alt_Mapping::Var_Struct_var out_; + + Alt_Mapping::Var_Struct_var ret_; +}; + +#endif /* ALT_MAPPING_TEST_VAR_STRUCT_H */ |