summaryrefslogtreecommitdiff
path: root/TAO/tests/Bug_3746_Regression
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tests/Bug_3746_Regression')
-rw-r--r--TAO/tests/Bug_3746_Regression/Test.idl20
-rw-r--r--TAO/tests/Bug_3746_Regression/Test_i.cpp28
-rw-r--r--TAO/tests/Bug_3746_Regression/Test_i.h34
-rw-r--r--TAO/tests/Bug_3746_Regression/client.cpp205
-rwxr-xr-xTAO/tests/Bug_3746_Regression/run_test.pl75
-rw-r--r--TAO/tests/Bug_3746_Regression/server.cpp112
6 files changed, 474 insertions, 0 deletions
diff --git a/TAO/tests/Bug_3746_Regression/Test.idl b/TAO/tests/Bug_3746_Regression/Test.idl
new file mode 100644
index 00000000000..df0af811264
--- /dev/null
+++ b/TAO/tests/Bug_3746_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 BoundSequences
+ {
+ typedef sequence<long, 10> SequenceOf10Long;
+ unsigned long SendSequenceOf10Long (in unsigned long LengthSent, in SequenceOf10Long inSeq);
+
+ /// 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_3746_Regression/Test_i.cpp b/TAO/tests/Bug_3746_Regression/Test_i.cpp
new file mode 100644
index 00000000000..684b38099e8
--- /dev/null
+++ b/TAO/tests/Bug_3746_Regression/Test_i.cpp
@@ -0,0 +1,28 @@
+//
+// $Id$
+//
+#include "Test_i.h"
+
+ACE_RCSID(TestLargeSequence,
+ TestLargeSequence,
+ "$Id$")
+
+BoundSequences::BoundSequences (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+{
+}
+
+::CORBA::ULong BoundSequences::SendSequenceOf10Long (const ::CORBA::ULong LengthSent, const ::Test::BoundSequences::SequenceOf10Long &inSeq)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "Server - BoundSequences::SendSequenceOf10Long (%u, length(%u)) is %C\n",
+ LengthSent, inSeq.length(),
+ ((LengthSent == inSeq.length())? "Correct" : "**** Incorrect ****")));
+ return inSeq.length();
+}
+
+void
+BoundSequences::shutdown (void)
+{
+ this->orb_->shutdown (0);
+}
diff --git a/TAO/tests/Bug_3746_Regression/Test_i.h b/TAO/tests/Bug_3746_Regression/Test_i.h
new file mode 100644
index 00000000000..5d51398d2f7
--- /dev/null
+++ b/TAO/tests/Bug_3746_Regression/Test_i.h
@@ -0,0 +1,34 @@
+//
+// $Id$
+//
+
+#ifndef HELLO_H
+#define HELLO_H
+#include /**/ "ace/pre.h"
+
+#include "TestS.h"
+
+/// Implement the Test::TestLargeSequence interface
+class BoundSequences
+ : public virtual POA_Test::BoundSequences
+{
+public:
+ /// Constructor
+ BoundSequences (CORBA::ORB_ptr orb);
+
+ // = The skeleton methods
+ virtual ::CORBA::ULong SendSequenceOf10Long (
+ ::CORBA::ULong LengthSent,
+ const ::Test::BoundSequences::SequenceOf10Long &inSeq
+ );
+
+ virtual void shutdown (void);
+
+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_3746_Regression/client.cpp b/TAO/tests/Bug_3746_Regression/client.cpp
new file mode 100644
index 00000000000..9093c0fa7bb
--- /dev/null
+++ b/TAO/tests/Bug_3746_Regression/client.cpp
@@ -0,0 +1,205 @@
+// $Id$
+
+#include "TestC.h"
+#include "ace/Get_Opt.h"
+
+ACE_RCSID(Bug_3746_Regression,
+ client,
+ "$Id$")
+
+const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
+
+int
+parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("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
+ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ int error= 0;
+ try
+ {
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ CORBA::Object_var tmp = orb->string_to_object(ior);
+
+ Test::BoundSequences_var TestThis =
+ Test::BoundSequences::_narrow(tmp.in ());
+
+ if (CORBA::is_nil (TestThis.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ "Nil Test::BoundSequences reference <%s>\n",
+ ior),
+ 1);
+ }
+
+ ////////////////////////////////////////////
+ ::Test::BoundSequences::SequenceOf10Long Seq;
+ ACE_DEBUG ((LM_DEBUG, "Client - Attempting to set length(11)\n"));
+ try
+ {
+ Seq.length (11);
+ ACE_DEBUG ((LM_DEBUG,
+ "Client - **FAILED** Incorrectly set length to %u\n",
+ Seq.length ()));
+ error= 1;
+ }
+ catch (const ::CORBA::BAD_PARAM &)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Client - Correctly threw bad_param\n"));
+ }
+ catch (const ::CORBA::Exception &ex)
+ {
+ ex._tao_print_exception ("Client - **FAILED** Incorrectly threw");
+ error= 1;
+ }
+ catch (...)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Client - **FAILED** Incorrectly threw something else\n"));
+ error= 1;
+ }
+
+ ////////////////////////////////////////////
+ ACE_DEBUG ((LM_DEBUG, "Client - Attempting to set length(10)\n"));
+ try
+ {
+ Seq.length (10);
+ ACE_DEBUG ((LM_DEBUG, "Client - %Correctly set length to %u\n",
+ ((10 == Seq.length ()) ? "C" : "**** Inc"),
+ Seq.length ()));
+ if (10 != Seq.length ())
+ error= 1;
+ }
+ catch (const ::CORBA::Exception &ex)
+ {
+ ex._tao_print_exception ("Client - **FAILED** Incorrectly threw");
+ error= 1;
+ }
+ catch (...)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Client - **FAILED** Incorrectly threw something else\n"));
+ error= 1;
+ }
+
+ //////////////////////////////////////////
+ ACE_DEBUG ((LM_DEBUG, "Client - Accessing [0]\n"));
+ try
+ {
+ // Just to read access Seq[0] without optimizing away
+ ACE_DEBUG ((LM_DEBUG, "", Seq[0]));
+ ACE_DEBUG ((LM_DEBUG, "Client - Correctly allowed access to [0]\n"));
+ }
+ catch (const ::CORBA::Exception &ex)
+ {
+ ex._tao_print_exception ("Client - **FAILED** Incorrectly threw");
+ error= 1;
+ }
+ catch (...)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Client - **FAILED** Incorrectly threw something else\n"));
+ error= 1;
+ }
+
+ ////////////////////////////////////////////
+ ACE_DEBUG ((LM_DEBUG, "Client - Accessing [10]\n"));
+ try
+ {
+ // Just to read access Seq[10] without optimizing away
+ ACE_DEBUG ((LM_DEBUG, "", Seq[10]));
+#if defined (TAO_CHECKED_SEQUENCE_INDEXING) && (TAO_CHECKED_SEQUENCE_INDEXING == 1)
+ ACE_DEBUG ((LM_DEBUG,
+ "Client - **** Incorrectly allowed access to [10]\n"));
+ error= 1;
+ }
+ catch (const ::CORBA::BAD_PARAM &)
+ {
+ ACE_DEBUG ((LM_DEBUG, "Client - Correctly threw bad_param\n"));
+#else
+ ACE_DEBUG ((LM_DEBUG, "Client - Correctly allowed access to [10]\n"));
+#endif // TAO_CHECKED_SEQUENCE_INDEXING
+ }
+ catch (const ::CORBA::Exception &ex)
+ {
+ ex._tao_print_exception ("Client - **FAILED** Incorrectly threw");
+ error= 1;
+ }
+ catch (...)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Client - **FAILED** Incorrectly threw something else\n"));
+ error= 1;
+ }
+
+ ////////////////////////////////////////////
+ ACE_DEBUG ((LM_DEBUG, "Client - Sending Seq\n"));
+ ::CORBA::ULong result;
+ try
+ {
+ result= TestThis->SendSequenceOf10Long (Seq.length (), Seq);
+ if (result != Seq.length())
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Client - **FAILED** Sent %u longs but "
+ "server received %u longs\n",
+ Seq.length(), result));
+ error= 1;
+ }
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ "Client - **SUCCESS** Sent and Server got %u longs\n",
+ result));
+ }
+ catch (const ::CORBA::Exception &ex)
+ {
+ ex._tao_print_exception ("Client - **FAILED** Incorrectly threw");
+ error= 1;
+ }
+ catch (...)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Client - **FAILED** Incorrectly threw something else\n"));
+ error= 1;
+ }
+
+ ////////////////////////////////////////////
+ ACE_DEBUG ((LM_DEBUG, "Client - Shutting down Server\n"));
+ TestThis->shutdown ();
+
+ ACE_DEBUG ((LM_DEBUG, "Client - Finishing\n"));
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Client - Exception caught:");
+ error= 1;
+ }
+
+ return error;
+}
diff --git a/TAO/tests/Bug_3746_Regression/run_test.pl b/TAO/tests/Bug_3746_Regression/run_test.pl
new file mode 100755
index 00000000000..ada2dbda5a4
--- /dev/null
+++ b/TAO/tests/Bug_3746_Regression/run_test.pl
@@ -0,0 +1,75 @@
+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;
+
+$status = 0;
+$debug_level = '0';
+
+foreach $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = '10';
+ }
+}
+
+my $server = PerlACE::TestTarget::create_target (1) || die "Create Client failed\n";
+my $client = PerlACE::TestTarget::create_target (2) || die "Create Server failed\n";
+
+my $iorbase = "test.ior";
+my $server_iorfile = $server->LocalFile ($iorbase);
+my $client_iorfile = $client->LocalFile ($iorbase);
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
+
+$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile");
+$CL = $client->CreateProcess ("client", "-k file://$client_iorfile");
+
+print "Starting Server\n";
+$server_status = $SV->Spawn ();
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ exit 1;
+}
+
+if ($server->WaitForFileTimed ($iorbase,
+ $server->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+
+if ($server->GetFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+print "Starting Client\n";
+$client_status = $CL->SpawnWaitKill (30); #$client->ProcessStartWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval());
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ $status = 1;
+}
+
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
+
+exit $status;
diff --git a/TAO/tests/Bug_3746_Regression/server.cpp b/TAO/tests/Bug_3746_Regression/server.cpp
new file mode 100644
index 00000000000..c6f2435e88e
--- /dev/null
+++ b/TAO/tests/Bug_3746_Regression/server.cpp
@@ -0,0 +1,112 @@
+// $Id$
+
+#include "Test_i.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_stdio.h"
+
+ACE_RCSID (Bug_3746_Regression,
+ server,
+ "$Id$")
+
+const ACE_TCHAR *ior_output_file = ACE_TEXT ("test.ior");
+
+int
+parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("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
+ACE_TMAIN(int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv);
+
+ CORBA::Object_var poa_object =
+ orb->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 ();
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ BoundSequences *test_impl = 0;
+ ACE_NEW_RETURN (test_impl,
+ BoundSequences (orb.in ()),
+ 1);
+ PortableServer::ServantBase_var owner_transfer (test_impl);
+
+ PortableServer::ObjectId_var id =
+ root_poa->activate_object (test_impl);
+
+ CORBA::Object_var object = root_poa->id_to_reference (id.in ());
+
+ Test::BoundSequences_var theServer =
+ Test::BoundSequences::_narrow (object.in ());
+
+ CORBA::String_var ior = orb->object_to_string (theServer.in ());
+
+ // 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,
+ "Server - Cannot open output file for writing IOR: %s\n",
+ ior_output_file),
+ 1);
+ }
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
+
+ poa_manager->activate ();
+
+ orb->run ();
+
+ ACE_DEBUG ((LM_DEBUG, "Server - Event loop finished\n"));
+
+ root_poa->destroy (1, 1);
+
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Server - Exception caught:");
+ return 1;
+ }
+
+ return 0;
+}