summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2006-04-24 10:14:31 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2006-04-24 10:14:31 +0000
commit20986e532401343c85c78bcb8df01674728403db (patch)
tree319df4e8c2bce696d86a25887f93177f3c51a930
parentbc397abbc415dcff498385cea743b6d59c3a9fd6 (diff)
downloadATCD-20986e532401343c85c78bcb8df01674728403db.tar.gz
ChangeLogTag: Mon Apr 24 06:59:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>Mon Apr 24 09:17:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>Mon Apr 24 09:39:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>Mon Apr 24 09:57:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>
-rw-r--r--TAO/tests/Bug_1676_Regression/Bug_1676_Regression.mpc19
-rw-r--r--TAO/tests/Bug_1676_Regression/Hello.cpp98
-rw-r--r--TAO/tests/Bug_1676_Regression/Hello.h54
-rw-r--r--TAO/tests/Bug_1676_Regression/Test.idl39
-rw-r--r--TAO/tests/Bug_1676_Regression/client.cpp125
-rwxr-xr-xTAO/tests/Bug_1676_Regression/run_test.pl49
-rw-r--r--TAO/tests/Bug_1676_Regression/server.cpp115
7 files changed, 499 insertions, 0 deletions
diff --git a/TAO/tests/Bug_1676_Regression/Bug_1676_Regression.mpc b/TAO/tests/Bug_1676_Regression/Bug_1676_Regression.mpc
new file mode 100644
index 00000000000..9a1892855d9
--- /dev/null
+++ b/TAO/tests/Bug_1676_Regression/Bug_1676_Regression.mpc
@@ -0,0 +1,19 @@
+// -*- MPC -*-
+// $Id$
+
+project(*Server): taoserver {
+ 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_1676_Regression/Hello.cpp b/TAO/tests/Bug_1676_Regression/Hello.cpp
new file mode 100644
index 00000000000..b0afc671195
--- /dev/null
+++ b/TAO/tests/Bug_1676_Regression/Hello.cpp
@@ -0,0 +1,98 @@
+//
+// $Id$
+//
+#include "Hello.h"
+
+ACE_RCSID(Hello, Hello, "$Id$")
+
+Hello::Hello (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+{
+}
+
+#if 0
+char *
+Hello::get_string (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ return CORBA::string_dup ("Hello there!");
+}
+#endif
+
+::Test::StringList *
+Hello::get_stringList (
+ // ACE_ENV_SINGLE_ARG_DECL_NOT_USED
+ ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException
+ ))
+{
+ Test::StringList * seq;
+ ACE_NEW_RETURN (seq,
+ Test::StringList(10),
+ 0);
+ seq->length(10);
+ for (CORBA::ULong i = 0; i<seq->length(); i++)
+ {
+ char tmp[255] = {0};
+ sprintf(tmp, "Hello World %d", i);
+ (*seq)[i] = CORBA::string_dup(tmp);
+ }
+
+ return seq;
+}
+
+void
+Hello::get_stringList2 (
+ ::CORBA::Boolean initialize,
+ ::Test::StringList_out osl
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException
+ ))
+{
+ // CORBA::String_var the_string = osl->length();
+ // ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Entering get_stringList2(%.4d)\n", osl));
+
+ if (initialize) {
+ ACE_NEW (osl,
+ Test::StringList(10));
+
+ osl->length(5);
+ for (CORBA::ULong i = 0; i<osl->length(); i++)
+ {
+ char tmp[255] = {0};
+ sprintf(tmp, "Hello Again %d", i);
+ (*osl)[i] = CORBA::string_dup(tmp);
+ }
+ }
+}
+
+void
+Hello::mod_stringList (
+ ::Test::StringList & iosl
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException
+ ))
+{
+ // osl->length(10);
+ for (CORBA::ULong i = 0; i<iosl.length(); i++)
+ {
+ char tmp[255] = {0};
+ sprintf(tmp, "Hello Client %d", i);
+ if (i%2) {
+ iosl[i] = CORBA::string_dup(tmp);
+ }
+ }
+}
+
+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_1676_Regression/Hello.h b/TAO/tests/Bug_1676_Regression/Hello.h
new file mode 100644
index 00000000000..d7bd79aab93
--- /dev/null
+++ b/TAO/tests/Bug_1676_Regression/Hello.h
@@ -0,0 +1,54 @@
+//
+// $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 ::Test::StringList * get_stringList (
+ ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException
+ ));
+
+ virtual void get_stringList2 (
+ ::CORBA::Boolean initialize,
+ ::Test::StringList_out osl
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException
+ ));
+
+ virtual void mod_stringList (
+ ::Test::StringList & iosl
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS
+ )
+ ACE_THROW_SPEC ((
+ ::CORBA::SystemException
+ ));
+
+ virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+private:
+ /// Use an ORB reference to convert strings to objects and shutdown
+ /// the application.
+ CORBA::ORB_var orb_;
+};
+
+#include /**/ "ace/post.h"
+#endif /* HELLO_H */
diff --git a/TAO/tests/Bug_1676_Regression/Test.idl b/TAO/tests/Bug_1676_Regression/Test.idl
new file mode 100644
index 00000000000..986c82a3fbb
--- /dev/null
+++ b/TAO/tests/Bug_1676_Regression/Test.idl
@@ -0,0 +1,39 @@
+// -*- IDL -*-
+
+//=============================================================================
+/**
+ * @file test.idl
+ *
+ * $Id$
+ *
+ * "test" IDL interface for the Uninitialized "out" param for sequence<string>
+ * can cause server to core test.
+ *
+ * @author Kees van Marle <kvmarle@ermedy.nl>
+ */
+//=============================================================================
+
+
+module Test
+{
+ typedef sequence<string> StringList;
+
+ /// A very simple interface
+ interface Hello
+ {
+ /// Return a string list
+ StringList get_stringList ();
+
+ /// Return a string list
+ void get_stringList2 (in boolean initialize, out StringList osl);
+
+ /// Modify a string list
+ void mod_stringList (inout StringList iosl);
+
+ /// 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_1676_Regression/client.cpp b/TAO/tests/Bug_1676_Regression/client.cpp
new file mode 100644
index 00000000000..2e2ec401a29
--- /dev/null
+++ b/TAO/tests/Bug_1676_Regression/client.cpp
@@ -0,0 +1,125 @@
+// $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);
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "\n(%P|%t) - get_stringList\n"));
+
+ Test::StringList_var seq =
+ hello->get_stringList (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ for (CORBA::ULong i = 0; i<seq->length(); i++) {
+ CORBA::String_var the_string = CORBA::string_dup ((*seq)[i]);
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%s>\n",
+ the_string.in ()));
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "\n(%P|%t) - get_stringList2 with initialization\n"));
+
+ Test::StringList_var seq2;
+ hello->get_stringList2(true, seq2.out());
+ ACE_TRY_CHECK;
+
+ for (CORBA::ULong i = 0; i<seq2->length(); i++) {
+ CORBA::String_var the_string = seq2.in()[i];
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%s>\n",
+ the_string.in ()));
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "\n(%P|%t) - get_stringList2 without initialization\n"));
+
+ hello->get_stringList2(false, seq2.out());
+ ACE_TRY_CHECK;
+
+ for (CORBA::ULong i = 0; i<seq2->length(); i++) {
+ CORBA::String_var the_string = seq2.in()[i];
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%s>\n",
+ the_string.in ()));
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "\n(%P|%t) - mod_stringList\n"));
+
+ hello->mod_stringList(seq.inout());
+ ACE_TRY_CHECK;
+
+ for (CORBA::ULong i = 0; i<seq->length(); i++) {
+ CORBA::String_var the_string = CORBA::string_dup ((*seq)[i]);
+ 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_1676_Regression/run_test.pl b/TAO/tests/Bug_1676_Regression/run_test.pl
new file mode 100755
index 00000000000..5d02e3606f1
--- /dev/null
+++ b/TAO/tests/Bug_1676_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");
+
+$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_1676_Regression/server.cpp b/TAO/tests/Bug_1676_Regression/server.cpp
new file mode 100644
index 00000000000..177aad4d1d8
--- /dev/null
+++ b/TAO/tests/Bug_1676_Regression/server.cpp
@@ -0,0 +1,115 @@
+// $Id$
+
+#include "Hello.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_stdio.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;
+}