summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarijke Hengstmengel <MHengstmengel@users.noreply.github.com>2011-09-28 11:53:26 +0000
committerMarijke Hengstmengel <MHengstmengel@users.noreply.github.com>2011-09-28 11:53:26 +0000
commit75be74d6481e655e84b4d23be0bdb51f80b8a9a6 (patch)
treef852c377d9f6afe5f9cc52150d19195180de8467
parentfd3f21e9a98ba85630ae728d7a431e561f369ca2 (diff)
downloadATCD-75be74d6481e655e84b4d23be0bdb51f80b8a9a6.tar.gz
Wed Sep 28 11:39:31 UTC 2011 Marijke Hengstmengel <mhengstmengel@remedy.nl>
* tests/Bug_2241_Regression: * tests/Bug_2241_Regression/Bug_2241_Regression.mpc: * tests/Bug_2241_Regression/Client_Task.h: * tests/Bug_2241_Regression/Client_Task.cpp: * tests/Bug_2241_Regression/Collocated_Test.cpp: * tests/Bug_2241_Regression/Hello.h: * tests/Bug_2241_Regression/Hello.cpp: * tests/Bug_2241_Regression/Server_Task.h: * tests/Bug_2241_Regression/Server_Task.cpp: * tests/Bug_2241_Regression/Test.idl: * tests/Bug_2241_Regression/run_test.pl: * bin/tao_orb_tests.lst: New test for '-ORBCollocationStrategy direct'
-rw-r--r--TAO/ChangeLog15
-rw-r--r--TAO/bin/tao_orb_tests.lst1
-rw-r--r--TAO/tests/Bug_2241_Regression/Bug_2241_Regression.mpc6
-rw-r--r--TAO/tests/Bug_2241_Regression/Client_Task.cpp53
-rw-r--r--TAO/tests/Bug_2241_Regression/Client_Task.h37
-rw-r--r--TAO/tests/Bug_2241_Regression/Collocated_Test.cpp106
-rw-r--r--TAO/tests/Bug_2241_Regression/Hello.cpp67
-rw-r--r--TAO/tests/Bug_2241_Regression/Hello.h34
-rw-r--r--TAO/tests/Bug_2241_Regression/Server_Task.cpp87
-rw-r--r--TAO/tests/Bug_2241_Regression/Server_Task.h48
-rw-r--r--TAO/tests/Bug_2241_Regression/Test.idl20
-rwxr-xr-xTAO/tests/Bug_2241_Regression/run_test.pl63
12 files changed, 537 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 6d546cffd03..7644bf406d2 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,18 @@
+Wed Sep 28 11:39:31 UTC 2011 Marijke Hengstmengel <mhengstmengel@remedy.nl>
+ * tests/Bug_2241_Regression:
+ * tests/Bug_2241_Regression/Bug_2241_Regression.mpc:
+ * tests/Bug_2241_Regression/Client_Task.h:
+ * tests/Bug_2241_Regression/Client_Task.cpp:
+ * tests/Bug_2241_Regression/Collocated_Test.cpp:
+ * tests/Bug_2241_Regression/Hello.h:
+ * tests/Bug_2241_Regression/Hello.cpp:
+ * tests/Bug_2241_Regression/Server_Task.h:
+ * tests/Bug_2241_Regression/Server_Task.cpp:
+ * tests/Bug_2241_Regression/Test.idl:
+ * tests/Bug_2241_Regression/run_test.pl:
+ * bin/tao_orb_tests.lst:
+ New test for '-ORBCollocationStrategy direct'
+
Sun Sep 25 17:02:27 UTC 2011 Marcel Smit <msmit@remedy.nl>
* tests/Parallel_Connect_Strategy/run_test.pl:
diff --git a/TAO/bin/tao_orb_tests.lst b/TAO/bin/tao_orb_tests.lst
index 8fc623c3e5f..9fd01633c5f 100644
--- a/TAO/bin/tao_orb_tests.lst
+++ b/TAO/bin/tao_orb_tests.lst
@@ -84,6 +84,7 @@ TAO/tests/Bug_2186_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MI
TAO/tests/Bug_2188_Regression/run_test.pl:
TAO/tests/Bug_2201_Regression/run_test.pl:
TAO/tests/Bug_2234_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !DISABLE_INTERCEPTORS
+TAO/tests/Bug_2241_Regression/run_test.pl: !ST
TAO/tests/Bug_2243_Regression/run_test.pl:
TAO/tests/Bug_2289_Regression/run_test.pl:
TAO/tests/Bug_2319_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !FIXED_BUGS_ONLY
diff --git a/TAO/tests/Bug_2241_Regression/Bug_2241_Regression.mpc b/TAO/tests/Bug_2241_Regression/Bug_2241_Regression.mpc
new file mode 100644
index 00000000000..9a975cb5ea0
--- /dev/null
+++ b/TAO/tests/Bug_2241_Regression/Bug_2241_Regression.mpc
@@ -0,0 +1,6 @@
+// -*- MPC -*-
+// $Id$
+
+project(Bug_2241_Regression): taoserver {
+ exename = Bug_2241_Regression
+}
diff --git a/TAO/tests/Bug_2241_Regression/Client_Task.cpp b/TAO/tests/Bug_2241_Regression/Client_Task.cpp
new file mode 100644
index 00000000000..e39e0d96191
--- /dev/null
+++ b/TAO/tests/Bug_2241_Regression/Client_Task.cpp
@@ -0,0 +1,53 @@
+//
+// $Id$
+//
+
+#include "Client_Task.h"
+#include "TestC.h"
+
+Client_Task::Client_Task (const ACE_TCHAR *ior,
+ CORBA::ORB_ptr corb,
+ ACE_Thread_Manager *thr_mgr)
+ : ACE_Task_Base (thr_mgr)
+ , input_ (ior)
+ , corb_ (CORBA::ORB::_duplicate (corb))
+
+{
+}
+
+int
+Client_Task::svc (void)
+{
+ try
+ {
+ CORBA::Object_var tmp =
+ this->corb_->string_to_object (input_);
+
+ Test::Hello_var hello =
+ Test::Hello::_narrow(tmp.in ());
+
+ if (CORBA::is_nil (hello.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ "Nil Test::Hello reference <%s>\n",
+ input_),
+ 1);
+ }
+
+ CORBA::String_var the_string =
+ hello->get_string ();
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
+ the_string.in ()));
+
+ hello->shutdown ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ return 1;
+ }
+
+ return 0;
+
+}
diff --git a/TAO/tests/Bug_2241_Regression/Client_Task.h b/TAO/tests/Bug_2241_Regression/Client_Task.h
new file mode 100644
index 00000000000..8f6557cdec8
--- /dev/null
+++ b/TAO/tests/Bug_2241_Regression/Client_Task.h
@@ -0,0 +1,37 @@
+//
+// $Id$
+//
+
+#ifndef COLLOCATED_TEST_CLIENT_TASK_H
+#define COLLOCATED_TEST_CLIENT_TASK_H
+#include /**/ "ace/pre.h"
+#include "ace/Task.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+#include "tao/ORB.h"
+
+
+/// Implement a Task to run the client as a thread
+class Client_Task : public ACE_Task_Base
+{
+public:
+
+ /// Constructor
+ Client_Task (const ACE_TCHAR *input,
+ CORBA::ORB_ptr corb,
+ ACE_Thread_Manager *thr_mgr);
+
+ /// Thread entry point
+ int svc (void);
+
+private:
+ const ACE_TCHAR *input_;
+
+ CORBA::ORB_var corb_;
+
+};
+
+#include /**/ "ace/post.h"
+#endif /* COLLOCATED_TEST_CLIENT_TASK_H */
diff --git a/TAO/tests/Bug_2241_Regression/Collocated_Test.cpp b/TAO/tests/Bug_2241_Regression/Collocated_Test.cpp
new file mode 100644
index 00000000000..282295ad5e3
--- /dev/null
+++ b/TAO/tests/Bug_2241_Regression/Collocated_Test.cpp
@@ -0,0 +1,106 @@
+//$Id$
+#include "Server_Task.h"
+#include "Client_Task.h"
+#include "ace/Get_Opt.h"
+#include "ace/Argv_Type_Converter.h"
+#include "ace/SString.h"
+#include "ace/Manual_Event.h"
+
+const ACE_TCHAR *output = ACE_TEXT("test.ior");
+const ACE_TCHAR *input = ACE_TEXT("file://test.ior");
+// static int named_orbs = 0;
+ACE_CString server_orb;
+ACE_CString client_orb;
+int
+parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:o:n"));
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o':
+ output = get_opts.opt_arg ();
+ break;
+ case 'k':
+ input = get_opts.opt_arg ();
+ break;
+ case 'n':
+ // named_orbs = 1;
+ server_orb.set ("server_orb");
+ client_orb.set ("client_orb");
+ break;
+ case '?':
+ default:
+ // This is a hack but that is okay!
+ return 0;
+ }
+ // Indicates successful parsing of the command line
+ return 0;
+}
+
+int
+ACE_TMAIN(int argc, ACE_TCHAR *argv[])
+{
+ if (parse_args (argc,
+ argv) == -1)
+ return -1;
+
+ try
+ {
+ ACE_Argv_Type_Converter satc (argc, argv);
+ CORBA::ORB_var sorb =
+ CORBA::ORB_init (satc.get_argc (),
+ satc.get_TCHAR_argv (),
+ server_orb.c_str ());
+
+ ACE_Manual_Event me;
+ Server_Task server_task (output,
+ sorb.in (),
+ me,
+ ACE_Thread_Manager::instance ());
+
+ if (server_task.activate (THR_NEW_LWP | THR_JOINABLE,
+ 1,
+ 1) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, "Error activating server task\n"));
+ }
+
+ // Wait for the server thread to do some processing
+ me.wait ();
+
+ ACE_Argv_Type_Converter catc (argc, argv);
+ CORBA::ORB_var corb =
+ CORBA::ORB_init (catc.get_argc (),
+ catc.get_TCHAR_argv (),
+ client_orb.c_str ());
+
+ Client_Task client_task (input,
+ corb.in (),
+ ACE_Thread_Manager::instance ());
+
+ if (client_task.activate (THR_NEW_LWP | THR_JOINABLE,
+ 1,
+ 1) == -1)
+ {
+ ACE_ERROR ((LM_ERROR, "Error activating client task\n"));
+ }
+
+ // Wait for the client and server to finish
+ ACE_Thread_Manager::instance ()->wait ();
+
+ // Now that all threads have completed we can destroy the ORB
+ sorb->destroy ();
+ if (server_orb != client_orb)
+ {
+ corb->destroy ();
+ }
+ }
+ catch (const CORBA::Exception&)
+ {
+ // Ignore exceptions..
+ }
+ return 0;
+}
diff --git a/TAO/tests/Bug_2241_Regression/Hello.cpp b/TAO/tests/Bug_2241_Regression/Hello.cpp
new file mode 100644
index 00000000000..cabcd9145d9
--- /dev/null
+++ b/TAO/tests/Bug_2241_Regression/Hello.cpp
@@ -0,0 +1,67 @@
+//
+// $Id$
+//
+#include "Hello.h"
+#include "tao/ORB_Core.h"
+#include "tao/ORB_Table.h"
+#include "tao/ORB_Core_Auto_Ptr.h"
+
+ Hello::Hello (CORBA::ORB_ptr orb,
+ ACE_thread_t thrid)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+ , thr_id_ (thrid)
+{
+}
+
+char *
+Hello::get_string (void)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) Upcall in process ..\n"));
+
+ // Use portable thread IDs
+ ACE_Thread_ID self_ID;
+ ACE_Thread_ID this_ID;
+ this_ID.id(this->thr_id_);
+
+ if (self_ID == this_ID)
+ {
+ if (this->orb_->orb_core ()->optimize_collocation_objects () &&
+ this->orb_->orb_core ()->use_global_collocation ())
+ {
+ ACE_ERROR ((LM_ERROR,
+ "(%P|%t) ERROR: A remote call has been made "
+ " exiting ..\n"));
+ ACE_OS::abort ();
+ }
+ else if (this->orb_->orb_core ()->optimize_collocation_objects () &&
+ this->orb_->orb_core ()->use_global_collocation () == 0)
+ {
+ TAO::ORB_Table * const orb_table =
+ TAO::ORB_Table::instance ();
+
+ TAO_ORB_Core_Auto_Ptr tmp (orb_table->find ("server_orb"));
+ if (tmp.get () == 0)
+ {
+ // We are running on a single ORB and this is an error.
+ ACE_ERROR ((LM_ERROR,
+ "(%P|%t) ERROR: A remote call has been made "
+ " with a single ORB "
+ " exiting ..\n"));
+ ACE_OS::abort ();
+ }
+ }
+ }
+
+ return CORBA::string_dup ("Hello there!");
+}
+
+void
+Hello::shutdown (void)
+{
+ // Give the client thread time to return from the collocated
+ // call to this method before shutting down the ORB. We sleep
+ // to avoid BAD_INV_ORDER exceptions on fast dual processor machines.
+ ACE_OS::sleep (1);
+ this->orb_->shutdown (0);
+}
diff --git a/TAO/tests/Bug_2241_Regression/Hello.h b/TAO/tests/Bug_2241_Regression/Hello.h
new file mode 100644
index 00000000000..1d5e27d075f
--- /dev/null
+++ b/TAO/tests/Bug_2241_Regression/Hello.h
@@ -0,0 +1,34 @@
+//
+// $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,
+ ACE_thread_t thr_id);
+
+ // = The skeleton methods
+ virtual char * get_string (void);
+
+ virtual void shutdown (void);
+
+private:
+ /// Use an ORB reference to conver strings to objects and shutdown
+ /// the application.
+ CORBA::ORB_var orb_;
+
+ ACE_thread_t thr_id_;
+};
+
+#include /**/ "ace/post.h"
+#endif /* HELLO_H */
diff --git a/TAO/tests/Bug_2241_Regression/Server_Task.cpp b/TAO/tests/Bug_2241_Regression/Server_Task.cpp
new file mode 100644
index 00000000000..98f37e052e3
--- /dev/null
+++ b/TAO/tests/Bug_2241_Regression/Server_Task.cpp
@@ -0,0 +1,87 @@
+//
+// $Id$
+//
+#include "Server_Task.h"
+#include "TestS.h"
+#include "Hello.h"
+
+#include "ace/Manual_Event.h"
+
+Server_Task::Server_Task (const ACE_TCHAR *output,
+ CORBA::ORB_ptr sorb,
+ ACE_Manual_Event &me,
+ ACE_Thread_Manager *thr_mgr)
+ : ACE_Task_Base (thr_mgr)
+ , output_ (output)
+ , me_ (me)
+ , sorb_ (CORBA::ORB::_duplicate (sorb))
+{
+}
+
+int
+Server_Task::svc (void)
+{
+ try
+ {
+ CORBA::Object_var poa_object =
+ this->sorb_->resolve_initial_references("RootPOA");
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in ());
+
+ 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 ();
+
+ Hello *hello_impl;
+ ACE_NEW_RETURN (hello_impl,
+ Hello (this->sorb_.in (),
+ ACE_Thread::self ()),
+ 1);
+
+ PortableServer::ServantBase_var owner_transfer(hello_impl);
+
+ PortableServer::ObjectId_var id =
+ root_poa->activate_object (hello_impl);
+
+ CORBA::Object_var object = root_poa->id_to_reference (id.in ());
+
+ Test::Hello_var hello =
+ Test::Hello::_narrow (object.in ());
+
+ CORBA::String_var ior =
+ this->sorb_->object_to_string (hello.in ());
+
+ // Output the IOR to the <this->output_>
+ FILE *output_file= ACE_OS::fopen (this->output_,
+ "w");
+ if (output_file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open output file for writing IOR: %s",
+ this->output_),
+ 1);
+
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
+
+ poa_manager->activate ();
+
+ // Signal the main thread before we call orb->run ();
+ this->me_.signal ();
+
+ this->sorb_->run ();
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/TAO/tests/Bug_2241_Regression/Server_Task.h b/TAO/tests/Bug_2241_Regression/Server_Task.h
new file mode 100644
index 00000000000..e42043c0711
--- /dev/null
+++ b/TAO/tests/Bug_2241_Regression/Server_Task.h
@@ -0,0 +1,48 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#ifndef COLLOCATED_SERVER_TASK_H
+#define COLLOCATED_SERVER_TASK_H
+
+#include /**/ "ace/pre.h"
+
+#include "ace/Task.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/ORB.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+class ACE_Manual_Event;
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+/// Implement a Task to run the server in a single thread
+class Server_Task : public ACE_Task_Base
+{
+public:
+ /// Constructor
+ Server_Task (const ACE_TCHAR *output,
+ CORBA::ORB_ptr sorb,
+ ACE_Manual_Event &me,
+ ACE_Thread_Manager *thr_mgr);
+
+ /// Thread entry point
+ int svc (void);
+
+private:
+ /// Output file for IOR
+ const ACE_TCHAR *output_;
+
+ /// Manual event to wake up the main thread to create a client
+ /// thread.
+ ACE_Manual_Event &me_;
+
+ CORBA::ORB_var sorb_;
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* COLLOCATED_SERVER_TASK_H */
diff --git a/TAO/tests/Bug_2241_Regression/Test.idl b/TAO/tests/Bug_2241_Regression/Test.idl
new file mode 100644
index 00000000000..3c0976e106d
--- /dev/null
+++ b/TAO/tests/Bug_2241_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 ();
+
+ /// 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_2241_Regression/run_test.pl b/TAO/tests/Bug_2241_Regression/run_test.pl
new file mode 100755
index 00000000000..e9c473e8341
--- /dev/null
+++ b/TAO/tests/Bug_2241_Regression/run_test.pl
@@ -0,0 +1,63 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+# $Id$
+# -*- perl -*-
+
+use lib "$ENV{ACE_ROOT}/bin";
+use PerlACE::TestTarget;
+
+my $server = PerlACE::TestTarget::create_target(1) || die "Create target 1 failed\n";
+
+$iorbase = "test.ior";
+my $server_iorfile = $server->LocalFile ($iorbase);
+$server->DeleteFile($iorbase);
+
+$status = 0;
+
+$SV = $server->CreateProcess ("Bug_2241_Regression");
+
+print STDERR "======== Running in Default Mode \n";
+$SV->Arguments ("-o $server_iorfile -k file://$server_iorfile");
+$sv = $SV->SpawnWaitKill ($server->ProcessStartWaitInterval());
+
+if ($sv != 0) {
+ print STDERR "ERROR in Collocated_Test\n";
+ $status = 1;
+}
+$server->DeleteFile($iorbase);
+
+print STDERR "======== Running with global ORBCollocationStrategy\n";
+$SV->Arguments ("-o $server_iorfile -k file://$server_iorfile -ORBCollocation global");
+$sv = $SV->SpawnWaitKill ($server->ProcessStartWaitInterval());
+
+if ($sv != 0) {
+ print STDERR "ERROR in Collocated_Test\n";
+ $status = 1;
+}
+$server->DeleteFile($iorbase);
+
+print STDERR "======== Running with global ORBCollocationStrategy thru_poa\n";
+$SV->Arguments ("-o $server_iorfile -k file://$server_iorfile -ORBCollocation global -ORBCollocationStrategy thru_poa");
+$sv = $SV->SpawnWaitKill ($server->ProcessStartWaitInterval());
+
+if ($sv != 0) {
+ print STDERR "ERROR in Collocated_Test\n";
+ $status = 1;
+}
+$server->DeleteFile($iorbase);
+
+print STDERR "======== Running with -ORBCollocation global -ORBCollocationStrategy direct \n";
+$SV->Arguments ("-o $server_iorfile -k file://$server_iorfile -ORBCollocation global -ORBCollocationStrategy direct");
+$sv = $SV->SpawnWaitKill ($server->ProcessStartWaitInterval());
+
+if ($sv != 0) {
+ print STDERR "ERROR in Collocated_Test\n";
+ $status = 1;
+}
+
+$server->DeleteFile($iorbase);
+$server->GetStderrLog();
+
+exit $status;