diff options
author | sma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-06-10 12:44:51 +0000 |
---|---|---|
committer | sma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-06-10 12:44:51 +0000 |
commit | 0030919dfb220c28b5ff7679b28da818eae8f137 (patch) | |
tree | acc42ec15338973c22df05832c295d7a9bc7e36d /TAO/tests | |
parent | ea3f93f36a114ff5ea408fecd3f291cf5dcd65a0 (diff) | |
download | ATCD-0030919dfb220c28b5ff7679b28da818eae8f137.tar.gz |
ChangeLogTag: Fri Jun 10 12:41:00 UTC 2011 Simon Massey <sma at prismtech dot com>
Diffstat (limited to 'TAO/tests')
-rw-r--r-- | TAO/tests/MT_NoUpcall_Client_Leader/chatter.cpp | 15 | ||||
-rw-r--r-- | TAO/tests/MT_NoUpcall_Client_Leader/chatter.h | 5 | ||||
-rw-r--r-- | TAO/tests/MT_NoUpcall_Client_Leader/client.cpp | 66 | ||||
-rw-r--r-- | TAO/tests/MT_NoUpcall_Client_Leader/police.cpp | 10 | ||||
-rwxr-xr-x | TAO/tests/MT_NoUpcall_Client_Leader/run_test.pl | 29 | ||||
-rw-r--r-- | TAO/tests/MT_NoUpcall_Client_Leader/server.cpp | 36 |
6 files changed, 87 insertions, 74 deletions
diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/chatter.cpp b/TAO/tests/MT_NoUpcall_Client_Leader/chatter.cpp index 6a9248bda6f..b29c1e9bfc1 100644 --- a/TAO/tests/MT_NoUpcall_Client_Leader/chatter.cpp +++ b/TAO/tests/MT_NoUpcall_Client_Leader/chatter.cpp @@ -28,7 +28,7 @@ Chatter::nrequests (void) int Chatter::svc (void) { - long nrq = nrequests (); + long nrq = -1; try { //sleep(1); @@ -43,12 +43,19 @@ Chatter::svc (void) ACE_ERROR_RETURN ((LM_ERROR, "Nil reference <%s>\n", ior_), -1); // make call on server + { + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, request_reply_count_mutex_, -1); + nrq= nrequests (); + nrequests_++; + } ACE_DEBUG((LM_INFO,"(%P|%t) Chatter[%d] started for %s\n", nrq, ior_)); - nrequests_++; intf_var->ping(); - nreplies_++; + { + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, request_reply_count_mutex_, -1); + nreplies_++; + } - ACE_DEBUG((LM_INFO,"(%P|%t) Chatter[%d] completed for %s\n", nrq, ior_)); + ACE_DEBUG((LM_INFO,"(%P|%t) Chatter[%d,%d,%d] completed for %s\n", nrq, nrequests_, nreplies_, ior_)); cond_.signal(); return 0; } diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/chatter.h b/TAO/tests/MT_NoUpcall_Client_Leader/chatter.h index 8e5a313a0fa..576a4419ea8 100644 --- a/TAO/tests/MT_NoUpcall_Client_Leader/chatter.h +++ b/TAO/tests/MT_NoUpcall_Client_Leader/chatter.h @@ -17,10 +17,11 @@ public: long nrequests (void); long nreplies (void); public: - long nrequests_; - long nreplies_; + volatile long nrequests_; + volatile long nreplies_; private: const ACE_TCHAR* ior_; ACE_Condition<ACE_Mutex>& cond_; + TAO_SYNCH_MUTEX request_reply_count_mutex_; }; #endif /* CHATTER_H */ diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/client.cpp b/TAO/tests/MT_NoUpcall_Client_Leader/client.cpp index fafa60c74d1..9d2dde85f95 100644 --- a/TAO/tests/MT_NoUpcall_Client_Leader/client.cpp +++ b/TAO/tests/MT_NoUpcall_Client_Leader/client.cpp @@ -7,6 +7,7 @@ #include "ace/SString.h" #include "ace/Get_Opt.h" +#include "ace/OS_NS_unistd.h" const ACE_TCHAR *ior_output_file = ACE_TEXT ("client.ior"); int nr_threads = 1; @@ -107,54 +108,57 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) ACE_Mutex mutex; ACE_Condition<ACE_Mutex> stop_condition (mutex); + { + ACE_GUARD_RETURN (ACE_Mutex, guard, mutex, -1); - const ACE_TCHAR* serverior = ACE_TEXT("file://server.ior"); - Chatter worker2 (orb_.in (), serverior, stop_condition); + const ACE_TCHAR* serverior = ACE_TEXT("file://server.ior"); + Chatter worker2 (orb_.in (), serverior, stop_condition); - if (worker2.activate (THR_NEW_LWP | THR_JOINABLE, 2) != 0) - ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", - "Cannot activate chatty client threads"), -1); + if (worker2.activate (THR_NEW_LWP | THR_JOINABLE, 2) != 0) + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", + "Cannot activate chatty client threads"), -1); + do { + stop_condition.wait (); + ACE_DEBUG((LM_INFO,"(%P|%t) So far, %d/%d requests/replies have been processed\n", + worker2.nrequests (), worker2.nreplies ())); + } while (worker2.nreplies () < 2); + ACE_OS::sleep (8); - do { - stop_condition.wait (); - ACE_DEBUG((LM_INFO,"(%P|%t) So far, %d/%d requests/replies have been processed\n", - worker2.nrequests (), worker2.nreplies ())); - } - while (worker2.nreplies () < 2); - - // Kill the peer - { - CORBA::Object_var rawObject = orb_->string_to_object( serverior); + // Kill the peer + { + CORBA::Object_var rawObject = orb_->string_to_object( serverior); - Test_Idl::SharedIntf_var intf_var = + Test_Idl::SharedIntf_var intf_var = Test_Idl::SharedIntf::_narrow(rawObject.in()); - if (CORBA::is_nil (intf_var.in ())) - ACE_ERROR_RETURN ((LM_ERROR, "Nil reference <%s>\n", serverior), -1); + if (CORBA::is_nil (intf_var.in ())) + ACE_ERROR_RETURN ((LM_ERROR, "Nil reference <%s>\n", serverior), -1); - // make call on server - ACE_DEBUG((LM_INFO,"(%P|%t) farewell START for %s\n", serverior)); + // make call on server + ACE_DEBUG((LM_INFO,"(%P|%t) farewell START for %s\n", serverior)); - intf_var->farewell(); + intf_var->farewell(); - ACE_DEBUG((LM_INFO,"(%P|%t) farewell COMPLETE for %s\n", serverior)); - } + ACE_DEBUG((LM_INFO,"(%P|%t) farewell COMPLETE for %s\n", serverior)); + } + ACE_OS::sleep (8); - ACE_DEBUG((LM_INFO,"(%P|%t) END OF CLIENT TEST\n")); + ACE_DEBUG((LM_INFO,"(%P|%t) END OF CLIENT TEST\n")); - orb_.in()->shutdown (); + orb_.in()->shutdown (); - worker.thr_mgr()->wait (); + worker.thr_mgr()->wait (); - root_poa->destroy(1,1); + root_poa->destroy(1,1); - orb_->destroy(); + orb_->destroy(); - ACE_DEBUG((LM_INFO,"(%P|%t) Client Test %C\n", - (worker2.nrequests() == worker2.nreplies())?"succeeded":"failed")); + ACE_DEBUG((LM_INFO,"(%P|%t) Client Test %C\n", + (worker2.nrequests() == worker2.nreplies())?"succeeded":"failed")); - result = (worker2.nrequests_ == worker2.nreplies_)? 0 : -1; + result = (worker2.nrequests_ == worker2.nreplies_)? 0 : -1; + } } catch (const CORBA::Exception& ex) { diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/police.cpp b/TAO/tests/MT_NoUpcall_Client_Leader/police.cpp index 17eb4ea649e..852ccd952f1 100644 --- a/TAO/tests/MT_NoUpcall_Client_Leader/police.cpp +++ b/TAO/tests/MT_NoUpcall_Client_Leader/police.cpp @@ -5,9 +5,11 @@ void poll (const char* filename) { - ACE_stat st; - for (int r=1; r != 0; r = ACE_OS::stat (filename, &st)) + int r; + do { - ACE_OS::sleep (1); - } + ACE_stat st; + r = ACE_OS::stat (filename, &st); + ACE_OS::sleep (1); // Allows time between waiting scans and for contents to be written + } while (r != 0); } diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/run_test.pl b/TAO/tests/MT_NoUpcall_Client_Leader/run_test.pl index d64c2393165..9b33af7e783 100755 --- a/TAO/tests/MT_NoUpcall_Client_Leader/run_test.pl +++ b/TAO/tests/MT_NoUpcall_Client_Leader/run_test.pl @@ -8,6 +8,8 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' use lib "$ENV{ACE_ROOT}/bin"; use PerlACE::TestTarget; +my $exit_status = 0; + 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"; @@ -15,7 +17,6 @@ my $client_conf = $server->LocalFile ("mt_noupcall$PerlACE::svcconf_ext"); my $server_conf = $server->LocalFile ("mt_noupcall$PerlACE::svcconf_ext"); $debug_level = '0'; - foreach $i (@ARGV) { if ($i eq '-d') { $debug_level = '10'; @@ -33,14 +34,11 @@ $client->DeleteFile($client_iorbase); $SV = $server->CreateProcess ("server", "-ORBDebugLevel $debug_level -ORBSvcConf $server_conf " . "-t 1"); - $server_status = $SV->Spawn (); - if ($server_status != 0) { print STDERR "ERROR: server returned $server_status\n"; exit 1; } - if ($server->WaitForFileTimed ($server_iorbase, $server->ProcessStartWaitInterval()) == -1) { print STDERR "ERROR: cannot find file <$server_iorfile>\n"; @@ -49,9 +47,7 @@ if ($server->WaitForFileTimed ($server_iorbase, } $CL = $client->CreateProcess ("client", "-t 1"); - $client_status = $CL->Spawn (); - if ($client_status != 0) { print STDERR "ERROR: client returned $client_status\n"; $SV->Kill (); $SV->TimedWait (1); @@ -66,26 +62,27 @@ if ($client->WaitForFileTimed ($client_iorbase, } print "INFO: Awaiting server ...\n"; - -$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + 30); - +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval() + 60); if ($server_status != 0) { print STDERR "ERROR: server returned $server_status\n"; - $status = 1; + $exit_status = 1; } print "INFO: Awaiting client ...\n"; - -$client_status = $CL->WaitKill ($client->ProcessStartWaitInterval()); - +$client_status = $CL->WaitKill ($client->ProcessStartWaitInterval() + 10); if ($client_status != 0) { print STDERR "ERROR: client returned $client_status\n"; - $status = 1; + $exit_status = 1; } $server->DeleteFile($server_iorfile); $client->DeleteFile($client_iorfile); -print "INFO: Test succeeded\n"; -exit 0; +if ($exit_status == 0) { + print "INFO: Test succeeded\n"; +} +else { + print "INFO: Test Failed!\n"; +} +exit $exit_status; diff --git a/TAO/tests/MT_NoUpcall_Client_Leader/server.cpp b/TAO/tests/MT_NoUpcall_Client_Leader/server.cpp index b8e2e942dbc..e2479ce29fd 100644 --- a/TAO/tests/MT_NoUpcall_Client_Leader/server.cpp +++ b/TAO/tests/MT_NoUpcall_Client_Leader/server.cpp @@ -109,29 +109,31 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) ACE_Mutex mutex; ACE_Condition<ACE_Mutex> stop_condition (mutex); - - Chatter worker2 (orb_.in (), ACE_TEXT("file://client.ior"), stop_condition); - if (worker2.activate (THR_NEW_LWP | THR_JOINABLE, 1) != 0) { - ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "Cannot activate chatty client threads"), -1); - } + ACE_GUARD_RETURN (ACE_Mutex, guard, mutex, -1); - do { - stop_condition.wait (); - ACE_DEBUG((LM_INFO,"(%P|%t) So far, %d/%d requests/replies have been processed\n", - worker2.nrequests (), worker2.nreplies ())); - } - while (worker2.nrequests () < 1); + Chatter worker2 (orb_.in (), ACE_TEXT("file://client.ior"), stop_condition); + if (worker2.activate (THR_NEW_LWP | THR_JOINABLE, 1) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) %p\n", "Cannot activate chatty client threads"), -1); + } - worker.thr_mgr()->wait (); + do { + stop_condition.wait (); + ACE_DEBUG((LM_INFO,"(%P|%t) So far, %d/%d requests/replies have been processed\n", + worker2.nrequests (), worker2.nreplies ())); + } while (worker2.nrequests () < 1); - root_poa->destroy(1, 1); + worker.thr_mgr()->wait (); - orb_->destroy(); + root_poa->destroy(1, 1); - ACE_DEBUG((LM_INFO,"(%P|%t) Server Test %C\n", - (worker2.nrequests() == worker2.nreplies())?"succeeded":"failed")); - result = (worker2.nrequests() == worker2.nreplies())? 0 : -1; + orb_->destroy(); + + ACE_DEBUG((LM_INFO,"(%P|%t) Server Test %C\n", + (worker2.nrequests() == worker2.nreplies())?"succeeded":"failed")); + result = (worker2.nrequests() == worker2.nreplies())? 0 : -1; + } } catch (const CORBA::Exception& ex) { |