summaryrefslogtreecommitdiff
path: root/TAO/tests/SHMIOP
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tests/SHMIOP')
-rw-r--r--TAO/tests/SHMIOP/SHMIOP_Test.mpc11
-rw-r--r--TAO/tests/SHMIOP/Test.idl9
-rw-r--r--TAO/tests/SHMIOP/run_test.pl84
-rw-r--r--TAO/tests/SHMIOP/run_test_collocated.pl40
-rw-r--r--TAO/tests/SHMIOP/shmiop_test.cpp126
-rw-r--r--TAO/tests/SHMIOP/static_shmiop.conf1
6 files changed, 271 insertions, 0 deletions
diff --git a/TAO/tests/SHMIOP/SHMIOP_Test.mpc b/TAO/tests/SHMIOP/SHMIOP_Test.mpc
new file mode 100644
index 00000000000..8ccc71387cc
--- /dev/null
+++ b/TAO/tests/SHMIOP/SHMIOP_Test.mpc
@@ -0,0 +1,11 @@
+project: taoidldefaults, taoserver, strategies {
+ exename = shmiop_test
+
+ IDL_Files {
+ Test.idl
+ }
+
+ Source_Files {
+ shmiop_test.cpp
+ }
+}
diff --git a/TAO/tests/SHMIOP/Test.idl b/TAO/tests/SHMIOP/Test.idl
new file mode 100644
index 00000000000..1f8ff5e7970
--- /dev/null
+++ b/TAO/tests/SHMIOP/Test.idl
@@ -0,0 +1,9 @@
+module Test
+{
+ interface Hello
+ {
+ string get_string ();
+
+ oneway void shutdown ();
+ };
+};
diff --git a/TAO/tests/SHMIOP/run_test.pl b/TAO/tests/SHMIOP/run_test.pl
new file mode 100644
index 00000000000..a4b44408ed5
--- /dev/null
+++ b/TAO/tests/SHMIOP/run_test.pl
@@ -0,0 +1,84 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+use lib "$ENV{ACE_ROOT}/bin";
+use PerlACE::TestTarget;
+use strict;
+
+my $status = 0;
+my $debug_level = 0;
+my $cdebug_level = 0;
+my $extra;
+foreach my $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = 10;
+ }
+ elsif ($i eq '-cdebug') {
+ $cdebug_level = 10;
+ }
+ elsif ($i eq 'with_collocated') {
+ $extra = "-s temp.ior";
+ }
+}
+
+my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
+my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
+
+my $iorbase = "server.ior";
+my $server_iorfile = $server->LocalFile ($iorbase);
+my $client_iorfile = $client->LocalFile ($iorbase);
+$server->DeleteFile ($iorbase);
+$client->DeleteFile ($iorbase);
+
+my $shm = '-ORBSvcConf static_shmiop.conf -ORBListenEndpoints shmiop://';
+
+my $SV = $server->CreateProcess ("shmiop_test", "-ORBDebugLevel $debug_level $shm -s $server_iorfile");
+my $CL = $client->CreateProcess ("shmiop_test", "-ORBDebugLevel $cdebug_level $shm -c $client_iorfile $extra");
+my $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;
+}
+
+my $client_status = $CL->SpawnWaitKill ($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);
+
+if ($extra ne '') {
+ unlink 'temp.ior';
+}
+
+exit $status;
diff --git a/TAO/tests/SHMIOP/run_test_collocated.pl b/TAO/tests/SHMIOP/run_test_collocated.pl
new file mode 100644
index 00000000000..2a6f251b73a
--- /dev/null
+++ b/TAO/tests/SHMIOP/run_test_collocated.pl
@@ -0,0 +1,40 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+use lib "$ENV{ACE_ROOT}/bin";
+use PerlACE::TestTarget;
+use strict;
+
+my $debug_level = 0;
+foreach my $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = 10;
+ }
+}
+
+my $target = PerlACE::TestTarget::create_target(1) || die "Create target 1 failed\n";
+
+my $iorbase = "server.ior";
+my $server_iorfile = $target->LocalFile ($iorbase);
+$target->DeleteFile ($iorbase);
+
+my $status = 0;
+
+print "Collocated\n\n";
+
+my $shm = '-ORBSvcConf static_shmiop.conf -ORBListenEndpoints shmiop://';
+
+my $SV = $target->CreateProcess ("shmiop_test", "-ORBDebugLevel $debug_level $shm " .
+ "-s $server_iorfile -c $server_iorfile");
+
+my $server = $SV->SpawnWaitKill ($target->ProcessStartWaitInterval ());
+
+if ($server != 0) {
+ print STDERR "ERROR: Collocated test returned $server\n";
+ $status = 1;
+}
+
+$target->DeleteFile ($iorbase);
+
+exit $status;
diff --git a/TAO/tests/SHMIOP/shmiop_test.cpp b/TAO/tests/SHMIOP/shmiop_test.cpp
new file mode 100644
index 00000000000..dfbd3699508
--- /dev/null
+++ b/TAO/tests/SHMIOP/shmiop_test.cpp
@@ -0,0 +1,126 @@
+#include "TestS.h"
+
+#include "tao/Strategies/advanced_resource.h"
+
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/SString.h"
+#include "ace/Task.h"
+
+struct Servant : virtual POA_Test::Hello
+{
+ explicit Servant (const CORBA::ORB_var &orb)
+ : orb_ (orb)
+ {}
+
+ char *get_string ()
+ {
+ CORBA::String_var str ("hello");
+ return str._retn ();
+ }
+
+ void shutdown ()
+ {
+ this->orb_->shutdown (0);
+ }
+
+ CORBA::ORB_var orb_;
+};
+
+struct ORBTask : ACE_Task_Base
+{
+ explicit ORBTask (const CORBA::ORB_var &orb)
+ : orb_ (orb)
+ {}
+
+ int svc ()
+ {
+ try
+ {
+ this->orb_->run ();
+ return 0;
+ }
+ catch (const CORBA::Exception &e)
+ {
+ e._tao_print_exception ("Exception caught from ORB::run:");
+ }
+ catch (...)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR unknown exception caught ")
+ ACE_TEXT ("from ORB::run\n")));
+ }
+ return 1;
+ }
+
+ CORBA::ORB_var orb_;
+};
+
+int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
+ ACE_Get_Opt opts (argc, argv, ACE_TEXT ("s:c:"));
+ const ACE_TCHAR *server = 0, *client = 0;
+ for (int o; (o = opts ()) != -1;)
+ {
+ switch (o)
+ {
+ case 's':
+ server = opts.opt_arg ();
+ break;
+ case 'c':
+ client = opts.opt_arg ();
+ break;
+ }
+ }
+
+ Servant srv (orb);
+ ORBTask task (orb);
+
+ if (server)
+ {
+ CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
+ PortableServer::POA_var poa = PortableServer::POA::_narrow (obj);
+ PortableServer::POAManager_var pm = poa->the_POAManager ();
+ pm->activate ();
+ Test::Hello_var srv_obj = srv._this ();
+ CORBA::String_var srv_str = orb->object_to_string (srv_obj);
+ FILE *f = ACE_OS::fopen (server, "w");
+ ACE_OS::fputs (srv_str, f);
+ ACE_OS::fclose (f);
+ if (!client)
+ task.activate();
+ }
+
+ if (client)
+ {
+ ACE_CString ior ("file://");
+ ior += ACE_TEXT_ALWAYS_CHAR (client);
+ CORBA::Object_var obj = orb->string_to_object (ior.c_str ());
+ Test::Hello_var hello = Test::Hello::_narrow (obj);
+ CORBA::String_var str = hello->get_string ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) - returned <%C>\n"),
+ str.in ()));
+ hello->shutdown ();
+ }
+ else if (server)
+ {
+ task.wait ();
+ }
+
+ orb->destroy ();
+ return 0;
+ }
+ catch (const CORBA::Exception &e)
+ {
+ e._tao_print_exception ("Exception caught:");
+ }
+ catch (...)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR unknown exception ")
+ ACE_TEXT ("caught in main\n")));
+ }
+ return 1;
+}
diff --git a/TAO/tests/SHMIOP/static_shmiop.conf b/TAO/tests/SHMIOP/static_shmiop.conf
new file mode 100644
index 00000000000..7fac80fcca5
--- /dev/null
+++ b/TAO/tests/SHMIOP/static_shmiop.conf
@@ -0,0 +1 @@
+static Advanced_Resource_Factory "-ORBProtocolFactory SHMIOP_Factory"