diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2008-11-12 10:49:28 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2008-11-12 10:49:28 +0000 |
commit | 6e739e5bfcb54117f33d74a96466ec5c2e6a8986 (patch) | |
tree | 122dcfff48cd3237962b0670ad2a460a0c2f8283 /TAO/DevGuideExamples | |
parent | adfe75d0691a8f2fa7bc5d0e48ca304d5a13f33c (diff) | |
download | ATCD-6e739e5bfcb54117f33d74a96466ec5c2e6a8986.tar.gz |
Wed Nov 12 10:49:30 UTC 2008 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'TAO/DevGuideExamples')
-rw-r--r-- | TAO/DevGuideExamples/AMH/MessengerClient.cpp | 32 | ||||
-rw-r--r-- | TAO/DevGuideExamples/AMH/MessengerServer.cpp | 33 | ||||
-rw-r--r-- | TAO/DevGuideExamples/AMH/run_test.pl | 86 | ||||
-rw-r--r-- | TAO/DevGuideExamples/AMH_AMI/run_test.pl | 2 | ||||
-rw-r--r-- | TAO/DevGuideExamples/BiDirectionalGIOP/client.cpp | 15 | ||||
-rw-r--r-- | TAO/DevGuideExamples/BiDirectionalGIOP/run_test.pl | 79 | ||||
-rw-r--r-- | TAO/DevGuideExamples/BiDirectionalGIOP/server.cpp | 13 | ||||
-rw-r--r-- | TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerClient.cpp | 5 | ||||
-rw-r--r-- | TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerServer.cpp | 12 |
9 files changed, 198 insertions, 79 deletions
diff --git a/TAO/DevGuideExamples/AMH/MessengerClient.cpp b/TAO/DevGuideExamples/AMH/MessengerClient.cpp index 8d06c8a18be..c6145c5bad4 100644 --- a/TAO/DevGuideExamples/AMH/MessengerClient.cpp +++ b/TAO/DevGuideExamples/AMH/MessengerClient.cpp @@ -2,16 +2,46 @@ #include "amh_pch.h" +#include "ace/Get_Opt.h" #include "MessengerC.h" #include <iostream> + +ACE_TString 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.optarg; + break; + + case '?': + default: + std::cerr << "usage: " << argv[0] << " -k <ior>" << std::endl; + return -1; + break; + } + 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.c_str()); if( CORBA::is_nil( obj.in() ) ) { std::cerr << "Could not get Messenger IOR." << std::endl; return 1; diff --git a/TAO/DevGuideExamples/AMH/MessengerServer.cpp b/TAO/DevGuideExamples/AMH/MessengerServer.cpp index 3d9edce0eda..60742b2413f 100644 --- a/TAO/DevGuideExamples/AMH/MessengerServer.cpp +++ b/TAO/DevGuideExamples/AMH/MessengerServer.cpp @@ -2,15 +2,46 @@ #include "amh_pch.h" +#include "ace/Get_Opt.h" #include "AMH_Messenger_i.h" #include <iostream> #include <fstream> + +ACE_TString ior_output_file; + +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.optarg; + break; + break; + case '?': + default: + std::cerr << "usage: " << argv[0] << "-o <iorfile>" << std::endl; + return -1; + break; + } + // Indicates sucessful 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; + } + //Get reference to the RootPOA. CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" ); PortableServer::POA_var poa = PortableServer::POA::_narrow( obj.in() ); @@ -27,7 +58,7 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) PortableServer::ObjectId_var oid = poa->activate_object( &servant ); obj = poa->id_to_reference( oid.in() ); CORBA::String_var str = orb->object_to_string( 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; diff --git a/TAO/DevGuideExamples/AMH/run_test.pl b/TAO/DevGuideExamples/AMH/run_test.pl index a38d0e8dce7..f5859b6315a 100644 --- a/TAO/DevGuideExamples/AMH/run_test.pl +++ b/TAO/DevGuideExamples/AMH/run_test.pl @@ -1,46 +1,76 @@ +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 $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n"; -$S = new PerlACE::Process("MessengerServer"); -$S->Spawn(); +my $iorbase = "Messenger.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); -if (PerlACE::waitforfile_timed ($ior, $PerlACE::wait_interval_for_process_creation) == -1) { - print STDERR "ERROR: cannot find file <$ior>\n"; - $S->Kill(); - unlink $ior; +$SV = $server->CreateProcess ("MessengerServer", "-ORBdebuglevel $debug_level -o $server_iorfile"); +$CL = $client->CreateProcess ("MessengerClient", "-k file://$client_iorfile"); +$server_status = $SV->Spawn (); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; exit 1; } -# start MessengerClient - -$C = new PerlACE::Process("MessengerClient"); -$C->Spawn(); +if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} -$CRET = $C->WaitKill(15); -$S->Kill(); +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; +} -# clean-up +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval()); -unlink $ior; +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; + $status = 1; +} -if ($CRET != 0) { - print STDERR "ERROR: Client returned <$CRET>\n"; - exit 1 ; -} +$server_status = $SV->Kill ($server->ProcessStopWaitInterval()); -exit 0; +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + $status = 1; +} +$server->GetStderrLog(); +$client->GetStderrLog(); +$server->DeleteFile($server_iorfile); +$client->DeleteFile($client_iorfile); +exit $status; diff --git a/TAO/DevGuideExamples/AMH_AMI/run_test.pl b/TAO/DevGuideExamples/AMH_AMI/run_test.pl index df9939b2454..332eeb84aa7 100644 --- a/TAO/DevGuideExamples/AMH_AMI/run_test.pl +++ b/TAO/DevGuideExamples/AMH_AMI/run_test.pl @@ -43,7 +43,7 @@ if (PerlACE::waitforfile_timed ($middle_ior, $PerlACE::wait_interval_for_process $C = new PerlACE::Process("client"); $C->Spawn(); -$CRET = $C->WaitKill(25); +$CRET = $C->WaitKill(45); $IS->Kill(); $MS->Kill(); diff --git a/TAO/DevGuideExamples/BiDirectionalGIOP/client.cpp b/TAO/DevGuideExamples/BiDirectionalGIOP/client.cpp index b5b029d3ff6..c40f8f0c91e 100644 --- a/TAO/DevGuideExamples/BiDirectionalGIOP/client.cpp +++ b/TAO/DevGuideExamples/BiDirectionalGIOP/client.cpp @@ -6,7 +6,6 @@ #include "simpleC.h" #include "ace/Get_Opt.h" -#include "ace/Argv_Type_Converter.h" #include "tao/BiDir_GIOP/BiDirGIOP.h" #include <iostream> @@ -39,14 +38,12 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { - if (parse_args (argc, argv) != 0) { - return 1; - } - try { - ACE_Argv_Type_Converter conv(argc, argv); - CORBA::ORB_var orb = CORBA::ORB_init(conv.get_argc(), - conv.get_TCHAR_argv (), ""); + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + if (parse_args (argc, argv) != 0) { + return 1; + } // Create a bidirectional POA CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); @@ -70,7 +67,7 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[]) poa_manager->activate (); // get server object - obj = orb->string_to_object(ACE_TEXT_ALWAYS_CHAR(ior.c_str())); + obj = orb->string_to_object(ior.c_str()); Simple_var server = Simple::_narrow (obj.in()); Callback_i callback_svt(orb.in()); diff --git a/TAO/DevGuideExamples/BiDirectionalGIOP/run_test.pl b/TAO/DevGuideExamples/BiDirectionalGIOP/run_test.pl index 1cf5908205d..3202a675d6f 100644 --- a/TAO/DevGuideExamples/BiDirectionalGIOP/run_test.pl +++ b/TAO/DevGuideExamples/BiDirectionalGIOP/run_test.pl @@ -1,41 +1,76 @@ +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'; -$iorfile = "test.ior"; -unlink $iorfile; +foreach $i (@ARGV) { + if ($i eq '-debug') { + $debug_level = '10'; + } +} -$SV = new PerlACE::Process ("server", "-o $iorfile -i 100"); -$CL = new PerlACE::Process ("client", "-k file://$iorfile"); +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"; -$SV->Spawn (); +my $iorbase = "test.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); -if (PerlACE::waitforfile_timed ($iorfile, $PerlACE::wait_interval_for_process_creation) == -1) { - print STDERR "ERROR: cannot find file <$iorfile>\n"; - $SV->Kill (); +$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile -i 100"); +$CL = $client->CreateProcess ("client", "-k file://$client_iorfile"); +$server_status = $SV->Spawn (); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; exit 1; } -$status = 0; +if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} -$client = $CL->SpawnWaitKill (15); -if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; +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; +} + +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval()); + +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -$server = $SV->WaitKill (5); -if ($server != 0) { - print STDERR "ERROR: server returned $server\n"; +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval()); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } -unlink $iorfile; +$server->GetStderrLog(); +$client->GetStderrLog(); + +$server->DeleteFile($server_iorfile); +$client->DeleteFile($client_iorfile); exit $status; diff --git a/TAO/DevGuideExamples/BiDirectionalGIOP/server.cpp b/TAO/DevGuideExamples/BiDirectionalGIOP/server.cpp index 5868a122c32..405b3d0637d 100644 --- a/TAO/DevGuideExamples/BiDirectionalGIOP/server.cpp +++ b/TAO/DevGuideExamples/BiDirectionalGIOP/server.cpp @@ -6,7 +6,6 @@ #include "callbackC.h" #include "ace/Get_Opt.h" -#include "ace/Argv_Type_Converter.h" #include "tao/BiDir_GIOP/BiDirGIOP.h" #include <iostream> #include <fstream> @@ -42,15 +41,13 @@ parse_args(int argc, ACE_TCHAR *argv[]) int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { - if (parse_args(argc, argv) != 0) { - return 1; - } - try { - ACE_Argv_Type_Converter conv(argc, argv); - CORBA::ORB_var orb = CORBA::ORB_init(conv.get_argc(), - conv.get_TCHAR_argv(), ""); + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + + if (parse_args(argc, argv) != 0) { + return 1; + } // Create a bidirectional POA CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); diff --git a/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerClient.cpp b/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerClient.cpp index f652a5769ff..07e3830c877 100644 --- a/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerClient.cpp +++ b/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerClient.cpp @@ -2,7 +2,6 @@ #include "MessengerC.h" #include "ace/Get_Opt.h" -#include "ace/Argv_Type_Converter.h" #include <iostream> int call_shutdown = 0; @@ -36,9 +35,7 @@ int ACE_TMAIN( int argc, ACE_TCHAR* argv[] ) { try { // Initialize the ORB. - ACE_Argv_Type_Converter conv(argc, argv); - CORBA::ORB_var orb = CORBA::ORB_init(conv.get_argc(), - conv.get_TCHAR_argv()); + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); // Parse arguments. if (parse_args (argc, argv) != 0) diff --git a/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerServer.cpp b/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerServer.cpp index 644268be083..0aba027c120 100644 --- a/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerServer.cpp +++ b/TAO/DevGuideExamples/Multithreading/GracefulShutdown/MessengerServer.cpp @@ -4,11 +4,11 @@ #include "Messenger_i.h" #include "MessengerShutdownTimer.h" #include "ace/Get_Opt.h" -#include "ace/Argv_Type_Converter.h" #include "ace/Reactor.h" #include "tao/ORB_Core.h" #include <iostream> #include <fstream> +ACE_TString ior_output_file; // By default, shutdown when client calls Messenger::shutdown(). MessengerServer::ShutdownMethod s_method = MessengerServer::s_client_call; @@ -95,7 +95,7 @@ void MessengerServer::shutdown_on_console_input () // parse arguments int MessengerServer::parse_args (int argc, ACE_TCHAR* argv[]) { - ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("xp:t:cr:")); + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("xp:t:cr:o:")); int c; while ((c = get_opts ()) != -1) @@ -116,6 +116,9 @@ int MessengerServer::parse_args (int argc, ACE_TCHAR* argv[]) case 'c': s_method = MessengerServer::s_console_input; break; + case 'o': + ior_output_file = get_opts.optarg; + break; case 'r': s_method = MessengerServer::s_run_time_value; timeout = ACE_OS::atoi(get_opts.opt_arg()); @@ -127,6 +130,7 @@ int MessengerServer::parse_args (int argc, ACE_TCHAR* argv[]) "-x (default) - shutdown on client invocation\n" "-p <n> - use polling loop for <n> iterations\n" "-t <n> - schedule timer for <n> seconds\n" + "-o <iorfile>\n" "-c - shutdown on console input\n" "-r <n> - run ORB for <n> seconds\n", argv[0]), @@ -146,9 +150,7 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize the ORB. - ACE_Argv_Type_Converter conv(argc, argv); - CORBA::ORB_var orb = CORBA::ORB_init(conv.get_argc(), - conv.get_TCHAR_argv()); + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); //Get reference to the RootPOA. CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" ); |