summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2007-04-15 06:19:54 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2007-04-15 06:19:54 +0000
commit0dd308ed29d50afa0ef6d92e27389fbc4db29f16 (patch)
tree7b04997b93b825ff6fb29d795f8aa5434159f521
parent952f51dae7f8e7f3d221627908722b6d17eb1880 (diff)
downloadATCD-0dd308ed29d50afa0ef6d92e27389fbc4db29f16.tar.gz
Sun Apr 15 06:18:56 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl>
-rw-r--r--TAO/ChangeLog9
-rw-r--r--TAO/tests/AMI/AMI.mpc1
-rw-r--r--TAO/tests/AMI/client.cpp22
-rwxr-xr-xTAO/tests/AMI/run_test.pl11
-rw-r--r--TAO/tests/Bug_2805_Regression/Bug_2805_Regression.mpc22
-rw-r--r--TAO/tests/Bug_2805_Regression/ami_test.idl39
-rw-r--r--TAO/tests/Bug_2805_Regression/ami_test_i.cpp99
-rw-r--r--TAO/tests/Bug_2805_Regression/ami_test_i.h61
-rw-r--r--TAO/tests/Bug_2805_Regression/client.cpp316
-rwxr-xr-xTAO/tests/Bug_2805_Regression/run_test.pl34
10 files changed, 587 insertions, 27 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index bab43f2c455..c4d41fcdbc1 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,12 @@
+Sun Apr 15 06:18:56 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * tests/AMI/client.cpp:
+ * tests/AMI/AMI.mpc:
+ * tests/AMI/run_test.pl:
+ * tests/Bug_2805_Regression/*:
+ Moved test for bug 2805 to its own regression, now the AMI
+ test should succeed again, but 2805 is failing
+
Sun Apr 15 06:01:56 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl>
* tests/Any/Recursive/Test.idl:
diff --git a/TAO/tests/AMI/AMI.mpc b/TAO/tests/AMI/AMI.mpc
index 1752743fd2e..eb64c8382f6 100644
--- a/TAO/tests/AMI/AMI.mpc
+++ b/TAO/tests/AMI/AMI.mpc
@@ -26,7 +26,6 @@ project(*Client): messaging, taoexe, portableserver, ami {
client.cpp
ami_testS.cpp
ami_testC.cpp
- ami_test_i.cpp
}
IDL_Files {
}
diff --git a/TAO/tests/AMI/client.cpp b/TAO/tests/AMI/client.cpp
index 408da1f031c..22157591b94 100644
--- a/TAO/tests/AMI/client.cpp
+++ b/TAO/tests/AMI/client.cpp
@@ -27,7 +27,6 @@ int nthreads = 5;
int niterations = 5;
int debug = 0;
int number_of_replies = 0;
-bool collocated = false;
CORBA::Long in_number = 931232;
const char * in_str = "Let's talk AMI.";
@@ -36,15 +35,12 @@ int parameter_corruption = 0;
int
parse_args (int argc, char *argv[])
{
- ACE_Get_Opt get_opts (argc, argv, "cdk:n:i:");
+ ACE_Get_Opt get_opts (argc, argv, "dk:n:i:");
int c;
while ((c = get_opts ()) != -1)
switch (c)
{
- case 'c':
- collocated = true;
- break;
case 'd':
debug = 1;
break;
@@ -199,19 +195,9 @@ main (int argc, char *argv[])
A::AMI_Test_var server;
- if (!collocated)
- {
- CORBA::Object_var object =
- orb->string_to_object (ior);
-
- server = A::AMI_Test::_narrow (object.in ());
- }
- else
- {
- AMI_Test_i * servant =
- new AMI_Test_i(orb.in(), in_number, in_str, true);
- server = servant->_this();
- }
+ CORBA::Object_var object =
+ orb->string_to_object (ior);
+ server = A::AMI_Test::_narrow (object.in ());
if (CORBA::is_nil (server.in ()))
{
diff --git a/TAO/tests/AMI/run_test.pl b/TAO/tests/AMI/run_test.pl
index dda1be7f98b..a1161d018d7 100755
--- a/TAO/tests/AMI/run_test.pl
+++ b/TAO/tests/AMI/run_test.pl
@@ -30,10 +30,10 @@ $iorfile = PerlACE::LocalFile ("server.ior");
unlink $iorfile;
if (PerlACE::is_vxworks_test()) {
- $SV = new PerlACE::ProcessVX ("server", "-ORBdebuglevel $debug_level -d -o server.ior");
+ $SV = new PerlACE::ProcessVX ("server", "-ORBdebuglevel $debug_level -o server.ior");
}
else {
- $SV = new PerlACE::Process ("server", "-ORBdebuglevel $debug_level -d -o $iorfile");
+ $SV = new PerlACE::Process ("server", "-ORBdebuglevel $debug_level -o $iorfile");
}
$SV->Spawn ();
@@ -62,14 +62,9 @@ $client2 = $CL2->SpawnWaitKill (60);
$server = $SV->WaitKill (10);
-$CL3 = new PerlACE::Process ("client",
- "-c -ORBdebuglevel $debug_level");
-
-$client3 = $CL3->SpawnWaitKill (60);
-
unlink $iorfile;
-if ($server != 0 || $client != 0 || $client2 != 0 || $client3 != 0) {
+if ($server != 0 || $client != 0 || $client2 != 0) {
exit 1;
}
diff --git a/TAO/tests/Bug_2805_Regression/Bug_2805_Regression.mpc b/TAO/tests/Bug_2805_Regression/Bug_2805_Regression.mpc
new file mode 100644
index 00000000000..403d3b798ae
--- /dev/null
+++ b/TAO/tests/Bug_2805_Regression/Bug_2805_Regression.mpc
@@ -0,0 +1,22 @@
+// -*- MPC -*-
+// $Id$
+
+project(*idl): taoidldefaults, ami {
+ IDL_Files {
+ ami_test.idl
+ }
+ custom_only = 1
+}
+
+project(*Client): messaging, taoexe, portableserver, ami {
+ after += *idl
+ Source_Files {
+ client.cpp
+ ami_testS.cpp
+ ami_testC.cpp
+ ami_test_i.cpp
+ }
+ IDL_Files {
+ }
+}
+
diff --git a/TAO/tests/Bug_2805_Regression/ami_test.idl b/TAO/tests/Bug_2805_Regression/ami_test.idl
new file mode 100644
index 00000000000..ffdc66d63d5
--- /dev/null
+++ b/TAO/tests/Bug_2805_Regression/ami_test.idl
@@ -0,0 +1,39 @@
+
+//=============================================================================
+/**
+ * @file ami_test.idl
+ *
+ * $Id$
+ *
+ * IDL description of the AMI Test interface
+ *
+ *
+ * @author Alexander Babu Arulanthu <alex@cs.wustl.edu>
+ * @author Michael Kircher <Michael.Kircher@mchp.siemens.de>
+ */
+//=============================================================================
+
+
+
+module A
+ {
+ exception DidTheRightThing {
+ long id;
+ string whatDidTheRightThing;
+ };
+
+ interface AMI_Test
+ {
+ long foo (out long out_l,
+ in long in_l,
+ in string in_str)
+ raises (DidTheRightThing);
+
+ attribute long yadda;
+
+ oneway void shutdown ();
+
+ void inout_arg_test (inout string str);
+ };
+
+ };
diff --git a/TAO/tests/Bug_2805_Regression/ami_test_i.cpp b/TAO/tests/Bug_2805_Regression/ami_test_i.cpp
new file mode 100644
index 00000000000..910cfd842b4
--- /dev/null
+++ b/TAO/tests/Bug_2805_Regression/ami_test_i.cpp
@@ -0,0 +1,99 @@
+
+//=============================================================================
+/**
+ * @file ami_test_i.cpp
+ *
+ * $Id$
+ *
+ * Implementation of the AMI Test interface.
+ *
+ *
+ * @author Alexander Babu Arulanthu <alex@cs.wustl.edu>
+ * @author Michael Kircher <Michael.Kircher@mchp.siemens.de>
+ */
+//=============================================================================
+
+
+#include "ami_test_i.h"
+#include "tao/debug.h"
+
+ACE_RCSID(AMI, ami_test_i, "$Id$")
+
+AMI_Test_i::AMI_Test_i (CORBA::ORB_ptr orb,
+ CORBA::Long in_l,
+ const char * in_str,
+ bool check_params)
+ : orb_ (CORBA::ORB::_duplicate (orb)),
+ number_ ((CORBA::Long) 931232),
+ yadda_ ((CORBA::Long) 140474),
+ in_l_ (in_l),
+ in_str_(CORBA::string_dup(in_str)),
+ check_params_(check_params)
+{
+}
+
+CORBA::Long
+AMI_Test_i::foo (CORBA::Long_out out_l,
+ CORBA::Long in_l,
+ const char* in_str)
+{
+ out_l = 931233;
+
+ //if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "%N:%l:(%P:%t):AMI_Test_i::foo: %d %s\n",
+ in_l,
+ in_str));
+
+ if (in_l == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Throwing Exception: A::DidTheRightThing\n"));
+ throw A::DidTheRightThing();
+ }
+
+ if (check_params_)
+ {
+ if (in_l_ != in_l || ACE_OS::strcmp(in_str_.in (), in_str) != 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "ERROR: Parameter corruption on in parameters: %d %d %s %s.\n",
+ in_l_, in_l, in_str_.in (), in_str));
+ return 0;
+ }
+ }
+
+ return 931234;
+}
+
+void
+AMI_Test_i::shutdown (void)
+{
+ this->orb_->shutdown (0);
+}
+
+
+CORBA::Long
+AMI_Test_i::yadda (void)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "%N:%l:(%P:%t):AMI_Test_i::(get_)yadda\n"));
+ return yadda_;
+}
+
+
+void
+AMI_Test_i::yadda (CORBA::Long yadda)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "%N:%l:(%P:%t):AMI_Test_i::(set_)yadda\n"));
+ yadda_ = yadda;
+}
+
+void
+AMI_Test_i::inout_arg_test (char *&)
+{
+ // No action, this operation is to test code generation for INOUT
+ // args in AMI operations.
+}
+
diff --git a/TAO/tests/Bug_2805_Regression/ami_test_i.h b/TAO/tests/Bug_2805_Regression/ami_test_i.h
new file mode 100644
index 00000000000..9ff1fe8cfb8
--- /dev/null
+++ b/TAO/tests/Bug_2805_Regression/ami_test_i.h
@@ -0,0 +1,61 @@
+
+//=============================================================================
+/**
+ * @file ami_test_i.h
+ *
+ * $Id$
+ *
+ * @author Michael Kircher <Michael.Kircher@mchp.siemens.de>
+ */
+//=============================================================================
+
+
+#ifndef TAO_AMI_TEST_I_H
+#define TAO_AMI_TEST_I_H
+
+#include "ami_testS.h"
+
+/**
+ * @class AMI_Test_i
+ *
+ * @brief AMI Test implementation
+ *
+ * Implements the AMI_Test interface in test.idl
+ */
+class AMI_Test_i : public POA_A::AMI_Test
+{
+public:
+ /// ctor
+ AMI_Test_i (CORBA::ORB_ptr orb,
+ CORBA::Long in_l = 0, const char * in_str = 0,
+ bool check_params = false);
+
+ // The AMI_Test methods.
+ CORBA::Long foo (CORBA::Long_out out_l,
+ CORBA::Long in_l,
+ const char* in_str);
+
+ void shutdown (void);
+
+ CORBA::Long yadda (void);
+
+ void yadda (CORBA::Long yadda);
+
+ void inout_arg_test (char *& str);
+
+private:
+ CORBA::ORB_var orb_;
+
+ CORBA::Long number_;
+
+ CORBA::Long yadda_;
+
+ CORBA::Long in_l_;
+
+ CORBA::String_var in_str_;
+
+ bool check_params_;
+};
+
+#endif /* TAO_AMI_TEST_I_H */
+
diff --git a/TAO/tests/Bug_2805_Regression/client.cpp b/TAO/tests/Bug_2805_Regression/client.cpp
new file mode 100644
index 00000000000..bd1d6952889
--- /dev/null
+++ b/TAO/tests/Bug_2805_Regression/client.cpp
@@ -0,0 +1,316 @@
+
+//=============================================================================
+/**
+ * @file client.cpp
+ *
+ * $Id$
+ *
+ * A client which uses the AMI callback model.
+ *
+ *
+ * @author Alexander Babu Arulanthu <alex@cs.wustl.edu>
+ * @author Michael Kircher <Michael.Kircher@mchp.siemens.de>
+ */
+//=============================================================================
+
+
+#include "ace/Get_Opt.h"
+#include "ace/Task.h"
+#include "ami_test_i.h"
+
+ACE_RCSID (AMI,
+ client,
+ "$Id$")
+
+const char *ior = "file://test.ior";
+int nthreads = 5;
+int niterations = 5;
+int debug = 0;
+int number_of_replies = 0;
+
+CORBA::Long in_number = 931232;
+const char * in_str = "Let's talk AMI.";
+int parameter_corruption = 0;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "dk:n:i:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'd':
+ debug = 1;
+ break;
+ case 'k':
+ ior = get_opts.opt_arg ();
+ break;
+ case 'n':
+ nthreads = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+ case 'i':
+ niterations = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-d "
+ "-k <ior> "
+ "-n <nthreads> "
+ "-i <niterations> "
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates sucessful parsing of the command line
+ return 0;
+}
+
+
+/**
+ * @class Client
+ *
+ * @brief Run the client thread
+ *
+ * Use the ACE_Task_Base class to run the client threads.
+ */
+class Client : public ACE_Task_Base
+{
+public:
+ /// ctor
+ Client (A::AMI_Test_ptr server, int niterations);
+
+ /// The thread entry point.
+ virtual int svc (void);
+
+ // private:
+ /// Var for the AMI_Test object.
+ A::AMI_Test_var ami_test_var_;
+
+ /// The number of iterations on each client thread.
+ int niterations_;
+
+ /// Var for AMI_AMI_Test_ReplyHandler object.
+ A::AMI_AMI_TestHandler_var the_handler_var_;
+};
+
+class Handler : public POA_A::AMI_AMI_TestHandler
+{
+public:
+ Handler (void)
+ {
+ };
+
+ void foo (CORBA::Long result,
+ CORBA::Long out_l)
+ {
+ if (result == 0)
+ {
+ ACE_ERROR((LM_ERROR, "ERROR: Callback method detected parameter corruption.\n"));
+ parameter_corruption = 1;
+ }
+
+ if (debug)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P | %t) : Callback method called: result <%d>, out_arg <%d>\n",
+ result,
+ out_l));
+ }
+
+ --number_of_replies;
+ };
+
+ void foo_excep (::Messaging::ExceptionHolder * excep_holder)
+ {
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Callback method <foo_excep> called: \n"));
+ try
+ {
+ excep_holder->raise_exception ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Caught exception:");
+ }
+ };
+
+ void get_yadda (CORBA::Long result)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Callback method <get_yadda> called: result <%d>\n",
+ result));
+ };
+
+ void get_yadda_excep (::Messaging::ExceptionHolder *)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Callback method <get_yadda_excep> called: \n"));
+ };
+
+ void set_yadda (void)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Callback method <set_yadda> called: \n"));
+ };
+
+ void set_yadda_excep (::Messaging::ExceptionHolder *)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Callback method <set_yadda_excep> called: \n"));
+ };
+ ~Handler (void)
+ {
+ };
+
+ void inout_arg_test (const char *)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Callback method <set_yadda_excep> called: \n"));
+ }
+
+ void inout_arg_test_excep (::Messaging::ExceptionHolder *)
+ {
+ }
+};
+
+// ReplyHandler.
+Handler handler;
+
+int
+main (int argc, char *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv);
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ A::AMI_Test_var server;
+
+ AMI_Test_i * servant =
+ new AMI_Test_i(orb.in(), in_number, in_str, true);
+ server = servant->_this();
+
+ if (CORBA::is_nil (server.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Object reference <%s> is nil\n",
+ ior),
+ 1);
+ }
+
+ // Activate POA to handle the call back.
+
+ CORBA::Object_var poa_object =
+ orb->resolve_initial_references("RootPOA");
+
+ if (CORBA::is_nil (poa_object.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to initialize the POA.\n"),
+ 1);
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in ());
+
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager ();
+
+ poa_manager->activate ();
+
+ // Let the client perform the test in a separate thread
+
+ Client client (server.in (), niterations);
+ if (client.activate (THR_NEW_LWP | THR_JOINABLE,
+ nthreads) != 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot activate client threads\n"),
+ 1);
+
+ // Main thread collects replies. It needs to collect
+ // <nthreads*niterations> replies.
+ number_of_replies = nthreads *niterations;
+
+ if (debug)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) : Entering perform_work loop to receive <%d> replies\n",
+ number_of_replies));
+ }
+
+ // ORB loop.
+
+ while (number_of_replies > 0)
+ {
+ CORBA::Boolean pending = orb->work_pending();
+
+ if (pending)
+ {
+ orb->perform_work();
+ }
+ }
+
+ if (debug)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) : Exited perform_work loop Received <%d> replies\n",
+ (nthreads*niterations) - number_of_replies));
+ }
+
+ client.thr_mgr ()->wait ();
+
+ ACE_DEBUG ((LM_DEBUG, "threads finished\n"));
+
+ root_poa->destroy (1, // ethernalize objects
+ 0 // wait for completion
+ );
+
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Caught exception:");
+ return 1;
+ }
+
+ return parameter_corruption;
+}
+
+// ****************************************************************
+
+Client::Client (A::AMI_Test_ptr server,
+ int niterations)
+ : ami_test_var_ (A::AMI_Test::_duplicate (server)),
+ niterations_ (niterations)
+{
+ the_handler_var_ = handler._this (/* */);
+}
+
+int
+Client::svc (void)
+{
+ try
+ {
+ for (int i = 0; i < this->niterations_; ++i)
+ {
+ ami_test_var_->sendc_foo (the_handler_var_.in (), in_number, in_str);
+ }
+ if (debug)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P | %t):<%d> Asynchronous methods issued\n",
+ niterations));
+ }
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("MT_Client: exception raised");
+ }
+ return 0;
+}
diff --git a/TAO/tests/Bug_2805_Regression/run_test.pl b/TAO/tests/Bug_2805_Regression/run_test.pl
new file mode 100755
index 00000000000..5eb689ff196
--- /dev/null
+++ b/TAO/tests/Bug_2805_Regression/run_test.pl
@@ -0,0 +1,34 @@
+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::Run_Test;
+
+$debug_level = '0';
+$iterations = '1';
+
+foreach $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = '1';
+ }
+}
+
+if (PerlACE::is_vxworks_test()) {
+ $CL = new PerlACE::ProcessVX ("client", "-ORBdebuglevel $debug_level");
+}
+else {
+ $CL = new PerlACE::Process ("client", "-ORBdebuglevel $debug_level");
+}
+
+$client = $CL->SpawnWaitKill (60);
+
+if ($client != 0) {
+ exit 1;
+}
+
+exit 0;
+