summaryrefslogtreecommitdiff
path: root/TAO/DevGuideExamples/Multithreading/ThreadPerConnection
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/Multithreading/ThreadPerConnection
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/Multithreading/ThreadPerConnection')
-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
3 files changed, 212 insertions, 53 deletions
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;