diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
commit | 0e49389337be86641451a5c36c24bf742fe97523 (patch) | |
tree | 197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/tests/Bug_2328_Regression | |
parent | 8008dd09ccf88d4edef237a184a698cac42f2952 (diff) | |
download | ATCD-0e49389337be86641451a5c36c24bf742fe97523.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/tests/Bug_2328_Regression')
-rw-r--r-- | TAO/tests/Bug_2328_Regression/Bug_2328_Regression.mpc | 19 | ||||
-rw-r--r-- | TAO/tests/Bug_2328_Regression/Hello.cpp | 26 | ||||
-rw-r--r-- | TAO/tests/Bug_2328_Regression/Hello.h | 33 | ||||
-rw-r--r-- | TAO/tests/Bug_2328_Regression/README | 16 | ||||
-rw-r--r-- | TAO/tests/Bug_2328_Regression/Test.idl | 20 | ||||
-rw-r--r-- | TAO/tests/Bug_2328_Regression/client.cpp | 89 | ||||
-rwxr-xr-x | TAO/tests/Bug_2328_Regression/run_test.pl | 49 | ||||
-rw-r--r-- | TAO/tests/Bug_2328_Regression/server.cpp | 116 |
8 files changed, 368 insertions, 0 deletions
diff --git a/TAO/tests/Bug_2328_Regression/Bug_2328_Regression.mpc b/TAO/tests/Bug_2328_Regression/Bug_2328_Regression.mpc new file mode 100644 index 00000000000..5fce9b69306 --- /dev/null +++ b/TAO/tests/Bug_2328_Regression/Bug_2328_Regression.mpc @@ -0,0 +1,19 @@ +// -*- MPC -*- +// $Id$ + +project(*Server): taoserver, codeset { + idlflags += -Sa -St + Source_Files { + Hello.cpp + server.cpp + } +} + +project(*Client): taoclient { + after += *Server + Source_Files { + TestC.cpp + client.cpp + } +} + diff --git a/TAO/tests/Bug_2328_Regression/Hello.cpp b/TAO/tests/Bug_2328_Regression/Hello.cpp new file mode 100644 index 00000000000..ac4c1c6fe85 --- /dev/null +++ b/TAO/tests/Bug_2328_Regression/Hello.cpp @@ -0,0 +1,26 @@ +// +// $Id$ +// +#include "Hello.h" + +ACE_RCSID(Hello, Hello, "$Id$") + +Hello::Hello (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +char * +Hello::get_string (const char * A, const char * B, const char * C) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, "Received: <%s>, <%s>, <%s>\n", A, B, C)); + return CORBA::string_dup ("Hello there!"); +} + +void +Hello::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/tests/Bug_2328_Regression/Hello.h b/TAO/tests/Bug_2328_Regression/Hello.h new file mode 100644 index 00000000000..4ef97cd1b6c --- /dev/null +++ b/TAO/tests/Bug_2328_Regression/Hello.h @@ -0,0 +1,33 @@ +// +// $Id$ +// + +#ifndef HELLO_H +#define HELLO_H +#include /**/ "ace/pre.h" + +#include "TestS.h" + +/// Implement the Test::Hello interface +class Hello + : public virtual POA_Test::Hello +{ +public: + /// Constructor + Hello (CORBA::ORB_ptr orb); + + // = The skeleton methods + virtual char * get_string (const char * A, const char * B, const char * C ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + /// Use an ORB reference to conver strings to objects and shutdown + /// the application. + CORBA::ORB_var orb_; +}; + +#include /**/ "ace/post.h" +#endif /* HELLO_H */ diff --git a/TAO/tests/Bug_2328_Regression/README b/TAO/tests/Bug_2328_Regression/README new file mode 100644 index 00000000000..53f14a09bed --- /dev/null +++ b/TAO/tests/Bug_2328_Regression/README @@ -0,0 +1,16 @@ +/** + +@page Bug_2328_Regression README File + +This test sends 3 strings to the server. The server is using the codeset +library, the client is configured that it doesn't use it. This gives a marshal +exception in TAO 1.4.7 because it uses UTF8 Latin1 to demarshal the strings +which then causes things to go wrong in the stream. + + To run the test use the run_test.pl script: + +$ ./run_test.pl + + the script returns 0 if the test was successful. + +*/ diff --git a/TAO/tests/Bug_2328_Regression/Test.idl b/TAO/tests/Bug_2328_Regression/Test.idl new file mode 100644 index 00000000000..528f0c5485c --- /dev/null +++ b/TAO/tests/Bug_2328_Regression/Test.idl @@ -0,0 +1,20 @@ +// +// $Id$ +// + +/// Put the interfaces in a module, to avoid global namespace pollution +module Test +{ + /// A very simple interface + interface Hello + { + /// Return a simple string + string get_string (in string A, in string B, in string C); + + /// A method to shutdown the ORB + /** + * This method is used to simplify the test shutdown process + */ + oneway void shutdown (); + }; +}; diff --git a/TAO/tests/Bug_2328_Regression/client.cpp b/TAO/tests/Bug_2328_Regression/client.cpp new file mode 100644 index 00000000000..d39919e7d85 --- /dev/null +++ b/TAO/tests/Bug_2328_Regression/client.cpp @@ -0,0 +1,89 @@ +// $Id$ + +#include "TestC.h" +#include "ace/Get_Opt.h" + +ACE_RCSID(Hello, client, "$Id$") + +const char *ior = "file://test.ior"; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "k:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.opt_arg (); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k <ior> " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var tmp = + orb->string_to_object(ior ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Test::Hello_var hello = + Test::Hello::_narrow(tmp.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (hello.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Nil Test::Hello reference <%s>\n", + ior), + 1); + } + + CORBA::String_var A = CORBA::string_dup ("DKWC"); + CORBA::String_var B = CORBA::string_dup ("kwc"); + CORBA::String_var C = CORBA::string_dup ("MV-files"); + CORBA::String_var the_string = + hello->get_string (A.in (), B.in (), C.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%s>\n", + the_string.in ())); + + hello->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/tests/Bug_2328_Regression/run_test.pl b/TAO/tests/Bug_2328_Regression/run_test.pl new file mode 100755 index 00000000000..f5831bdb8e9 --- /dev/null +++ b/TAO/tests/Bug_2328_Regression/run_test.pl @@ -0,0 +1,49 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib '../../../bin'; +use PerlACE::Run_Test; + +$status = 0; + +$iorfile = PerlACE::LocalFile ("server.ior"); +unlink $iorfile; + +if (PerlACE::is_vxworks_test()) { + $SV = new PerlACE::ProcessVX ("server", "-o server.ior"); +} +else { + $SV = new PerlACE::Process ("server", "-o $iorfile"); +} +$CL = new PerlACE::Process ("client", " -k file://$iorfile -ORBNegotiateCodesets 0"); + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$client = $CL->SpawnWaitKill (300); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +$server = $SV->WaitKill (10); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; diff --git a/TAO/tests/Bug_2328_Regression/server.cpp b/TAO/tests/Bug_2328_Regression/server.cpp new file mode 100644 index 00000000000..69fe7692d76 --- /dev/null +++ b/TAO/tests/Bug_2328_Regression/server.cpp @@ -0,0 +1,116 @@ +// $Id$ + +#include "Hello.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "tao/Codeset/Codeset.h" + +ACE_RCSID (Hello, + server, + "$Id$") + +const char *ior_output_file = "test.ior"; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "o:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + ior_output_file = get_opts.opt_arg (); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-o <iorfile>" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (root_poa.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil RootPOA\n"), + 1); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + Hello *hello_impl; + ACE_NEW_RETURN (hello_impl, + Hello (orb.in ()), + 1); + PortableServer::ServantBase_var owner_transfer(hello_impl); + + Test::Hello_var hello = + hello_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (hello.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Output the IOR to the <ior_output_file> + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); + + root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} |