summaryrefslogtreecommitdiff
path: root/TAO/tests/Client_Leaks
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-03-28 03:32:27 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-03-28 03:32:27 +0000
commitb61ca1c497bdd22453bf6177601e376094ab5c1d (patch)
treeb1ef956f09309000ecf4e1eaae2e774dcf993d89 /TAO/tests/Client_Leaks
parent217175d6097bc2a4218871c26aafc99ebc6d6f9a (diff)
downloadATCD-b61ca1c497bdd22453bf6177601e376094ab5c1d.tar.gz
ChangeLogTag:Tue Mar 27 19:27:19 2001 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'TAO/tests/Client_Leaks')
-rw-r--r--TAO/tests/Client_Leaks/Client_Task.cpp47
-rw-r--r--TAO/tests/Client_Leaks/Client_Task.h16
-rw-r--r--TAO/tests/Client_Leaks/Process_Factory.cpp2
-rw-r--r--TAO/tests/Client_Leaks/child.cpp4
-rw-r--r--TAO/tests/Client_Leaks/client.cpp7
-rwxr-xr-xTAO/tests/Client_Leaks/run_test.pl4
-rw-r--r--TAO/tests/Client_Leaks/server.cpp2
7 files changed, 73 insertions, 9 deletions
diff --git a/TAO/tests/Client_Leaks/Client_Task.cpp b/TAO/tests/Client_Leaks/Client_Task.cpp
index 3bee2b5f454..61d60e45ba1 100644
--- a/TAO/tests/Client_Leaks/Client_Task.cpp
+++ b/TAO/tests/Client_Leaks/Client_Task.cpp
@@ -10,21 +10,37 @@ Client_Task::Client_Task (Test::Process_Factory_ptr process_factory,
int iterations)
: process_factory_ (Test::Process_Factory::_duplicate (process_factory))
, iterations_ (iterations)
+ , successful_calls_ (0)
{
}
int
+Client_Task::successful_calls (void) const
+{
+ return this->successful_calls_;
+}
+
+int
Client_Task::svc (void)
{
ACE_DEBUG ((LM_DEBUG, "(%P|%t) Starting client task\n"));
ACE_DECLARE_NEW_CORBA_ENV;
+
+ int successful_calls = 0;
+
ACE_TRY
{
+ this->validate_connection (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
for (int i = 0; i != this->iterations_; ++i)
{
- this->one_iteration (ACE_TRY_ENV);
+ int retval = this->one_iteration (ACE_TRY_ENV);
ACE_TRY_CHECK;
+ if (retval != 0)
+ successful_calls++;
+
if (i % 10 == 0)
{
ACE_DEBUG ((LM_DEBUG,
@@ -35,14 +51,39 @@ Client_Task::svc (void)
}
ACE_CATCHANY
{
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "Exception caught:");
return -1;
}
ACE_ENDTRY;
ACE_DEBUG ((LM_DEBUG, "(%P|%t) Client task finished\n"));
+
+ ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->mutex_, -1);
+ this->successful_calls_ += successful_calls;
+
return 0;
}
void
+Client_Task::validate_connection (CORBA::Environment &ACE_TRY_ENV)
+{
+ ACE_TRY
+ {
+ for (int i = 0; i != 100; ++i)
+ {
+ (void) this->process_factory_->_non_existent (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+ }
+ ACE_CATCH (CORBA::TRANSIENT, ex)
+ {
+ // Ignore transient exceptions
+ }
+ ACE_ENDTRY;
+ ACE_CHECK;
+}
+
+int
Client_Task::one_iteration (CORBA::Environment &ACE_TRY_ENV)
{
ACE_TRY
@@ -56,6 +97,8 @@ Client_Task::one_iteration (CORBA::Environment &ACE_TRY_ENV)
process->shutdown (ACE_TRY_ENV);
ACE_TRY_CHECK;
+
+ return 1;
}
ACE_CATCH(Test::Spawn_Failed, ignored)
{
@@ -68,4 +111,6 @@ Client_Task::one_iteration (CORBA::Environment &ACE_TRY_ENV)
"Exception caught:");
}
ACE_ENDTRY;
+
+ return 0;
}
diff --git a/TAO/tests/Client_Leaks/Client_Task.h b/TAO/tests/Client_Leaks/Client_Task.h
index f45000f6018..0b47599a18d 100644
--- a/TAO/tests/Client_Leaks/Client_Task.h
+++ b/TAO/tests/Client_Leaks/Client_Task.h
@@ -21,12 +21,18 @@ public:
Client_Task (Test::Process_Factory_ptr process_Factory,
int iterations);
+ /// Return the total number of sucessful calls
+ int successful_calls (void) const;
+
/// Thread entry point
int svc (void);
private:
- /// Run one iteration of the test
- void one_iteration (CORBA::Environment &ACE_TRY_ENV);
+ /// Run one iteration of the test
+ int one_iteration (CORBA::Environment &ACE_TRY_ENV);
+
+ /// Make sure that the thread has a connection available
+ void validate_connection (CORBA::Environment &ACE_TRY_ENV);
private:
/// Reference to the test interface
@@ -34,6 +40,12 @@ private:
/// Total number of processes created by each thread
int iterations_;
+
+ /// At least some calls must be successful
+ int successful_calls_;
+
+ /// Implement the Monitor Object Pattern.
+ TAO_SYNCH_MUTEX mutex_;
};
#include "ace/post.h"
diff --git a/TAO/tests/Client_Leaks/Process_Factory.cpp b/TAO/tests/Client_Leaks/Process_Factory.cpp
index ee0f819c6dd..6c3a83fac70 100644
--- a/TAO/tests/Client_Leaks/Process_Factory.cpp
+++ b/TAO/tests/Client_Leaks/Process_Factory.cpp
@@ -38,7 +38,7 @@ Process_Factory::create_new_process (CORBA::Environment &ACE_TRY_ENV)
CORBA::String_var ior =
this->orb_->object_to_string (startup_callback.in (), ACE_TRY_ENV);
ACE_CHECK_RETURN (Test::Process::_nil ());
-
+
const char* argv[3] = {
"child",
ior.in (),
diff --git a/TAO/tests/Client_Leaks/child.cpp b/TAO/tests/Client_Leaks/child.cpp
index 2d5b51a97f2..b0205868b58 100644
--- a/TAO/tests/Client_Leaks/child.cpp
+++ b/TAO/tests/Client_Leaks/child.cpp
@@ -84,8 +84,8 @@ main (int argc, char *argv[])
}
ACE_CATCHANY
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
- "Exception caught:");
+ // Do not print error messages, they only make the test output
+ // confusing.
return 1;
}
ACE_ENDTRY;
diff --git a/TAO/tests/Client_Leaks/client.cpp b/TAO/tests/Client_Leaks/client.cpp
index 04f12f17db2..cd4765cd026 100644
--- a/TAO/tests/Client_Leaks/client.cpp
+++ b/TAO/tests/Client_Leaks/client.cpp
@@ -88,6 +88,13 @@ main (int argc, char *argv[])
orb->destroy (ACE_TRY_ENV);
ACE_TRY_CHECK;
+
+ // Only pass the test if 90% of the calls worked
+ if (client_task.successful_calls () < 0.9 * iterations * threads)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "ERROR: no calls were successful\n"));
+ }
}
ACE_CATCHANY
{
diff --git a/TAO/tests/Client_Leaks/run_test.pl b/TAO/tests/Client_Leaks/run_test.pl
index f58aec1adda..4e6f814bf85 100755
--- a/TAO/tests/Client_Leaks/run_test.pl
+++ b/TAO/tests/Client_Leaks/run_test.pl
@@ -16,13 +16,13 @@ $CL = new PerlACE::Process ("client", " -k file://$iorfile");
$SV->Spawn ();
-if (PerlACE::waitforfile_timed ($iorfile, 5) == -1) {
+if (PerlACE::waitforfile_timed ($iorfile, 15) == -1) {
print STDERR "ERROR: cannot find file <$iorfile>\n";
$SV->Kill (); $SV->TimedWait (1);
exit 1;
}
-$client = $CL->SpawnWaitKill (300);
+$client = $CL->SpawnWaitKill (600);
if ($client != 0) {
print STDERR "ERROR: client returned $client\n";
diff --git a/TAO/tests/Client_Leaks/server.cpp b/TAO/tests/Client_Leaks/server.cpp
index c0b57feed90..f6e61ccf181 100644
--- a/TAO/tests/Client_Leaks/server.cpp
+++ b/TAO/tests/Client_Leaks/server.cpp
@@ -92,7 +92,7 @@ main (int argc, char *argv[])
Server_Task server_task (orb.in (),
ACE_Thread_Manager::instance ());
- if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 4, 1) == -1)
+ if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 8, 1) == -1)
{
ACE_ERROR ((LM_ERROR, "Error activating server task\n"));
}