summaryrefslogtreecommitdiff
path: root/TAO/DevGuideExamples
diff options
context:
space:
mode:
authordbudko <dbudko@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-11-20 09:30:08 +0000
committerdbudko <dbudko@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-11-20 09:30:08 +0000
commit36c78fff873dadec71a5d1405bac10ab34a802fa (patch)
tree7abac907ea72817aa256f749054205ae05a0f04d /TAO/DevGuideExamples
parent09c7e9bb146c39cae19cb8a8a89493815702e88a (diff)
downloadATCD-36c78fff873dadec71a5d1405bac10ab34a802fa.tar.gz
Fri Nov 20 09:28:50 UTC 2009 Denis Budko <denis.budko@remedy.nl>
* orbsvcs/DevGuideExamples/EventServices/OMG_TypedEC/run_test.pl: * orbsvcs/DevGuideExamples/EventServices/RTEC_Federated/run_test.pl: * orbsvcs/DevGuideExamples/EventServices/OMG_SupplierSideEC/run_test.pl: * orbsvcs/DevGuideExamples/EventServices/RTEC_Filter/run_test.pl: * orbsvcs/DevGuideExamples/EventServices/OMG_Basic/run_test.pl: * orbsvcs/DevGuideExamples/EventServices/RTEC_MCast_Federated/run_test.pl: * orbsvcs/DevGuideExamples/EventServices/RTEC_Basic/run_test.pl: * orbsvcs/tests/Security/EndpointPolicy/run_test.pl: * DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp: * DevGuideExamples/Multithreading/ThreadPool/MessengerClient.cpp: * DevGuideExamples/Multithreading/ThreadPool/run_test.pl: * DevGuideExamples/Multithreading/GracefulShutdown/MessengerServer.cpp: * DevGuideExamples/Multithreading/GracefulShutdown/MessengerClient.cpp: * DevGuideExamples/Multithreading/GracefulShutdown/run_test.pl: * DevGuideExamples/Multithreading/ThreadPerConnection/MessengerServer.cpp: * DevGuideExamples/Multithreading/ThreadPerConnection/MessengerClient.cpp: * DevGuideExamples/Multithreading/ThreadPerConnection/run_test.pl: * DevGuideExamples/AMH_AMI/inner_server.cpp: * DevGuideExamples/AMH_AMI/client.cpp: * DevGuideExamples/AMH_AMI/middle_server.cpp: * DevGuideExamples/AMH_AMI/run_test.pl: * tests/OctetSeq/run_test1.pl: * tests/OctetSeq/run_test2.pl: * tests/OctetSeq/run_test.pl: * tests/Bug_1330_Regression/server.cpp: * tests/Bug_1330_Regression/run_test.pl: * tests/Leader_Followers/run_test.pl: * tests/NestedUpcall/MT_Client_Test/run_test.pl: * tests/Bug_2702_Regression/run_test.pl: * tests/IPV6/run_test.pl: * tests/MProfile_Connection_Timeout/run_test.pl: Tests are converted to use new test framework and added to fuzz build.
Diffstat (limited to 'TAO/DevGuideExamples')
-rw-r--r--TAO/DevGuideExamples/AMH_AMI/client.cpp35
-rw-r--r--TAO/DevGuideExamples/AMH_AMI/inner_server.cpp39
-rw-r--r--TAO/DevGuideExamples/AMH_AMI/middle_server.cpp47
-rwxr-xr-xTAO/DevGuideExamples/AMH_AMI/run_test.pl136
-rw-r--r--TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerClient.cpp9
-rw-r--r--TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerServer.cpp27
-rwxr-xr-xTAO/DevGuideExamples/Multithreading/GracefulShutdown/run_test.pl331
-rw-r--r--TAO/DevGuideExamples/Multithreading/ThreadPerConnection/MessengerClient.cpp35
-rw-r--r--TAO/DevGuideExamples/Multithreading/ThreadPerConnection/MessengerServer.cpp37
-rwxr-xr-xTAO/DevGuideExamples/Multithreading/ThreadPerConnection/run_test.pl193
-rw-r--r--TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerClient.cpp35
-rw-r--r--TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp37
-rwxr-xr-xTAO/DevGuideExamples/Multithreading/ThreadPool/run_test.pl399
13 files changed, 1019 insertions, 341 deletions
diff --git a/TAO/DevGuideExamples/AMH_AMI/client.cpp b/TAO/DevGuideExamples/AMH_AMI/client.cpp
index 42b494a6700..5ec095e74c4 100644
--- a/TAO/DevGuideExamples/AMH_AMI/client.cpp
+++ b/TAO/DevGuideExamples/AMH_AMI/client.cpp
@@ -1,18 +1,49 @@
// $Id$
#include "amh_ami_pch.h"
-
+#include "ace/Get_Opt.h"
#include "middleC.h"
#include <iostream>
+
+const ACE_TCHAR *ior_file = ACE_TEXT ("file://middle.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_file = get_opts.opt_arg ();
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-k <ior_file> "
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates successful parsing of the command line
+ return 0;
+}
+
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
try {
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
// Read and destringify the Asynch_Except_Demo object's IOR.
- CORBA::Object_var obj = orb->string_to_object( "file://middle.ior" );
+ CORBA::Object_var obj = orb->string_to_object(ior_file);
if( CORBA::is_nil( obj.in() ) ) {
std::cerr << "Could not get middle IOR." << std::endl;
return 1;
diff --git a/TAO/DevGuideExamples/AMH_AMI/inner_server.cpp b/TAO/DevGuideExamples/AMH_AMI/inner_server.cpp
index 9dc4446b5d2..c38ecc815fe 100644
--- a/TAO/DevGuideExamples/AMH_AMI/inner_server.cpp
+++ b/TAO/DevGuideExamples/AMH_AMI/inner_server.cpp
@@ -5,23 +5,41 @@
#include "inner_i.h"
#include "ace/SString.h"
#include "ace/OS_String.h"
+#include "ace/Get_Opt.h"
#include <iostream>
#include <fstream>
int dont_crash = 1;
+const ACE_TCHAR *ior_output_file = ACE_TEXT ("inner.ior");
+
int
parse_args (int argc, ACE_TCHAR *argv[])
{
- int c = 0;
- while (c < argc)
- {
- if (ACE_OS::strcasecmp (argv[c], ACE_TEXT("-crash")) == 0)
- dont_crash = 0;
- c++;
- }
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("c:o:"));
+ int c;
- return 1;
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'c':
+ dont_crash = 0;
+ break;
+ case 'o':
+ ior_output_file = get_opts.opt_arg ();
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-o <iorfile> "
+ "-c "
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates sucessful parsing of the command line
+ return 0;
}
int
@@ -31,7 +49,8 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
- parse_args (argc, argv);
+ if (parse_args (argc, argv) != 0)
+ return 1;
//Get reference to the RootPOA.
CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" );
@@ -49,7 +68,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
PortableServer::ObjectId_var oid = poa->activate_object( servant.in() );
obj = poa->id_to_reference( oid.in() );
CORBA::String_var str = orb->object_to_string( obj.in() );
- ACE_CString iorname ("inner.ior");
+ ACE_CString iorname (ior_output_file);
std::ofstream iorFile (iorname.c_str());
iorFile << str.in() << std::endl;
iorFile.close();
diff --git a/TAO/DevGuideExamples/AMH_AMI/middle_server.cpp b/TAO/DevGuideExamples/AMH_AMI/middle_server.cpp
index 98e8dea90a7..c023790e131 100644
--- a/TAO/DevGuideExamples/AMH_AMI/middle_server.cpp
+++ b/TAO/DevGuideExamples/AMH_AMI/middle_server.cpp
@@ -4,25 +4,49 @@
#include "middle_i.h"
#include "ace/OS_String.h"
+#include "ace/Get_Opt.h"
#include <iostream>
#include <fstream>
int use_synch = 0;
+const ACE_TCHAR *ior_output_file = ACE_TEXT ("middle.ior");
+const ACE_TCHAR *ior_input_file = ACE_TEXT ("file://inner.ior");
+
int
parse_args (int argc, ACE_TCHAR *argv[])
{
- int c = 0;
- while (c < argc)
- {
- if (ACE_OS::strcasecmp (argv[c], ACE_TEXT("-no_AMH")) == 0)
- use_synch = 1;
- c++;
- }
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:i:n"));
+ int c;
- return 1;
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o':
+ ior_output_file = get_opts.opt_arg ();
+ break;
+ case 'i':
+ ior_input_file = get_opts.opt_arg ();
+ break;
+ case 'n':
+ use_synch = 1;
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-o <ior_output_file> "
+ "-i <ior_input_file> "
+ "-n"
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates sucessful parsing of the command line
+ return 0;
}
+
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
@@ -30,7 +54,8 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
- parse_args(argc,argv);
+ if (parse_args (argc, argv) != 0)
+ return 1;
//Get reference to the RootPOA.
CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" );
@@ -40,7 +65,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
PortableServer::POAManager_var mgr = poa->the_POAManager();
mgr->activate();
- obj = orb->string_to_object("file://inner.ior");
+ obj = orb->string_to_object(ior_input_file);
Inner_var peer =
Inner::_narrow(obj.in());
if (CORBA::is_nil(peer.in()))
@@ -63,7 +88,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
obj = poa->id_to_reference( oid.in() );
CORBA::String_var str = orb->object_to_string( obj.in() );
- ACE_CString iorname("middle.ior");
+ ACE_CString iorname(ior_output_file);
std::ofstream iorFile (iorname.c_str());
iorFile << str.in() << std::endl;
iorFile.close();
diff --git a/TAO/DevGuideExamples/AMH_AMI/run_test.pl b/TAO/DevGuideExamples/AMH_AMI/run_test.pl
index 332eeb84aa7..1e73cf21dc8 100755
--- a/TAO/DevGuideExamples/AMH_AMI/run_test.pl
+++ b/TAO/DevGuideExamples/AMH_AMI/run_test.pl
@@ -1,60 +1,120 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
# $Id$
+# -*- perl -*-
-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;
+
+$status = 0;
+$debug_level = '0';
+
+foreach $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = '10';
+ }
+}
+
+my $in_server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
+my $md_server = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
+my $client = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
-use Env (ACE_ROOT);
-use lib "$ACE_ROOT/bin";
-use PerlACE::Run_Test;
+my $inner_ior = "inner.ior";
+my $middle_ior = "middle.ior";
-$inner_ior = PerlACE::LocalFile ("inner.ior");
-$middle_ior = PerlACE::LocalFile ("middle.ior");
-unlink $inner_ior;
-unlink $middle_ior;
+# Files which used by inner_server
+my $in_server_inner_ior = $in_server->LocalFile ($inner_ior);
+$in_server->DeleteFile($inner_ior);
-# start inner_server
+# Files which used by middle server
+my $md_server_inner_ior = $md_server->LocalFile ($inner_ior);
+my $md_server_middle_ior = $md_server->LocalFile ($middle_ior);
+$md_server->DeleteFile($inner_ior);
+$md_server->DeleteFile($middle_ior);
-$IS = new PerlACE::Process("inner_server");
-$IS->Spawn();
+# Files which used by inner_server
+my $client_iorfile = $client->LocalFile ($middle_ior);
+$client->DeleteFile($middle_ior);
-if (PerlACE::waitforfile_timed ($inner_ior, $PerlACE::wait_interval_for_process_creation) == -1) {
- print STDERR "ERROR: cannot find file <$inner_ior>\n";
- $IS->Kill();
- unlink $inner_ior;
+$IS = $in_server->CreateProcess ("inner_server",
+ "-ORBdebuglevel $debug_level " .
+ "-o $in_server_inner_ior");
+
+$MD = $md_server->CreateProcess ("middle_server",
+ "-ORBdebuglevel $debug_level " .
+ "-o $md_server_middle_ior " .
+ "-i file://$md_server_inner_ior");
+
+$CL = $client->CreateProcess ("client", "-k file://$client_iorfile");
+
+$server_status = $IS->Spawn ();
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
exit 1;
}
+if ($in_server->WaitForFileTimed ($inner_ior,
+ $in_server->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$in_server_inner_ior>\n";
+ $IS->Kill (); $IS->TimedWait (1);
+ exit 1;
+}
-# start middle_server
+if ($in_server->GetFile ($inner_ior) == -1) {
+ print STDERR "ERROR: cannot retrieve file <$in_server_inner_ior>\n";
+ $IS->Kill (); $IS->TimedWait (1);
+ exit 1;
+}
+if ($md_server->PutFile ($inner_ior) == -1) {
+ print STDERR "ERROR: cannot set file <$md_server_inner_ior>\n";
+ $IS->Kill (); $IS->TimedWait (1);
+ exit 1;
+}
-$MS = new PerlACE::Process("middle_server");
-$MS->Spawn();
+$server_status = $MD->Spawn ();
-if (PerlACE::waitforfile_timed ($middle_ior, $PerlACE::wait_interval_for_process_creation) == -1) {
- print STDERR "ERROR: cannot find file <$middle_ior>\n";
- $MS->Kill();
- unlink $middle_ior;
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
exit 1;
}
-# start client
+if ($md_server->WaitForFileTimed ($middle_ior,
+ $md_server->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$md_server_middle_ior>\n";
+ $MD->Kill (); $MD->TimedWait (1);
+ $IS->Kill (); $IS->TimedWait (1);
+ exit 1;
+}
-$C = new PerlACE::Process("client");
-$C->Spawn();
+if ($md_server->GetFile ($middle_ior) == -1) {
+ print STDERR "ERROR: cannot retrieve file <$md_server_middle_ior>\n";
+ $MD->Kill (); $MD->TimedWait (1);
+ $IS->Kill (); $IS->TimedWait (1);
+ exit 1;
+}
+if ($client->PutFile ($middle_ior) == -1) {
+ print STDERR "ERROR: cannot set file <$client_iorfile>\n";
+ $MD->Kill (); $MD->TimedWait (1);
+ $IS->Kill (); $IS->TimedWait (1);
+ exit 1;
+}
-$CRET = $C->WaitKill(45);
-$IS->Kill();
-$MS->Kill();
+$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval() + 30);
-# clean-up
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
-unlink $inner_ior;
-unlink $middle_ior;
+$IS->Kill ();
+$MD->Kill ();
-if ($CRET != 0) {
- print STDERR "ERROR: Client returned <$CRET>\n";
- exit 1 ;
-}
+$in_server->DeleteFile($inner_ior);
+$md_server->DeleteFile($inner_ior);
+$md_server->DeleteFile($middle_ior);
+$client->DeleteFile($middle_ior);
-exit 0;
+exit $status;
diff --git a/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerClient.cpp b/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerClient.cpp
index e2f551e93d7..5c5aef8f034 100644
--- a/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerClient.cpp
+++ b/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerClient.cpp
@@ -5,16 +5,20 @@
#include <iostream>
int call_shutdown = 0;
+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("x"));
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:x"));
int c;
while ((c = get_opts ()) != -1)
{
switch (c)
{
+ case 'k':
+ ior = get_opts.opt_arg ();
+ break;
case 'x':
call_shutdown = 1;
break;
@@ -22,6 +26,7 @@ int parse_args (int argc, ACE_TCHAR* argv[])
default:
ACE_ERROR_RETURN ((LM_ERROR,
"usage: %s\n"
+ "-k <ior> "
"-x - call shutdown on server\n",
argv[0]),
-1);
@@ -42,7 +47,7 @@ int ACE_TMAIN( int argc, ACE_TCHAR* argv[] )
return 1;
// Read and destringify the Messenger object's IOR.
- CORBA::Object_var obj = orb->string_to_object( "file://Messenger.ior" );
+ CORBA::Object_var obj = orb->string_to_object(ior);
if( CORBA::is_nil( obj.in() ) ) {
std::cerr << "Could not get Messenger IOR." << std::endl;
return 1;
diff --git a/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerServer.cpp b/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerServer.cpp
index 1d08615f6d6..b249ddc8228 100644
--- a/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerServer.cpp
+++ b/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerServer.cpp
@@ -8,7 +8,8 @@
#include "tao/ORB_Core.h"
#include <iostream>
#include <fstream>
-ACE_TString ior_output_file;
+
+ACE_TString ior_output_file = ACE_TEXT ("test.ior");
// By default, shutdown when client calls Messenger::shutdown().
MessengerServer::ShutdownMethod s_method = MessengerServer::s_client_call;
@@ -152,6 +153,14 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+ // Create a MessengerServer object.
+ MessengerServer * server = new MessengerServer (orb.in());
+ ACE_Auto_Ptr<MessengerServer> safe_ptr (server);
+
+ // Parse arguments to determine how we should shutdown.
+ if (server->parse_args (argc, argv) != 0)
+ return 1;
+
//Get reference to the RootPOA.
CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" );
PortableServer::POA_var poa = PortableServer::POA::_narrow( obj.in() );
@@ -169,17 +178,11 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
poa->activate_object( &messenger_servant );
CORBA::Object_var messenger_obj = poa->id_to_reference( oid.in() );
CORBA::String_var str = orb->object_to_string( messenger_obj.in() );
- std::ofstream iorFile( "Messenger.ior" );
+ std::ofstream iorFile(ACE_TEXT_ALWAYS_CHAR (ior_output_file.c_str ()));
iorFile << str.in() << std::endl;
iorFile.close();
- std::cout << "IOR written to file Messenger.ior" << std::endl;
-
- // Create a MessengerServer object.
- MessengerServer * server = new MessengerServer (orb.in());
-
- // Parse arguments to determine how we should shutdown.
- if (server->parse_args (argc, argv) != 0)
- return 1;
+ std::cout << "IOR written to file " <<
+ ACE_TEXT_ALWAYS_CHAR (ior_output_file.c_str ()) << std::endl;
switch (s_method)
{
@@ -211,10 +214,6 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
server->run (timeout);
break;
}
-
- // Finished.
- delete server;
-
}
catch(const CORBA::Exception& ex) {
std::cerr << "CORBA exception: " << ex << std::endl;
diff --git a/TAO/DevGuideExamples/Multithreading/GracefulShutdown/run_test.pl b/TAO/DevGuideExamples/Multithreading/GracefulShutdown/run_test.pl
index 327eae8a96d..a6c5964fc80 100755
--- a/TAO/DevGuideExamples/Multithreading/GracefulShutdown/run_test.pl
+++ b/TAO/DevGuideExamples/Multithreading/GracefulShutdown/run_test.pl
@@ -1,125 +1,201 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
# $Id$
+# -*- perl -*-
-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;
+
+$status = 0;
+$debug_level = '0';
+
+foreach $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = '10';
+ }
+}
+
+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";
-use Env (ACE_ROOT);
-use lib "$ACE_ROOT/bin";
-use PerlACE::Run_Test;
+my $iorbase = "server.ior";
+my $server_iorfile = $server->LocalFile ($iorbase);
+my $client_iorfile = $client->LocalFile ($iorbase);
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
-$ior = PerlACE::LocalFile ("Messenger.ior");
-unlink $ior;
+my $hostname = $server->HostName ();
+my $server_args = "-ORBdebuglevel $debug_level " .
+ "-ORBListenEndpoints iiop://$hostname -o $server_iorfile";
-$server_args = "-ORBListenEndpoints iiop://localhost";
+$SV = $server->CreateProcess ("MessengerServer",
+ $server_args . " -x");
+$CL = $client->CreateProcess ("MessengerClient",
+ "-k file://$client_iorfile -x");
# -------------------------------------------------------------------
# Test 1: Shutdown on client invocation
# -------------------------------------------------------------------
-# start MessengerServer
-
print STDOUT "\n\nTest 1: Shutdown on client invocation.\n";
print STDOUT "Running MessengerServer...\n";
-$S1 = new PerlACE::Process("MessengerServer", $server_args . " -x");
-$S1->Spawn();
-if (PerlACE::waitforfile_timed ($ior, $PerlACE::wait_interval_for_process_creation) == -1) {
- print STDERR "ERROR: cannot find file <$ior>\n";
- $S1->Kill();
- unlink $ior;
+$server_status = $SV->Spawn ();
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
exit 1;
}
-# start MessengerClient
+if ($server->WaitForFileTimed ($iorbase,
+ $server->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
-$C1 = new PerlACE::Process("MessengerClient", "-x");
-$C1->Spawn();
+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;
+}
-$C1RET = $C1->WaitKill(15);
-$S1->Kill();
+$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval());
-# clean-up
+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;
+}
-unlink $ior;
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
-if ($C1RET != 0) {
- print STDERR "ERROR: Client returned <$C1RET>\n";
- exit 1 ;
-}
+exit $status if ($status != 0);
# -------------------------------------------------------------------
# Test 2: Shutdown after <n> iterations through polling loop
# -------------------------------------------------------------------
-# start MessengerServer
-
-$iter = 10;
+my $iter = 10;
print STDOUT "\n\nTest 2: Shutdown after <$iter> iterations through polling loop.\n";
print STDOUT "Running MessengerServer...\n";
-$S2 = new PerlACE::Process("MessengerServer", $server_args . " -p " . $iter);
-$S2->Spawn();
-if (PerlACE::waitforfile_timed ($ior, $PerlACE::wait_interval_for_process_creation) == -1) {
- print STDERR "ERROR: cannot find file <$ior>\n";
- $S2->Kill();
- unlink $ior;
+$SV->Arguments ($server_args . " -p " . $iter);
+$CL->Arguments ("-k file://$client_iorfile");
+
+$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;
}
-# start MessengerClient
+$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval());
-$C2 = new PerlACE::Process("MessengerClient");
-$C2->Spawn();
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
-$C2RET = $C2->WaitKill(15);
-$S2->WaitKill($iter+5);
+$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + $iter);
-# clean-up
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ $status = 1;
+}
-unlink $ior;
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
-if ($C2RET != 0) {
- print STDERR "ERROR: Client returned <$C2RET>\n";
- exit 1 ;
-}
+exit $status if ($status != 0);
# -------------------------------------------------------------------
-# Test 3: Schedule a timer with the ORB's reactor to shutdown
+# Test 3: Schedule a timer with the ORB's reactor to shutdown.
# in <n> seconds
# -------------------------------------------------------------------
-# start MessengerServer
-
-$sec = 10;
+my $sec = 10;
print STDOUT "\n\nTest 3: Schedule a timer with the ORB's reactor to shutdown in <$sec> seconds.\n";
print STDOUT "Running MessengerServer...\n";
-$S3 = new PerlACE::Process("MessengerServer", $server_args . " -t " . $sec);
-$S3->Spawn();
-if (PerlACE::waitforfile_timed ($ior, $PerlACE::wait_interval_for_process_creation) == -1) {
- print STDERR "ERROR: cannot find file <$ior>\n";
- $S3->Kill();
- unlink $ior;
+$SV->Arguments ($server_args . " -t " . $sec);
+$CL->Arguments ("-k file://$client_iorfile");
+
+$server_status = $SV->Spawn ();
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
exit 1;
}
-# start MessengerClient
+if ($server->WaitForFileTimed ($iorbase,
+ $server->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
-$C3 = new PerlACE::Process("MessengerClient");
-$C3->Spawn();
+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;
+}
-$C3RET = $C3->WaitKill(15);
-$S3->WaitKill($sec+5);
+$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval());
-# clean-up
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
-unlink $ior;
+$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + $sec);
-if ($C3RET != 0) {
- print STDERR "ERROR: Client returned <$C3RET>\n";
- exit 1 ;
-}
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ $status = 1;
+}
+
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
+
+exit $status if ($status != 0);
# -------------------------------------------------------------------
# Test 4: Use the overloaded version of CORBA::ORB::run() that takes
@@ -127,79 +203,110 @@ if ($C3RET != 0) {
# should process events before returning.
# -------------------------------------------------------------------
-# start MessengerServer
-
print STDOUT "\n\nTest 4: Use the overloaded version of CORBA::ORB::run()\n";
print STDOUT "that takes an ACE_Time_Value parameter indicating how long\n";
print STDOUT "run() should process events before returning (<$sec> seconds).\n";
print STDOUT "Running MessengerServer...\n";
-$S4 = new PerlACE::Process("MessengerServer", $server_args . " -r " . $sec);
-$S4->Spawn();
-if (PerlACE::waitforfile_timed ($ior, $PerlACE::wait_interval_for_process_creation) == -1) {
- print STDERR "ERROR: cannot find file <$ior>\n";
- $S4->Kill();
- unlink $ior;
+$SV->Arguments ($server_args . " -r " . $sec);
+$CL->Arguments ("-k file://$client_iorfile");
+
+$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;
}
-# start MessengerClient
+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;
+}
-$C4 = new PerlACE::Process("MessengerClient");
-$C4->Spawn();
+$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval());
-$C4RET = $C4->WaitKill(15);
-$S4->WaitKill($sec+5);
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
-# clean-up
+$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + $sec);
-unlink $ior;
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ $status = 1;
+}
-if ($C4RET != 0) {
- print STDERR "ERROR: Client returned <$C4RET>\n";
- exit 1 ;
-}
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
+exit $status if ($status != 0);
# -------------------------------------------------------------------
# Test 5: Spawn a separate thread to shutdown the ORB on any
# input from the console (terminal)
# -------------------------------------------------------------------
-# start MessengerServer
-
print STDOUT "\n\nTest 5: Spawn a separate thread to shutdown the ORB on any input from the console (terminal).\n";
print STDOUT "Running MessengerServer...\n";
-$S5 = new PerlACE::Process("MessengerServer", $server_args . " -c");
-$S5->Spawn();
-if (PerlACE::waitforfile_timed ($ior, $PerlACE::wait_interval_for_process_creation) == -1) {
- print STDERR "ERROR: cannot find file <$ior>\n";
- $S5->Kill();
- unlink $ior;
- exit 1;
-}
+$SV->Arguments ($server_args . " -c ");
+$CL->Arguments ("-k file://$client_iorfile");
-# start MessengerClient
+$server_status = $SV->Spawn ();
-$C5 = new PerlACE::Process("MessengerClient");
-$C5->Spawn();
-
-$C5RET = $C5->WaitKill(15);
-print STDOUT "Enter any input to shutdown MessengerServer...\n";
-$S5->WaitKill(15);
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ exit 1;
+}
-# clean-up
+if ($server->WaitForFileTimed ($iorbase,
+ $server->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
-unlink $ior;
+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;
+}
-if ($C5RET != 0) {
- print STDERR "ERROR: Client returned <$C5RET>\n";
- exit 1 ;
-}
+$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval());
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
-exit 0;
+print STDOUT "Enter any input to shutdown MessengerServer...\n";
+$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/DevGuideExamples/Multithreading/ThreadPerConnection/MessengerClient.cpp b/TAO/DevGuideExamples/Multithreading/ThreadPerConnection/MessengerClient.cpp
index 1e24fd500ef..b4269742a43 100644
--- a/TAO/DevGuideExamples/Multithreading/ThreadPerConnection/MessengerClient.cpp
+++ b/TAO/DevGuideExamples/Multithreading/ThreadPerConnection/MessengerClient.cpp
@@ -1,15 +1,48 @@
// $Id$
#include "MessengerC.h"
+#include "ace/Get_Opt.h"
#include <iostream>
+
+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 successful parsing of the command line
+ return 0;
+}
+
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
try {
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
// Read and destringify the Messenger object's IOR.
- CORBA::Object_var obj = orb->string_to_object( "file://Messenger.ior" );
+ CORBA::Object_var obj = orb->string_to_object(ior);
if( CORBA::is_nil( obj.in() ) ) {
std::cerr << "Could not get Messenger IOR." << std::endl;
return 1;
diff --git a/TAO/DevGuideExamples/Multithreading/ThreadPerConnection/MessengerServer.cpp b/TAO/DevGuideExamples/Multithreading/ThreadPerConnection/MessengerServer.cpp
index 5dc50c06521..512254aabea 100644
--- a/TAO/DevGuideExamples/Multithreading/ThreadPerConnection/MessengerServer.cpp
+++ b/TAO/DevGuideExamples/Multithreading/ThreadPerConnection/MessengerServer.cpp
@@ -1,8 +1,38 @@
// $Id$
#include "Messenger_i.h"
+#include "ace/Get_Opt.h"
#include <iostream>
#include <fstream>
+
+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 {
@@ -17,6 +47,9 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
PortableServer::POAManager_var mgr = poa->the_POAManager();
mgr->activate();
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
// Create a servant.
PortableServer::Servant_var<Messenger_i> messenger_servant = new Messenger_i;
@@ -26,10 +59,10 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
poa->activate_object( messenger_servant.in() );
CORBA::Object_var messenger_obj = poa->id_to_reference( oid.in() );
CORBA::String_var str = orb->object_to_string( messenger_obj.in() );
- std::ofstream iorFile( "Messenger.ior" );
+ std::ofstream iorFile(ACE_TEXT_ALWAYS_CHAR (ior_output_file));
iorFile << str.in() << std::endl;
iorFile.close();
- std::cout << "IOR written to file Messenger.ior" << std::endl;
+ std::cout << "IOR written to file " << ACE_TEXT_ALWAYS_CHAR (ior_output_file) << std::endl;
// Accept requests from clients.
orb->run();
diff --git a/TAO/DevGuideExamples/Multithreading/ThreadPerConnection/run_test.pl b/TAO/DevGuideExamples/Multithreading/ThreadPerConnection/run_test.pl
index e669d1d1995..cc23b7a59b2 100755
--- a/TAO/DevGuideExamples/Multithreading/ThreadPerConnection/run_test.pl
+++ b/TAO/DevGuideExamples/Multithreading/ThreadPerConnection/run_test.pl
@@ -1,76 +1,169 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
# $Id$
+# -*- perl -*-
-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 Env (ACE_ROOT);
-use lib "$ACE_ROOT/bin";
-use PerlACE::Run_Test;
+$status = 0;
+$debug_level = '0';
-$ior = PerlACE::LocalFile ("Messenger.ior");
-unlink $ior;
+foreach $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = '10';
+ }
+}
-# start MessengerServer
+my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
+my $client1 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
+my $client2 = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
+my $client3 = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
+my $client4 = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
+
+my $iorbase = "server.ior";
+my $server_iorfile = $server->LocalFile ($iorbase);
+my $client1_iorfile = $client1->LocalFile ($iorbase);
+my $client2_iorfile = $client2->LocalFile ($iorbase);
+my $client3_iorfile = $client3->LocalFile ($iorbase);
+my $client4_iorfile = $client4->LocalFile ($iorbase);
+$server->DeleteFile($iorbase);
+$client1->DeleteFile($iorbase);
+$client2->DeleteFile($iorbase);
+$client3->DeleteFile($iorbase);
+$client4->DeleteFile($iorbase);
+
+my $hostname = $server->HostName ();
+
+$SV = $server->CreateProcess ("MessengerServer",
+ "-ORBdebuglevel $debug_level " .
+ "-ORBSvcConf server.conf " .
+ "-ORBListenEndpoints iiop://$hostname " .
+ "-o $server_iorfile");
+$CL1 = $client1->CreateProcess ("MessengerClient", "-k file://$client1_iorfile");
+$CL2 = $client2->CreateProcess ("MessengerClient", "-k file://$client2_iorfile");
+$CL3 = $client3->CreateProcess ("MessengerClient", "-k file://$client3_iorfile");
+$CL4 = $client4->CreateProcess ("MessengerClient", "-k file://$client4_iorfile");
print STDOUT "Starting MessengerServer\n";
+$server_status = $SV->Spawn ();
-$S = new PerlACE::Process("MessengerServer", "-ORBSvcConf server.conf -ORBListenEndpoints iiop://localhost");
-$S->Spawn();
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ exit 1;
+}
-if (PerlACE::waitforfile_timed ($ior, $PerlACE::wait_interval_for_process_creation) == -1) {
- print STDERR "ERROR: cannot find file <$ior>\n";
- $S->Kill();
- unlink $ior;
+if ($server->WaitForFileTimed ($iorbase,
+ $server->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
exit 1;
}
-# start several MessengerClients
+if ($server->GetFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client1->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client1_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client2->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client2_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client3->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client3_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client4->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client4_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
print STDOUT "\n\nStarting 4 MessengerClients.\n";
-print STDOUT "Each client should get a new connection \
-and its own thread in the server.\n\n";
+print STDOUT "Each client should get a new connection ".
+ "and its own thread in the server.\n\n";
-$C1 = new PerlACE::Process("MessengerClient");
-$C2 = new PerlACE::Process("MessengerClient");
-$C3 = new PerlACE::Process("MessengerClient");
-$C4 = new PerlACE::Process("MessengerClient");
-$C1->Spawn();
-$C2->Spawn();
-$C3->Spawn();
-$C4->Spawn();
+$client_status = $CL1->Spawn ();
-$C1RET = $C1->WaitKill(15);
-$C2RET = $C2->WaitKill(15);
-$C3RET = $C3->WaitKill(15);
-$C4RET = $C4->WaitKill(15);
-$S->Kill();
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
-# clean-up
+$client_status = $CL2->Spawn ();
-unlink $ior;
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ $CL1->Kill (); $CL1->TimedWait (1);
+ exit 1;
+}
-if ($C1RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C1RET>\n";
- exit 1 ;
-}
+$client_status = $CL3->Spawn ();
-if ($C2RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C2RET>\n";
- exit 1 ;
-}
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ $CL1->Kill (); $CL1->TimedWait (1);
+ $CL2->Kill (); $CL2->TimedWait (1);
+ exit 1;
+}
-if ($C3RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C3RET>\n";
- exit 1 ;
-}
+$client_status = $CL4->Spawn ();
-if ($C4RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C4RET>\n";
- exit 1 ;
-}
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ $CL1->Kill (); $CL1->TimedWait (1);
+ $CL2->Kill (); $CL2->TimedWait (1);
+ $CL3->Kill (); $CL3->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL1->WaitKill ($client1->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
-exit 0;
+$client_status = $CL2->WaitKill ($client2->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$client_status = $CL3->WaitKill ($client3->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$client_status = $CL4->WaitKill ($client4->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+$SV->Kill ();
+$server->DeleteFile($iorbase);
+$client1->DeleteFile($iorbase);
+$client2->DeleteFile($iorbase);
+$client3->DeleteFile($iorbase);
+$client4->DeleteFile($iorbase);
+exit $status;
diff --git a/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerClient.cpp b/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerClient.cpp
index 1e24fd500ef..b4269742a43 100644
--- a/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerClient.cpp
+++ b/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerClient.cpp
@@ -1,15 +1,48 @@
// $Id$
#include "MessengerC.h"
+#include "ace/Get_Opt.h"
#include <iostream>
+
+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 successful parsing of the command line
+ return 0;
+}
+
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
try {
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init( argc, argv );
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
// Read and destringify the Messenger object's IOR.
- CORBA::Object_var obj = orb->string_to_object( "file://Messenger.ior" );
+ CORBA::Object_var obj = orb->string_to_object(ior);
if( CORBA::is_nil( obj.in() ) ) {
std::cerr << "Could not get Messenger IOR." << std::endl;
return 1;
diff --git a/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp b/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp
index 2e0865eac9d..2097b73a3a3 100644
--- a/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp
+++ b/TAO/DevGuideExamples/Multithreading/ThreadPool/MessengerServer.cpp
@@ -1,11 +1,40 @@
// $Id$
#include "Messenger_i.h"
+#include "ace/Get_Opt.h"
#include <iostream>
#include <fstream>
// 1. Define a "task" class for implenting the thread pool threads.
#include "ace/Task.h"
+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;
+}
+
class ORB_Task : public ACE_Task_Base
{
public:
@@ -38,6 +67,9 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
PortableServer::POAManager_var mgr = poa->the_POAManager();
mgr->activate();
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
// Create a servant.
PortableServer::Servant_var<Messenger_i> messenger_servant = new Messenger_i;
@@ -47,10 +79,11 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
poa->activate_object( messenger_servant.in() );
CORBA::Object_var messenger_obj = poa->id_to_reference( oid.in() );
CORBA::String_var str = orb->object_to_string( messenger_obj.in() );
- std::ofstream iorFile( "Messenger.ior" );
+ std::ofstream iorFile(ACE_TEXT_ALWAYS_CHAR (ior_output_file));
iorFile << str.in() << std::endl;
iorFile.close();
- std::cout << "IOR written to file Messenger.ior" << std::endl;
+ std::cout << "IOR written to file " <<
+ ACE_TEXT_ALWAYS_CHAR (ior_output_file) << std::endl;
// 3. Create and activate threads for the thread pool.
ORB_Task task (orb.in());
diff --git a/TAO/DevGuideExamples/Multithreading/ThreadPool/run_test.pl b/TAO/DevGuideExamples/Multithreading/ThreadPool/run_test.pl
index a73ce34a799..a3fb0021480 100755
--- a/TAO/DevGuideExamples/Multithreading/ThreadPool/run_test.pl
+++ b/TAO/DevGuideExamples/Multithreading/ThreadPool/run_test.pl
@@ -1,115 +1,322 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
# $Id$
+# -*- perl -*-
-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;
+
+$status = 0;
+$debug_level = '0';
+
+foreach $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = '10';
+ }
+}
-use Env (ACE_ROOT);
-use lib "$ACE_ROOT/bin";
-use PerlACE::Run_Test;
+my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n";
+my $client1 = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n";
+my $client2 = PerlACE::TestTarget::create_target (3) || die "Create target 3 failed\n";
+my $client3 = PerlACE::TestTarget::create_target (4) || die "Create target 4 failed\n";
+my $client4 = PerlACE::TestTarget::create_target (5) || die "Create target 5 failed\n";
+my $client5 = PerlACE::TestTarget::create_target (6) || die "Create target 6 failed\n";
+my $client6 = PerlACE::TestTarget::create_target (7) || die "Create target 7 failed\n";
+my $client7 = PerlACE::TestTarget::create_target (8) || die "Create target 8 failed\n";
+my $client8 = PerlACE::TestTarget::create_target (9) || die "Create target 9 failed\n";
+my $client9 = PerlACE::TestTarget::create_target (10) || die "Create target 10 failed\n";
-$ior = PerlACE::LocalFile ("Messenger.ior");
-unlink $ior;
+my $iorbase = "server.ior";
+my $server_iorfile = $server->LocalFile ($iorbase);
+my $client1_iorfile = $client1->LocalFile ($iorbase);
+my $client2_iorfile = $client2->LocalFile ($iorbase);
+my $client3_iorfile = $client3->LocalFile ($iorbase);
+my $client4_iorfile = $client4->LocalFile ($iorbase);
+my $client5_iorfile = $client5->LocalFile ($iorbase);
+my $client6_iorfile = $client6->LocalFile ($iorbase);
+my $client7_iorfile = $client7->LocalFile ($iorbase);
+my $client8_iorfile = $client8->LocalFile ($iorbase);
+my $client9_iorfile = $client9->LocalFile ($iorbase);
+$server->DeleteFile($iorbase);
+$client1->DeleteFile($iorbase);
+$client2->DeleteFile($iorbase);
+$client3->DeleteFile($iorbase);
+$client4->DeleteFile($iorbase);
+$client5->DeleteFile($iorbase);
+$client6->DeleteFile($iorbase);
+$client7->DeleteFile($iorbase);
+$client8->DeleteFile($iorbase);
+$client9->DeleteFile($iorbase);
-# start MessengerServer
+my $hostname = $server->HostName ();
+
+$SV = $server->CreateProcess ("MessengerServer",
+ "-ORBdebuglevel $debug_level " .
+ "-ORBListenEndpoints iiop://$hostname " .
+ "-o $server_iorfile");
+$CL1 = $client1->CreateProcess ("MessengerClient", "-k file://$client1_iorfile");
+$CL2 = $client2->CreateProcess ("MessengerClient", "-k file://$client2_iorfile");
+$CL3 = $client3->CreateProcess ("MessengerClient", "-k file://$client3_iorfile");
+$CL4 = $client4->CreateProcess ("MessengerClient", "-k file://$client4_iorfile");
+$CL5 = $client5->CreateProcess ("MessengerClient", "-k file://$client5_iorfile");
+$CL6 = $client6->CreateProcess ("MessengerClient", "-k file://$client6_iorfile");
+$CL7 = $client7->CreateProcess ("MessengerClient", "-k file://$client7_iorfile");
+$CL8 = $client8->CreateProcess ("MessengerClient", "-k file://$client8_iorfile");
+$CL9 = $client9->CreateProcess ("MessengerClient", "-k file://$client9_iorfile");
print STDOUT "Starting MessengerServer\n";
+$server_status = $SV->Spawn ();
-$S = new PerlACE::Process("MessengerServer", "-ORBListenEndpoints iiop://localhost");
-$S->Spawn();
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ exit 1;
+}
-if (PerlACE::waitforfile_timed ($ior, $PerlACE::wait_interval_for_process_creation) == -1) {
- print STDERR "ERROR: cannot find file <$ior>\n";
- $S->Kill();
- unlink $ior;
+if ($server->WaitForFileTimed ($iorbase,
+ $server->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
exit 1;
}
-# start several MessengerClients
+if ($server->GetFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client1->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client1_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client2->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client2_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client3->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client3_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client4->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client4_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client5->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client5_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client6->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client6_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client7->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client7_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client8->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client8_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client9->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client9_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
print STDOUT "\n\nStarting 9 MessengerClients.\n";
print STDOUT "The server should use different threads to handle requests.\n\n";
-$C1 = new PerlACE::Process("MessengerClient");
-$C2 = new PerlACE::Process("MessengerClient");
-$C3 = new PerlACE::Process("MessengerClient");
-$C4 = new PerlACE::Process("MessengerClient");
-$C5 = new PerlACE::Process("MessengerClient");
-$C6 = new PerlACE::Process("MessengerClient");
-$C7 = new PerlACE::Process("MessengerClient");
-$C8 = new PerlACE::Process("MessengerClient");
-$C9 = new PerlACE::Process("MessengerClient");
-$C1->Spawn();
-$C2->Spawn();
-$C3->Spawn();
-$C4->Spawn();
-$C5->Spawn();
-$C6->Spawn();
-$C7->Spawn();
-$C8->Spawn();
-$C9->Spawn();
-
-$C1RET = $C1->WaitKill(15);
-$C2RET = $C2->WaitKill(15);
-$C3RET = $C3->WaitKill(15);
-$C4RET = $C4->WaitKill(15);
-$C5RET = $C5->WaitKill(15);
-$C6RET = $C6->WaitKill(15);
-$C7RET = $C7->WaitKill(15);
-$C8RET = $C8->WaitKill(15);
-$C9RET = $C9->WaitKill(15);
-$S->Kill();
-
-# clean-up
-
-unlink $ior;
-
-if ($C1RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C1RET>\n";
- exit 1 ;
-}
-
-if ($C2RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C2RET>\n";
- exit 1 ;
-}
-
-if ($C3RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C3RET>\n";
- exit 1 ;
-}
-
-if ($C4RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C4RET>\n";
- exit 1 ;
-}
-
-if ($C5RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C5RET>\n";
- exit 1 ;
-}
-
-if ($C6RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C6RET>\n";
- exit 1 ;
-}
-
-if ($C7RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C7RET>\n";
- exit 1 ;
-}
-
-if ($C8RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C8RET>\n";
- exit 1 ;
-}
-
-if ($C9RET != 0) {
- print STDERR "ERROR: Client 1 returned <$C9RET>\n";
- exit 1 ;
-}
-
-exit 0;
+$client_status = $CL1->Spawn ();
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL2->Spawn ();
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ $CL1->Kill (); $CL1->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL3->Spawn ();
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ $CL1->Kill (); $CL1->TimedWait (1);
+ $CL2->Kill (); $CL2->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL4->Spawn ();
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ $CL1->Kill (); $CL1->TimedWait (1);
+ $CL2->Kill (); $CL2->TimedWait (1);
+ $CL3->Kill (); $CL3->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL5->Spawn ();
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ $CL1->Kill (); $CL1->TimedWait (1);
+ $CL2->Kill (); $CL2->TimedWait (1);
+ $CL3->Kill (); $CL3->TimedWait (1);
+ $CL4->Kill (); $CL4->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL6->Spawn ();
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ $CL1->Kill (); $CL1->TimedWait (1);
+ $CL2->Kill (); $CL2->TimedWait (1);
+ $CL3->Kill (); $CL3->TimedWait (1);
+ $CL4->Kill (); $CL4->TimedWait (1);
+ $CL5->Kill (); $CL5->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL7->Spawn ();
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ $CL1->Kill (); $CL1->TimedWait (1);
+ $CL2->Kill (); $CL2->TimedWait (1);
+ $CL3->Kill (); $CL3->TimedWait (1);
+ $CL4->Kill (); $CL4->TimedWait (1);
+ $CL5->Kill (); $CL5->TimedWait (1);
+ $CL6->Kill (); $CL6->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL8->Spawn ();
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ $CL1->Kill (); $CL1->TimedWait (1);
+ $CL2->Kill (); $CL2->TimedWait (1);
+ $CL3->Kill (); $CL3->TimedWait (1);
+ $CL4->Kill (); $CL4->TimedWait (1);
+ $CL5->Kill (); $CL5->TimedWait (1);
+ $CL6->Kill (); $CL6->TimedWait (1);
+ $CL7->Kill (); $CL7->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL9->Spawn ();
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ $CL1->Kill (); $CL1->TimedWait (1);
+ $CL2->Kill (); $CL2->TimedWait (1);
+ $CL3->Kill (); $CL3->TimedWait (1);
+ $CL4->Kill (); $CL4->TimedWait (1);
+ $CL5->Kill (); $CL5->TimedWait (1);
+ $CL6->Kill (); $CL6->TimedWait (1);
+ $CL7->Kill (); $CL7->TimedWait (1);
+ $CL8->Kill (); $CL8->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL1->WaitKill ($client1->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$client_status = $CL2->WaitKill ($client2->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$client_status = $CL3->WaitKill ($client3->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$client_status = $CL4->WaitKill ($client4->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$client_status = $CL5->WaitKill ($client5->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$client_status = $CL6->WaitKill ($client6->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$client_status = $CL7->WaitKill ($client7->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$client_status = $CL8->WaitKill ($client8->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$client_status = $CL9->WaitKill ($client9->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+$SV->Kill ();
+$server->DeleteFile($iorbase);
+$client1->DeleteFile($iorbase);
+$client2->DeleteFile($iorbase);
+$client3->DeleteFile($iorbase);
+$client4->DeleteFile($iorbase);
+$client5->DeleteFile($iorbase);
+$client6->DeleteFile($iorbase);
+$client7->DeleteFile($iorbase);
+$client8->DeleteFile($iorbase);
+$client9->DeleteFile($iorbase);
+exit $status;