diff options
Diffstat (limited to 'TAO/tests')
151 files changed, 10307 insertions, 4103 deletions
diff --git a/TAO/tests/AMH_Oneway/run_test.pl b/TAO/tests/AMH_Oneway/run_test.pl index 551e6fbb23c..91885767c43 100755 --- a/TAO/tests/AMH_Oneway/run_test.pl +++ b/TAO/tests/AMH_Oneway/run_test.pl @@ -33,7 +33,7 @@ if ($sv != 0) { if ($server->WaitForFileTimed ($iorbase, $server->ProcessStartWaitInterval()) == -1) { print STDERR "ERROR: cannot find file <$server_iorfile>\n"; - $SV->Kill (); $SV->TimedWait (1); + $sv->Kill (); $sv->TimedWait (1); exit 1; } diff --git a/TAO/tests/Big_AMI/client.cpp b/TAO/tests/Big_AMI/client.cpp index a8b4332aed0..ac7a4292842 100644 --- a/TAO/tests/Big_AMI/client.cpp +++ b/TAO/tests/Big_AMI/client.cpp @@ -143,10 +143,10 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) return 1; // We reuse the object_var smart pointer! - object_var = orb->string_to_object (ior); + CORBA::Object_var ior_object = orb->string_to_object (ior); A::AMI_Test_var ami_test_var = - A::AMI_Test::_narrow (object_var.in ()); + A::AMI_Test::_narrow (ior_object.in ()); if (CORBA::is_nil (ami_test_var.in ())) { diff --git a/TAO/tests/Big_AMI/run_test.pl b/TAO/tests/Big_AMI/run_test.pl index 90c93b94d93..5606488c3a3 100755 --- a/TAO/tests/Big_AMI/run_test.pl +++ b/TAO/tests/Big_AMI/run_test.pl @@ -6,7 +6,7 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; $debug_level = '0'; $iterations = '10'; @@ -18,35 +18,48 @@ foreach $i (@ARGV) { } } -$iorfile = PerlACE::LocalFile ("server.ior"); +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"; -unlink $iorfile; +my $iorbase = "server.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", "-ORBdebuglevel $debug_level -d -o server.ior"); -} -else { - $SV = new PerlACE::Process ("server", "-ORBdebuglevel $debug_level -d -o $iorfile"); -} +$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -d -o $server_iorfile"); +$CL = $client->CreateProcess ("client", "-k file://$client_iorfile -i $iterations -x -b $payload"); -$SV->Spawn (); +$server_status = $SV->Spawn (); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + exit 1; +} -if (PerlACE::waitforfile_timed ($iorfile, $PerlACE::wait_interval_for_process_creation) == -1) { - print STDERR "ERROR: cannot find file <$iorfile>\n"; +if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; $SV->Kill (); $SV->TimedWait (1); exit 1; } -$CL = new PerlACE::Process ("client", " -k file://$iorfile -i $iterations -x -b $payload"); +$client_status = $CL->SpawnWaitKill (60); -$client = $CL->SpawnWaitKill (60); -$server = $SV->WaitKill (10); +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; + $status = 1; +} -unlink $iorfile; +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval()); -if ($server != 0 || $client != 0) { - exit 1; +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + $status = 1; } -exit 0; +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +exit $status; diff --git a/TAO/tests/Bug_2936_Regression/run_test.pl b/TAO/tests/Bug_2936_Regression/run_test.pl index ce13c4307a9..78e53c6fd7f 100755 --- a/TAO/tests/Bug_2936_Regression/run_test.pl +++ b/TAO/tests/Bug_2936_Regression/run_test.pl @@ -6,20 +6,26 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; + +my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; $status = 0; -$file = PerlACE::LocalFile ("test.ior"); -unlink $file; +my $iorbase = "test.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +$server->DeleteFile($iorbase); -my $class = (PerlACE::is_vxworks_test() ? 'PerlACE::ProcessVX' : - 'PerlACE::Process'); -$SV = new $class ("server"); +$SV = $server->CreateProcess ("server"); print STDERR "\n\n==== Running bug 2936 regression test\n"; -$SV->Spawn (); +$test = $SV->Spawn (); + +if ($test != 0) { + print STDERR "ERROR: test returned $test\n"; + exit 1; +} $collocated = $SV->WaitKill (30); @@ -28,6 +34,6 @@ if ($collocated != 0) { $status = 1; } -unlink $file; +$server->DeleteFile($iorbase); exit $status; diff --git a/TAO/tests/Bug_2953_Regression/server.cpp b/TAO/tests/Bug_2953_Regression/server.cpp index 067e7c26441..d5cb1f217c1 100644 --- a/TAO/tests/Bug_2953_Regression/server.cpp +++ b/TAO/tests/Bug_2953_Regression/server.cpp @@ -160,7 +160,7 @@ removeServant( RTCORBA::ThreadpoolId id) { PortableServer::ObjectId_var oid = poa->servant_to_id(servant); - poa->deactivate_object(oid); + poa->deactivate_object(oid.in()); rtorb->destroy_threadpool(id); ACE_DEBUG ((LM_DEBUG, "Destroyed threadpool with id <%d>\n", diff --git a/TAO/tests/Bug_3547_Regression/Stock_Quoter_Client.cpp b/TAO/tests/Bug_3547_Regression/Stock_Quoter_Client.cpp index 5ea95176562..87f319ebccc 100644 --- a/TAO/tests/Bug_3547_Regression/Stock_Quoter_Client.cpp +++ b/TAO/tests/Bug_3547_Regression/Stock_Quoter_Client.cpp @@ -6,6 +6,33 @@ #include "Stock_QuoterC.h" #include "UDPTestC.h" #include "ace/streams.h" +#include "ace/Task.h" + +class OrbTask : public ACE_Task_Base +{ +public: + OrbTask(const CORBA::ORB_ptr orb) + : orb_(CORBA::ORB::_duplicate(orb)) + { + } + + virtual int svc() + { + try + { + this->orb_->run (); + } + catch (const CORBA::Exception&) + { + } + return 0; + } + +private: + CORBA::ORB_var orb_; +}; + +static int n_threads = 1; unsigned char Msg[1000] = { 0 } ; @@ -25,6 +52,14 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) CORBA::Object_var stock_quoter_obj = orb->resolve_initial_references ("MyStockQuoter"); + OrbTask task(orb.in()); + + if (task.activate (THR_NEW_LWP | THR_JOINABLE, + n_threads) != 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot activate threads\n"), + 1); + UDPTestI_var server = UDPTestI::_narrow (udp_obj.in ()); Stock_Quoter_var quoter = Stock_Quoter::_narrow (stock_quoter_obj.in()); @@ -47,6 +82,8 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) quoter->shutdown (); + task.wait(); + orb->destroy (); } catch (CORBA::Exception& e) diff --git a/TAO/tests/Bug_3553_Regression/Bug_3553_Regression.mpc b/TAO/tests/Bug_3553_Regression/Bug_3553_Regression.mpc new file mode 100644 index 00000000000..5d39f6ca5f6 --- /dev/null +++ b/TAO/tests/Bug_3553_Regression/Bug_3553_Regression.mpc @@ -0,0 +1,37 @@ +// -*- MPC -*- +// $Id$ + +project(*idl): taoidldefaults { + idlflags += -Sp + IDL_Files { + Test.idl + } + custom_only = 1 +} + +project(*Server): taoserver, iortable { + after += *idl + Source_Files { + Hello.cpp + Bug_3553_Regression_server.cpp + } + Source_Files { + TestC.cpp + TestS.cpp + } + IDL_Files { + } +} + +project(*Client): taoclient, rtcorba, avoids_corba_e_micro { + after += *idl + Source_Files { + Bug_3553_Regression_client.cpp + } + Source_Files { + TestC.cpp + } + IDL_Files { + } +} + diff --git a/TAO/tests/Bug_3553_Regression/Bug_3553_Regression_client.cpp b/TAO/tests/Bug_3553_Regression/Bug_3553_Regression_client.cpp new file mode 100644 index 00000000000..4e8556742ed --- /dev/null +++ b/TAO/tests/Bug_3553_Regression/Bug_3553_Regression_client.cpp @@ -0,0 +1,124 @@ +// $Id$ + +#include "TestC.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "tao/Policy_Current.h" +#include "tao/Policy_Current.h" +#include "ace/Get_Opt.h" + +ACE_RCSID(TransportCache, client, "$Id$") + +int cache_size = 512; +int port_nr = 27530; + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("c:p:")); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'c': + cache_size = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'p': + port_nr = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-c <transport_cache_size>\n" + "-p <server_port_nr>\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + try + { + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + if (parse_args(argc, argv) != 0) + return 1; + + // Get the RTORB. + CORBA::Object_var obj = orb->resolve_initial_references ("RTORB"); + RTCORBA::RTORB_var rtorb = RTCORBA::RTORB::_narrow (obj.in()); + //create the private connections policy. This means that every connection + // to the server uses his own socket. + CORBA::PolicyList policies (1); + policies.length (1); + policies[0] = rtorb->create_private_connection_policy (); + + CORBA::Object_var pol_current_object = orb->resolve_initial_references ("PolicyCurrent"); + + CORBA::PolicyCurrent_var policy_current = + CORBA::PolicyCurrent::_narrow (pol_current_object.in ()); + + if (CORBA::is_nil (policy_current.in ())) + { + ACE_ERROR ((LM_ERROR, "ERROR: Nil policy current\n")); + return 1; + } + policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE); + + Test::Hello_var *hello_array = 0; + ACE_NEW_RETURN (hello_array, Test::Hello_var [cache_size], -1); + + int iter = 1; + for (iter = 1; iter <= cache_size; ++iter) + { + char object_string[256]; + char reference_string[256]; + ACE_OS::sprintf (reference_string, "TransportCacheTest%d", iter); + ACE_OS::sprintf (object_string, "corbaloc:iiop:localhost:%d/", port_nr); + ACE_OS::strcat (object_string, reference_string); + + CORBA::Object_var hello_obj = orb->string_to_object (object_string); + orb->register_initial_reference (reference_string, hello_obj.in ()); + + CORBA::String_var ior_string = orb->object_to_string (hello_obj.in()); + ACE_DEBUG((LM_DEBUG, ACE_TEXT("IOR string for reference %d : %C\n"), + iter, ior_string.in ())); + hello_array[iter-1] = Test::Hello::_narrow(hello_obj.in ()); + } + //now we've got the references -> call each and everyone of them + for (iter = 0; iter < cache_size; ++iter) + { + Test::Hello_var hello = hello_array[iter]; + if (CORBA::is_nil (hello.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + ACE_TEXT ("Nil Test::Hello reference\n")), + 1); + } + + CORBA::String_var the_string = hello->get_string (); + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C> from reference %d\n", + the_string.in (), iter + 1)); + } + //shutdown the server + if (iter >= 0) + hello_array[0]->shutdown (); + + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return 0; +} diff --git a/TAO/tests/Bug_3553_Regression/Bug_3553_Regression_server.cpp b/TAO/tests/Bug_3553_Regression/Bug_3553_Regression_server.cpp new file mode 100644 index 00000000000..4341198321e --- /dev/null +++ b/TAO/tests/Bug_3553_Regression/Bug_3553_Regression_server.cpp @@ -0,0 +1,102 @@ +// $Id$ + +#include "Hello.h" +#include "ace/Get_Opt.h" +#include "tao/IORTable/IORTable.h" + +ACE_RCSID (Hello, + server, + "$Id$") + +int cache_size = 512; + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("c:")); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'c': + cache_size = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-c <transport_cache_size> " + "\n", + argv [0]), + -1); + } + return 0; +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + try + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv); + + if (parse_args(argc, argv) != 0) + return 1; + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA"); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in ()); + + if (CORBA::is_nil (root_poa.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil RootPOA\n"), + 1); + + Hello *hello_impl = 0; + ACE_NEW_RETURN (hello_impl, + Hello (orb.in ()), + 1); + + PortableServer::ObjectId_var id = + root_poa->activate_object (hello_impl); + + CORBA::Object_var object = root_poa->id_to_reference (id.in ()); + + Test::Hello_var hello = Test::Hello::_narrow (object.in ()); + + CORBA::Object_var table_obj = orb->resolve_initial_references("IORTable"); + IORTable::Table_var table = IORTable::Table::_narrow(table_obj.in()); + for (int i = 1; i <= cache_size; ++i) + { + CORBA::String_var ior_string = orb->object_to_string (object.in()); + ACE_DEBUG((LM_DEBUG, ACE_TEXT("Registering object %d with IOR string: %C\n"), + i, ior_string.in ())); + char identifier[256]; + ACE_OS::sprintf (identifier, "TransportCacheTest%d", i); + table->bind(identifier, ior_string.in()); + } + + PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); + poa_manager->activate (); + + orb->run (); + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); + + root_poa->destroy (1, 1); + + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return 0; +} diff --git a/TAO/tests/Bug_3553_Regression/Hello.cpp b/TAO/tests/Bug_3553_Regression/Hello.cpp new file mode 100644 index 00000000000..df5dc90d3d9 --- /dev/null +++ b/TAO/tests/Bug_3553_Regression/Hello.cpp @@ -0,0 +1,23 @@ +// +// $Id$ +// +#include "Hello.h" + +ACE_RCSID(Hello, Hello, "$Id$") + +Hello::Hello (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +char * +Hello::get_string (void) +{ + return CORBA::string_dup ("Hello there!"); +} + +void +Hello::shutdown (void) +{ + this->orb_->shutdown (0); +} diff --git a/TAO/tests/Bug_3553_Regression/Hello.h b/TAO/tests/Bug_3553_Regression/Hello.h new file mode 100644 index 00000000000..f87205c3011 --- /dev/null +++ b/TAO/tests/Bug_3553_Regression/Hello.h @@ -0,0 +1,31 @@ +// +// $Id$ +// + +#ifndef HELLO_H +#define HELLO_H +#include /**/ "ace/pre.h" + +#include "TestS.h" + +/// Implement the Test::Hello interface +class Hello + : public virtual POA_Test::Hello +{ +public: + /// Constructor + Hello (CORBA::ORB_ptr orb); + + // = The skeleton methods + virtual char * get_string (void); + + virtual void shutdown (void); + +private: + /// Use an ORB reference to conver strings to objects and shutdown + /// the application. + CORBA::ORB_var orb_; +}; + +#include /**/ "ace/post.h" +#endif /* HELLO_H */ diff --git a/TAO/tests/Bug_3553_Regression/Test.idl b/TAO/tests/Bug_3553_Regression/Test.idl new file mode 100644 index 00000000000..3c0976e106d --- /dev/null +++ b/TAO/tests/Bug_3553_Regression/Test.idl @@ -0,0 +1,20 @@ +// +// $Id$ +// + +/// Put the interfaces in a module, to avoid global namespace pollution +module Test +{ + /// A very simple interface + interface Hello + { + /// Return a simple string + string get_string (); + + /// A method to shutdown the ORB + /** + * This method is used to simplify the test shutdown process + */ + oneway void shutdown (); + }; +}; diff --git a/TAO/tests/Bug_3553_Regression/run_test.pl b/TAO/tests/Bug_3553_Regression/run_test.pl new file mode 100755 index 00000000000..1a8599748b6 --- /dev/null +++ b/TAO/tests/Bug_3553_Regression/run_test.pl @@ -0,0 +1,64 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +$status = 0; +$debug_level = '0'; +$cache_size = '256'; +$port = '27530'; + +foreach $i (@ARGV) { + if ($i eq '-debug') { + $debug_level = '10'; + } + if ($i eq '-high') { + $cache_size = '1024'; + } + if ($i eq '-mid') { + $cache_size = '512'; + } + if ($i eq '-low') { + $cache_size = '256'; + } +} + +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 = $server->CreateProcess ("server", + "-c $cache_size -ORBdebuglevel $debug_level -ORBListenEndpoints iiop://localhost:$port"); +$CL = $client->CreateProcess ("client", + "-c $cache_size -p $port -ORBdebuglevel $debug_level"); + +$server_status = $SV->Spawn (); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + exit 1; +} + +# just for all security... +sleep(5); + +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval()); + +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; +} + +exit $status; diff --git a/TAO/tests/Bug_3558_Regression/client.cpp b/TAO/tests/Bug_3558_Regression/client.cpp index 9173e7bf9c5..42c66a099f6 100644 --- a/TAO/tests/Bug_3558_Regression/client.cpp +++ b/TAO/tests/Bug_3558_Regression/client.cpp @@ -147,7 +147,7 @@ test_server (void *arg) ACE_TEXT ("%D Shutdown server %d\n"), server_nr)); - if (!CORBA::is_nil(hello)) + if (!CORBA::is_nil(hello.in ())) { try { diff --git a/TAO/tests/Bug_3567_Regression/client.cpp b/TAO/tests/Bug_3567_Regression/client.cpp index 37bdddd9a43..188a2de3914 100644 --- a/TAO/tests/Bug_3567_Regression/client.cpp +++ b/TAO/tests/Bug_3567_Regression/client.cpp @@ -23,7 +23,7 @@ const ACE_TCHAR *ior = ACE_TEXT("file://test.ior"); int nthreads = 5; int niterations = 10; int debug = 0; -int number_of_replies = 0; +ACE_Atomic_Op <TAO_SYNCH_MUTEX, long> number_of_replies = 0; CORBA::Long in_number = 931232; const char * in_str = "Let's talk AMI."; @@ -98,7 +98,9 @@ class Client : public ACE_Task_Base { public: /// ctor - Client (A::AMI_Test_ptr server, int niterations); + Client (A::AMI_Test_ptr server, int niterations, A::AMI_AMI_TestHandler_ptr hnd); + /// dtor + ~Client () ; /// The thread entry point. virtual int svc (void); @@ -119,7 +121,7 @@ class Handler : public POA_A::AMI_AMI_TestHandler public: Handler (void) { - }; + } void set_ami_test (A::AMI_Test_ptr ami_test) { @@ -146,7 +148,7 @@ public: ami_test_var_->sendc_set_yadda (0, 5); --number_of_replies; - }; + } void foo_excep (::Messaging::ExceptionHolder * excep_holder) { @@ -161,35 +163,35 @@ public: { ex._tao_print_exception ("Caught exception:"); } - }; + } void get_yadda (CORBA::Long result) { ACE_DEBUG ((LM_DEBUG, "Callback method <get_yadda> called: result <%d>\n", result)); - }; + } void get_yadda_excep (::Messaging::ExceptionHolder *) { ACE_DEBUG ((LM_DEBUG, "Callback method <get_yadda_excep> called:\n")); - }; + } void set_yadda (void) { ACE_DEBUG ((LM_DEBUG, "Callback method <set_yadda> called:\n")); - }; + } void set_yadda_excep (::Messaging::ExceptionHolder *) { ACE_DEBUG ((LM_DEBUG, "Callback method <set_yadda_excep> called:\n")); - }; + } ~Handler (void) { - }; + } void inout_arg_test (const char *) { @@ -204,9 +206,6 @@ public: A::AMI_Test_var ami_test_var_; }; -// ReplyHandler. -Handler handler; - int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { @@ -251,8 +250,18 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) poa_manager->activate (); // Let the client perform the test in a separate thread + Handler handler; + PortableServer::ObjectId_var id = + root_poa->activate_object (&handler); + + CORBA::Object_var hnd_object = root_poa->id_to_reference (id.in ()); + + A::AMI_AMI_TestHandler_var the_handler_var = + A::AMI_AMI_TestHandler::_narrow (hnd_object.in ()); + + handler.set_ami_test (server.in ()); - Client client (server.in (), niterations); + Client client (server.in (), niterations, the_handler_var.in ()); if (client.activate (THR_NEW_LWP | THR_JOINABLE, nthreads) != 0) ACE_ERROR_RETURN ((LM_ERROR, @@ -267,7 +276,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) : Entering perform_work loop to receive <%d> replies\n", - number_of_replies)); + number_of_replies.value ())); } // ORB loop. @@ -285,7 +294,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) : Exited perform_work loop Received <%d> replies\n", - (nthreads*niterations) - number_of_replies)); + (nthreads*niterations) - number_of_replies.value ())); } client.thr_mgr ()->wait (); @@ -312,12 +321,16 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) // **************************************************************** Client::Client (A::AMI_Test_ptr server, - int niterations) - : ami_test_var_ (A::AMI_Test::_duplicate (server)), - niterations_ (niterations) + int niterations, + A::AMI_AMI_TestHandler_ptr hnd) + : ami_test_var_ (A::AMI_Test::_duplicate (server)) + , niterations_ (niterations) + , the_handler_var_ (A::AMI_AMI_TestHandler::_duplicate (hnd)) +{ +} + +Client::~Client () { - handler.set_ami_test (server); - the_handler_var_ = handler._this (/* */); } int @@ -332,7 +345,7 @@ Client::svc (void) if (debug) { ACE_DEBUG ((LM_DEBUG, - "(%P|%t) :<%d> Asynchronous methods issued\n", + "(%P|%t) <%d> Asynchronous methods issued\n", niterations)); } } @@ -357,7 +370,8 @@ Worker::svc (void) if (pending) { - this->orb_->perform_work(); + ACE_Time_Value tm (1, 0); + this->orb_->perform_work(tm); } } diff --git a/TAO/tests/Bug_3574_Regression/Bug_3574_Regression.mpc b/TAO/tests/Bug_3574_Regression/Bug_3574_Regression.mpc new file mode 100644 index 00000000000..9635718fe6c --- /dev/null +++ b/TAO/tests/Bug_3574_Regression/Bug_3574_Regression.mpc @@ -0,0 +1,8 @@ +// -*- MPC -*- +// $Id$ + +project(*): taoclient { + Source_Files { + test.cpp + } +} diff --git a/TAO/tests/Bug_3574_Regression/README b/TAO/tests/Bug_3574_Regression/README new file mode 100644 index 00000000000..4d31b51afe4 --- /dev/null +++ b/TAO/tests/Bug_3574_Regression/README @@ -0,0 +1,7 @@ +# $Id$ + +Description: +- sequence of 100 elements, means buffer allocation of 100 elements +- shrink to 99, means reinitialize 1 element to zap the old value +- extend to 100, means no allocation + diff --git a/TAO/tests/Bug_3574_Regression/run_test.pl b/TAO/tests/Bug_3574_Regression/run_test.pl new file mode 100755 index 00000000000..397c63d65bc --- /dev/null +++ b/TAO/tests/Bug_3574_Regression/run_test.pl @@ -0,0 +1,22 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +my $client = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; + +$CL = $client->CreateProcess ("client", "-ORBInitRef MyObjectId=file://myobj.ior"); + +$test = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval()); + +if ($test != 0) { + print STDERR "ERROR: test returned $test\n"; + exit 1; +} + +exit 0; diff --git a/TAO/tests/Bug_3574_Regression/test.cpp b/TAO/tests/Bug_3574_Regression/test.cpp new file mode 100644 index 00000000000..0e2c361dfa3 --- /dev/null +++ b/TAO/tests/Bug_3574_Regression/test.cpp @@ -0,0 +1,51 @@ +// $Id$ + +#include "tao/StringSeqC.h" + +int +ACE_TMAIN (int, ACE_TCHAR *[]) +{ + char const *str = "Some string"; + + CORBA::StringSeq seq; + seq.length (100); + for (CORBA::ULong i = 0; i < seq.length (); ++i) + { + seq[i] = str; + } + + // Save a pointer to the whole buffer. + char const * const *wholebuf = seq.get_buffer (); + + // This call should reinitialize the the 100th element + // (the fact that the shrunk elements are reinitialized is TAO + // specific but we test for it). + seq.length (99); + // No reallocation should happen for the buffer. + ACE_TEST_ASSERT (seq.get_buffer () == wholebuf); + // And set the length to the same value + seq.length (99); + ACE_TEST_ASSERT (seq.get_buffer () == wholebuf); + // We cannot be sure that the pointer to the reinitialized 100th + // element is different from the old one since memory manager can + // return the same pointer that we've just released but it must + // not be 0 and it must be an empty string. + ACE_TEST_ASSERT (wholebuf[99] != 0); + ACE_TEST_ASSERT (ACE_OS::strcmp (wholebuf[99], "") == 0); + + // Extend the sequence to the original size. + seq.length (100); + // No reallocation should happen for the buffer. + ACE_TEST_ASSERT (seq.get_buffer () == wholebuf); + // And now we can test absolutely legally that the 100th + // element was reinitialized as CORBA spec requires. + ACE_TEST_ASSERT (seq[99].in () != 0); + ACE_TEST_ASSERT (ACE_OS::strcmp (seq[99].in (), "") == 0); + seq.length (101); + // Reallocation should happen for the buffer. + ACE_TEST_ASSERT (seq.get_buffer () != wholebuf); + ACE_TEST_ASSERT (seq[100].in () != 0); + ACE_TEST_ASSERT (ACE_OS::strcmp (seq[100].in (), "") == 0); + + return 0; +} diff --git a/TAO/tests/Bug_3575_Regression/Bug_3575_Regression.mpc b/TAO/tests/Bug_3575_Regression/Bug_3575_Regression.mpc new file mode 100644 index 00000000000..9635718fe6c --- /dev/null +++ b/TAO/tests/Bug_3575_Regression/Bug_3575_Regression.mpc @@ -0,0 +1,8 @@ +// -*- MPC -*- +// $Id$ + +project(*): taoclient { + Source_Files { + test.cpp + } +} diff --git a/TAO/tests/Bug_3575_Regression/README b/TAO/tests/Bug_3575_Regression/README new file mode 100644 index 00000000000..d046ba031f0 --- /dev/null +++ b/TAO/tests/Bug_3575_Regression/README @@ -0,0 +1,5 @@ +# $Id$ + +Description: Before bug#3575 was fixed string_sequence_element::_retn() was +returning a pointer to a newly initialized element in a sequence loosing +the old pointer. diff --git a/TAO/tests/Bug_3575_Regression/run_test.pl b/TAO/tests/Bug_3575_Regression/run_test.pl new file mode 100755 index 00000000000..397c63d65bc --- /dev/null +++ b/TAO/tests/Bug_3575_Regression/run_test.pl @@ -0,0 +1,22 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +my $client = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; + +$CL = $client->CreateProcess ("client", "-ORBInitRef MyObjectId=file://myobj.ior"); + +$test = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval()); + +if ($test != 0) { + print STDERR "ERROR: test returned $test\n"; + exit 1; +} + +exit 0; diff --git a/TAO/tests/Bug_3575_Regression/test.cpp b/TAO/tests/Bug_3575_Regression/test.cpp new file mode 100644 index 00000000000..c461eb6431b --- /dev/null +++ b/TAO/tests/Bug_3575_Regression/test.cpp @@ -0,0 +1,19 @@ +// $Id$ + +#include "tao/StringSeqC.h" + +int +ACE_TMAIN (int, ACE_TCHAR *[]) +{ + char const *str = "Some string"; + + CORBA::StringSeq seq; + seq.length (1); + seq[0] = str; + char const *beforeptr = seq[0].in (); + CORBA::String_var tmp = seq[0]._retn (); + // The pointer returned by in() and _retn() must be the same. + ACE_TEST_ASSERT (beforeptr == tmp.in ()); + + return 0; +} diff --git a/TAO/tests/Bug_3597_Regression/Bug_3597_Regression.mpc b/TAO/tests/Bug_3597_Regression/Bug_3597_Regression.mpc new file mode 100644 index 00000000000..bddd65f8a15 --- /dev/null +++ b/TAO/tests/Bug_3597_Regression/Bug_3597_Regression.mpc @@ -0,0 +1,9 @@ +// -*- MPC -*- +// $Id$ + +project(*Server): taoserver { + Source_Files { + server.cpp + } +} + diff --git a/TAO/tests/Bug_3597_Regression/run_test.pl b/TAO/tests/Bug_3597_Regression/run_test.pl new file mode 100755 index 00000000000..d1d85802727 --- /dev/null +++ b/TAO/tests/Bug_3597_Regression/run_test.pl @@ -0,0 +1,22 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; + +$SV = $server->CreateProcess ("server"); + +$test = $SV->SpawnWaitKill ($server->ProcessStartWaitInterval()); + +if ($test != 0) { + print STDERR "ERROR: test returned $test\n"; + exit 1; +} + +exit 0; diff --git a/TAO/tests/Bug_3597_Regression/server.cpp b/TAO/tests/Bug_3597_Regression/server.cpp new file mode 100644 index 00000000000..81e60283d0b --- /dev/null +++ b/TAO/tests/Bug_3597_Regression/server.cpp @@ -0,0 +1,86 @@ +// $Id$ + +#include "tao/corba.h" +#include "ace/Log_Msg.h" +#include "ace/Log_Msg_Backend.h" +#include "ace/Log_Record.h" + +const ACE_TCHAR* mykey = ACE_TEXT("KEY"); + +class Backend : public ACE_Log_Msg_Backend +{ +public: + Backend () + : ok_ (false) {} + + virtual int open (const ACE_TCHAR *logger_key); + + virtual int reset (void); + + virtual int close (void); + + virtual ssize_t log (ACE_Log_Record &log_record); + + bool ok (void) const; + +private: + bool ok_; +}; + +int +Backend::open (const ACE_TCHAR *key) +{ + if (ACE_OS::strcmp (key, mykey) == 0) + this->ok_ = true; + return 0; +} + +int +Backend::reset (void) +{ + return 0; +} + +int +Backend::close (void) +{ + return 0; +} + +ssize_t +Backend::log (ACE_Log_Record &) +{ + return 1; +} + +bool +Backend::ok (void) const +{ + return this->ok_; +} + +int ACE_TMAIN (int, ACE_TCHAR *argv[]) +{ + Backend b; + ACE_Log_Msg_Backend *old_b = ACE_Log_Msg::msg_backend (&b); + + ACE_LOG_MSG->set_flags (ACE_Log_Msg::CUSTOM); + + ACE_TCHAR *my_argv[3]; + my_argv[0] = argv[0]; + my_argv[1] = const_cast<ACE_TCHAR *> (ACE_TEXT ("-ORBServiceConfigLoggerKey")); + my_argv[2] = const_cast<ACE_TCHAR *> (mykey); + int my_argc = 3; + + CORBA::ORB_var orb2_ = CORBA::ORB_init (my_argc, my_argv, "ServerORB1"); + + if (!b.ok ()) + { + ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Key not ok!\n"), 1); + } + + // Reset the backend to avoid references to our soon-to-be-destroyed one. + ACE_Log_Msg::msg_backend (old_b); + + return 0; +} diff --git a/TAO/tests/Bug_3598a_Regression/Bug_3598a_Regression.mpc b/TAO/tests/Bug_3598a_Regression/Bug_3598a_Regression.mpc new file mode 100644 index 00000000000..0e883f6f7b0 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/Bug_3598a_Regression.mpc @@ -0,0 +1,39 @@ +// -*- MPC -*- +// $Id$ + +project(*idl): taoidldefaults { + idlflags += -Sp + IDL_Files { + Test.idl + } + custom_only = 1 +} + +project(*Server): taoserver, strategies { + after += *idl + Source_Files { + Hello.cpp + server.cpp + } + Source_Files { + TestC.cpp + TestS.cpp + } + IDL_Files { + } +} + +project(*Client): taoclient, pi, strategies { + after += *idl + Source_Files { + ClientORBInitializer.cpp + ClientRequest_Interceptor.cpp + client.cpp + } + Source_Files { + TestC.cpp + } + IDL_Files { + } +} + diff --git a/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.cpp b/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.cpp new file mode 100644 index 00000000000..2f4406185c9 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.cpp @@ -0,0 +1,28 @@ +// -*- C++ -*- +// +// $Id$ + +#include "ClientORBInitializer.h" + +void +ClientORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr) +{ + // No-op +} + +void +ClientORBInitializer::post_init (PortableInterceptor::ORBInitInfo_ptr info) +{ + PortableInterceptor::ClientRequestInterceptor_ptr cri = + PortableInterceptor::ClientRequestInterceptor::_nil (); + + ACE_NEW_THROW_EX (cri, + ClientRequest_Interceptor, + CORBA::NO_MEMORY ()); + + PortableInterceptor::ClientRequestInterceptor_var + client_interceptor = cri; + + info->add_client_request_interceptor (client_interceptor.in ()); + +} diff --git a/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.h b/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.h new file mode 100644 index 00000000000..1c0ca44b138 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.h @@ -0,0 +1,50 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ClientORBInitializer.h + * + * $Id$ + */ +//============================================================================= +#ifndef CLIENTORBINITIALIZER_H +#define CLIENTORBINITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "tao/PortableInterceptorC.h" +#include "ClientRequest_Interceptor.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/// RTCORBA ORB initializer. +class ClientORBInitializer : + public virtual PortableInterceptor::ORBInitializer, + public virtual ::CORBA::LocalObject +{ +public: + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info); +}; + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" + +#endif /* CLIENTORBINITIALIZER_H */ diff --git a/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.cpp b/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.cpp new file mode 100644 index 00000000000..8c25c69b51e --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.cpp @@ -0,0 +1,89 @@ +// $Id$ + +#include "ClientRequest_Interceptor.h" + +#include "tao/CORBA_String.h" +#include "tao/debug.h" +#include "ace/Log_Msg.h" + + CORBA::Boolean + ClientRequest_Interceptor::success_flag_ = 0; + + ClientRequest_Interceptor::ClientRequest_Interceptor (void) + : name_ ("ClientRequest_Interceptor") + { + } + + ClientRequest_Interceptor::~ClientRequest_Interceptor (void) + { + } + + char * + ClientRequest_Interceptor::name () + { + return CORBA::string_dup (this->name_); + } + + void + ClientRequest_Interceptor::destroy () + { + // No-op + } + + void + ClientRequest_Interceptor::send_poll ( + PortableInterceptor::ClientRequestInfo_ptr ri + ) + { + // Print debug + CORBA::String_var op = + ri->operation (); + + + ACE_DEBUG ((LM_DEBUG, + "TAO_FT (%P|%t): ClientRequest_Interceptor::send_poll called for operation: %C\n", + op.in ())); + } + + void + ClientRequest_Interceptor::send_request ( + PortableInterceptor::ClientRequestInfo_ptr ri) + { + // Print debug + CORBA::String_var op = + ri->operation (); + + + ACE_DEBUG ((LM_DEBUG, + "ClientRequest_Interceptor::send_request called for operation: %C - things are going well...\n", + op.in ())); + } + + void + ClientRequest_Interceptor::receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr) + { + // No-op + } + + void + ClientRequest_Interceptor::receive_other ( + PortableInterceptor::ClientRequestInfo_ptr) + { + // No-op + } + + void + ClientRequest_Interceptor::receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr ri) + { + // Print debug + CORBA::String_var op = + ri->operation (); + + + ACE_DEBUG ((LM_DEBUG, + "ClientRequest_Interceptor::receive_exception called for operation: %C - test has succeeded...\n", + op.in ())); + success_flag_ = 1; + } diff --git a/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.h b/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.h new file mode 100644 index 00000000000..36e4fc7032d --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.h @@ -0,0 +1,68 @@ +// -*- C++ -*- +//============================================================================= +/** + * @file ClientRequest_Interceptor.h + * + * $Id$ + */ +//============================================================================= +#ifndef CLIENTREQUEST_INTERCEPTOR_H +#define CLIENTREQUEST_INTERCEPTOR_H +#include /**/ "ace/pre.h" + +#include "tao/PI/PI.h" +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** +* @class ClientRequest_Interceptor +* +*/ +class ClientRequest_Interceptor +: public virtual PortableInterceptor::ClientRequestInterceptor, + public virtual ::CORBA::LocalObject +{ +public: + +ClientRequest_Interceptor (void); + +~ClientRequest_Interceptor (void); + +/// Canonical name of the interceptor. +virtual char * name (); + + +virtual void destroy (); + +virtual void send_poll (PortableInterceptor::ClientRequestInfo_ptr); + +virtual void send_request (PortableInterceptor::ClientRequestInfo_ptr ri); + +virtual void receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri); + +virtual void receive_other (PortableInterceptor::ClientRequestInfo_ptr ri); + +virtual void receive_exception (PortableInterceptor::ClientRequestInfo_ptr ri); + +static CORBA::Boolean success_flag_; + +private: + +/// Name of the interceptor +const char *name_; + +}; +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /*CLIENTREQUEST_INTERCEPTOR_H*/ + diff --git a/TAO/tests/Bug_3598a_Regression/Hello.cpp b/TAO/tests/Bug_3598a_Regression/Hello.cpp new file mode 100644 index 00000000000..7b9497529ec --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/Hello.cpp @@ -0,0 +1,23 @@ +// +// $Id$ +// +#include "Hello.h" + +ACE_RCSID(Hello, Hello, "Hello.cpp,v 1.3 2002/01/29 20:21:07 okellogg Exp") + +Hello::Hello (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +char * +Hello::get_string () +{ + return CORBA::string_dup ("Hello there!"); +} + +void +Hello::shutdown () +{ + this->orb_->shutdown (0 ); +} diff --git a/TAO/tests/Bug_3598a_Regression/Hello.h b/TAO/tests/Bug_3598a_Regression/Hello.h new file mode 100644 index 00000000000..782b1b2f573 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/Hello.h @@ -0,0 +1,31 @@ +// +// $Id$ +// + +#ifndef HELLO_H +#define HELLO_H +#include /**/ "ace/pre.h" + +#include "TestS.h" + +/// Implement the Test::Hello interface +class Hello + : public virtual POA_Test::Hello +{ +public: + /// Constructor + Hello (CORBA::ORB_ptr orb); + + // = The skeleton methods + virtual char * get_string (); + + virtual void shutdown (); + +private: + /// Use an ORB reference to conver strings to objects and shutdown + /// the application. + CORBA::ORB_var orb_; +}; + +#include /**/ "ace/post.h" +#endif /* HELLO_H */ diff --git a/TAO/tests/Bug_3598a_Regression/README b/TAO/tests/Bug_3598a_Regression/README new file mode 100644 index 00000000000..b2d570b8158 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/README @@ -0,0 +1,12 @@ +$Id$ + +This test attempts to contact a server IOR with no connectable profile in it (on account of how there is no server running). + +The method invocation should fail but the installed client request interceptor should have its send_request and receive_exception methods invoked regardless. + +The expected result looks like: + +Client about to make method call that is doomed to failure... +ClientRequest_Interceptor::send_request called for operation: get_string - things are going well... +ClientRequest_Interceptor::receive_exception called for operation: get_string - test has succeeded... +Success - the server was unreachable and PI receive_exception was invoked. diff --git a/TAO/tests/Bug_3598a_Regression/Test.idl b/TAO/tests/Bug_3598a_Regression/Test.idl new file mode 100644 index 00000000000..3c0976e106d --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/Test.idl @@ -0,0 +1,20 @@ +// +// $Id$ +// + +/// Put the interfaces in a module, to avoid global namespace pollution +module Test +{ + /// A very simple interface + interface Hello + { + /// Return a simple string + string get_string (); + + /// A method to shutdown the ORB + /** + * This method is used to simplify the test shutdown process + */ + oneway void shutdown (); + }; +}; diff --git a/TAO/tests/Bug_3598a_Regression/client.cpp b/TAO/tests/Bug_3598a_Regression/client.cpp new file mode 100644 index 00000000000..06919103896 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/client.cpp @@ -0,0 +1,103 @@ +// $Id$ + +#include "TestC.h" +#include "ace/Get_Opt.h" +#include "tao/PortableInterceptorC.h" +#include "ClientORBInitializer.h" +#include "tao/ORBInitializer_Registry.h" +#include "tao/Strategies/advanced_resource.h" +#include "tao/Strategies/OC_Endpoint_Selector_Loader.h" + +ACE_RCSID(Hello, client, "client.cpp,v 1.5 2002/01/29 20:21:07 okellogg Exp") + +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 sucessful parsing of the command line + return 0; +} + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + try + { + PortableInterceptor::ORBInitializer_ptr temp_orb_initializer = + PortableInterceptor::ORBInitializer::_nil (); + PortableInterceptor::ORBInitializer_var orb_initializer; + + // Register the ClientRequest_Interceptor ORBInitializer. + ACE_NEW_RETURN (temp_orb_initializer, + ClientORBInitializer, + -1); + + orb_initializer = temp_orb_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in ()); + + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var tmp = + orb->string_to_object (ACE_TEXT_ALWAYS_CHAR (ior)); + + Test::Hello_var hello = + Test::Hello::_narrow(tmp.in () ); + + if (CORBA::is_nil (hello.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Nil Test::Hello reference <%s>\n", + ior), + 1); + } + + ACE_DEBUG ((LM_DEBUG, "Client about to make method call that is doomed to failure...\n")); + + CORBA::String_var the_string = + hello->get_string (); + + ACE_ERROR_RETURN ((LM_DEBUG, + "Error - the remote call succeeded which is bloody miraculous given that no server is running !!\n"), + 1); + } + catch (const CORBA::Exception&) + { + if (ClientRequest_Interceptor::success_flag_) + { + ACE_DEBUG ((LM_DEBUG, "Success - the server was unreachable and PI receive_exception was invoked.\n")); + return 0; + } + else + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Error: regression failed - interceptor receive_exception interception point was not invoked !!\n"), + 1); + } + } + + return 1; +} diff --git a/TAO/tests/Bug_3598a_Regression/run_test.pl b/TAO/tests/Bug_3598a_Regression/run_test.pl new file mode 100755 index 00000000000..0af02716e71 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/run_test.pl @@ -0,0 +1,76 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +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"; + +my $iorbase = "server.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile"); +$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; +} + +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; +} + +$client_status = $CL->SpawnWaitKill (60); + +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; +} + +$server->GetStderrLog(); +$client->GetStderrLog(); + +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +exit $status; diff --git a/TAO/tests/Bug_3598a_Regression/server.cpp b/TAO/tests/Bug_3598a_Regression/server.cpp new file mode 100644 index 00000000000..95d61429e99 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/server.cpp @@ -0,0 +1,99 @@ +// $Id$ + +#include "Hello.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" + +ACE_RCSID (Hello, + server, + "server.cpp,v 1.6 2003/11/01 11:15:11 dhinton Exp") + +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 + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv); + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA" ); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () ); + + if (CORBA::is_nil (root_poa.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil RootPOA\n"), + 1); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (); + + if (parse_args (argc, argv) != 0) + return 1; + + Hello *hello_impl = 0; + ACE_NEW_RETURN (hello_impl, + Hello (orb.in ()), + 1); + PortableServer::ServantBase_var owner_transfer(hello_impl); + + Test::Hello_var hello = + hello_impl->_this (); + + CORBA::String_var ior = + orb->object_to_string (hello.in () ); + + // Output the IOR to the <ior_output_file> + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + root_poa->destroy (1, 1 ); + + orb->destroy (); + + ACE_DEBUG ((LM_DEBUG, "Event loop finished.\n")); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return 0; +} diff --git a/TAO/tests/Bug_3598a_Regression/svc.conf b/TAO/tests/Bug_3598a_Regression/svc.conf new file mode 100644 index 00000000000..75b92f3c589 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/svc.conf @@ -0,0 +1 @@ +static OC_Endpoint_Selector_Factory "-connect_timeout 1300" diff --git a/TAO/tests/Bug_3630_Regression/Bug_3630_Regression.mpc b/TAO/tests/Bug_3630_Regression/Bug_3630_Regression.mpc new file mode 100644 index 00000000000..bddd65f8a15 --- /dev/null +++ b/TAO/tests/Bug_3630_Regression/Bug_3630_Regression.mpc @@ -0,0 +1,9 @@ +// -*- MPC -*- +// $Id$ + +project(*Server): taoserver { + Source_Files { + server.cpp + } +} + diff --git a/TAO/tests/Bug_3630_Regression/TAO Conf File.conf b/TAO/tests/Bug_3630_Regression/TAO Conf File.conf new file mode 100644 index 00000000000..d02ffc26c2b --- /dev/null +++ b/TAO/tests/Bug_3630_Regression/TAO Conf File.conf @@ -0,0 +1 @@ +static Server_Strategy_Factory "-ORBConcurrency thread-per-connection" diff --git a/TAO/tests/Bug_3630_Regression/TAO_Conf_File.conf b/TAO/tests/Bug_3630_Regression/TAO_Conf_File.conf new file mode 100644 index 00000000000..d02ffc26c2b --- /dev/null +++ b/TAO/tests/Bug_3630_Regression/TAO_Conf_File.conf @@ -0,0 +1 @@ +static Server_Strategy_Factory "-ORBConcurrency thread-per-connection" diff --git a/TAO/tests/Bug_3630_Regression/run_test.pl b/TAO/tests/Bug_3630_Regression/run_test.pl new file mode 100755 index 00000000000..02ca089516f --- /dev/null +++ b/TAO/tests/Bug_3630_Regression/run_test.pl @@ -0,0 +1,29 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; + +$SV = $server->CreateProcess ("server"); + +$server_status = $SV->Spawn (); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + exit 1; +} + +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval()); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + $status = 1; +} + +exit $status; diff --git a/TAO/tests/Bug_3630_Regression/server.cpp b/TAO/tests/Bug_3630_Regression/server.cpp new file mode 100644 index 00000000000..f2e0bf4d4ae --- /dev/null +++ b/TAO/tests/Bug_3630_Regression/server.cpp @@ -0,0 +1,103 @@ +// $Id$ + +#include "tao/ORB.h" +#include "tao/ORB_Core.h" + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + int result = 0; + int extra_argc = 2; + int second_extra_argc = 2; + int largc = argc; + int second_largc = argc; + + try + { + ACE_TCHAR **extra = 0; + ACE_NEW_RETURN (extra, ACE_TCHAR *[extra_argc], -1); + extra[0] = ACE::strnew (ACE_TEXT ("-ORBSvcConf")); + extra[1] = ACE::strnew (ACE_TEXT ("TAO Conf File.conf")); + + ACE_TCHAR **largv = new ACE_TCHAR *[largc+extra_argc]; + for (int i = 0; i < largc; i++) + largv[i] = argv[i]; + + + for (int i = 0; i < extra_argc; i++) + largv[argc+i] = extra[i]; + + largc += extra_argc; + + CORBA::ORB_var orb = CORBA::ORB_init (largc, largv, "FirstORB"); + if(CORBA::is_nil(orb.in ())) + { + ACE_ERROR((LM_ERROR,ACE_TEXT ("Test failed. CORBA::ORB_init returned NIL ORB\n"),1)); + + for (int i = 0; i < extra_argc; i++) + ACE::strdelete (extra[i]); + + delete [] extra; + delete [] largv; + + return -1; + } + + orb->destroy (); + orb = CORBA::ORB::_nil (); + + for (int i = 0; i < extra_argc; i++) + ACE::strdelete (extra[i]); + delete [] extra; + delete [] largv; + + + ACE_TCHAR **second_extra = 0; + ACE_NEW_RETURN (second_extra, ACE_TCHAR *[second_extra_argc], -1); + extra[0] = ACE::strnew (ACE_TEXT ("-ORBSvcConf")); + extra[1] = ACE::strnew (ACE_TEXT ("TAO_Conf_File.conf")); + ACE_TCHAR **second_largv = new ACE_TCHAR *[second_largc+second_extra_argc]; + for (int i = 0; i < second_largc; i++) + second_largv[i] = argv[i]; + for (int i = 0; i < second_extra_argc; i++) + second_largv[argc+i] = second_extra[i]; + + second_largc += second_extra_argc; + + CORBA::ORB_var second_orb = CORBA::ORB_init (second_largc, second_largv, "SecondORB"); + if(CORBA::is_nil(second_orb.in ())) + { + ACE_ERROR((LM_ERROR,ACE_TEXT ("Test failed. CORBA::ORB_init returned NIL ORB\n"),1)); + + for (int i = 0; i < extra_argc; i++) + ACE::strdelete (second_extra[i]); + + delete [] second_extra; + delete [] second_largv; + + return -1; + } + + second_orb->destroy (); + second_orb = CORBA::ORB::_nil (); + + for (int i2 = 0; i2 < second_extra_argc; i2++) + ACE::strdelete (second_extra[i2]); + + delete [] second_extra; + delete [] second_largv; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + } + + if (result == 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Test passed!"))); + else + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Test failed. Result: %d\n"), + result)); + return result; +} diff --git a/TAO/tests/Bug_3636_Regression/Bug_3636_Regression.mpc b/TAO/tests/Bug_3636_Regression/Bug_3636_Regression.mpc new file mode 100644 index 00000000000..fbab84719e4 --- /dev/null +++ b/TAO/tests/Bug_3636_Regression/Bug_3636_Regression.mpc @@ -0,0 +1,37 @@ +// -*- MPC -*- +// $Id$ + +project(*idl): taoidldefaults { + idlflags += -Sp + IDL_Files { + Test.idl + } + custom_only = 1 +} + +project(*Server): taoserver { + after += *idl + Source_Files { + Hello.cpp + server.cpp + } + Source_Files { + TestC.cpp + TestS.cpp + } + IDL_Files { + } +} + +project(*Client): taoclient { + after += *idl + Source_Files { + client.cpp + } + Source_Files { + TestC.cpp + } + IDL_Files { + } +} + diff --git a/TAO/tests/Bug_3636_Regression/Hello.cpp b/TAO/tests/Bug_3636_Regression/Hello.cpp new file mode 100644 index 00000000000..df5dc90d3d9 --- /dev/null +++ b/TAO/tests/Bug_3636_Regression/Hello.cpp @@ -0,0 +1,23 @@ +// +// $Id$ +// +#include "Hello.h" + +ACE_RCSID(Hello, Hello, "$Id$") + +Hello::Hello (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +char * +Hello::get_string (void) +{ + return CORBA::string_dup ("Hello there!"); +} + +void +Hello::shutdown (void) +{ + this->orb_->shutdown (0); +} diff --git a/TAO/tests/Bug_3636_Regression/Hello.h b/TAO/tests/Bug_3636_Regression/Hello.h new file mode 100644 index 00000000000..f87205c3011 --- /dev/null +++ b/TAO/tests/Bug_3636_Regression/Hello.h @@ -0,0 +1,31 @@ +// +// $Id$ +// + +#ifndef HELLO_H +#define HELLO_H +#include /**/ "ace/pre.h" + +#include "TestS.h" + +/// Implement the Test::Hello interface +class Hello + : public virtual POA_Test::Hello +{ +public: + /// Constructor + Hello (CORBA::ORB_ptr orb); + + // = The skeleton methods + virtual char * get_string (void); + + virtual void shutdown (void); + +private: + /// Use an ORB reference to conver strings to objects and shutdown + /// the application. + CORBA::ORB_var orb_; +}; + +#include /**/ "ace/post.h" +#endif /* HELLO_H */ diff --git a/TAO/tests/Bug_3636_Regression/Test.idl b/TAO/tests/Bug_3636_Regression/Test.idl new file mode 100644 index 00000000000..3c0976e106d --- /dev/null +++ b/TAO/tests/Bug_3636_Regression/Test.idl @@ -0,0 +1,20 @@ +// +// $Id$ +// + +/// Put the interfaces in a module, to avoid global namespace pollution +module Test +{ + /// A very simple interface + interface Hello + { + /// Return a simple string + string get_string (); + + /// A method to shutdown the ORB + /** + * This method is used to simplify the test shutdown process + */ + oneway void shutdown (); + }; +}; diff --git a/TAO/tests/Bug_3636_Regression/client.cpp b/TAO/tests/Bug_3636_Regression/client.cpp new file mode 100644 index 00000000000..d1f53d7502e --- /dev/null +++ b/TAO/tests/Bug_3636_Regression/client.cpp @@ -0,0 +1,77 @@ +// $Id$ + +#include "TestC.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_unistd.h" + +ACE_RCSID(Hello, client, "$Id$") + +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 + { + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var tmp = orb->string_to_object(ior); + + Test::Hello_var hello = Test::Hello::_narrow(tmp.in ()); + + if (CORBA::is_nil (hello.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Nil Test::Hello reference <%s>\n", + ior), + 1); + } + + CORBA::String_var the_string = hello->get_string (); + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n", + the_string.in ())); + + ACE_OS::sleep (10); + + hello->shutdown (); + + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return 0; +} diff --git a/TAO/tests/Bug_3636_Regression/run_test.pl b/TAO/tests/Bug_3636_Regression/run_test.pl new file mode 100755 index 00000000000..d4c8c6c0428 --- /dev/null +++ b/TAO/tests/Bug_3636_Regression/run_test.pl @@ -0,0 +1,73 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +$status = 0; +$debug_level = '0'; + +foreach $i (@ARGV) { + if ($i eq '-debug') { + $debug_level = '11'; + } +} + +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"; + +my $iorbase = "server.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile"); +$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; +} + +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; +} + +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval()); + +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; +} + +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +exit $status; diff --git a/TAO/tests/Bug_3636_Regression/server.cpp b/TAO/tests/Bug_3636_Regression/server.cpp new file mode 100644 index 00000000000..601e72a15ea --- /dev/null +++ b/TAO/tests/Bug_3636_Regression/server.cpp @@ -0,0 +1,130 @@ +// $Id$ + +#include "Hello.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/Log_Msg.h" + +ACE_RCSID (Hello, + server, + "$Id$") + +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[]) +{ + int idle_count = 0; + try + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv); + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA"); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in ()); + + if (CORBA::is_nil (root_poa.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil RootPOA\n"), + 1); + + PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); + + if (parse_args (argc, argv) != 0) + return 1; + + Hello *hello_impl = 0; + ACE_NEW_RETURN (hello_impl, + Hello (orb.in ()), + 1); + PortableServer::ServantBase_var owner_transfer(hello_impl); + + PortableServer::ObjectId_var id = + root_poa->activate_object (hello_impl); + + CORBA::Object_var object = root_poa->id_to_reference (id.in ()); + + Test::Hello_var hello = Test::Hello::_narrow (object.in ()); + + CORBA::String_var ior = orb->object_to_string (hello.in ()); + + // Output the IOR to the <ior_output_file> + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s\n", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + poa_manager->activate (); + + for (;;) + { + ACE_Time_Value tv (0, 500); + while (orb->work_pending (tv)) + { + ACE_DEBUG ((LM_DEBUG, "Work pending\n")); + ACE_Time_Value tv2 (0, 500); + if (orb->work_pending (tv2)) + { + ACE_Time_Value work_tv (0, 500); + orb->perform_work (work_tv); + } + } + ++idle_count; + } + + orb->destroy (); + } + catch (const CORBA::BAD_INV_ORDER&) + { + // Expected + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + if (idle_count == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Got unexpected idle_count %d\n", idle_count), 1); + } + else + { + ACE_DEBUG ((LM_DEBUG, "Got %d idle moments\n", idle_count)); + } + + return 0; +} diff --git a/TAO/tests/Compression/Compression_Test.mpc b/TAO/tests/Compression/Compression_Test.mpc index ce461817d7c..daa9d2aea4f 100644 --- a/TAO/tests/Compression/Compression_Test.mpc +++ b/TAO/tests/Compression/Compression_Test.mpc @@ -1,9 +1,23 @@ // -*- MPC -*- // $Id$ -project(*Server): taoserver, compression, zlibcompressor { +project(*Zlib_Server): taoserver, compression, zlibcompressor, { + exename = zlibserver Source_Files { - server.cpp + zlibserver.cpp } } +project(*Bzip2_Server): taoserver, compression, bzip2compressor, { + exename = bzip2server + Source_Files { + bzip2server.cpp + } +} + +project(*Lzo_Server): taoserver, compression, lzocompressor, { + exename = lzoserver + Source_Files { + lzoserver.cpp + } +} diff --git a/TAO/tests/Compression/bzip2server.cpp b/TAO/tests/Compression/bzip2server.cpp new file mode 100644 index 00000000000..79cf5feb27c --- /dev/null +++ b/TAO/tests/Compression/bzip2server.cpp @@ -0,0 +1,190 @@ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "tao/ORB.h" +#include "tao/Compression/Compression.h" +#include "tao/Compression/bzip2/Bzip2Compressor_Factory.h" + +ACE_RCSID (Hello, + server, + "$Id$") + +bool +test_invalid_compression_factory (Compression::CompressionManager_ptr cm) +{ + bool succeed = false; + try + { + // Get an invalid compression factory + Compression::CompressorFactory_var factory = + cm->get_factory (100); + } + catch (const Compression::UnknownCompressorId& ex) + { + ACE_UNUSED_ARG (ex); + succeed = true; + } + catch (const CORBA::Exception&) + { + } + + if (!succeed) + { + ACE_ERROR ((LM_ERROR, + "(%t) ERROR, get invalid compression factory failed\n")); + } + + return succeed; +} + +bool +test_duplicate_compression_factory ( + Compression::CompressionManager_ptr cm, + Compression::CompressorFactory_ptr cf) +{ + bool succeed = false; + try + { + // Register duplicate + cm->register_factory (cf); + } + catch (const Compression::FactoryAlreadyRegistered&) + { + succeed = true; + } + catch (const CORBA::Exception&) + { + } + + if (!succeed) + { + ACE_ERROR ((LM_ERROR, + "(%t) ERROR, register duplicate factory failed\n")); + } + + return succeed; +} + +bool +test_register_nil_compression_factory ( + Compression::CompressionManager_ptr cm) +{ + bool succeed = false; + try + { + // Register nil factory + cm->register_factory (Compression::CompressorFactory::_nil()); + } + catch (const CORBA::BAD_PARAM& ex) + { + if ((ex.minor() & 0xFFFU) == 44) + { + succeed = true; + } + } + catch (const CORBA::Exception&) + { + } + + if (!succeed) + { + ACE_ERROR ((LM_ERROR, + "(%t) ERROR, register nill factory failed\n")); + } + + return succeed; +} + +bool +test_compression (CORBA::ULong nelements, + Compression::CompressionManager_ptr cm) +{ + bool succeed = false; + + CORBA::OctetSeq mytest; + mytest.length (nelements); + for (CORBA::ULong j = 0; j != nelements; ++j) + { + mytest[j] = 'a'; + } + + Compression::Compressor_var compressor = cm->get_compressor ( + ::Compression::COMPRESSORID_BZIP2, 6); + + CORBA::OctetSeq myout; + myout.length ((CORBA::ULong)(mytest.length() * 1.1)); + + compressor->compress (mytest, myout); + + CORBA::OctetSeq decompress; + decompress.length (nelements); + + compressor->decompress (myout, decompress); + + if (decompress != mytest) + { + ACE_ERROR ((LM_ERROR, "Error, decompress not working\n")); + } + else + { + succeed = true; + ACE_DEBUG ((LM_DEBUG, "Compression worked with bzip2, original " + "size %d, compressed size %d\n", + mytest.length(), myout.length ())); + } + return succeed; +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + int retval = 0; + try + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv); + + CORBA::Object_var compression_manager = + orb->resolve_initial_references("CompressionManager"); + + Compression::CompressionManager_var manager = + Compression::CompressionManager::_narrow (compression_manager.in ()); + + if (CORBA::is_nil(manager.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil compression manager\n"), + 1); + + Compression::CompressorFactory_ptr compressor_factory; + + ACE_NEW_RETURN (compressor_factory, TAO::Bzip2_CompressorFactory (), 1); + + Compression::CompressorFactory_var compr_fact = compressor_factory; + manager->register_factory(compr_fact.in ()); + + if (!test_duplicate_compression_factory (manager.in (), compr_fact.in ())) + retval = 1; + + if (!test_register_nil_compression_factory (manager.in ())) + retval = 1; + + if (!test_compression (1024, manager.in ())) + retval = 1; + + if (!test_compression (5, manager.in ())) + retval = 1; + + if (!test_invalid_compression_factory (manager.in ())) + retval = 1; + + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + retval = 1; + } + + return retval; +} diff --git a/TAO/tests/Compression/lzoserver.cpp b/TAO/tests/Compression/lzoserver.cpp new file mode 100644 index 00000000000..735e14d7c30 --- /dev/null +++ b/TAO/tests/Compression/lzoserver.cpp @@ -0,0 +1,191 @@ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "tao/ORB.h" +#include "tao/Compression/Compression.h" +#include "tao/Compression/lzo/LzoCompressor_Factory.h" + +ACE_RCSID (Hello, + server, + "$Id$") + +bool +test_invalid_compression_factory (Compression::CompressionManager_ptr cm) +{ + bool succeed = false; + try + { + // Get an invalid compression factory + Compression::CompressorFactory_var factory = + cm->get_factory (100); + } + catch (const Compression::UnknownCompressorId& ex) + { + ACE_UNUSED_ARG (ex); + succeed = true; + } + catch (const CORBA::Exception&) + { + } + + if (!succeed) + { + ACE_ERROR ((LM_ERROR, + "(%t) ERROR, get invalid compression factory failed\n")); + } + + return succeed; +} + + +bool +test_duplicate_compression_factory ( + Compression::CompressionManager_ptr cm, + Compression::CompressorFactory_ptr cf) +{ + bool succeed = false; + try + { + // Register duplicate + cm->register_factory (cf); + } + catch (const Compression::FactoryAlreadyRegistered&) + { + succeed = true; + } + catch (const CORBA::Exception&) + { + } + + if (!succeed) + { + ACE_ERROR ((LM_ERROR, + "(%t) ERROR, register duplicate factory failed\n")); + } + + return succeed; +} + +bool +test_register_nil_compression_factory ( + Compression::CompressionManager_ptr cm) +{ + bool succeed = false; + try + { + // Register nil factory + cm->register_factory (Compression::CompressorFactory::_nil()); + } + catch (const CORBA::BAD_PARAM& ex) + { + if ((ex.minor() & 0xFFFU) == 44) + { + succeed = true; + } + } + catch (const CORBA::Exception&) + { + } + + if (!succeed) + { + ACE_ERROR ((LM_ERROR, + "(%t) ERROR, register nill factory failed\n")); + } + + return succeed; +} + +bool +test_compression (CORBA::ULong nelements, + Compression::CompressionManager_ptr cm) +{ + bool succeed = false; + + CORBA::OctetSeq mytest; + mytest.length (nelements); + for (CORBA::ULong j = 0; j != nelements; ++j) + { + mytest[j] = 'a'; + } + + Compression::Compressor_var compressor = cm->get_compressor ( + ::Compression::COMPRESSORID_LZO, 6); + + CORBA::OctetSeq myout; + myout.length ((CORBA::ULong)(mytest.length() * 1.1)); + + compressor->compress (mytest, myout); + + CORBA::OctetSeq decompress; + decompress.length (nelements); + + compressor->decompress (myout, decompress); + + if (decompress != mytest) + { + ACE_ERROR ((LM_ERROR, "Error, decompress not working\n")); + } + else + { + succeed = true; + ACE_DEBUG ((LM_DEBUG, "Compression worked with lzo, original " + "size %d, compressed size %d\n", + mytest.length(), myout.length ())); + } + return succeed; +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + int retval = 0; + try + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv); + + CORBA::Object_var compression_manager = + orb->resolve_initial_references("CompressionManager"); + + Compression::CompressionManager_var manager = + Compression::CompressionManager::_narrow (compression_manager.in ()); + + if (CORBA::is_nil(manager.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil compression manager\n"), + 1); + + Compression::CompressorFactory_ptr compressor_factory; + + ACE_NEW_RETURN (compressor_factory, TAO::Lzo_CompressorFactory (), 1); + + Compression::CompressorFactory_var compr_fact = compressor_factory; + manager->register_factory(compr_fact.in ()); + + if (!test_duplicate_compression_factory (manager.in (), compr_fact.in ())) + retval = 1; + + if (!test_register_nil_compression_factory (manager.in ())) + retval = 1; + + if (!test_compression (1024, manager.in ())) + retval = 1; + + if (!test_compression (5, manager.in ())) + retval = 1; + + if (!test_invalid_compression_factory (manager.in ())) + retval = 1; + + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + retval = 1; + } + + return retval; +} diff --git a/TAO/tests/Compression/run_test.pl b/TAO/tests/Compression/run_test.pl index d1d85802727..202d8d7e1c7 100755 --- a/TAO/tests/Compression/run_test.pl +++ b/TAO/tests/Compression/run_test.pl @@ -10,7 +10,17 @@ use PerlACE::TestTarget; my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; -$SV = $server->CreateProcess ("server"); +my @tests = qw( + zlibserver + bzip2server + lzoserver + ); + +foreach my $process (@tests) { + +$SV = $server->CreateProcess ("$process"); +my $executable = $SV->Executable; +next unless -e $executable; $test = $SV->SpawnWaitKill ($server->ProcessStartWaitInterval()); @@ -18,5 +28,6 @@ if ($test != 0) { print STDERR "ERROR: test returned $test\n"; exit 1; } +} exit 0; diff --git a/TAO/tests/Compression/server.cpp b/TAO/tests/Compression/zlibserver.cpp index d96d398167a..bdd9c164380 100644 --- a/TAO/tests/Compression/server.cpp +++ b/TAO/tests/Compression/zlibserver.cpp @@ -50,9 +50,8 @@ test_duplicate_compression_factory ( // Register duplicate cm->register_factory (cf); } - catch (const Compression::FactoryAlreadyRegistered& ex) + catch (const Compression::FactoryAlreadyRegistered&) { - ACE_UNUSED_ARG (ex); succeed = true; } catch (const CORBA::Exception&) @@ -98,6 +97,45 @@ test_register_nil_compression_factory ( return succeed; } +bool +test_compression (CORBA::ULong nelements, + Compression::CompressionManager_ptr cm) +{ + bool succeed = false; + + CORBA::OctetSeq mytest; + mytest.length (nelements); + for (CORBA::ULong j = 0; j != nelements; ++j) + { + mytest[j] = 'a'; + } + + Compression::Compressor_var compressor = cm->get_compressor (::Compression::COMPRESSORID_ZLIB, 6); + + CORBA::OctetSeq myout; + myout.length ((CORBA::ULong)(mytest.length() * 1.1)); + + compressor->compress (mytest, myout); + + CORBA::OctetSeq decompress; + decompress.length (nelements); + + compressor->decompress (myout, decompress); + + if (decompress != mytest) + { + ACE_ERROR ((LM_ERROR, "Error, decompress not working\n")); + + } + else + { + succeed = true; + ACE_DEBUG ((LM_DEBUG, "Compression worked with zlib, original " + "size %d, compressed size %d\n", + mytest.length(), myout.length ())); + } + return succeed; +} int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) @@ -132,34 +170,12 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) if (!test_register_nil_compression_factory (manager.in ())) retval = 1; - CORBA::ULong const nelements = 1024; - CORBA::OctetSeq mytest; - mytest.length (1024); - for (CORBA::ULong j = 0; j != nelements; ++j) - { - mytest[j] = 'a'; - } - - Compression::Compressor_var compressor = manager->get_compressor (::Compression::COMPRESSORID_ZLIB, 6); - - CORBA::OctetSeq myout; - myout.length ((CORBA::ULong)(mytest.length() * 1.1)); - - compressor->compress (mytest, myout); - - CORBA::OctetSeq decompress; - decompress.length (1024); - - compressor->decompress (myout, decompress); + if (!test_compression (1024, manager.in ())) + retval = 1; - if (decompress != mytest) - { - ACE_ERROR ((LM_ERROR, "Error, decompress not working\n")); - } - else - { - ACE_DEBUG ((LM_DEBUG, "Compression worked, original size %d, compressed size %d\n", mytest.length(), myout.length ())); - } + if (!test_compression (5, manager.in ())) + retval = 1; + if (!test_invalid_compression_factory (manager.in ())) retval = 1; diff --git a/TAO/tests/DIOP/client.cpp b/TAO/tests/DIOP/client.cpp index ebb233285eb..dbb73d07644 100644 --- a/TAO/tests/DIOP/client.cpp +++ b/TAO/tests/DIOP/client.cpp @@ -46,7 +46,7 @@ parse_args (int argc, ACE_TCHAR *argv[]) switch (c) { case 'd': - TAO_debug_level++; + ++TAO_debug_level; break; case 'k': ior = get_opts.opt_arg (); @@ -142,8 +142,7 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); root_poa->destroy (1, // ethernalize objects - 0 // wait for completion - ); + 0); // wait for completion orb->destroy (); diff --git a/TAO/tests/DiffServ/run_test.pl b/TAO/tests/DiffServ/run_test.pl index 4cc87edc15e..bf1e25c4775 100755 --- a/TAO/tests/DiffServ/run_test.pl +++ b/TAO/tests/DiffServ/run_test.pl @@ -6,49 +6,51 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; $status = 0; -$iorfile = PerlACE::LocalFile ("simple_servant.ior"); -unlink $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"; -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", "-ORBDebuglevel 1 -p 20000"); -} -else { - $SV = new PerlACE::Process ("server", "-ORBdebuglevel 1 -p 20000"); -} -$CL = new PerlACE::Process ("client", " -ORBdebuglevel 1 -n 10 -k file://$iorfile"); - -$server = $SV->Spawn (); +my $iorbase = "simple_servant.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +$SV = $server->CreateProcess ("server", "-ORBdebuglevel 1 -p 20000"); +$CL = $client->CreateProcess ("client", "-ORBdebuglevel 1 -n 10 -k file://$client_iorfile"); -if ($server != 0) { - print STDERR "ERROR: server returned $server\n"; +$server_status = $SV->Spawn (); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; exit 1; } -if (PerlACE::waitforfile_timed ($iorfile, - $PerlACE::wait_interval_for_process_creation) == -1) { - print STDERR "ERROR: cannot find file <$iorfile>\n"; +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 (300); +$client_status = $CL->SpawnWaitKill (300); -if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -$server = $SV->WaitKill (10); +$server_status = $SV->WaitKill (10); -if ($server != 0) { - print STDERR "ERROR: server returned $server\n"; +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } -unlink $iorfile; +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); exit $status; diff --git a/TAO/tests/FL_Cube/client.cpp b/TAO/tests/FL_Cube/client.cpp index 275cbc8bc45..746b9c64bd9 100644 --- a/TAO/tests/FL_Cube/client.cpp +++ b/TAO/tests/FL_Cube/client.cpp @@ -5,9 +5,9 @@ ACE_RCSID(FL_Cube, client, "$Id$") -#include <FL/Fl.h> -#include <FL/Fl_Window.h> -#include <FL/Fl_Roller.h> +#include <FL/Fl.H> +#include <FL/Fl_Window.H> +#include <FL/Fl_Roller.H> class Client { diff --git a/TAO/tests/FL_Cube/server.cpp b/TAO/tests/FL_Cube/server.cpp index 95638b5fdbd..a1fa8259e32 100644 --- a/TAO/tests/FL_Cube/server.cpp +++ b/TAO/tests/FL_Cube/server.cpp @@ -6,7 +6,7 @@ ACE_RCSID(FL_Cube, server, "$Id$") -#include <FL/Fl.h> +#include <FL/Fl.H> const ACE_TCHAR *ior_output_file = 0; diff --git a/TAO/tests/FL_Cube/test_i.h b/TAO/tests/FL_Cube/test_i.h index f4f97040b86..df7b3e46e23 100644 --- a/TAO/tests/FL_Cube/test_i.h +++ b/TAO/tests/FL_Cube/test_i.h @@ -18,7 +18,7 @@ #include "testS.h" -#include <FL/Fl_Gl_Window.h> +#include <FL/Fl_Gl_Window.H> class Simple_Window : public Fl_Gl_Window diff --git a/TAO/tests/IDL_Inherited_Operation/InheritedOp.idl b/TAO/tests/IDL_Inherited_Operation/InheritedOp.idl new file mode 100644 index 00000000000..b8d54bafcb2 --- /dev/null +++ b/TAO/tests/IDL_Inherited_Operation/InheritedOp.idl @@ -0,0 +1,33 @@ +//$Id$ + +#ifndef INHERITED_OP_IDL +#define INHERITED_OP_IDL + +module Outer +{ + module Inner + { + interface Base + { + void BaseOp (); + }; + }; +}; + +module Outer +{ + module Inner + { + interface Base; + }; +}; + +module Outer +{ + interface Derived : Inner::Base + { + void shutdown (); + }; +}; + +#endif /* INHERITED_OP_IDL */ diff --git a/TAO/tests/IDL_Inherited_Operation/InheritedOp.mpc b/TAO/tests/IDL_Inherited_Operation/InheritedOp.mpc new file mode 100644 index 00000000000..ab64f74834c --- /dev/null +++ b/TAO/tests/IDL_Inherited_Operation/InheritedOp.mpc @@ -0,0 +1,54 @@ +// -*- MPC -*- +// $Id$ + +project(*idl): taoidldefaults { + IDL_Files { + InheritedOp.idl + } + custom_only = 1 +} + +project(*Server): taoserver { + after += *idl + + Source_Files { + InheritedOpC.cpp + InheritedOpS.cpp + InheritedOp_i.cpp + server.cpp + } + + Header_Files { + InheritedOpC.h + InheritedOpS.h + InheritedOp_i.h + } + + Inline_Files { + InheritedOpC.inl + InheritedOpS.inl + } + + IDL_Files { + } +} + +project(*Client): taoclient { + after += *idl + + Source_Files { + InheritedOpC.cpp + client.cpp + } + + Header_Files { + InheritedOpC.h + } + + Inline_Files { + InheritedOpC.inl + } + + IDL_Files { + } +} diff --git a/TAO/tests/IDL_Inherited_Operation/InheritedOp_i.cpp b/TAO/tests/IDL_Inherited_Operation/InheritedOp_i.cpp new file mode 100644 index 00000000000..d7727558b6a --- /dev/null +++ b/TAO/tests/IDL_Inherited_Operation/InheritedOp_i.cpp @@ -0,0 +1,20 @@ +// $Id:$ + +#include "InheritedOp_i.h" + +Derived_i::Derived_i (CORBA::ORB_ptr orb) + : orb_ (orb) +{ +} + +void +Derived_i::BaseOp (void) +{ + ACE_DEBUG ((LM_DEBUG, "BaseOp upcall successful\n")); +} + +void +Derived_i::shutdown (void) +{ + orb_->shutdown (); +} diff --git a/TAO/tests/IDL_Inherited_Operation/InheritedOp_i.h b/TAO/tests/IDL_Inherited_Operation/InheritedOp_i.h new file mode 100644 index 00000000000..2248ee1d872 --- /dev/null +++ b/TAO/tests/IDL_Inherited_Operation/InheritedOp_i.h @@ -0,0 +1,22 @@ +// -*- C++ -*- +// $Id:$ + +#ifndef INHERITED_OP_I_H +#define INHERITED_OP_I_H + + +#include "InheritedOpS.h" + +class Derived_i : public virtual POA_Outer::Derived +{ +public: + Derived_i (CORBA::ORB_ptr orb); + + virtual void BaseOp (void); + virtual void shutdown (void); + +private: + CORBA::ORB_ptr orb_; +}; + +#endif // INHERITED_OP_I_H diff --git a/TAO/tests/IDL_Inherited_Operation/README b/TAO/tests/IDL_Inherited_Operation/README new file mode 100644 index 00000000000..2bde20e4f2a --- /dev/null +++ b/TAO/tests/IDL_Inherited_Operation/README @@ -0,0 +1,41 @@ +/** + +@page IDL Inherited Operation Test README File + + This test checks that an IDL compiler bug, fixed by + + Fri Mar 20 16:04:58 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu> + + never gets re-introduced. The IDL declarations that caused the + original bug are: + + - A base interface, with an operation, is declared inside 2 + nested modules. + - The nested modules are closed. + - The nested modules are reopened, and forward declaration of + the base interface appears inside. + - The nested modules are closed. + - The outer module is reopened, and a derived interface + declaration appears inside, using the partially scoped + name of the base interface. + + This type of IDL caused the base interface operation to be missing + from the operation table in generated code for the derived + interface. Client calls to this operation on a derived object + would result in a BAD_OPERATION exception. + + The test is here instead of in the IDL_Test directory because + the bug can be detected only at runtime, by a remote call. + IDL_Test is designed to catch only: + + - Error messages incorrectly caused by legal IDL + - Errors from incompilable generated code + - Incorrect repository IDs, fetched by a local stub call + + To run the test use the run_test.pl script: + +$ ./run_test.pl + + the script returns 0 if the test was successful. + +*/ diff --git a/TAO/tests/IDL_Inherited_Operation/client.cpp b/TAO/tests/IDL_Inherited_Operation/client.cpp new file mode 100644 index 00000000000..77c06765b20 --- /dev/null +++ b/TAO/tests/IDL_Inherited_Operation/client.cpp @@ -0,0 +1,53 @@ +// $Id$ + +#include "InheritedOpC.h" + +const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior"); + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + CORBA::ORB_var orb; + Outer::Derived_var target; + + try + { + orb = CORBA::ORB_init (argc, argv); + + CORBA::Object_var tmp = orb->string_to_object (ior); + + target = Outer::Derived::_narrow (tmp.in ()); + + if (CORBA::is_nil (target.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + ACE_TEXT ("Nil Outer::Derived ") + ACE_TEXT ("reference <%s>\n"), + ior), + 1); + } + + target->BaseOp (); + target->shutdown (); + + orb->destroy (); + } + catch (const CORBA::BAD_OPERATION&) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("client - target operation ") + ACE_TEXT ("BaseOp returned BAD_OPERATION\n"))); + target->shutdown (); + orb->destroy (); + return 1; + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("client - Exception caught:"); + target->shutdown (); + orb->destroy (); + return 1; + } + + return 0; +} diff --git a/TAO/tests/IDL_Inherited_Operation/run_test.pl b/TAO/tests/IDL_Inherited_Operation/run_test.pl new file mode 100755 index 00000000000..5423a45e191 --- /dev/null +++ b/TAO/tests/IDL_Inherited_Operation/run_test.pl @@ -0,0 +1,52 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +$status = 0; + +my $server = PerlACE::TestTarget::create_target (1) || die "Create server failed\n"; +my $client = PerlACE::TestTarget::create_target (2) || die "Create client failed\n"; + +my $iorbase = "test.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +$server->DeleteFile($iorbase); + +$SV = $server->CreateProcess ("server"); +$CL = $client->CreateProcess ("client"); +$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; +} + +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval()); + +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; +} + +$server->DeleteFile($iorbase); + +exit $status; diff --git a/TAO/tests/IDL_Inherited_Operation/server.cpp b/TAO/tests/IDL_Inherited_Operation/server.cpp new file mode 100644 index 00000000000..947cad657b0 --- /dev/null +++ b/TAO/tests/IDL_Inherited_Operation/server.cpp @@ -0,0 +1,75 @@ +// $Id$ + +#include "InheritedOp_i.h" + +const ACE_TCHAR *ior_output_file = ACE_TEXT ("test.ior"); + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + try + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv); + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA"); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in ()); + + if (CORBA::is_nil (root_poa.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil RootPOA\n"), + 1); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (); + + Derived_i *derived_impl = 0; + ACE_NEW_RETURN (derived_impl, + Derived_i (orb.in ()), + 1); + PortableServer::ServantBase_var owner_transfer (derived_impl); + + PortableServer::ObjectId_var id = + root_poa->activate_object (derived_impl); + + CORBA::Object_var object = + root_poa->id_to_reference (id.in ()); + + Outer::Derived_var derived = + Outer::Derived::_narrow (object.in ()); + + CORBA::String_var ior = orb->object_to_string (derived.in ()); + + // Output the IOR to the <ior_output_file> + FILE *output_file = ACE_OS::fopen (ior_output_file, "w"); + + if (output_file == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Cannot open output ") + ACE_TEXT ("file for writing IOR: %s\n"), + ior_output_file), + 1); + } + + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + poa_manager->activate (); + + orb->run (); + + root_poa->destroy (true, true); + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("server - Exception caught:"); + return 1; + } + + return 0; +} diff --git a/TAO/tests/IDL_Test/IDL_Test.mpc b/TAO/tests/IDL_Test/IDL_Test.mpc index bd5fc8bcd83..1ce29af84cb 100644 --- a/TAO/tests/IDL_Test/IDL_Test.mpc +++ b/TAO/tests/IDL_Test/IDL_Test.mpc @@ -1,16 +1,9 @@ // -*- MPC -*- // $Id$ - -project(*Main): taoserver, messaging, gen_ostream { - exename = main +project(*IDL): taoserver, messaging, gen_ostream { + custom_only=1 idlflags += -GC -GH -Gd -GT - verbatim(gnuace, macros) { - ifeq ($(OSTYPE),VMS) - CCFLAGS += -Wc/DISTINGUISH_NESTED_ENUMS - endif - } - IDL_Files { array.idl Bug_2350_Regression.idl @@ -66,12 +59,126 @@ project(*Main): taoserver, messaging, gen_ostream { typecode.idl valuetype.idl } +} + +project(*Main): taoserver, messaging, gen_ostream { + exename = main + after += *IDL + verbatim(gnuace, macros) { + ifeq ($(OSTYPE),VMS) + CCFLAGS += -Wc/DISTINGUISH_NESTED_ENUMS + endif + } + + IDL_Files { + } Source_Files { + anonymousA.cpp + anonymousC.cpp + anonymousS.cpp + arrayC.cpp + arrayS.cpp + array_onlyA.cpp + array_onlyC.cpp + array_onlyS.cpp + Bug_2350_RegressionC.cpp + Bug_2350_RegressionS.cpp + Bug_2577_RegressionC.cpp + Bug_2577_RegressionS.cpp + Bug_2582_RegressionC.cpp + Bug_2582_RegressionS.cpp + Bug_2583_RegressionC.cpp + Bug_2583_RegressionS.cpp + Bug_2616_RegressionC.cpp + Bug_2616_RegressionS.cpp + Bug_2619_RegressionC.cpp + Bug_2619_RegressionS.cpp + constantsA.cpp + constantsC.cpp + constantsS.cpp + dif2A.cpp + dif2C.cpp + dif2S.cpp + enum_in_structC.cpp + enum_in_structS.cpp + fullC.cpp + fullS.cpp + fwdC.cpp + fwdS.cpp + generic_objectA.cpp + generic_objectC.cpp + generic_objectS.cpp + gperfC.cpp + gperfS.cpp + includedC.cpp + includedS.cpp + includingC.cpp + includingS.cpp + inheritA.cpp + inheritC.cpp + inheritS.cpp + interfaceC.cpp + interfaceS.cpp + keywordsA.cpp + keywordsC.cpp + keywordsS.cpp main.cpp - *C.cpp - *S.cpp - *A.cpp + moduleA.cpp + moduleC.cpp + moduleS.cpp + nested_scopeC.cpp + nested_scopeS.cpp + old_arrayC.cpp + old_arrayS.cpp + old_constantsC.cpp + old_constantsS.cpp + old_sequenceC.cpp + old_sequenceS.cpp + old_structC.cpp + old_structS.cpp + old_union2C.cpp + old_union2S.cpp + old_unionC.cpp + old_unionS.cpp + paramsC.cpp + paramsS.cpp + pragmaA.cpp + pragmaC.cpp + pragmaS.cpp + primtypesA.cpp + primtypesC.cpp + primtypesS.cpp + reopened_modulesC.cpp + reopened_modulesS.cpp + reopen_include1C.cpp + reopen_include1S.cpp + reopen_include2C.cpp + reopen_include2S.cpp + repo_id_modA.cpp + repo_id_modC.cpp + repo_id_modS.cpp + sequenceC.cpp + sequenceS.cpp + simple2C.cpp + simple2S.cpp + simpleC.cpp + simpleS.cpp + structC.cpp + structS.cpp + typecodeA.cpp + typecodeC.cpp + typecodeS.cpp + typedefA.cpp + typedefC.cpp + typedefS.cpp + typeprefixC.cpp + typeprefixS.cpp + unionC.cpp + unionS.cpp + valuetypeA.cpp + valuetypeC.cpp + valuetypeS.cpp } Template_Files { diff --git a/TAO/tests/NestedUpcall/MT_Client_Test/client.cpp b/TAO/tests/NestedUpcall/MT_Client_Test/client.cpp index 80ed7e05974..2935b601b93 100644 --- a/TAO/tests/NestedUpcall/MT_Client_Test/client.cpp +++ b/TAO/tests/NestedUpcall/MT_Client_Test/client.cpp @@ -25,6 +25,7 @@ #include "ace/Read_Buffer.h" #include "ace/OS_NS_unistd.h" #include "ace/OS_NS_fcntl.h" +#include "ace/Malloc_Base.h" ACE_RCSID(MT_Client_Test, client, "$Id$") @@ -178,7 +179,7 @@ MT_Client::run (void) MT_Client::~MT_Client (void) { if (this->object_key_ != 0) - ACE_OS::free (this->object_key_); + ACE_Allocator::instance ()->free (this->object_key_); if (this->argv_ != 0) delete [] this->argv_; } diff --git a/TAO/tests/NestedUpcall/MT_Client_Test/server.cpp b/TAO/tests/NestedUpcall/MT_Client_Test/server.cpp index 04dbf25ca9e..cc902da6345 100644 --- a/TAO/tests/NestedUpcall/MT_Client_Test/server.cpp +++ b/TAO/tests/NestedUpcall/MT_Client_Test/server.cpp @@ -21,8 +21,47 @@ #include "tao/debug.h" #include "ace/OS_NS_stdio.h" +#include "ace/Event_Handler.h" +#include "ace/Sig_Handler.h" + ACE_RCSID(MT_Client_Test, server, "$Id$") +class TestShutdown : public ACE_Event_Handler +{ +public: + TestShutdown (CORBA::ORB_ptr orb) + : orb_(CORBA::ORB::_duplicate (orb)) + { +#if !defined(ACE_LACKS_UNIX_SIGNALS) + this->shutdown_.register_handler (SIGTERM, this); + this->shutdown_.register_handler (SIGINT, this); +#elif defined(ACE_WIN32) + this->shutdown_.register_handler (SIGINT, this); +#endif + } + + ~TestShutdown (void) + { +#if !defined(ACE_LACKS_UNIX_SIGNALS) + this->shutdown_.remove_handler (SIGTERM); + this->shutdown_.remove_handler (SIGINT); +#elif defined(ACE_WIN32) + this->shutdown_.remove_handler (SIGINT); +#endif + } + + virtual int handle_signal (int, siginfo_t*, ucontext_t*) + { + this->orb_->shutdown (); + return 0; + } + +private: + CORBA::ORB_var orb_; + + ACE_Sig_Handler shutdown_; +}; + MT_Object_Server::MT_Object_Server (void) : ior_output_file_ (0) { @@ -103,6 +142,9 @@ MT_Object_Server::init (int argc, ACE_TCHAR** argv) int MT_Object_Server::run (void) { + CORBA::ORB_var orb = this->orb_manager_.orb (); + TestShutdown killer (orb.in ()); + int result = this->orb_manager_.run (); if (result == -1) diff --git a/TAO/tests/Portable_Interceptors/Bug_3582/run_test.pl b/TAO/tests/Portable_Interceptors/Bug_3582/run_test.pl index b35f2687020..de707d44f51 100755 --- a/TAO/tests/Portable_Interceptors/Bug_3582/run_test.pl +++ b/TAO/tests/Portable_Interceptors/Bug_3582/run_test.pl @@ -2,57 +2,70 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' & eval 'exec perl -S $0 $argv:q' if 0; -# -*- perl -*- -# # $Id$ - +# -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; -$file1base = "test.ior"; -$file1 = PerlACE::LocalFile ("$file1base"); +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"; -unlink $file1; +my $iorbase = "server.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); -if (PerlACE::is_vxworks_test()) { -$SV1 = new PerlACE::ProcessVX ("server", "-o $file1base -n 1"); -} -else { -$SV1 = new PerlACE::Process ("server", "-o $file1 -n 1"); -} -$CL = new PerlACE::Process ("client", "-p file://$file1"); - -$status = 0; +$SV = $server->CreateProcess ("server", "-o $server_iorfile -n 1"); +$CL = $client->CreateProcess ("client", "-p file://$client_iorfile"); print STDERR "\n\n==== Running PortableInterceptor::Redirection test\n"; -$SV1->Spawn (); +$server_status = $SV->Spawn (); + +if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} -if (PerlACE::waitforfile_timed ($file1, $PerlACE::wait_interval_for_process_creation) == -1) { - print STDERR "ERROR: cannot find file <$file1>\n"; - $SV1->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; } -$client = $CL->SpawnWaitKill (60); +$client_status = $CL->SpawnWaitKill (60); -if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -$SV1->WaitKill (5); +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval()); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + $status = 1; +} print "Restarting Client to provoke TRANSIENT exception\n"; -$client = $CL->SpawnWaitKill (60); +$client_status = $CL->SpawnWaitKill (60); -if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -unlink $file1; +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); exit $status; diff --git a/TAO/tests/RTCORBA/Banded_Connections/run_test.pl b/TAO/tests/RTCORBA/Banded_Connections/run_test.pl index 1a7accccdbe..a873e5ec41f 100755 --- a/TAO/tests/RTCORBA/Banded_Connections/run_test.pl +++ b/TAO/tests/RTCORBA/Banded_Connections/run_test.pl @@ -6,17 +6,21 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; -$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"; + +$iorbase1 = "test1.ior"; +$iorbase2 = "test2.ior"; + +$client_iorfile1 = $client->LocalFile ($iorbase1); +$client_iorfile2 = $client->LocalFile ($iorbase2); -$iorfile1base = "test1.ior"; -$iorfile2base = "test2.ior"; -$iorfile1 = PerlACE::LocalFile ("$iorfile1base"); -$iorfile2 = PerlACE::LocalFile ("$iorfile2base"); +$client->DeleteFile ($iorbase1); +$client->DeleteFile ($iorbase2); -unlink $iorfile1; -unlink $iorfile2; +$status = 0; print STDERR "\n********** RTCORBA Priority Banded Connections Unit Test\n"; @@ -43,54 +47,43 @@ else { "-b bands.unix"; } -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", $server_args); -} -else { - $SV = new PerlACE::Process ("server", $server_args); -} -if (PerlACE::is_vxworks_rtp_test()) { - $CL = new PerlACE::ProcessVX ("client", "-n file://$iorfile1base -o file://$iorfile2base"); -} -else { - $CL = new PerlACE::Process ("client", "-n file://$iorfile1 -o file://$iorfile2"); -} +$SV = $server->CreateProcess ("server", $server_args), + +$CL = $client->CreateProcess ("client", "-n file://$client_iorfile1 -o file://$client_iorfile2"); $SV->Spawn(); -if (PerlACE::waitforfile_timed ($iorfile2, $PerlACE::wait_interval_for_process_creation) == -1) -{ - $server = $SV->TimedWait (1); - if ($server == 2) - { + +if ($client->WaitForFileTimed ($iorbase2, + $client->ProcessStartWaitInterval()) == -1) { + $server_status = $SV->TimedWait (1); + if ($server_status == 2) { # Mark as no longer running to avoid errors on exit. $SV->{RUNNING} = 0; exit $status; } - else - { - print STDERR "ERROR: cannot find file <$iorfile2>\n"; + else { + print STDERR "ERROR: cannot find file <$client_iorfile2>\n"; $SV->Kill (); exit 1; } } -$client = $CL->SpawnWaitKill (60); +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval ()); -if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -$server = $SV->WaitKill (30); +$server_status = $SV->WaitKill (30); -if ($server != 0) -{ - print STDERR "ERROR: server returned $server\n"; +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } -unlink $iorfile1; -unlink $iorfile2; +$client->DeleteFile ($iorbase1); +$client->DeleteFile ($iorbase2); # Clean up SHMIOP files PerlACE::check_n_cleanup_files ("server_shmiop_*"); diff --git a/TAO/tests/RTCORBA/Bug_3382_Regression/run_test.pl b/TAO/tests/RTCORBA/Bug_3382_Regression/run_test.pl index cfa55dc34cf..cf568688b34 100755 --- a/TAO/tests/RTCORBA/Bug_3382_Regression/run_test.pl +++ b/TAO/tests/RTCORBA/Bug_3382_Regression/run_test.pl @@ -6,61 +6,54 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib '../../../../bin'; -use PerlACE::Run_Test; +use PerlACE::TestTarget; -$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"; -$iorfile = PerlACE::LocalFile ("test.ior"); +$iorbase = "test.ior"; -unlink $iorfile; +$server_iorfile = $server->LocalFile ($iorbase); +$client_iorfile = $client->LocalFile ($iorbase); -if (PerlACE::is_vxworks_test()) { - $TEST = new PerlACE::ProcessVX ("simple_client", , "-ORBSvcConfDirective \"static RT_ORB_Loader '-ORBSchedPolicy SCHED_FIFO -ORBScopePolicy SYSTEM -ORBPriorityMapping continuous'\""); -} -else { - $TEST = new PerlACE::Process ("simple_client", , "-ORBSvcConfDirective \"static RT_ORB_Loader '-ORBSchedPolicy SCHED_FIFO -ORBScopePolicy SYSTEM -ORBPriorityMapping continuous'\""); -} +$server->DeleteFile ($iorbase); +$client->DeleteFile ($iorbase); + + +$status = 0; -$test = $TEST->SpawnWaitKill (60); +$PROC = $server->CreateProcess ("simple_client", , "-ORBSvcConfDirective \"static RT_ORB_Loader '-ORBSchedPolicy SCHED_FIFO -ORBScopePolicy SYSTEM -ORBPriorityMapping continuous'\""); -if ($test != 0) +$proc_status = $PROC->SpawnWaitKill ($server->ProcessStartWaitInterval ()); + +if ($proc_status != 0) { - print STDERR "ERROR: simple_client returned $test\n"; + print STDERR "ERROR: simple_client returned $proc_status\n"; $status = 1; } -if (PerlACE::is_vxworks_test()) { - $TEST = new PerlACE::ProcessVX ("simple_client", , "-ORBSvcConfDirective \"static RT_ORB_Loader '-ORBSchedPolicy SCHED_FIFO -ORBScopePolicy SYSTEM -ORBPriorityMapping linear'\""); -} -else { - $TEST = new PerlACE::Process ("simple_client", , "-ORBSvcConfDirective \"static RT_ORB_Loader '-ORBSchedPolicy SCHED_FIFO -ORBScopePolicy SYSTEM -ORBPriorityMapping linear'\""); -} +$PROC = $server->CreateProcess ("simple_client", , "-ORBSvcConfDirective \"static RT_ORB_Loader '-ORBSchedPolicy SCHED_FIFO -ORBScopePolicy SYSTEM -ORBPriorityMapping linear'\""); -$test = $TEST->SpawnWaitKill (60); +$proc_status = $PROC->SpawnWaitKill ($server->ProcessStartWaitInterval ()); -if ($test != 0) +if ($proc_status != 0) { - print STDERR "ERROR: simple_client returned $test\n"; + print STDERR "ERROR: simple_client returned $proc_status\n"; $status = 1; } - print STDERR "\n RTCORBA CLIENT_PROPAGATED Linear Priority Mapping Unit Test\n\n"; -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", , "-o test.ior"); -} -else { - $SV = new PerlACE::Process ("server", , "-o $iorfile"); -} -$CL = new PerlACE::Process ("client", "-k file://$iorfile"); +$SV = $server->CreateProcess ("server", , "-o $server_iorfile"); +$CL = $client->CreateProcess ("client", "-k file://$client_iorfile"); $SV->Spawn (); -if (PerlACE::waitforfile_timed ($iorfile, 10) == -1) +if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { - $server = $SV->TimedWait (1); - if ($server == 2) + $server_status = $SV->TimedWait (1); + if ($server_status == 2) { # Mark as no longer running to avoid errors on exit. $SV->{RUNNING} = 0; @@ -68,28 +61,29 @@ if (PerlACE::waitforfile_timed ($iorfile, 10) == -1) } else { - print STDERR "ERROR: cannot find file <$iorfile>\n"; + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; $SV->Kill (); exit 1; } } -$client = $CL->SpawnWaitKill (60); +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval ()); -if ($client != 0) +if ($client_status != 0) { - print STDERR "ERROR: client returned $client\n"; + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -$server = $SV->WaitKill (60); +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval ()); -if ($server != 0) +if ($server_status != 0) { - print STDERR "ERROR: server returned $server\n"; + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } -unlink $iorfile; +$server->DeleteFile ($iorbase); +$client->DeleteFile ($iorbase); exit $status; diff --git a/TAO/tests/RTCORBA/Client_Propagated/run_test.pl b/TAO/tests/RTCORBA/Client_Propagated/run_test.pl index a5b2484f4fd..833ef825961 100755 --- a/TAO/tests/RTCORBA/Client_Propagated/run_test.pl +++ b/TAO/tests/RTCORBA/Client_Propagated/run_test.pl @@ -6,64 +6,67 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; $status = 0; -$iorfilebase = "test.ior"; -$iorfile = PerlACE::LocalFile ("$iorfilebase"); +$debug_level = '0'; -unlink $iorfile; +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"; + +my $iorbase = "test.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); print STDERR "\n RTCORBA CLIENT_PROPAGATED Priority Unit Test\n\n"; -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", , "-o $iorfilebase"); -} -else { - $SV = new PerlACE::Process ("server", , "-o $iorfile"); -} -if (PerlACE::is_vxworks_rtp_test()) { - $CL = new PerlACE::ProcessVX ("client", "-k file://$iorfilebase"); -} -else { - $CL = new PerlACE::Process ("client", "-k file://$iorfile"); -} +$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile"); +$CL = $client->CreateProcess ("client", "-ORBdebuglevel $debug_level -k file://$client_iorfile"); -$SV->Spawn (); +$server_status = $SV->Spawn (); -if (PerlACE::waitforfile_timed ($iorfile, $PerlACE::wait_interval_for_process_creation) == -1) -{ +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + exit 1; +} + +if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { $server = $SV->TimedWait (1); - if ($server == 2) - { + if ($server == 2) { # Mark as no longer running to avoid errors on exit. $SV->{RUNNING} = 0; exit $status; - } - else - { - print STDERR "ERROR: cannot find file <$iorfile>\n"; + } else { + print STDERR "ERROR: cannot find file <$iorbase>\n"; $SV->Kill (); exit 1; } } -$client = $CL->SpawnWaitKill (60); +$client_status = $CL->SpawnWaitKill (60); -if ($client != 0) -{ - print STDERR "ERROR: client returned $client\n"; +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -$server = $SV->WaitKill (60); +$server_status = $SV->WaitKill (60); -if ($server != 0) -{ - print STDERR "ERROR: server returned $server\n"; +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } -unlink $iorfile; +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); exit $status; diff --git a/TAO/tests/RTCORBA/Client_Protocol/run_test.pl b/TAO/tests/RTCORBA/Client_Protocol/run_test.pl index 3fd19cdf619..6b2ab9b6115 100755 --- a/TAO/tests/RTCORBA/Client_Protocol/run_test.pl +++ b/TAO/tests/RTCORBA/Client_Protocol/run_test.pl @@ -6,72 +6,77 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; + +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"; $status = 0; -$iorfile1base = "test1.ior"; -$iorfile2base = "test2.ior"; -$iorfile1 = PerlACE::LocalFile ("$iorfile1base"); -$iorfile2 = PerlACE::LocalFile ("$iorfile2base"); -unlink $iorfile1; -unlink $iorfile2; +my $iorbase1 = "test1.ior"; +my $iorbase2 = "test2.ior"; + +my $server_iorfile1 = $server->LocalFile ($iorbase1); +my $server_iorfile2 = $server->LocalFile ($iorbase2); + +my $client_iorfile1 = $client->LocalFile ($iorbase1); +my $client_iorfile2 = $client->LocalFile ($iorbase2); + +$server->DeleteFile ($iorbase1); +$server->DeleteFile ($iorbase2); + +$client->DeleteFile ($iorbase1); +$client->DeleteFile ($iorbase2); print STDERR "\n********** RTCORBA Client Protocol Policy Unit Test\n\n"; # Arguments are platform-dependent (UIOP not available on Windows). $server_args = - (PerlACE::is_vxworks_test() ? "" : (($^O eq "MSWin32") ? "-p 1413566210 " : "-p 1413566208 ")) - ."-ORBendpoint iiop:// " - .(PerlACE::is_vxworks_test() ? "" : "-ORBendpoint shmiop:// ") + + (($^O eq "MSWin32") ? "-p 1413566210 " : "-p 1413566208 ") + ."-ORBendpoint iiop:// -ORBendpoint shmiop:// " .(($^O eq "MSWin32" || $^O eq "VMS") ? "" : "-ORBEndpoint uiop:// "); + + $client_args = - "-s file://$iorfile1 -c file://$iorfile2 " + "-s file://$client_iorfile1 -c file://$client_iorfile2 " .(($^O eq "MSWin32" || $^O eq "VMS") ? "" : "-p 1413566210 ") ."-ORBdebuglevel 1 "; -#if ($^O eq "MSWin32") { -# $server_args = -# "-p 1413566210 " -# ."-ORBendpoint iiop:// -ORBendpoint shmiop:// "; -# $client_args = -# "-s file://$iorfile1 -c file://$iorfile2 -ORBdebuglevel 1"; -#} - # Start server. -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", "-s $iorfile1base -c $iorfile2base $server_args"); -} -else { - $SV = new PerlACE::Process ("server", "-s $iorfile1 -c $iorfile2 $server_args"); -} -$CL = new PerlACE::Process ("client", $client_args); +$SV = $server->CreateProcess ("server", "-s $server_iorfile1 -c $server_iorfile2 $server_args"); + +$CL = $client->CreateProcess ("client", $client_args); $SV->Spawn (); -if (PerlACE::waitforfile_timed ($iorfile2, $PerlACE::wait_interval_for_process_creation) == -1) { - print STDERR "ERROR: cannot find file <$iorfile2>\n"; - $SV->Kill (); +if ($server->WaitForFileTimed ($iorbase2, + $server->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile2>\n"; + $SV->Kill (); $SV->TimedWait (1); exit 1; } # Start client. -$client = $CL->SpawnWaitKill (60); +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval ()); -if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -$server = $SV->WaitKill (60); +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval ()); -if ($server != 0) { - print STDERR "ERROR: server returned $server\n"; +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } -unlink $iorfile1; -unlink $iorfile2; +$server->DeleteFile ($iorbase1); +$server->DeleteFile ($iorbase2); + +$client->DeleteFile ($iorbase1); +$client->DeleteFile ($iorbase2); # Clean up SHMIOP files PerlACE::check_n_cleanup_files ("server_shmiop_*"); diff --git a/TAO/tests/RTCORBA/Collocation/run_test.pl b/TAO/tests/RTCORBA/Collocation/run_test.pl index 46d8206fc43..9fe7d6a1927 100755 --- a/TAO/tests/RTCORBA/Collocation/run_test.pl +++ b/TAO/tests/RTCORBA/Collocation/run_test.pl @@ -6,32 +6,29 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; $continuous = ($^O eq 'hpux'); print STDERR "\n********** RTCORBA Collocation Unit Test **********\n\n"; -if (PerlACE::is_vxworks_test()) { - $T = new PerlACE::ProcessVX ("Collocation"); -} -else { - $T = new PerlACE::Process ("Collocation"); -} +my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; + +$T = $server->CreateProcess ("Collocation"); if ($continuous) { - $T->Arguments("-ORBSvcConf continuous$PerlACE::svcconf_ext"); + $T->Arguments("-ORBSvcConf continuous$PerlACE::svcconf_ext"); } -$test = $T->SpawnWaitKill(60); +$test = $T->SpawnWaitKill($server->ProcessStartWaitInterval ()); if ($test == 2) { - # Mark as no longer running to avoid errors on exit. - $T->{RUNNING} = 0; + # Mark as no longer running to avoid errors on exit. + $T->{RUNNING} = 0; } else { - if ($test != 0) { - print STDERR "ERROR: test returned $test\n"; - exit 1; - } + if ($test != 0) { + print STDERR "ERROR: test returned $test\n"; + exit 1; + } } exit 0; diff --git a/TAO/tests/RTCORBA/Destroy_Thread_Pool/run_test.pl b/TAO/tests/RTCORBA/Destroy_Thread_Pool/run_test.pl index 5da7912d505..761cda62243 100755 --- a/TAO/tests/RTCORBA/Destroy_Thread_Pool/run_test.pl +++ b/TAO/tests/RTCORBA/Destroy_Thread_Pool/run_test.pl @@ -6,27 +6,23 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; + +my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; $continuous = ($^O eq 'hpux'); print STDERR "\n********** RTCORBA Destroy_Thread_Pool Unit Test **********\n\n"; -if (PerlACE::is_vxworks_test()) { - $T = new PerlACE::ProcessVX ("Destroy_Thread_Pool"); -} -else { - $T = new PerlACE::Process ("Destroy_Thread_Pool"); -} - +$SV = $server->CreateProcess ("Destroy_Thread_Pool"); if ($continuous) { - $T->Arguments("-ORBSvcConf continuous$PerlACE::svcconf_ext"); + $SV->Arguments("-ORBSvcConf continuous$PerlACE::svcconf_ext"); } -$test = $T->SpawnWaitKill (60); +$server_status = $SV->SpawnWaitKill (60); -if ($test != 0) { - print STDERR "ERROR: test returned $test\n"; +if ($server_status != 0) { + print STDERR "ERROR: test returned $server_status\n"; exit 1; } diff --git a/TAO/tests/RTCORBA/Dynamic_Thread_Pool/client.cpp b/TAO/tests/RTCORBA/Dynamic_Thread_Pool/client.cpp index eebb1d299ba..4d1a63cc19c 100644 --- a/TAO/tests/RTCORBA/Dynamic_Thread_Pool/client.cpp +++ b/TAO/tests/RTCORBA/Dynamic_Thread_Pool/client.cpp @@ -95,7 +95,6 @@ Task::svc (void) // We need to set the client thread CORBA priority current->the_priority (get_implicit_thread_CORBA_priority (this->orb_.in ())); - CORBA::Long tc = 0; for (int i = 0; i != iterations; ++i) @@ -129,7 +128,7 @@ Task::svc (void) } } - ACE_OS::sleep (10); + ACE_OS::sleep (20); CORBA::Long end = 0; CORBA::Long re = @@ -145,11 +144,6 @@ Task::svc (void) { ACE_ERROR ((LM_ERROR, "Dynamic thread count should be 0, not %d\n", end)); } - - if (shutdown_server) - { - test->shutdown (); - } } catch (const CORBA::Exception& ex) { @@ -173,47 +167,61 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) if (result != 0) return result; - // Thread Manager for managing task. - ACE_Thread_Manager thread_manager; - - // Create task. - Task task (thread_manager, - orb.in ()); - - // Task activation flags. - long flags = - THR_NEW_LWP | - THR_JOINABLE | - orb->orb_core ()->orb_params ()->thread_creation_flags (); - - // Activate task. - result = - task.activate (flags); - if (result == -1) + if (shutdown_server) { - if (errno == EPERM) - { - ACE_ERROR_RETURN ((LM_ERROR, - "Cannot create thread with scheduling policy %s\n" - "because the user does not have the appropriate privileges, terminating program....\n" - "Check svc.conf options and/or run as root\n", - sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())), - 2); - } - else - // Unexpected error. - ACE_ASSERT (0); - } + CORBA::Object_var object = + orb->string_to_object (ior); - // Wait for task to exit. - result = - thread_manager.wait (); - ACE_ASSERT (result != -1); + test_var test = + test::_narrow (object.in ()); - if (decreased == false) - { - ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Number of threads didn't decrease\n"), -1); + test->shutdown (); } + else + { + + // Thread Manager for managing task. + ACE_Thread_Manager thread_manager; + + // Create task. + Task task (thread_manager, + orb.in ()); + + // Task activation flags. + long flags = + THR_NEW_LWP | + THR_JOINABLE | + orb->orb_core ()->orb_params ()->thread_creation_flags (); + + // Activate task. + result = + task.activate (flags); + if (result == -1) + { + if (errno == EPERM) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot create thread with scheduling policy %s\n" + "because the user does not have the appropriate privileges, terminating program....\n" + "Check svc.conf options and/or run as root\n", + sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())), + 2); + } + else + // Unexpected error. + ACE_ASSERT (0); + } + + // Wait for task to exit. + result = + thread_manager.wait (); + ACE_ASSERT (result != -1); + + if (decreased == false) + { + ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Number of threads didn't decrease\n"), -1); + } + } } catch (const CORBA::Exception& ex) { diff --git a/TAO/tests/RTCORBA/Dynamic_Thread_Pool/run_test.pl b/TAO/tests/RTCORBA/Dynamic_Thread_Pool/run_test.pl index 3c9e0d22062..11c893bb82b 100644 --- a/TAO/tests/RTCORBA/Dynamic_Thread_Pool/run_test.pl +++ b/TAO/tests/RTCORBA/Dynamic_Thread_Pool/run_test.pl @@ -6,23 +6,27 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; $number_of_clients = 1; $status = 0; $continuous = ($^O eq 'hpux'); +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"; + @configurations = ( - { + { file => "ior_3", description => "Invoking methods on servant in second RT thread pool (with lanes)", - }, + }, ); for $test (@configurations) { - unlink $test->{file}; + $server->DeleteFile($test->{file}); + $client->DeleteFile($test->{file}); } sub run_clients @@ -33,28 +37,23 @@ sub run_clients for ($i = 0; $i < $clients; $i++) { - $CL[$i] = new PerlACE::Process ("client", $arg); + $CL[$i] = $client->CreateProcess ("client", $arg); $CL[$i]->Spawn (); } for ($i = 0; $i < $clients; $i++) { - $client = $CL[$i]->WaitKill (120); - if ($client != 0) + $client_status = $CL[$i]->WaitKill ($client->ProcessStopWaitInterval () + 90); + if ($client_status != 0) { - print STDERR "ERROR: client returned $client\n"; + print STDERR "ERROR: client returned $client_status\n"; $status = 1; goto kill_server; } } } -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server"); -} -else { - $SV = new PerlACE::Process ("server"); -} +$SV = $server->CreateProcess ("server"); if ($continuous) { $SV->Arguments ("-ORBSvcConf continuous$PerlACE::svcconf_ext"); @@ -64,10 +63,11 @@ $SV->Spawn (); for $test (@configurations) { - if (PerlACE::waitforfile_timed ($test->{file}, $PerlACE::wait_interval_for_process_creation) == -1) + if ($server->WaitForFileTimed ($test->{file}, + $server->ProcessStartWaitInterval()) == -1) { - $server = $SV->TimedWait (1); - if ($server == 2) + $server_status = $SV->TimedWait (1); + if ($server_status == 2) { # Mark as no longer running to avoid errors on exit. $SV->{RUNNING} = 0; @@ -88,28 +88,29 @@ for $test (@configurations) print STDERR "$test->{description}\n"; print STDERR "*************************************************************\n\n"; - run_clients ("-k file://".PerlACE::LocalFile($test->{file}), $number_of_clients); + run_clients ("-k file://".$client->LocalFile($test->{file}), $number_of_clients); } print STDERR "\n************************\n"; print STDERR "Shutting down the server\n"; print STDERR "************************\n\n"; -run_clients ("-k file://".PerlACE::LocalFile($configurations[0]->{file})." -i 0 -x", 1); +run_clients ("-k file://".$client->LocalFile($configurations[0]->{file})." -i 1 -x", 1); kill_server: -$server = $SV->WaitKill (5); +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval () + (2 * $number_of_clients * 100)); -if ($server != 0) +if ($server_status != 0) { - print STDERR "ERROR: server returned $server\n"; + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } for $test (@configurations) { - unlink $test->{file}; + $server->DeleteFile ($test->{file}); + $client->DeleteFile ($test->{file}); } exit $status diff --git a/TAO/tests/RTCORBA/Explicit_Binding/run_test.pl b/TAO/tests/RTCORBA/Explicit_Binding/run_test.pl index 77203ccc787..0b445fdf8e5 100755 --- a/TAO/tests/RTCORBA/Explicit_Binding/run_test.pl +++ b/TAO/tests/RTCORBA/Explicit_Binding/run_test.pl @@ -6,48 +6,51 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; -$status = 0; -$iorbase = "test.ior"; -$iorfile = PerlACE::LocalFile ("$iorbase"); +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"; + +my $iorbase = "test.ior"; + +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); -unlink $iorfile; +$status = 0; print STDERR "\n********** RTCORBA Explicit Binding Unit Test\n\n"; +$SV = $server->CreateProcess ("server", "-o $server_iorfile -ORBendpoint iiop:// -ORBendpoint shmiop://"); -if (PerlACE::is_vxworks_test()) { -$SV = new PerlACE::ProcessVX ("server", "-o $iorbase -ORBendpoint iiop:// -ORBendpoint shmiop://"); -} -else { -$SV = new PerlACE::Process ("server", "-o $iorfile -ORBendpoint iiop:// -ORBendpoint shmiop://"); -} -$CL = new PerlACE::Process ("client", "-o file://$iorfile -ORBdebuglevel 1"); +$CL = $client->CreateProcess ("client", "-o file://$client_iorfile -ORBdebuglevel 1"); $SV->Spawn (); -if (PerlACE::waitforfile_timed ($iorfile, $PerlACE::wait_interval_for_process_creation) == -1) { - print STDERR "ERROR: cannot find file <$iorfile>\n"; - $SV->Kill (); +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 (60); +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval ()); -if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -$server = $SV->WaitKill (60); +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval ()); -if ($server != 0) { - print STDERR "ERROR: server returned $server\n"; +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } -unlink $iorfile; +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); # Clean up SHMIOP files PerlACE::check_n_cleanup_files ("server_shmiop_*"); diff --git a/TAO/tests/RTCORBA/Linear_Priority/run_test.pl b/TAO/tests/RTCORBA/Linear_Priority/run_test.pl index 9258e0539ca..72aaa9fa9f4 100755 --- a/TAO/tests/RTCORBA/Linear_Priority/run_test.pl +++ b/TAO/tests/RTCORBA/Linear_Priority/run_test.pl @@ -6,71 +6,54 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; + +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"; + +my $iorbase = "ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); $status = 0; -$iorfile = PerlACE::LocalFile("ior"); -@configurations = - ( - { +@configurations = ({ server => "-b empty_file -l empty_file", - client => "-b empty_file -p empty_file -x", - }, - { + client => "-b empty_file -p empty_file -x",}, { server => "-b bands -l empty_file", - client => "-b empty_file -p empty_file -x", - }, - { + client => "-b empty_file -p empty_file -x",}, { server => "-b empty_file -l lanes", - client => "-b empty_file -p empty_file -x", - }, - { + client => "-b empty_file -p empty_file -x",}, { server => "-b bands -l lanes", - client => "-b empty_file -p empty_file -x", - }, - { + client => "-b empty_file -p empty_file -x",}, { server => "-b empty_file -l empty_file", - client => "-b bands -p empty_file -x", - }, - { + client => "-b bands -p empty_file -x", }, { server => "-b empty_file -l lanes", - client => "-b bands -p empty_file -x", - }, - { + client => "-b bands -p empty_file -x", }, { server => "-b empty_file -l empty_file", - client => "-b empty_file -p invocation_priorities -x", - }, - { + client => "-b empty_file -p invocation_priorities -x",}, { server => "-b bands -l empty_file", - client => "-b empty_file -p invocation_priorities -x", - }, - { + client => "-b empty_file -p invocation_priorities -x",}, { server => "-b bands -l lanes", - client => "-b empty_file -p invocation_priorities -x", - }, - { + client => "-b empty_file -p invocation_priorities -x",}, { server => "-b empty_file -l empty_file", - client => "-b bands -p invocation_priorities -x", - }, - { + client => "-b bands -p invocation_priorities -x",}, { server => "-b empty_file -l lanes", - client => "-b bands -p invocation_priorities -x", - }, - ); + client => "-b bands -p invocation_priorities -x",}, ); sub run_client { my $arg = shift; - $CL = new PerlACE::Process ("client", "-k file://$iorfile " . $arg); + $CL = $client->CreateProcess ("client", "-k file://$client_iorfile " . $arg); $CL->Spawn (); - $client = $CL->WaitKill (120); + $client_status = $CL->WaitKill ($client->ProcessStopWaitInterval ()); - if ($client != 0) - { - print STDERR "ERROR: client returned $client\n"; + if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; zap_server (1); } @@ -78,59 +61,53 @@ sub run_client sub run_server { - if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", @_); - } - else { - $SV = new PerlACE::Process ("server", @_); - } + $SV = $server->CreateProcess ("server", @_); if ($SV->Spawn () == -1) { - exit 1; + exit 1; } - - if (PerlACE::waitforfile_timed ($iorfile, $PerlACE::wait_interval_for_process_creation) == -1) - { + + if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { check_supported_priorities ($SV); - print STDERR "ERROR: cannot find ior file: $iorfile\n"; - $status = 1; - zap_server (1); + print STDERR "ERROR: cannot find ior file: $server_iorfile\n"; + $status = 1; + zap_server (1); } } sub zap_server { - $server = $SV->WaitKill (5); + $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval ()); - if ($server != 0) - { - print STDERR "ERROR: server returned $server\n"; + if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } + + $server->DeleteFile($iorbase); + $client->DeleteFile($iorbase); - unlink $iorfile; - - if ($_[0]) - { + if ($_[0]) { exit $status; } } sub check_supported_priorities { - $process = shift; - $returnVal = $process->TimedWait (1); - if ($returnVal == 2) { - # Mark as no longer running to avoid errors on exit. - $process->{RUNNING} = 0; - exit 0; - } + $process = shift; + $returnVal = $process->TimedWait (1); + if ($returnVal == 2) { + # Mark as no longer running to avoid errors on exit. + $process->{RUNNING} = 0; + exit 0; + } } -for $test (@configurations) -{ +for $test (@configurations) { print STDERR "\n******************************************************\n"; - unlink $iorfile; + $server->DeleteFile($iorbase); + $client->DeleteFile($iorbase); run_server ($test->{server}); diff --git a/TAO/tests/RTCORBA/MT_Client_Protocol_Priority/run_test.pl b/TAO/tests/RTCORBA/MT_Client_Protocol_Priority/run_test.pl index 2ccabdd6f4c..e8d6307ca18 100755 --- a/TAO/tests/RTCORBA/MT_Client_Protocol_Priority/run_test.pl +++ b/TAO/tests/RTCORBA/MT_Client_Protocol_Priority/run_test.pl @@ -6,7 +6,10 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; + +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"; $status = 0; $quiet = 0; @@ -17,9 +20,16 @@ if ($#ARGV >= 0 && $ARGV[0] eq '-q') { } # Test parameters. -$iorfilebase = "test.ior"; -$iorfile = PerlACE::LocalFile ("$iorfilebase"); -$data_file = PerlACE::LocalFile ("test_run.data"); + +my $iorbase = "test.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +$database = "test_run.data"; +$data_file = $server->LocalFile ($database); +$server->DeleteFile ($database); $debug_level = 1; $iterations = 50; @@ -45,26 +55,18 @@ else { $priority2 = 50; } -# Clean up leftovers from previous runs. -unlink $iorfile; -unlink $data_file; - $server_args = "-ORBdebuglevel $debug_level " ."-ORBendpoint iiop:// " .(PerlACE::is_vxworks_test() ? "" : "-ORBendpoint shmiop:// "); $client_args = - "-o file://$iorfile " + "-o file://$client_iorfile " ."-a $priority1 -b $priority2 -e 1413566210 -f 0 -n $iterations"; -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", "-o $iorfilebase $server_args"); -} -else { - $SV = new PerlACE::Process ("server", "-o $iorfile $server_args"); -} -$CL = new PerlACE::Process ("client", $client_args); +$SV = $server->CreateProcess ("server", "-o $server_iorfile $server_args"); + +$CL = $client->CreateProcess ("client", $client_args); print STDERR "\n********** MT Client Protocol & CLIENT_PROPAGATED combo Test\n\n"; @@ -82,11 +84,11 @@ $fh = \*OLDERR; # Run server and client. $SV->Spawn (); -if (PerlACE::waitforfile_timed ($iorfile, $PerlACE::wait_interval_for_process_creation) == -1) -{ - $server = $SV->TimedWait (1); - if ($server == 2) - { + +if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { + $server_status = $SV->TimedWait (1); + if ($server_status == 2) { # Could not change priority levels so exit. # redirect STDOUT away from $data_file and set back to normal @@ -99,27 +101,24 @@ if (PerlACE::waitforfile_timed ($iorfile, $PerlACE::wait_interval_for_process_cr $SV->{RUNNING} = 0; exit $status; } - else - { - print STDERR "ERROR: cannot find file <$iorfile>\n"; - $SV->Kill (); + else { + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); exit 1; } } -$client = $CL->SpawnWaitKill (60); +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval ()); -if ($client != 0) -{ - print STDERR "ERROR: client returned $client\n"; +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -$server = $SV->WaitKill (60); +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval ()); -if ($server != 0) -{ - print STDERR "ERROR: server returned $server\n"; +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } @@ -128,35 +127,34 @@ close (STDOUT); open (STDOUT, ">&OLDOUT"); open (STDERR, ">&OLDERR"); -unlink $iorfile; +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); # Run a processing script on the test output. print STDERR "\n********** Processing test output\n\n"; $errors = system ("perl process-output.pl $data_file $iterations $priority1 $priority2") >> 8; -if ($errors > 0) -{ +if ($errors > 0) { $status = 1; if (!$quiet) { print STDERR "Errors Detected, printing output\n"; - if (open (DATA, "<$data_file")) - { + if (open (DATA, "<$data_file")) { print STDERR "================================= Begin\n"; print STDERR <DATA>; print STDERR "================================= End\n"; close (DATA); } - else - { + else { print STDERR "ERROR: Could not open $data_file\n"; } } } -unlink $iorfile; -unlink $data_file; +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); +$server->DeleteFile($database); # Clean up shmiop files PerlACE::check_n_cleanup_files ("server_shmiop_*"); diff --git a/TAO/tests/RTCORBA/ORB_init/run_test.pl b/TAO/tests/RTCORBA/ORB_init/run_test.pl index 3f20a5b7483..87716f406d6 100755 --- a/TAO/tests/RTCORBA/ORB_init/run_test.pl +++ b/TAO/tests/RTCORBA/ORB_init/run_test.pl @@ -6,18 +6,15 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; print STDERR "\n********** RTCORBA ORB_init Unit Test **********\n\n"; -if (PerlACE::is_vxworks_test()) { - $T = new PerlACE::ProcessVX ("ORB_init"); -} -else { - $T = new PerlACE::Process ("ORB_init"); -} +my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; + +$SV = $server->CreateProcess ("ORB_init"); -$test = $T->SpawnWaitKill (60); +$test = $SV->SpawnWaitKill ($server->ProcessStartWaitInterval()); if ($test != 0) { print STDERR "ERROR: test returned $test\n"; diff --git a/TAO/tests/RTCORBA/Persistent_IOR/run_test.pl b/TAO/tests/RTCORBA/Persistent_IOR/run_test.pl index 3eef51efca3..2ee248e195d 100755 --- a/TAO/tests/RTCORBA/Persistent_IOR/run_test.pl +++ b/TAO/tests/RTCORBA/Persistent_IOR/run_test.pl @@ -6,9 +6,13 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; + +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"; $status = 0; + $iiop_port = 27532; $tp_iiop_port = 27533; @@ -27,20 +31,22 @@ $extra_server_args = ($continuous ? "-ORBSvcConf continuous$PerlACE::svcconf_ext ); @configurations = - ( - { + ({ iorfiles => [ "persistent_ior", "tp_persistent_ior", "transient_ior" ], - server => "-a tp_persistent_ior -p persistent_ior -t transient_ior $extra_server_args", - clients => [ "-k file://".PerlACE::LocalFile("tp_persistent_ior"), - "-k file://".PerlACE::LocalFile("persistent_ior"), - "-k file://".PerlACE::LocalFile("transient_ior")." -x" ], - }, - { + server => "-a ". $server->LocalFile ("tp_persistent_ior") ." -p ". + $server->LocalFile ("persistent_ior") ." -t ". + $server->LocalFile ("transient_ior") ." $extra_server_args", + clients => [ "-k file://".$client->LocalFile("tp_persistent_ior"), + "-k file://".$client->LocalFile("persistent_ior"), + "-k file://".$client->LocalFile("transient_ior")." -x" ], + }, { iorfiles => [ "not_used_ior_1", "not_used_ior_2", "transient_ior" ], - server => "-a not_used_ior_1 -p not_used_ior_2 -t transient_ior $extra_server_args", - clients => [ "-k file://".PerlACE::LocalFile("tp_persistent_ior"), - "-k file://".PerlACE::LocalFile("persistent_ior"), - "-k file://".PerlACE::LocalFile("transient_ior")." -x" ], + server => "-a ". $server->LocalFile ("not_used_ior_1") ." -p ". + $server->LocalFile ("not_used_ior_2") ." -t ". + $server->LocalFile ("transient_ior") ." $extra_server_args", + clients => [ "-k file://".$client->LocalFile("tp_persistent_ior"), + "-k file://".$client->LocalFile("persistent_ior"), + "-k file://".$client->LocalFile("transient_ior")." -x" ], }, ); @@ -48,15 +54,14 @@ sub run_client { print "\nRunning client with the following args: @_\n\n"; - $CL = new PerlACE::Process ("client", @_); + $CL = $client->CreateProcess ("client", @_); $CL->Spawn (); - $client = $CL->WaitKill (120); + $client_status = $CL->WaitKill ($client->ProcessStopWaitInterval ()+200); - if ($client != 0) - { - print STDERR "ERROR: client returned $client\n"; + if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; zap_server (1); } @@ -70,25 +75,12 @@ sub run_server print "\nRunning server with the following args: $args\n\n"; - if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", $args); - } - else { - $SV = new PerlACE::Process ("server", $args); - } - + $SV = $server->CreateProcess ("server", $args); $SV->Spawn (); - # $server = $SV->Wait (10); - # if ($server == 0) - # { - # return 0; - # } - - for $file (@$iorfiles) - { - if (PerlACE::waitforfile_timed ($file, 5) == -1) - { + for $file (@$iorfiles) { + if ($server->WaitForFileTimed ($file, + $server->ProcessStartWaitInterval ()) == -1) { print STDERR "ERROR: cannot find ior file: $file\n"; $status = 1; zap_server (1); @@ -98,48 +90,43 @@ sub run_server sub zap_server { - $server = $SV->WaitKill (5); + $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval ()); - if ($server != 0) - { - print STDERR "ERROR: server returned $server\n"; + if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } - if ($_[0]) - { - for $file (@iorfiles) - { - unlink $file; + if ($_[0]) { + for $file (@iorfiles) { + $server->DeleteFile ($file); } exit $status; } } -for $file (@iorfiles) -{ - unlink $file; +for $file (@iorfiles) { + $server->DeleteFile ($file); + $client->DeleteFile ($file); } -for $test (@configurations) -{ +for $test (@configurations) { print STDERR "\n******************************************************\n"; run_server ($test->{server}, $test->{iorfiles}); my $clients = $test->{clients}; - for $args (@$clients) - { + for $args (@$clients) { run_client ($args); } zap_server (0); } -for $file (@iorfiles) -{ - unlink $file; +for $file (@iorfiles) { + $server->DeleteFile ($file); + $client->DeleteFile ($file); } exit $status; diff --git a/TAO/tests/RTCORBA/Policies/run_test.pl b/TAO/tests/RTCORBA/Policies/run_test.pl index 03c90ceff0b..9629a5c8a64 100755 --- a/TAO/tests/RTCORBA/Policies/run_test.pl +++ b/TAO/tests/RTCORBA/Policies/run_test.pl @@ -6,19 +6,15 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; -if (PerlACE::is_vxworks_test()) { - $T = new PerlACE::ProcessVX ("Policies"); -} -else { - $T = new PerlACE::Process ("Policies"); -} +my $policies = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; -$test = $T->SpawnWaitKill (60); +$SV = $policies->CreateProcess ("Policies"); +$status = $SV->SpawnWaitKill ($policies->ProcessStopWaitInterval ()); -if ($test != 0) { - print STDERR "ERROR: test returned $test\n"; +if ($status != 0) { + print STDERR "ERROR: test returns $status\n"; exit 1; } diff --git a/TAO/tests/RTCORBA/Policy_Combinations/run_test.pl b/TAO/tests/RTCORBA/Policy_Combinations/run_test.pl index d36852652b7..0f283da95ba 100755 --- a/TAO/tests/RTCORBA/Policy_Combinations/run_test.pl +++ b/TAO/tests/RTCORBA/Policy_Combinations/run_test.pl @@ -6,10 +6,13 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; $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"; + @iorfiles = ( "root", @@ -30,48 +33,40 @@ $status = 0; sub run_client { - $CL = new PerlACE::Process ("client", @_); + $CL = $client->CreateProcess ("client", @_); $CL->Spawn (); - $client = $CL->WaitKill (120); + $client_status = $CL->WaitKill ($client->ProcessStartWaitInterval ()); - if ($client != 0) - { - print STDERR "ERROR: client returned $client\n"; + if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; goto kill_server; } } -for $file (@iorfiles) -{ - unlink $file; +for $file (@iorfiles) { + $server->DeleteFile ($file); } -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server"); -} -else { - $SV = new PerlACE::Process ("server"); -} +$SV = $server->CreateProcess ("server"); + $SV->Spawn (); -for $file (@iorfiles) -{ - $file = PerlACE::LocalFile($file); - if (PerlACE::waitforfile_timed ($file, $PerlACE::wait_interval_for_process_creation) == -1) - { - $server = $SV->TimedWait (1); - if ($server == 2) - { +for $file (@iorfiles) { + $server_iorfile = $server->LocalFile ($file); + $client_iorfile = $server->LocalFile ($file); + if ($server->WaitForFileTimed ($file, + $server->ProcessStartWaitInterval()) == -1) { + $server_status = $SV->TimedWait (1); + if ($server_status == 2) { # Mark as no longer running to avoid errors on exit. $SV->{RUNNING} = 0; exit $status; } - else - { - print STDERR "ERROR: cannot find ior file: $file\n"; + else { + print STDERR "ERROR: cannot find ior file: $server_iorfile\n"; $status = 1; goto kill_server; } @@ -81,32 +76,27 @@ for $file (@iorfiles) print STDERR "Invoking methods on servant in $file poa\n"; print STDERR "******************************************************\n\n"; - run_client ("-k file://$file"); + run_client ("-k file://$client_iorfile"); } -{ - print STDERR "\n**************************\n"; - print STDERR "Shutting down the server\n"; - print STDERR "**************************\n\n"; - - run_client ("-k file://$iorfiles[0] -i 0 -x"); -} +print STDERR "\n**************************\n"; +print STDERR "Shutting down the server\n"; +print STDERR "**************************\n\n"; - kill_server: - -{ - $server = $SV->WaitKill (5); - - if ($server != 0) - { - print STDERR "ERROR: server returned $server\n"; +$ior_file = $client->LocalFile ($iorfiles[0]); +run_client ("-k file://$ior_file -i 0 -x"); + +kill_server: + print STDERR "Killing server...\n"; + $server_status = $SV->Kill ($server->ProcessStopWaitInterval ()); + + if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } - - for $file (@iorfiles) - { - unlink $file; + + for $file (@iorfiles) { + $server->DeleteFile ($file); } -} exit $status; diff --git a/TAO/tests/RTCORBA/Priority_Inversion_With_Bands/run_test.pl b/TAO/tests/RTCORBA/Priority_Inversion_With_Bands/run_test.pl index fe69e135062..d4ae066b917 100755 --- a/TAO/tests/RTCORBA/Priority_Inversion_With_Bands/run_test.pl +++ b/TAO/tests/RTCORBA/Priority_Inversion_With_Bands/run_test.pl @@ -6,118 +6,105 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; $server_static_threads = 1; $server_dynamic_threads = 0; + $status = 0; + $continuous = ($^O eq 'hpux'); $common_args = ($continuous ? "-ORBSvcConf continuous$PerlACE::svcconf_ext" : ''); +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"; + + @configurations = - ( - { - file => "ior_2", - args => "-b 0", - description => "Invoking methods on servant in thread lanes without bands", - }, - { - file => "ior_2", - args => "-b 1", - description => "Invoking methods on servant in thread lanes with bands", - }, - { - file => "ior_1", - args => "-b 0", - description => "Invoking methods on servant in thread pool without bands", - }, - { - file => "ior_1", - args => "-b 1", - description => "Invoking methods on servant in thread pool with bands", - }, - ); + ({ + file => "ior_2", + args => "-b 0", + description => "Invoking methods on servant in thread lanes without bands", + },{ + file => "ior_2", + args => "-b 1", + description => "Invoking methods on servant in thread lanes with bands", + },{ + file => "ior_1", + args => "-b 0", + description => "Invoking methods on servant in thread pool without bands", + },{ + file => "ior_1", + args => "-b 1", + description => "Invoking methods on servant in thread pool with bands", + },); sub run_test - { - for $test (@configurations) - { - unlink PerlACE::LocalFile($test->{file}); - } +{ + for $test (@configurations) { + $server->DeleteFile ($test->{file}); + } my @parms = @_; $arg = $parms[0]; - if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", "$common_args -s $server_static_threads -d $server_dynamic_threads"); - } - else { - $SV = new PerlACE::Process ("server", "$common_args -s $server_static_threads -d $server_dynamic_threads"); + $SV = $server->CreateProcess ("server", "$common_args -s $server_static_threads -d $server_dynamic_threads"); + + $server_status = $SV->Spawn (); + if ($server_status == -1) { + exit $server_status; } - $server = $SV->Spawn (); - if ($server == -1) - { - exit $status; - } - - for $test (@configurations) - { - if (PerlACE::waitforfile_timed (PerlACE::LocalFile($test->{file}),$PerlACE::wait_interval_for_process_creation ) == -1) - { - $server = $SV->TimedWait (1); - if ($server == 2) - { + for $test (@configurations) { + if ($server->WaitForFileTimed ($test->{file}, + $server->ProcessStartWaitInterval()) == -1) { + $server_status = $SV->TimedWait (1); + if ($server_status == 2) { # Mark as no longer running to avoid errors on exit. $SV->{RUNNING} = 0; exit $status; - } - else - { + } + else { print STDERR "ERROR: cannot find ior file: $test->{file}\n"; $status = 1; goto kill_server; - } - } + } + } print $test->{file}."\n"; - } + } - $CL[$i] = new PerlACE::Process ("client", "$common_args $arg"); + $CL[$i] = $client->CreateProcess ("client", "$common_args $arg"); $CL[$i]->Spawn (); - $client = $CL[$i]->WaitKill (20); - if ($client != 0) - { - print STDERR "ERROR: client returned $client\n"; + $client_status = $CL[$i]->WaitKill ($client->ProcessStartWaitInterval (60)); + if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; goto kill_server; - } + } - kill_server: +kill_server: - $server = $SV->WaitKill (120); + $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval (120)); - if ($server != 0) - { - print STDERR "ERROR: server returned $server\n"; + if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; - } + } - for $test (@configurations) - { - unlink PerlACE::LocalFile($test->{file}); - } - } + for $test (@configurations) { + $server->DeleteFile ($test->{file}); + } +} -for $test (@configurations) - { +for $test (@configurations) { print STDERR "\n*************************************************************\n"; print STDERR "$test->{description}\n"; print STDERR "*************************************************************\n\n"; - my $file = PerlACE::LocalFile($test->{file}); + my $file = $server->LocalFile($test->{file}); run_test ("-k file://$file $test->{args}"); - } +} exit $status diff --git a/TAO/tests/RTCORBA/Private_Connection/run_test.pl b/TAO/tests/RTCORBA/Private_Connection/run_test.pl index f54ae35555f..0c6655e2976 100755 --- a/TAO/tests/RTCORBA/Private_Connection/run_test.pl +++ b/TAO/tests/RTCORBA/Private_Connection/run_test.pl @@ -6,50 +6,60 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; $status = 0; -$iorfile1 = PerlACE::LocalFile ("test1.ior"); -$iorfile2 = PerlACE::LocalFile ("test2.ior"); +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"; -unlink $iorfile1; -unlink $iorfile2; +my $iorbase1 = "test1.ior"; +my $iorbase2 = "test2.ior"; + +my $server_iorfile1 = $server->LocalFile ($iorbase1); +my $client_iorfile1 = $client->LocalFile ($iorbase1); + +my $server_iorfile2 = $server->LocalFile ($iorbase2); +my $client_iorfile2 = $client->LocalFile ($iorbase2); + +$server->DeleteFile ($iorbase1); +$server->DeleteFile ($iorbase2); + +$client->DeleteFile ($iorbase1); +$client->DeleteFile ($iorbase2); print STDERR "\n********** RTCORBA Private Connection Unit Test\n\n"; -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", "-o test1.ior -p test2.ior"); -} -else { - $SV = new PerlACE::Process ("server", "-o $iorfile1 -p $iorfile2"); -} -$CL = new PerlACE::Process ("client", "-o file://$iorfile1 -p file://$iorfile2 -ORBdebuglevel 3 "); +$SV = $server->CreateProcess ("server", "-o $server_iorfile1 -p $server_iorfile2"); +$CL = $client->CreateProcess ("client", "-o file://$client_iorfile1 -p file://$client_iorfile2 -ORBdebuglevel 3 "); $SV->Spawn (); -if (PerlACE::waitforfile_timed ($iorfile2, $PerlACE::wait_interval_for_process_creation) == -1) -{ - print STDERR "ERROR: cannot find file <$iorfile2>\n"; - $SV->Kill (); +if ($server->WaitForFileTimed ($iorbase2, + $server->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile2>\n"; + $SV->Kill (); $SV->TimedWait (1); exit 1; } -$client = $CL->SpawnWaitKill (60); +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval ()); -if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -$server = $SV->WaitKill (60); +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval ()); -if ($server != 0) { - print STDERR "ERROR: server returned $server \n"; +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status \n"; $status = 1; } -unlink $iorfile1; -unlink $iorfile2; +$server->DeleteFile ($iorbase1); +$server->DeleteFile ($iorbase2); + +$client->DeleteFile ($iorbase1); +$client->DeleteFile ($iorbase2); exit $status; diff --git a/TAO/tests/RTCORBA/Profile_And_Endpoint_Selection/run_test.pl b/TAO/tests/RTCORBA/Profile_And_Endpoint_Selection/run_test.pl index 94688ceb93e..ada7040bb13 100755 --- a/TAO/tests/RTCORBA/Profile_And_Endpoint_Selection/run_test.pl +++ b/TAO/tests/RTCORBA/Profile_And_Endpoint_Selection/run_test.pl @@ -6,19 +6,30 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; use English; -$status = 0; -$iorfile = "ior_2"; -$client_debuglevel = 0; -$server_debuglevel = 0; -$client_debug = 0; -$server_debug = 0; -$iiop = 1; -$shmiop = 1; +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"; -$extra_client_args = "-k file://$iorfile -ORBdebuglevel $client_debuglevel -d $client_debug -x"; +my $iorbase = "ior_2"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); + +$server->DeleteFile ($iorbase); +$client->DeleteFile ($iorbase); + +my $client_debuglevel = 0; +my $server_debuglevel = 0; + +my $client_debug = 0; +my $server_debug = 0; + +my $iiop = 1; +my $shmiop = 1; +my $status = 0; + +$extra_client_args = "-k file://$client_iorfile -ORBdebuglevel $client_debuglevel -d $client_debug -x"; $extra_server_args = "-ORBdebuglevel $server_debuglevel -d $server_debug"; if ($OSNAME eq "solaris") { @@ -74,16 +85,15 @@ sub run_client my $client_args = "@_" . " $extra_client_args"; print "client $client_args\n"; - - $CL = new PerlACE::Process ("client", "$client_args"); + + $CL = $client->CreateProcess ("client", "$client_args"); $CL->Spawn (); - $client = $CL->WaitKill (120); + $client_status = $CL->WaitKill ($client->ProcessStopWaitInterval (120)); - if ($client != 0) - { - print STDERR "ERROR: client returned $client\n"; + if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; zap_server (1); } @@ -95,56 +105,53 @@ sub run_server print "server $server_args\n"; - $SV = new PerlACE::Process ("server", "$server_args"); + $SV = $server->CreateProcess ("server", "$server_args"); $SV->Spawn (); - if (PerlACE::waitforfile_timed ($iorfile,$PerlACE::wait_interval_for_process_creation ) == -1) - { + if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { check_supported_priorities ($SV); - print STDERR "ERROR: cannot find ior file: $iorfile\n"; - $status = 1; - zap_server (1); + print STDERR "ERROR: cannot find ior file <$server_iorfile>\n"; + $status = 1; + zap_server (1); } } sub zap_server { - $server = $SV->WaitKill (5); + $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval ()); - if ($server != 0) - { - print STDERR "ERROR: server returned $server\n"; + if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } - unlink $iorfile; + $server->DeleteFile ($iorbase); - if ($_[0]) - { + if ($_[0]) { exit $status; } } sub check_supported_priorities { - $process = shift; - $returnVal = $process->TimedWait (1); - if ($returnVal == 2) { - # Mark as no longer running to avoid errors on exit. - $process->{RUNNING} = 0; - exit 0; - } + $process = shift; + $returnVal = $process->TimedWait (1); + if ($returnVal == 2) { + # Mark as no longer running to avoid errors on exit. + $process->{RUNNING} = 0; + exit 0; + } } -for $test (@configurations) -{ +for $test (@configurations) { my $clients = $test->{clients}; - for $args (@$clients) - { + for $args (@$clients) { print STDERR "\n******************************************************\n\n"; - unlink $iorfile; + $server->DeleteFile ($iorbase); + $client->DeleteFile ($iorbase); run_server ($test->{server}); @@ -154,7 +161,8 @@ for $test (@configurations) } } -unlink "ior_1"; +$server->DeleteFile ($iorbase); +$client->DeleteFile ($iorbase); # Clean up SHMIOP files PerlACE::check_n_cleanup_files ("server_shmiop_*"); diff --git a/TAO/tests/RTCORBA/RTMutex/run_test.pl b/TAO/tests/RTCORBA/RTMutex/run_test.pl index 30ceabb45c4..502e544ca79 100755 --- a/TAO/tests/RTCORBA/RTMutex/run_test.pl +++ b/TAO/tests/RTCORBA/RTMutex/run_test.pl @@ -6,21 +6,18 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; print STDERR "\n********** RTCORBA RTMutex Unit Test **********\n\n"; -if (PerlACE::is_vxworks_test()) { - $T = new PerlACE::ProcessVX ("server"); -} -else { - $T = new PerlACE::Process ("server"); -} +my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; + +$SV = $server->CreateProcess ("server"); -$test = $T->SpawnWaitKill (60); +$server_status = $SV->SpawnWaitKill ($server->ProcessStartWaitInterval (60)); -if ($test != 0) { - print STDERR "ERROR: test returned $test\n"; +if ($server_status != 0) { + print STDERR "ERROR: test returned $server_status\n"; exit 1; } diff --git a/TAO/tests/RTCORBA/Server_Declared/run_test.pl b/TAO/tests/RTCORBA/Server_Declared/run_test.pl index 82d5e912a39..777edcbd732 100755 --- a/TAO/tests/RTCORBA/Server_Declared/run_test.pl +++ b/TAO/tests/RTCORBA/Server_Declared/run_test.pl @@ -6,13 +6,25 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; -$iorfile1 = PerlACE::LocalFile ("test1.ior"); -$iorfile2 = PerlACE::LocalFile ("test2.ior"); +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"; + +my $iorbase1 = "test1.ior"; +my $iorbase2 = "test2.ior"; +my $client_iorfile1 = $client->LocalFile ("$iorbase1"); +my $server_iorfile1 = $server->LocalFile ("$iorbase1"); + +my $client_iorfile2 = $client->LocalFile ("$iorbase2"); +my $server_iorfile2 = $server->LocalFile ("$iorbase2"); + +$server->DeleteFile($iorbase1); +$client->DeleteFile($iorbase1); + +$server->DeleteFile($iorbase2); +$client->DeleteFile($iorbase2); -unlink $iorfile1; -unlink $iorfile2; $status = 0; $server_args = @@ -35,57 +47,54 @@ elsif ($^O eq "hpux") { } if ($continuous) { - $server_args .= " -ORBSvcConf continuous$PerlACE::svcconf_ext"; + $server_args .= " -ORBSvcConf continuous$PerlACE::svcconf_ext"; } -$client_args = "-p file://$iorfile1 -o file://$iorfile2"; -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server", "-p test1.ior -o test2.ior $server_args"); -} -else { - $SV = new PerlACE::Process ("server", "-p $iorfile1 -o $iorfile2 $server_args"); -} -$CL = new PerlACE::Process ("client", $client_args); +$SV = $server->CreateProcess ("server", "-p $server_iorfile1 -o $server_iorfile2 $server_args"); +$CL = $client->CreateProcess ("client", "-p file://$client_iorfile1 -o file://$client_iorfile2"); print STDERR "\n********** RTCORBA SERVER_DECLARED Priority Unit Test\n\n"; +$server_status = $SV->Spawn (); -$SV->Spawn (); +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + exit 1; +} -if (PerlACE::waitforfile_timed ($iorfile2, $PerlACE::wait_interval_for_process_creation) == -1) -{ - $server = $SV->TimedWait (1); - if ($server == 2) - { +if ($server->WaitForFileTimed ($iorbase2, + $server->ProcessStartWaitInterval ()) == -1) { + $server_status = $SV->TimedWait (1); + if ($server_status == 2) { # Mark as no longer running to avoid errors on exit. - $SV->{RUNNING} = 0; - exit $status; - } - else - { - print STDERR "ERROR: cannot find file <$iorfile2>\n"; - $SV->Kill (); + $SV->{RUNNING} = 0; + exit $status; + } + else { + print STDERR "ERROR: cannot find file <$server_iorfile2>\n"; + $SV->Kill (); exit 1; } } -$client = $CL->SpawnWaitKill (60); +$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval ()); -if ($client != 0) -{ - print STDERR "ERROR: client returned $client\n"; +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } -$server = $SV->WaitKill (60); +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval ()); -if ($server != 0) -{ - print STDERR "ERROR: server returned $server\n"; +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } -unlink $iorfile1; -unlink $iorfile2; +$server->DeleteFile($iorbase1); +$client->DeleteFile($iorbase1); + +$server->DeleteFile($iorbase2); +$client->DeleteFile($iorbase2); exit $status; diff --git a/TAO/tests/RTCORBA/Server_Protocol/run_test.pl b/TAO/tests/RTCORBA/Server_Protocol/run_test.pl index 3ebdb34632b..101b3a7a7d5 100755 --- a/TAO/tests/RTCORBA/Server_Protocol/run_test.pl +++ b/TAO/tests/RTCORBA/Server_Protocol/run_test.pl @@ -6,20 +6,23 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; -$iorfilebase = "test.ior"; -$iorfile = PerlACE::LocalFile ("$iorfilebase"); +use PerlACE::TestTarget; + +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"; + +my $iorbase = "test.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); -unlink $iorfile; $status = 0; -$server_reverse_conf = PerlACE::LocalFile ("server_reverse$PerlACE::svcconf_ext"); -$server_iiop_conf = PerlACE::LocalFile ("server_iiop$PerlACE::svcconf_ext"); -$server_uiop_conf = PerlACE::LocalFile ("server_uiop$PerlACE::svcconf_ext"); -$server_shmiop_conf = PerlACE::LocalFile ("server_shmiop$PerlACE::svcconf_ext"); -$server_iiop_uiop_conf = PerlACE::LocalFile ("server_iiop_uiop$PerlACE::svcconf_ext"); -$server_iiop_shmiop_conf = PerlACE::LocalFile ("server_iiop_shmiop$PerlACE::svcconf_ext"); -$server_reverse_nt_conf = PerlACE::LocalFile ("server_reverse_nt$PerlACE::svcconf_ext"); +$server_reverse_conf = $server->LocalFile ("server_reverse$PerlACE::svcconf_ext"); +$server_iiop_uiop_conf = $server->LocalFile ("server_iiop_uiop$PerlACE::svcconf_ext"); +$server_iiop_shmiop_conf = $server->LocalFile ("server_iiop_shmiop$PerlACE::svcconf_ext"); +$server_reverse_nt_conf = $server->LocalFile ("server_reverse_nt$PerlACE::svcconf_ext"); # Configurations for all tests to be run. @server_opts = @@ -63,57 +66,50 @@ print STDERR "********** RTCORBA Server Protocol Policy Unit Test\n"; $test_number = 0; -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server"); -} -else { - $SV = new PerlACE::Process ("server"); -} -$CL = new PerlACE::Process ("client"); +$SV = $server->CreateProcess ("server"); + +$CL = $client->CreateProcess ("client"); foreach $o (@server_opts) { print STDERR "\n\n----------------------------------\n"; print STDERR " ".$comments[$test_number]; - if (PerlACE::is_vxworks_test()) { - my $args = "$o -o $iorfilebase"; - } - else { - my $args = "$o -o $iorfile"; - } + my $args = "$o -o $server_iorfile"; - unlink $iorfile; + $server->DeleteFile ($iorbase); $SV->Arguments ($args); $SV->Spawn (); - if (PerlACE::waitforfile_timed ($iorfile, $PerlACE::wait_interval_for_process_creation) == -1) { - print STDERR "ERROR: cannot find IOR file <$iorfile>\n"; + if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; $SV->Kill (); $SV->TimedWait (1); exit 1; } - $CL->Arguments ("-k file://$iorfile -ORBdebuglevel 1"); + $CL->Arguments ("-k file://$client_iorfile -ORBdebuglevel 1"); - $client = $CL->SpawnWaitKill (60); + $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval ()); - if ($client != 0) { - print STDERR "ERROR: client returned $client\n"; + if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; } - $server = $SV->WaitKill (60); + $server_status = $SV->WaitKill ($server->ProcessStopWaitInterval ()); - if ($server != 0) { - print STDERR "ERROR: server returned $server\n"; + if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; } $test_number++; } -unlink $iorfile; +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); # Clean up SHMIOP files PerlACE::check_n_cleanup_files ("server_shmiop_*"); diff --git a/TAO/tests/RTCORBA/Thread_Pool/run_test.pl b/TAO/tests/RTCORBA/Thread_Pool/run_test.pl index 2ef990c01ce..d51b5d263d5 100755 --- a/TAO/tests/RTCORBA/Thread_Pool/run_test.pl +++ b/TAO/tests/RTCORBA/Thread_Pool/run_test.pl @@ -6,31 +6,31 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; + +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"; $number_of_clients = 4; $status = 0; $continuous = ($^O eq 'hpux'); @configurations = - ( - { - file => "ior_1", - description => "Invoking methods on servant in default thread pool", - }, - { - file => "ior_2", - description => "Invoking methods on servant in first RT thread pool (without lanes)", - }, - { - file => "ior_3", - description => "Invoking methods on servant in second RT thread pool (with lanes)", + ({ + file => "ior_1", + description => "Invoking methods on servant in default thread pool", + },{ + file => "ior_2", + description => "Invoking methods on servant in first RT thread pool (without lanes)", + },{ + file => "ior_3", + description => "Invoking methods on servant in second RT thread pool (with lanes)", }, ); -for $test (@configurations) -{ - unlink $test->{file}; +for $test (@configurations) { + $server->DeleteFile ($test->{file}); + $client->DeleteFile ($test->{file}); } sub run_clients @@ -38,87 +38,78 @@ sub run_clients my @parms = @_; $arg = $parms[0]; $clients = $parms[1]; + - for ($i = 0; $i < $clients; $i++) - { - $CL[$i] = new PerlACE::Process ("client", $arg); + for ($i = 0; $i < $clients; $i++) { + $CL[$i] = $client->CreateProcess ("client", $arg); $CL[$i]->Spawn (); } - for ($i = 0; $i < $clients; $i++) - { - $client = $CL[$i]->WaitKill (120); - if ($client != 0) - { - print STDERR "ERROR: client returned $client\n"; + for ($i = 0; $i < $clients; $i++) { + $client_status = $CL[$i]->WaitKill ($client->ProcessStopWaitInterval (120)); + if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; $status = 1; goto kill_server; } } + print STDERR "Finished running clients"; } -if (PerlACE::is_vxworks_test()) { - $SV = new PerlACE::ProcessVX ("server"); -} -else { - $SV = new PerlACE::Process ("server"); -} +$SV = $server->CreateProcess ("server"); if ($continuous) { - $SV->Arguments ("-ORBSvcConf continuous$PerlACE::svcconf_ext"); + $SV->Arguments ("-ORBSvcConf continuous$PerlACE::svcconf_ext"); } $SV->Spawn (); -for $test (@configurations) -{ - if (PerlACE::waitforfile_timed ($test->{file}, $PerlACE::wait_interval_for_process_creation) == -1) - { - $server = $SV->TimedWait (1); - if ($server == 2) - { +for $test (@configurations) { + if ($server->WaitForFileTimed ($test->{file}, + $server->ProcessStartWaitInterval()) == -1) { + $server_status = $SV->TimedWait (1); + if ($server_status == 2) { # Mark as no longer running to avoid errors on exit. $SV->{RUNNING} = 0; exit $status; } - else - { + else { print STDERR "ERROR: cannot find ior file: $test->{file}\n"; $status = 1; goto kill_server; - } + } } - } - -for $test (@configurations) - { +} + +for $test (@configurations) { print STDERR "\n*************************************************************\n"; print STDERR "$test->{description}\n"; print STDERR "*************************************************************\n\n"; - run_clients ("-k file://".PerlACE::LocalFile($test->{file}), $number_of_clients); - } + $iorfile = $client->LocalFile ($test->{file}); + run_clients ("-k file://$iorfile", $number_of_clients); + print STDERR "Prepare next cycle"; +} print STDERR "\n************************\n"; print STDERR "Shutting down the server\n"; print STDERR "************************\n\n"; -run_clients ("-k file://".PerlACE::LocalFile($configurations[0]->{file})." -i 0 -x", 1); +$client_iorfile = $client->LocalFile ($configurations[0]->{file}); +run_clients ("-k file://$client_iorfile -i 0 -x", 1); kill_server: -$server = $SV->WaitKill (5); +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval () + (2 * $number_of_clients * 100)); -if ($server != 0) - { - print STDERR "ERROR: server returned $server\n"; +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; $status = 1; - } +} -for $test (@configurations) - { - unlink $test->{file}; - } +for $test (@configurations) { + $client->DeleteFile ($test->{file}); + $server->DeleteFile ($test->{file}); +} exit $status - diff --git a/TAO/tests/Sequence_Iterators/Bounded_String.cpp b/TAO/tests/Sequence_Iterators/Bounded_String.cpp new file mode 100644 index 00000000000..5fa03c18753 --- /dev/null +++ b/TAO/tests/Sequence_Iterators/Bounded_String.cpp @@ -0,0 +1,675 @@ +/** + * @file Bounded_String.cpp + * + * @brief test for STL iterator behaviour of CORBA bounded string sequence + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ + +#include "tao/Bounded_Basic_String_Sequence_T.h" +#include "tao/CORBA_String.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" + +#include <iostream> +#include <iterator> +#include <sstream> + +#if defined TAO_HAS_SEQUENCE_ITERATORS && TAO_HAS_SEQUENCE_ITERATORS == 1 + +typedef TAO::bounded_basic_string_sequence<char, 4> s_sequence; + +#define FAIL_RETURN_IF(CONDITION) \ + if (CONDITION) \ + { \ + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ + return 1; \ + } + +template <typename ITERATOR_T> +int test_sequence () +{ + s_sequence a; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test for correct behaviour for empty sequence + FAIL_RETURN_IF (a.begin() != a.end ()); + + // setup of an example sequence + a.length (4); + + const char * elem0_cstr = "elem0"; + const char * elem1_cstr = "elem1"; + const char * elem2_cstr = "elem2"; + const char * elem3_cstr = "elem3"; + + a[0] = CORBA::string_dup (elem0_cstr); + a[1] = CORBA::string_dup (elem1_cstr); + a[2] = CORBA::string_dup (elem2_cstr); + a[3] = CORBA::string_dup (elem3_cstr); + + // test iterator copy constructor + ITERATOR_T a_it (a.begin ()); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test assignment operator + a_it = a.begin (); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test non const dereferencing + // JWH2 - I don't think this test makes sense. I believe the compiler + // will always return a const value since the dereference is on + // the right hand side of the assignment (i.e., r value). + //char* value0 = *a_it; + //FAIL_RETURN_IF (ACE_OS::strcmp (value0, elem0_cstr) != 0); + + // test const dereferencing + const char* const value1 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value1, elem0_cstr) != 0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.begin()); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem1_cstr) != 0); + + // test < operator + FAIL_RETURN_IF (!(a.begin () < a_it)); + FAIL_RETURN_IF (a_it < a.begin ()); + + // test difference type + int a_diff = a_it - a.begin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.end (); + a_it--; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem3_cstr) != 0); + + // test pre-decrement operator + a_it = a.end (); + --a_it; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem3_cstr) != 0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.begin (); + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[0]) != 0); + a_it += 2; + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[2]) != 0); + + // test operator[] write + // NOTE: This now changes the sequence a. + // NOTE: This does not work for const_iterators which are + // sometimes used in this function. + // a_it[0] = CORBA::string_dup (elem0_cstr); + // FAIL_RETURN_IF (ACE_OS::strcmp (a[2],elem0_cstr) != 0); + + // reset content of sequence a + //a[2] = CORBA::string_dup (elem2_cstr); + + // test for loop behaviour + s_sequence b = a; + ITERATOR_T b_it = b.begin (); + + for (a_it = a.begin (); + a_it != a.end (); + a_it++, b_it++) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, *b_it) != 0); + } + + s_sequence test; + test.length (4); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + ITERATOR_T copytest_iter = test.begin (); + for (ITERATOR_T copya_iter = a.begin (); + copya_iter != a.end (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*copya_iter, *copytest_iter) != 0); + } + + /// Testing - using ostream_iterator + std::ostringstream ostream; + std::copy (a.begin (), + a.end (), + // JWH2 - I changed value_type to const_value_type. Is that + // the correct approach? + std::ostream_iterator<s_sequence::const_value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename ITERATOR_T> +int test_const_sequence () +{ + // setup of an example sequence + s_sequence setup; + setup.length (4); + + const char * elem0_cstr = "elem0"; + const char * elem1_cstr = "elem1"; + const char * elem2_cstr = "elem2"; + const char * elem3_cstr = "elem3"; + + setup[0] = CORBA::string_dup (elem0_cstr); + setup[1] = CORBA::string_dup (elem1_cstr); + setup[2] = CORBA::string_dup (elem2_cstr); + setup[3] = CORBA::string_dup (elem3_cstr); + + const s_sequence a = setup; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test iterator copy constructor + ITERATOR_T a_it (a.begin ()); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test assignment operator + a_it = a.begin (); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test non const dereferencing + // JWH2 - I don't think this test makes sense. I believe the compiler + // will always return a const value since the dereference is on + // the right hand side of the assignment (i.e., r value). + //char* value0 = *a_it; + //FAIL_RETURN_IF (ACE_OS::strcmp (value0, elem0_cstr) != 0); + + // test const dereferencing + const char* const value1 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value1, elem0_cstr) != 0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.begin()); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem1_cstr) != 0); + + // test < operator + FAIL_RETURN_IF (!(a.begin () < a_it)); + FAIL_RETURN_IF (a_it < a.begin ()); + + // test difference type + int a_diff = a_it - a.begin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.end (); + a_it--; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem3_cstr) != 0); + + // test pre-decrement operator + a_it = a.end (); + --a_it; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem3_cstr) != 0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.begin (); + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[0]) != 0); + a_it += 2; + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[2]) != 0); + + // test for loop behaviour + s_sequence b = a; + ITERATOR_T b_it = b.begin (); + + for (a_it = a.begin (); + a_it != a.end (); + a_it++, b_it++) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, *b_it) != 0); + } + + s_sequence test; + test.length (4); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + ITERATOR_T copytest_iter = test.begin (); + for (ITERATOR_T copya_iter = a.begin (); + copya_iter != a.end (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*copya_iter, *copytest_iter) != 0); + } + + /// Testing - using ostream_iterator + std::ostringstream ostream; + std::copy (a.begin (), + a.end (), + // JWH2 - I changed value_type to const_value_type. Is that + // the correct approach? + std::ostream_iterator<s_sequence::const_value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename REVERSE_ITERATOR_T> +int test_sequence_reverse () +{ + s_sequence a; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test for correct behaviour for empty sequence + + FAIL_RETURN_IF (a.begin() != a.end ()); + + // setup of an example sequence + a.length (4); + + const char * elem0_cstr = "elem0"; + const char * elem1_cstr = "elem1"; + const char * elem2_cstr = "elem2"; + const char * elem3_cstr = "elem3"; + + a.length (4); + a[0] = CORBA::string_dup (elem0_cstr); + a[1] = CORBA::string_dup (elem1_cstr); + a[2] = CORBA::string_dup (elem2_cstr); + a[3] = CORBA::string_dup (elem3_cstr); + + // test iterator copy constructor + REVERSE_ITERATOR_T a_it (a.rbegin ()); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test assignment operator + a_it = a.rbegin (); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test non const dereferencing + // JWH2 - I don't think this test makes sense. I believe the compiler + // will always return a const value since the dereference is on + // the right hand side of the assignment (i.e., r value). + //char* value0 = *a_it; + //FAIL_RETURN_IF (ACE_OS::strcmp (value0, elem3_cstr) != 0); + + // test const dereferencing + const char* const value1 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value1, elem3_cstr) != 0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.rbegin()); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem2_cstr) != 0); + + // test < operator + FAIL_RETURN_IF (!(a.rbegin () < a_it)); + FAIL_RETURN_IF (a_it < a.rbegin ()); + + // test difference type + int a_diff = a_it - a.rbegin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + REVERSE_ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + REVERSE_ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.rend (); + a_it--; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem0_cstr) != 0); + + // test pre-decrement operator + a_it = a.rend (); + --a_it; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem0_cstr) != 0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.rbegin (); + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[3]) != 0); + a_it += 2; + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[1]) != 0); + + // test operator[] write + // NOTE: This now changes the sequence a. + // this is not possible for const iterators which are + // sometimes used by this function. + // a_it[0] = CORBA::string_dup (elem0_cstr); + // FAIL_RETURN_IF (ACE_OS::strcmp (a[1],elem0_cstr) != 0); + + // reset content of sequence a + //a[1] = CORBA::string_dup (elem1_cstr); + + // test for loop behaviour + s_sequence b = a; + REVERSE_ITERATOR_T b_it = b.rbegin (); + + for (a_it = a.rbegin (); + a_it != a.rend (); + a_it++, b_it++) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, *b_it) != 0); + } + + s_sequence test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + REVERSE_ITERATOR_T copytest_iter = test.rbegin (); + for (REVERSE_ITERATOR_T copya_iter = a.rbegin (); + copya_iter != a.rend (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*copya_iter, *copytest_iter) != 0); + } + + /// Testing - using ostream_iterator + std::ostringstream ostream; + std::copy (a.rbegin (), + a.rend (), + // JWH2 - I changed value_type to const_value_type. Is that + // the correct approach? + std::ostream_iterator<s_sequence::const_value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem3\nelem2\nelem1\nelem0\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename REVERSE_ITERATOR_T> +int test_const_sequence_reverse () +{ + // setup of an example sequence + s_sequence setup; + setup.length (4); + + const char * elem0_cstr = "elem0"; + const char * elem1_cstr = "elem1"; + const char * elem2_cstr = "elem2"; + const char * elem3_cstr = "elem3"; + + setup[0] = CORBA::string_dup (elem0_cstr); + setup[1] = CORBA::string_dup (elem1_cstr); + setup[2] = CORBA::string_dup (elem2_cstr); + setup[3] = CORBA::string_dup (elem3_cstr); + + const s_sequence a = setup; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test iterator copy constructor + REVERSE_ITERATOR_T a_it (a.rbegin ()); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test assignment operator + a_it = a.rbegin (); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test non const dereferencing + // JWH2 - I don't think this test makes sense. I believe the compiler + // will always return a const value since the dereference is on + // the right hand side of the assignment (i.e., r value). + //char* value0 = *a_it; + //FAIL_RETURN_IF (ACE_OS::strcmp (value0, elem3_cstr) != 0); + + // test const dereferencing + const char* const value1 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value1, elem3_cstr) != 0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.rbegin()); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem2_cstr) != 0); + + // test < operator + FAIL_RETURN_IF (!(a.rbegin () < a_it)); + FAIL_RETURN_IF (a_it < a.rbegin ()); + + // test difference type + int a_diff = a_it - a.rbegin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + REVERSE_ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + REVERSE_ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.rend (); + a_it--; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem0_cstr) != 0); + + // test pre-decrement operator + a_it = a.rend (); + --a_it; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem0_cstr) != 0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.rbegin (); + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[3]) != 0); + a_it += 2; + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[1]) != 0); + + // test for loop behaviour + s_sequence b = a; + REVERSE_ITERATOR_T b_it = b.rbegin (); + + for (a_it = a.rbegin (); + a_it != a.rend (); + a_it++, b_it++) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, *b_it) != 0); + } + + s_sequence test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + REVERSE_ITERATOR_T copytest_iter = test.rbegin (); + for (REVERSE_ITERATOR_T copya_iter = a.rbegin (); + copya_iter != a.rend (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*copya_iter, *copytest_iter) != 0); + } + + /// Testing - using ostream_iterator + std::ostringstream ostream; + std::copy (a.rbegin (), + a.rend (), + // JWH2 - I changed value_type to const_value_type. Is that + // the correct approach? + std::ostream_iterator<s_sequence::const_value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem3\nelem2\nelem1\nelem0\n") != 0); + + return 0; +} + +#endif + +//----------------------------------------------------------------------------- + +int ACE_TMAIN(int,ACE_TCHAR*[]) +{ + int status = 0; + +#if defined TAO_HAS_SEQUENCE_ITERATORS && TAO_HAS_SEQUENCE_ITERATORS == 1 + + // Test Generic_Sequence_Iterator. + status += test_sequence<s_sequence::iterator> (); + + // Test Const_Generic_Sequence_Iterator with non-const sequence. + status += test_sequence<s_sequence::const_iterator> (); + + // Test Const_Generic_Sequence_Iterator with const sequence. + status += test_const_sequence<s_sequence::const_iterator> (); + + // Test Generic_Sequence_Reverse_Iterator. + status += test_sequence_reverse<s_sequence::reverse_iterator> (); + + // Test Const_Generic_Sequence_Reverse_Iterator with non-const sequence. + status += test_sequence_reverse<s_sequence::const_reverse_iterator> (); + + // Test Const_Generic_Sequence_Reverse_Iterator with const sequence. + status += test_const_sequence_reverse<s_sequence::const_reverse_iterator> (); + +#endif + + return status; +} + diff --git a/TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc b/TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc new file mode 100644 index 00000000000..2750d6ef2a3 --- /dev/null +++ b/TAO/tests/Sequence_Iterators/Sequence_Iterators.mpc @@ -0,0 +1,31 @@ +// -*- MPC -*- +// $Id$ + +project(StringSeq) : taoexe { + exename = StringSeq + Source_Files { + StringSeq.cpp + } +} + +project(Bounded_String) : taoexe { + exename = Bounded_String + Source_Files { + Bounded_String.cpp + } +} + +project(Unbounded_Value) : taoexe { + exename = Unbounded_Value + Source_Files { + Unbounded_Value.cpp + } +} + +project(Unbounded_Objectref) : taoexe { + exename = Unbounded_Objectref + Source_Files { + mock_reference.cpp + Unbounded_Objectref.cpp + } +} diff --git a/TAO/tests/Sequence_Iterators/StringSeq.cpp b/TAO/tests/Sequence_Iterators/StringSeq.cpp new file mode 100644 index 00000000000..639c0ff6196 --- /dev/null +++ b/TAO/tests/Sequence_Iterators/StringSeq.cpp @@ -0,0 +1,961 @@ +/** + * @file StringSeq.cpp + * + * @brief test for STL iterator behaviour of CORBA unbounded string sequence + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ + +#include "tao/StringSeqC.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" + +#include <iostream> +#include <iterator> +#include <sstream> + +#define FAIL_RETURN_IF(CONDITION) \ + if (CONDITION) \ + { \ + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ + return 1; \ + } + +//----------------------------------------------------------------------------- + +#if defined TAO_HAS_SEQUENCE_ITERATORS && TAO_HAS_SEQUENCE_ITERATORS == 1 + +template <typename ITERATOR_T> +int test_sequence () +{ + ::CORBA::StringSeq a; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test for correct behaviour for empty sequence + + FAIL_RETURN_IF (a.begin() != a.end ()); + + // setup of an example sequence + + const char * elem0_cstr = "elem0"; + const char * elem1_cstr = "elem1"; + const char * elem2_cstr = "elem2"; + const char * elem3_cstr = "elem3"; + + a.length (4); + // Create a case to test for memory leaks + // in the sequence. + a[0] = CORBA::string_dup (elem0_cstr); + a[0] = CORBA::string_dup (elem0_cstr); + a[1] = CORBA::string_dup (elem1_cstr); + a[2] = CORBA::string_dup (elem2_cstr); + a[3] = CORBA::string_dup (elem3_cstr); + + // test iterator copy constructor + ITERATOR_T a_it (a.begin ()); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test assignment operator + a_it = a.begin (); + + // Create a case to test for memory leaks + // in the iterator. + *a_it = CORBA::string_dup (elem0_cstr); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test non const dereferencing + // I'm not sure this test makes sense since what's returned from + // dereferencing the iterator is an r value. + const char* value_seq = a[0]; + FAIL_RETURN_IF (ACE_OS::strcmp (value_seq, elem0_cstr) != 0); + const char* value0 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value0, elem0_cstr) != 0); + + // test const dereferencing + const char* const value1 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value1, elem0_cstr) != 0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.begin()); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem1_cstr) != 0); + + // test < operator + FAIL_RETURN_IF (!(a.begin () < a_it)); + FAIL_RETURN_IF (a_it < a.begin ()); + + // test difference type + int a_diff = a_it - a.begin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.end (); + a_it--; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem3_cstr) != 0); + + // test pre-decrement operator + a_it = a.end (); + --a_it; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem3_cstr) != 0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.begin (); + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[0]) != 0); + a_it += 2; + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[2]) != 0); + + // test operator[] write + // NOTE: This assignment actually modifies the third element + // in the sequence since the iterator was previously positioned + // at the third element. I believe these are the proper semantics + // for using the bracket operator with an iterator. The number + // in the brackets is additive - not absolute. + a_it[0] = CORBA::string_dup (elem2_cstr); + FAIL_RETURN_IF (ACE_OS::strcmp (a[2], elem2_cstr) != 0); + + // reset content of sequence a + a[1] = CORBA::string_dup (elem1_cstr); + + // test for loop behaviour + ::CORBA::StringSeq b = a; + ITERATOR_T b_it = b.begin (); + + for (a_it = a.begin (); + a_it != a.end (); + a_it++, b_it++) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, *b_it) != 0); + } + + ::CORBA::StringSeq test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + ITERATOR_T copytest_iter = test.begin (); + for (ITERATOR_T copya_iter = a.begin (); + copya_iter != a.end (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*copya_iter, *copytest_iter) != 0); + } + + /// Testing - using ostream_iterator + std::ostringstream ostream; + std::copy (a.begin (), + a.end (), + std::ostream_iterator<CORBA::StringSeq::const_value_type> (ostream, + "\n")); + + // The third sequence element has been modified. Either we need to restore + // the original sequence values or modify the test here. I modified the + // test since it's easier. + FAIL_RETURN_IF ( + ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename ITERATOR_T> +int test_sequence_const_iterator () +{ + ::CORBA::StringSeq a; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test for correct behaviour for empty sequence + + FAIL_RETURN_IF (a.begin() != a.end ()); + + // setup of an example sequence + + const char * elem0_cstr = "elem0"; + const char * elem1_cstr = "elem1"; + const char * elem2_cstr = "elem2"; + const char * elem3_cstr = "elem3"; + + a.length (4); + a[0] = CORBA::string_dup (elem0_cstr); + a[0] = CORBA::string_dup (elem0_cstr); + a[1] = CORBA::string_dup (elem1_cstr); + a[2] = CORBA::string_dup (elem2_cstr); + a[3] = CORBA::string_dup (elem3_cstr); + + // test iterator copy constructor + ITERATOR_T a_it (a.begin ()); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test assignment operator + a_it = a.begin (); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test non const dereferencing + // I'm not sure non-const deferencing makes sense since + // we are getting an r value. + const char * value0 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value0, elem0_cstr) != 0); + + // test const dereferencing + const char* const value1 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value1, elem0_cstr) != 0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.begin()); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem1_cstr) != 0); + + // test < operator + FAIL_RETURN_IF (!(a.begin () < a_it)); + FAIL_RETURN_IF (a_it < a.begin ()); + + // test difference type + int a_diff = a_it - a.begin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.end (); + a_it--; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem3_cstr) != 0); + + // test pre-decrement operator + a_it = a.end (); + --a_it; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem3_cstr) != 0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.begin (); + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[0]) != 0); + a_it += 2; + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[2]) != 0); + + // test for loop behaviour + ::CORBA::StringSeq b = a; + ITERATOR_T b_it = b.begin (); + + for (a_it = a.begin (); + a_it != a.end (); + a_it++, b_it++) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, *b_it) != 0); + } + + ::CORBA::StringSeq test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + ITERATOR_T copytest_iter = test.begin (); + for (ITERATOR_T copya_iter = a.begin (); + copya_iter != a.end (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*copya_iter, *copytest_iter) != 0); + } + + /// Testing - using ostream_iterator + std::ostringstream ostream; + std::copy (a.begin (), + a.end (), + std::ostream_iterator<CORBA::StringSeq::const_value_type>(ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename ITERATOR_T> +int test_const_sequence () +{ + // setup of an example sequence + const char * elem0_cstr = "elem0"; + const char * elem1_cstr = "elem1"; + const char * elem2_cstr = "elem2"; + const char * elem3_cstr = "elem3"; + + ::CORBA::StringSeq setup; + setup.length (4); + setup[0] = CORBA::string_dup (elem0_cstr); + setup[1] = CORBA::string_dup (elem1_cstr); + setup[2] = CORBA::string_dup (elem2_cstr); + setup[3] = CORBA::string_dup (elem3_cstr); + + const ::CORBA::StringSeq a = setup; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + ITERATOR_T c_iter1 (a.begin ()); + ITERATOR_T c_iter2 = a.begin (); + FAIL_RETURN_IF (!(c_iter1 == c_iter2)); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test iterator copy constructor + ITERATOR_T a_it (a.begin ()); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test non const dereferencing + // JWH2 - This test shouldn't be done when dealing with + // a const iterator (which we sometimes do with the current + // testing setup). + //typename ITERATOR_T::element_type value0 = *a_it; + //FAIL_RETURN_IF (ACE_OS::strcmp (value0, elem0_cstr) != 0); + + // test const dereferencing + typename ITERATOR_T::const_element_type value1 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value1, elem0_cstr) != 0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.begin()); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem1_cstr) != 0); + + // test < operator + FAIL_RETURN_IF (!(a.begin () < a_it)); + FAIL_RETURN_IF (a_it < a.begin ()); + + // test difference type + int a_diff = a_it - a.begin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.end (); + a_it--; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem3_cstr) != 0); + + // test pre-decrement operator + a_it = a.end (); + --a_it; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem3_cstr) != 0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.begin (); + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[0]) != 0); + a_it += 2; + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[2]) != 0); + + // test for loop behaviour + const ::CORBA::StringSeq b = a; + ITERATOR_T b_it = b.begin (); + + for (a_it = a.begin (); + a_it != a.end (); + a_it++, b_it++) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, *b_it) != 0); + } + + ::CORBA::StringSeq test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + ITERATOR_T copytest_iter = test.begin (); + for (ITERATOR_T copya_iter = a.begin (); + copya_iter != a.end (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*copya_iter, *copytest_iter) != 0); + } + + /// Testing - using ostream_iterator + std::ostringstream ostream; + std::copy (a.begin (), + a.end (), + std::ostream_iterator<CORBA::StringSeq::const_value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename REVERSE_ITERATOR_T> +int test_sequence_reverse () +{ + ::CORBA::StringSeq a; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test for correct behaviour for empty sequence + + FAIL_RETURN_IF (a.begin() != a.end ()); + + // setup of an example sequence + const char * elem0_cstr = "elem0"; + const char * elem1_cstr = "elem1"; + const char * elem2_cstr = "elem2"; + const char * elem3_cstr = "elem3"; + + a.length (4); + a[0] = CORBA::string_dup (elem0_cstr); + a[1] = CORBA::string_dup (elem1_cstr); + a[2] = CORBA::string_dup (elem2_cstr); + a[3] = CORBA::string_dup (elem3_cstr); + + // test iterator copy constructor + REVERSE_ITERATOR_T a_it (a.rbegin ()); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test assignment operator + a_it = a.rbegin (); + + // Create a case to test for memory leaks + // in the iterator. + *a_it = CORBA::string_dup (elem3_cstr); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test non const dereferencing + typename REVERSE_ITERATOR_T::element_type value0 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value0, elem3_cstr) != 0); + + // test const dereferencing + const char* const value1 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value1, elem3_cstr) != 0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.rbegin()); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem2_cstr) != 0); + + // test < operator + FAIL_RETURN_IF (!(a.rbegin () < a_it)); + FAIL_RETURN_IF (a_it < a.rbegin ()); + + // test difference type + int a_diff = a_it - a.rbegin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + REVERSE_ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + REVERSE_ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.rend (); + a_it--; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem0_cstr) != 0); + + // test pre-decrement operator + a_it = a.rend (); + --a_it; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem0_cstr) != 0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.rbegin (); + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[3]) != 0); + a_it += 2; + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[1]) != 0); + + // test operator[] write + a_it[0] = CORBA::string_dup (elem0_cstr); + FAIL_RETURN_IF (ACE_OS::strcmp (a[1],elem0_cstr) != 0); + + // reset content of sequence a + a[1] = CORBA::string_dup (elem1_cstr); + + // test for loop behaviour + ::CORBA::StringSeq b = a; + REVERSE_ITERATOR_T b_it = b.rbegin (); + + for (a_it = a.rbegin (); + a_it != a.rend (); + a_it++, b_it++) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, *b_it) != 0); + } + + ::CORBA::StringSeq test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + REVERSE_ITERATOR_T copytest_iter = test.rbegin (); + for (REVERSE_ITERATOR_T copya_iter = a.rbegin (); + copya_iter != a.rend (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*copya_iter, *copytest_iter) != 0); + } + + /// Testing - using ostream_iterator + std::ostringstream ostream; + std::copy (a.rbegin (), + a.rend (), + std::ostream_iterator<CORBA::StringSeq::element_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem3\nelem2\nelem1\nelem0\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename REVERSE_ITERATOR_T> +int test_sequence_reverse_const_iterator () +{ + ::CORBA::StringSeq a; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test for correct behaviour for empty sequence + + FAIL_RETURN_IF (a.begin() != a.end ()); + + // setup of an example sequence + const char * elem0_cstr = "elem0"; + const char * elem1_cstr = "elem1"; + const char * elem2_cstr = "elem2"; + const char * elem3_cstr = "elem3"; + + a.length (4); + a[0] = CORBA::string_dup (elem0_cstr); + a[1] = CORBA::string_dup (elem1_cstr); + a[2] = CORBA::string_dup (elem2_cstr); + a[3] = CORBA::string_dup (elem3_cstr); + + // test iterator copy constructor + REVERSE_ITERATOR_T a_it (a.rbegin ()); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test assignment operator + a_it = a.rbegin (); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test non const dereferencing + typename REVERSE_ITERATOR_T::const_element_type value0 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value0, elem3_cstr) != 0); + + // test const dereferencing + const char* const value1 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value1, elem3_cstr) != 0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.rbegin()); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem2_cstr) != 0); + + // test < operator + FAIL_RETURN_IF (!(a.rbegin () < a_it)); + FAIL_RETURN_IF (a_it < a.rbegin ()); + + // test difference type + int a_diff = a_it - a.rbegin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + REVERSE_ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + REVERSE_ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.rend (); + a_it--; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem0_cstr) != 0); + + // test pre-decrement operator + a_it = a.rend (); + --a_it; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem0_cstr) != 0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.rbegin (); + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[3]) != 0); + a_it += 2; + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[1]) != 0); + + // test for loop behaviour + ::CORBA::StringSeq b = a; + REVERSE_ITERATOR_T b_it = b.rbegin (); + + for (a_it = a.rbegin (); + a_it != a.rend (); + a_it++, b_it++) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, *b_it) != 0); + } + + ::CORBA::StringSeq test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + REVERSE_ITERATOR_T copytest_iter = test.rbegin (); + for (REVERSE_ITERATOR_T copya_iter = a.rbegin (); + copya_iter != a.rend (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*copya_iter, *copytest_iter) != 0); + } + + /// Testing - using ostream_iterator + std::ostringstream ostream; + std::copy (a.rbegin (), + a.rend (), + std::ostream_iterator<CORBA::StringSeq::element_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem3\nelem2\nelem1\nelem0\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename REVERSE_ITERATOR_T> +int test_const_sequence_reverse () +{ + // setup of an example sequence + const char * elem0_cstr = "elem0"; + const char * elem1_cstr = "elem1"; + const char * elem2_cstr = "elem2"; + const char * elem3_cstr = "elem3"; + + ::CORBA::StringSeq setup;; + setup.length (4); + setup[0] = CORBA::string_dup (elem0_cstr); + setup[1] = CORBA::string_dup (elem1_cstr); + setup[2] = CORBA::string_dup (elem2_cstr); + setup[3] = CORBA::string_dup (elem3_cstr); + + const ::CORBA::StringSeq a = setup; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test iterator copy constructor + REVERSE_ITERATOR_T a_it (a.rbegin ()); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test non const dereferencing + typename REVERSE_ITERATOR_T::const_element_type value0 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value0, elem3_cstr) != 0); + + // test const dereferencing + const char* const value1 = *a_it; + FAIL_RETURN_IF (ACE_OS::strcmp (value1, elem3_cstr) != 0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.rbegin()); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem2_cstr) != 0); + + // test < operator + FAIL_RETURN_IF (!(a.rbegin () < a_it)); + FAIL_RETURN_IF (a_it < a.rbegin ()); + + // test difference type + int a_diff = a_it - a.rbegin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + REVERSE_ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + REVERSE_ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.rend (); + a_it--; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem0_cstr) != 0); + + // test pre-decrement operator + a_it = a.rend (); + --a_it; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, elem0_cstr) != 0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.rbegin (); + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[3]) != 0); + a_it += 2; + FAIL_RETURN_IF (ACE_OS::strcmp (a_it[0],a[1]) != 0); + + // test for loop behaviour + ::CORBA::StringSeq b = a; + REVERSE_ITERATOR_T b_it = b.rbegin (); + + for (a_it = a.rbegin (); + a_it != a.rend (); + a_it++, b_it++) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*a_it, *b_it) != 0); + } + + ::CORBA::StringSeq test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + REVERSE_ITERATOR_T copytest_iter = test.rbegin (); + for (REVERSE_ITERATOR_T copya_iter = a.rbegin (); + copya_iter != a.rend (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (ACE_OS::strcmp (*copya_iter, *copytest_iter) != 0); + } + + /// Testing - using ostream_iterator + std::ostringstream ostream; + std::copy (a.rbegin (), + a.rend (), + std::ostream_iterator<CORBA::StringSeq::const_element_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem3\nelem2\nelem1\nelem0\n") != 0); + + return 0; +} + +#endif + +//----------------------------------------------------------------------------- + +int ACE_TMAIN(int,ACE_TCHAR*[]) +{ + int status = 0; + +#if defined TAO_HAS_SEQUENCE_ITERATORS && TAO_HAS_SEQUENCE_ITERATORS == 1 + + // Test Generic_Sequence_Iterator. + status += test_sequence< ::CORBA::StringSeq::iterator> (); + + // g++ seems to make the conversion from iterator to const_iterator + // and Windows doesn't. Not sure why. + // Test Const_Generic_Sequence_Iterator with non-const sequence. + status += test_sequence_const_iterator < + ::CORBA::StringSeq::const_iterator> (); + + // Test Const_Generic_Sequence_Iterator with const sequence. + status += test_const_sequence< ::CORBA::StringSeq::const_iterator> (); + + // Test Generic_Sequence_Reverse_Iterator. + status += test_sequence_reverse< ::CORBA::StringSeq::reverse_iterator> (); + + // Test Const_Generic_Sequence_Reverse_Iterator with non-const sequence. + status += test_sequence_reverse_const_iterator< + ::CORBA::StringSeq::const_reverse_iterator> (); + + // Test Const_Generic_Sequence_Reverse_Iterator with const sequence. + status += test_const_sequence_reverse< + ::CORBA::StringSeq::const_reverse_iterator> (); +#endif + + return status; +} diff --git a/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp b/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp new file mode 100644 index 00000000000..17532c58c3c --- /dev/null +++ b/TAO/tests/Sequence_Iterators/Unbounded_Objectref.cpp @@ -0,0 +1,669 @@ +/** + * @file Unbounded_Objectref.cpp + * + * @brief test for STL iterator behaviour of CORBA unbounded object reference + * sequence + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ + +#include "ace/Log_Msg.h" + +#include <iostream> +#include <iterator> +#include <sstream> + +#include "tao/Object_Reference_Traits_T.h" +#include "mock_reference.hpp" +#include "tao/Unbounded_Object_Reference_Sequence_T.h" + +#define FAIL_RETURN_IF(CONDITION) \ + if (CONDITION) \ + { \ + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ + return 1; \ + } + +#if defined TAO_HAS_SEQUENCE_ITERATORS && TAO_HAS_SEQUENCE_ITERATORS == 1 + +typedef TAO::unbounded_object_reference_sequence<mock_reference, mock_reference_var> tested_sequence; + +template <typename ITERATOR_T> +int test_sequence () +{ + tested_sequence a; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test for correct behaviour for empty sequence + + FAIL_RETURN_IF (a.begin() != a.end ()); + + mock_reference* elem0 = mock_reference::allocate (0); + mock_reference* elem1 = mock_reference::allocate (1); + mock_reference* elem2 = mock_reference::allocate (2); + mock_reference* elem3 = mock_reference::allocate (3); + + // setup of an example sequence + a.length (4); + + a[0] = elem0; + a[1] = elem1; + a[2] = elem2; + a[3] = elem3; + + // test iterator copy constructor + ITERATOR_T a_it (a.begin ()); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test assignment operator + a_it = a.begin (); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test non const dereferencing + mock_reference* value0 = *a_it; + FAIL_RETURN_IF (value0->id () != elem0->id ()); + + // test const dereferencing + const mock_reference* const value1 = *a_it; + FAIL_RETURN_IF (value1->id () != elem0->id ()); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.begin()); + FAIL_RETURN_IF ((*a_it)->id () != elem1->id ()); + + // test < operator + FAIL_RETURN_IF (!(a.begin () < a_it)); + FAIL_RETURN_IF (a_it < a.begin ()); + + // test difference type + int a_diff = a_it - a.begin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.end (); + a_it--; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem3->id ()); + + // test pre-decrement operator + a_it = a.end (); + --a_it; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem3->id ()); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.begin (); + FAIL_RETURN_IF (a_it[0]->id () != a[0]->id ()); + a_it += 2; + FAIL_RETURN_IF (a_it[0]->id () != a[2]->id ()); + + // test for loop behaviour + tested_sequence b = a; + ITERATOR_T b_it = b.begin (); + + for (a_it = a.begin (); + a_it != a.end (); + a_it++, b_it++) + { + FAIL_RETURN_IF ((*a_it)->id () != (*b_it)->id ()); + } + + tested_sequence test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + ITERATOR_T copytest_iter = test.begin (); + for (ITERATOR_T copya_iter = a.begin (); + copya_iter != a.end (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF ((*copya_iter)->id () != (*copytest_iter)->id ()); + } + + /// Testing - using ostream_iterator + /// JWH2 - I don't think the ostream test makes sense for object references. + /* + std::ostringstream ostream; + std::copy (a.begin (), + a.end (), + std::ostream_iterator<tested_sequence::value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0); + */ + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename ITERATOR_T> +int test_const_sequence () +{ + // setup of an example sequence + tested_sequence setup; + setup.length (4); + + mock_reference* elem0 = mock_reference::allocate (0); + mock_reference* elem1 = mock_reference::allocate (1); + mock_reference* elem2 = mock_reference::allocate (2); + mock_reference* elem3 = mock_reference::allocate (3); + + // setup of an example sequence + setup[0] = elem0; + setup[1] = elem1; + setup[2] = elem2; + setup[3] = elem3; + + const tested_sequence a = setup; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test iterator copy constructor + ITERATOR_T a_it (a.begin ()); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test assignment operator + a_it = a.begin (); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test non const dereferencing + mock_reference* value0 = *a_it; + FAIL_RETURN_IF (value0->id () != elem0->id ()); + + // test const dereferencing + const mock_reference* const value1 = *a_it; + FAIL_RETURN_IF (value1->id () != elem0->id ()); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.begin()); + FAIL_RETURN_IF ((*a_it)->id () != elem1->id ()); + + // test < operator + FAIL_RETURN_IF (!(a.begin () < a_it)); + FAIL_RETURN_IF (a_it < a.begin ()); + + // test difference type + int a_diff = a_it - a.begin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.end (); + a_it--; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem3->id ()); + + // test pre-decrement operator + a_it = a.end (); + --a_it; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem3->id ()); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.begin (); + FAIL_RETURN_IF ((a_it[0])->id () != a[0]->id ()); + a_it += 2; + FAIL_RETURN_IF ((a_it[0])->id () != a[2]->id ()); + + // test for loop behaviour + tested_sequence b = a; + ITERATOR_T b_it = b.begin (); + + for (a_it = a.begin (); + a_it != a.end (); + a_it++, b_it++) + { + FAIL_RETURN_IF ((*a_it)->id () != (*b_it)->id ()); + } + + tested_sequence test; + test.length (4); + + /* + * The copy call below causes double deletes and seg faults. + */ + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + ITERATOR_T copytest_iter = test.begin (); + for (ITERATOR_T copya_iter = a.begin (); + copya_iter != a.end (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF ((*copya_iter)->id () != (*copytest_iter)->id ()); + } + + /// Testing - using ostream_iterator + /// JWH2 - I don't think the ostream test makes sense for object references. + /* + std::ostringstream ostream; + std::copy (a.begin (), + a.end (), + std::ostream_iterator<tested_sequence::value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem0\nelem1\nelem2\nelem3\n") != 0); + */ + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename REVERSE_ITERATOR_T> +int test_sequence_reverse () +{ + tested_sequence a; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test for correct behaviour for empty sequence + + FAIL_RETURN_IF (a.begin() != a.end ()); + + // setup of an example sequence + a.length (4); + + mock_reference* elem0 = mock_reference::allocate (0); + mock_reference* elem1 = mock_reference::allocate (1); + mock_reference* elem2 = mock_reference::allocate (2); + mock_reference* elem3 = mock_reference::allocate (3); + + // setup of an example sequence + a.length (4); + a[0] = elem0; + a[1] = elem1; + a[2] = elem2; + a[3] = elem3; + + // test iterator copy constructor + REVERSE_ITERATOR_T a_it (a.rbegin ()); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test assignment operator + a_it = a.rbegin (); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test non const dereferencing + mock_reference* value0 = *a_it; + FAIL_RETURN_IF (value0->id () != elem3->id ()); + + // test const dereferencing + const mock_reference* const value1 = *a_it; + FAIL_RETURN_IF (value1->id () != elem3->id ()); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.rbegin()); + FAIL_RETURN_IF ((*a_it)->id () != elem2->id ()); + + // test < operator + FAIL_RETURN_IF (!(a.rbegin () < a_it)); + FAIL_RETURN_IF (a_it < a.rbegin ()); + + // test difference type + int a_diff = a_it - a.rbegin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + REVERSE_ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + REVERSE_ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.rend (); + a_it--; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem0->id ()); + + // test pre-decrement operator + a_it = a.rend (); + --a_it; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem0->id ()); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.rbegin (); + FAIL_RETURN_IF ((a_it[0])->id () != a[3]->id ()); + a_it += 2; + FAIL_RETURN_IF ((a_it[0])->id () != a[1]->id ()); + + // test for loop behaviour + tested_sequence b = a; + REVERSE_ITERATOR_T b_it = b.rbegin (); + + for (a_it = a.rbegin (); + a_it != a.rend (); + a_it++, b_it++) + { + FAIL_RETURN_IF ((*a_it)->id () != (*b_it)->id ()); + } + + tested_sequence test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + REVERSE_ITERATOR_T copytest_iter = test.rbegin (); + for (REVERSE_ITERATOR_T copya_iter = a.rbegin (); + copya_iter != a.rend (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF ((*copya_iter)->id () != (*copytest_iter)->id ()); + } + + /// Testing - using ostream_iterator + /// JWH2 - I don't think the ostream test makes sense for object references. + /* + std::ostringstream ostream; + std::copy (a.rbegin (), + a.rend (), + std::ostream_iterator<tested_sequence::value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem3\nelem2\nelem1\nelem0\n") != 0); + */ + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename REVERSE_ITERATOR_T> +int test_const_sequence_reverse () +{ + // setup of an example sequence + tested_sequence setup; + setup.length (4); + + mock_reference* elem0 = mock_reference::allocate (0); + mock_reference* elem1 = mock_reference::allocate (1); + mock_reference* elem2 = mock_reference::allocate (2); + mock_reference* elem3 = mock_reference::allocate (3); + + // setup of an example sequence + setup[0] = elem0; + setup[1] = elem1; + setup[2] = elem2; + setup[3] = elem3; + + const tested_sequence a = setup; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test iterator copy constructor + REVERSE_ITERATOR_T a_it (a.rbegin ()); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test assignment operator + a_it = a.rbegin (); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test non const dereferencing + mock_reference* value0 = *a_it; + FAIL_RETURN_IF (value0->id () != elem3->id ()); + + // test const dereferencing + const mock_reference* const value1 = *a_it; + FAIL_RETURN_IF (value1->id () != elem3->id ()); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.rbegin()); + FAIL_RETURN_IF ((*a_it)->id () != elem2->id ()); + + // test < operator + FAIL_RETURN_IF (!(a.rbegin () < a_it)); + FAIL_RETURN_IF (a_it < a.rbegin ()); + + // test difference type + int a_diff = a_it - a.rbegin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + REVERSE_ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + REVERSE_ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.rend (); + a_it--; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem0->id ()); + + // test pre-decrement operator + a_it = a.rend (); + --a_it; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF ((*a_it)->id () != elem0->id ()); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.rbegin (); + FAIL_RETURN_IF ((a_it[0])->id () != a[3]->id ()); + a_it += 2; + FAIL_RETURN_IF ((a_it[0])->id () != a[1]->id ()); + + // test operator[] write + // NOTE: This now changes the sequence a. + // this is not possible for const iterators + // a_it[0] = CORBA::string_dup (elem0_cstr); + // FAIL_RETURN_IF (ACE_OS::strcmp (a[1],elem0_cstr) != 0); + + // reset content of sequence a + //a[1] = CORBA::string_dup (elem1_cstr); + + // test for loop behaviour + tested_sequence b = a; + REVERSE_ITERATOR_T b_it = b.rbegin (); + + for (a_it = a.rbegin (); + a_it != a.rend (); + a_it++, b_it++) + { + FAIL_RETURN_IF ((*a_it)->id () != (*b_it)->id ()); + } + + tested_sequence test; + test.length (a.length ()); + + /* + * The copy call below causes double deletes and seg faults. + */ + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + REVERSE_ITERATOR_T copytest_iter = test.rbegin (); + for (REVERSE_ITERATOR_T copya_iter = a.rbegin (); + copya_iter != a.rend (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF ((*copya_iter)->id () != (*copytest_iter)->id ()); + } + + /// Testing - using ostream_iterator + /// JWH2 - I don't think the ostream test makes sense for object references. + /* + std::ostringstream ostream; + std::copy (a.rbegin (), + a.rend (), + std::ostream_iterator<tested_sequence::value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("elem3\nelem2\nelem1\nelem0\n") != 0); + */ + + return 0; +} + +#endif + +//----------------------------------------------------------------------------- + +int ACE_TMAIN(int,ACE_TCHAR*[]) +{ + int status = 0; + +#if defined TAO_HAS_SEQUENCE_ITERATORS && TAO_HAS_SEQUENCE_ITERATORS == 1 + + // Test Generic_Sequence_Iterator. + status += test_sequence< tested_sequence::iterator> (); + + // g++ seems to make the conversion from iterator to const_iterator + // and Windows doesn't. Not sure why. + // Test Const_Generic_Sequence_Iterator with non-const sequence. + status += test_sequence< tested_sequence::const_iterator> (); + + // Test Const_Generic_Sequence_Iterator with const sequence. + status += test_const_sequence< tested_sequence::const_iterator> (); + + // Test Generic_Sequence_Reverse_Iterator. + status += test_sequence_reverse< tested_sequence::reverse_iterator> (); + + // Test Const_Generic_Sequence_Reverse_Iterator with non-const sequence. + status += test_sequence_reverse< tested_sequence::const_reverse_iterator> (); + + // Test Const_Generic_Sequence_Reverse_Iterator with const sequence. + status += test_const_sequence_reverse< tested_sequence::const_reverse_iterator> (); + +#endif /* TAO_HAS_SEQUENCE_ITERATORS == 1 */ + + return status; +} diff --git a/TAO/tests/Sequence_Iterators/Unbounded_Value.cpp b/TAO/tests/Sequence_Iterators/Unbounded_Value.cpp new file mode 100644 index 00000000000..70b3b8097a4 --- /dev/null +++ b/TAO/tests/Sequence_Iterators/Unbounded_Value.cpp @@ -0,0 +1,692 @@ +/** + * @file Unbounded_Value.cpp + * + * @brief test for STL iterator behaviour of CORBA bounded string sequence + * + * $Id$ + * + * @author Friedhelm Wolf (fwolf@dre.vanderbilt.edu) + */ + +#include "tao/Unbounded_Value_Sequence_T.h" +#include "ace/Log_Msg.h" + +#include <iostream> +#include <iterator> +#include <sstream> + +#if defined TAO_HAS_SEQUENCE_ITERATORS && TAO_HAS_SEQUENCE_ITERATORS == 1 + +typedef TAO::unbounded_value_sequence<int> v_sequence; + +#define FAIL_RETURN_IF(CONDITION) \ + if (CONDITION) \ + { \ + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ + return 1; \ + } + +template <typename ITERATOR_T> +int test_sequence () +{ + v_sequence a; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test for correct behaviour for empty sequence + FAIL_RETURN_IF (a.begin() != a.end ()); + + // setup of an example sequence + a.length (4); + + int elem0 = 0; + int elem1 = 1; + int elem2 = 2; + int elem3 = 3; + + a[0] = elem0; + a[1] = elem1; + a[2] = elem2; + a[3] = elem3; + + // test iterator copy constructor + ITERATOR_T a_it (a.begin ()); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test assignment operator + a_it = a.begin (); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test non const dereferencing + // JWH2 - I don't think this test makes sense. I believe the compiler + // will always return a const value since the dereference is on + // the right hand side of the assignment (i.e., r value). + //int value0 = *a_it; + //FAIL_RETURN_IF (value0 != elem0); + + // test const dereferencing + int value1 = *a_it; + FAIL_RETURN_IF (value1 != elem0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.begin()); + FAIL_RETURN_IF (*a_it != elem1); + + // test < operator + FAIL_RETURN_IF (!(a.begin () < a_it)); + FAIL_RETURN_IF (a_it < a.begin ()); + + // test difference type + int a_diff = a_it - a.begin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.end (); + a_it--; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (*a_it != elem3); + + // test pre-decrement operator + a_it = a.end (); + --a_it; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (*a_it != elem3); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.begin (); + FAIL_RETURN_IF (a_it[0] != a[0]); + a_it += 2; + FAIL_RETURN_IF (a_it[0] != a[2]); + + // test operator[] write + // NOTE: This now changes the sequence a. + // NOTE: This does not work for const_iterators + // a_it[0] = elem0; + // FAIL_RETURN_IF (a[2] != elem0); + + // reset content of sequence a + //a[2] = elem2; + + // test for loop behaviour + v_sequence b = a; + ITERATOR_T b_it = b.begin (); + + for (a_it = a.begin (); + a_it != a.end (); + a_it++, b_it++) + { + FAIL_RETURN_IF (*a_it != *b_it); + } + + v_sequence test; + test.length (4); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + ITERATOR_T copytest_iter = test.begin (); + for (ITERATOR_T copya_iter = a.begin (); + copya_iter != a.end (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (*copya_iter != *copytest_iter); + } + + /// Testing - using ostream_iterator + + std::ostringstream ostream; + std::copy (a.begin (), + a.end (), + // JWH2 - I changed value_type to const_value_type. Is that + // the correct approach? + std::ostream_iterator<v_sequence::const_value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("0\n1\n2\n3\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename ITERATOR_T> +int test_const_sequence () +{ + // setup of an example sequence + v_sequence setup; + setup.length (4); + + int elem0 = 0; + int elem1 = 1; + int elem2 = 2; + int elem3 = 3; + + setup[0] = elem0; + setup[1] = elem1; + setup[2] = elem2; + setup[3] = elem3; + + const v_sequence a = setup; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test iterator copy constructor + ITERATOR_T a_it (a.begin ()); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test assignment operator + a_it = a.begin (); + FAIL_RETURN_IF (a_it != a.begin ()); + + // test non const dereferencing + // JWH2 - I don't think this test makes sense. I believe the compiler + // will always return a const value since the dereference is on + // the right hand side of the assignment (i.e., r value). + //char* value0 = *a_it; + //FAIL_RETURN_IF (value0 != elem0); + + // test const dereferencing + int value1 = *a_it; + FAIL_RETURN_IF (value1 != elem0); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.begin()); + FAIL_RETURN_IF (*a_it != elem1); + + // test < operator + FAIL_RETURN_IF (!(a.begin () < a_it)); + FAIL_RETURN_IF (a_it < a.begin ()); + + // test difference type + int a_diff = a_it - a.begin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.end (); + a_it--; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (*a_it != elem3); + + // test pre-decrement operator + a_it = a.end (); + --a_it; + FAIL_RETURN_IF (a_it == a.end ()); + FAIL_RETURN_IF ((a.end () - a_it) != 1); + FAIL_RETURN_IF (*a_it != elem3); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.begin (); + FAIL_RETURN_IF (a_it[0] != a[0]); + a_it += 2; + FAIL_RETURN_IF (a_it[0] != a[2]); + + // test operator[] write + // NOTE: This now changes the sequence a. + // NOTE: This does not work for const_iterators + // a_it[0] = elem0; + // FAIL_RETURN_IF (a[2] != elem0); + + // reset content of sequence a + //a[2] = elem2; + + // test for loop behaviour + v_sequence b = a; + ITERATOR_T b_it = b.begin (); + + for (a_it = a.begin (); + a_it != a.end (); + a_it++, b_it++) + { + FAIL_RETURN_IF (*a_it != *b_it); + } + + v_sequence test; + test.length (4); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + ITERATOR_T copytest_iter = test.begin (); + for (ITERATOR_T copya_iter = a.begin (); + copya_iter != a.end (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (*copya_iter != *copytest_iter); + } + + /// Testing - using ostream_iterator + + std::ostringstream ostream; + std::copy (a.begin (), + a.end (), + // JWH2 - I changed value_type to const_value_type. Is that + // the correct approach? + std::ostream_iterator<v_sequence::const_value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("0\n1\n2\n3\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename REVERSE_ITERATOR_T> +int test_sequence_reverse () +{ + v_sequence a; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test for correct behaviour for empty sequence + + FAIL_RETURN_IF (a.begin() != a.end ()); + + // setup of an example sequence + a.length (4); + + int elem0 = 0; + int elem1 = 1; + int elem2 = 2; + int elem3 = 3; + + a[0] = elem0; + a[1] = elem1; + a[2] = elem2; + a[3] = elem3; + + // test iterator copy constructor + REVERSE_ITERATOR_T a_it (a.rbegin ()); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test assignment operator + a_it = a.rbegin (); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test non const dereferencing + // JWH2 - I don't think this test makes sense. I believe the compiler + // will always return a const value since the dereference is on + // the right hand side of the assignment (i.e., r value). + //int value0 = *a_it; + //FAIL_RETURN_IF (value0 != elem3); + + // test const dereferencing + int value1 = *a_it; + FAIL_RETURN_IF (value1 != elem3); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.rbegin()); + FAIL_RETURN_IF (*a_it != elem2); + + // test < operator + FAIL_RETURN_IF (!(a.rbegin () < a_it)); + FAIL_RETURN_IF (a_it < a.rbegin ()); + + // test difference type + int a_diff = a_it - a.rbegin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + REVERSE_ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + REVERSE_ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.rend (); + a_it--; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (*a_it != elem0); + + // test pre-decrement operator + a_it = a.rend (); + --a_it; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (*a_it != elem0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.rbegin (); + FAIL_RETURN_IF (a_it[0] != a[3]); + a_it += 2; + FAIL_RETURN_IF (a_it[0] != a[1]); + + // test operator[] write + // NOTE: This now changes the sequence a. + // this is not possible for const iterators + // a_it[0] = elem0; + // FAIL_RETURN_IF (a[1] != elem0); + + // reset content of sequence a + //a[1] = elem1; + + // test for loop behaviour + v_sequence b = a; + REVERSE_ITERATOR_T b_it = b.rbegin (); + + for (a_it = a.rbegin (); + a_it != a.rend (); + a_it++, b_it++) + { + FAIL_RETURN_IF (*a_it != *b_it); + } + + v_sequence test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + REVERSE_ITERATOR_T copytest_iter = test.rbegin (); + for (REVERSE_ITERATOR_T copya_iter = a.rbegin (); + copya_iter != a.rend (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (*copya_iter != *copytest_iter); + } + + /// Testing - using ostream_iterator + + std::ostringstream ostream; + std::copy (a.rbegin (), + a.rend (), + // JWH2 - I changed value_type to const_value_type. Is that + // the correct approach? + std::ostream_iterator<v_sequence::const_value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("3\n2\n1\n0\n") != 0); + + return 0; +} + +//----------------------------------------------------------------------------- + +template <typename REVERSE_ITERATOR_T> +int test_const_sequence_reverse () +{ + // setup of an example sequence + v_sequence setup; + setup.length (4); + + int elem0 = 0; + int elem1 = 1; + int elem2 = 2; + int elem3 = 3; + + setup[0] = elem0; + setup[1] = elem1; + setup[2] = elem2; + setup[3] = elem3; + + const v_sequence a = setup; + + // test equality operator + FAIL_RETURN_IF (!(a.begin () == a.begin ())); + + // test non-equality operator + FAIL_RETURN_IF (a.end () != a.end ()); + + // test iterator copy constructor + REVERSE_ITERATOR_T a_it (a.rbegin ()); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test assignment operator + a_it = a.rbegin (); + FAIL_RETURN_IF (a_it != a.rbegin ()); + + // test non const dereferencing + // JWH2 - I don't think this test makes sense. I believe the compiler + // will always return a const value since the dereference is on + // the right hand side of the assignment (i.e., r value). + //int value0 = *a_it; + //FAIL_RETURN_IF (value0 != elem3); + + // test const dereferencing + int value1 = *a_it; + FAIL_RETURN_IF (value1 != elem3); + + // test increment operation + a_it++; + FAIL_RETURN_IF (a_it == a.rbegin()); + FAIL_RETURN_IF (*a_it != elem2); + + // test < operator + FAIL_RETURN_IF (!(a.rbegin () < a_it)); + FAIL_RETURN_IF (a_it < a.rbegin ()); + + // test difference type + int a_diff = a_it - a.rbegin (); + FAIL_RETURN_IF (a_diff != 1); + + // test copy constructor + REVERSE_ITERATOR_T a_it1 (a_it); + FAIL_RETURN_IF (a_it1 != a_it); + + // test preincrement operator + ++a_it1; + FAIL_RETURN_IF ((a_it1 - a_it) != 1); + + // test = and += operator + REVERSE_ITERATOR_T a_it2 = a_it += 3; + FAIL_RETURN_IF (a_it2 != a_it); + FAIL_RETURN_IF ((a_it - a_it1) != 2); + + // test + operator + a_it2 = a_it1 + 3; + FAIL_RETURN_IF ((a_it2 - a_it1) != 3); + + // test post-decrement operation + a_it = a.rend (); + a_it--; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (*a_it != elem0); + + // test pre-decrement operator + a_it = a.rend (); + --a_it; + FAIL_RETURN_IF (a_it == a.rend ()); + FAIL_RETURN_IF ((a.rend () - a_it) != 1); + FAIL_RETURN_IF (*a_it != elem0); + + // test -= operator + a_it -= 3; + FAIL_RETURN_IF ((a_it1 - a_it) != 2); + + // test - operator + a_it2 = a_it1 - 2; + FAIL_RETURN_IF ((a_it1 - a_it2) != 2); + + // test operator[] read + a_it = a.rbegin (); + FAIL_RETURN_IF (a_it[0] != a[3]); + a_it += 2; + FAIL_RETURN_IF (a_it[0] != a[1]); + + // test operator[] write + // NOTE: This now changes the sequence a. + // this is not possible for const iterators + // a_it[0] = elem0; + // FAIL_RETURN_IF (a[1] != elem0); + + // reset content of sequence a + //a[1] = elem1; + + // test for loop behaviour + v_sequence b = a; + REVERSE_ITERATOR_T b_it = b.rbegin (); + + for (a_it = a.rbegin (); + a_it != a.rend (); + a_it++, b_it++) + { + FAIL_RETURN_IF (*a_it != *b_it); + } + + v_sequence test; + test.length (a.length ()); + + std::copy (a.begin (), + a.end (), + test.begin ()); + + FAIL_RETURN_IF (test.length () != a.length ()); + + REVERSE_ITERATOR_T copytest_iter = test.rbegin (); + for (REVERSE_ITERATOR_T copya_iter = a.rbegin (); + copya_iter != a.rend (); + ++copya_iter, ++copytest_iter) + { + FAIL_RETURN_IF (*copya_iter != *copytest_iter); + } + + /// Testing - using ostream_iterator + + std::ostringstream ostream; + std::copy (a.rbegin (), + a.rend (), + // JWH2 - I changed value_type to const_value_type. Is that + // the correct approach? + std::ostream_iterator<v_sequence::const_value_type> (ostream, + "\n")); + + FAIL_RETURN_IF ( + ostream.str ().compare ("3\n2\n1\n0\n") != 0); + + return 0; +} + +#endif + +//----------------------------------------------------------------------------- + +int ACE_TMAIN(int,ACE_TCHAR*[]) +{ + int status = 0; + +#if defined TAO_HAS_SEQUENCE_ITERATORS && TAO_HAS_SEQUENCE_ITERATORS == 1 + + // Test Generic_Sequence_Iterator. + status += test_sequence<v_sequence::iterator> (); + + // g++ seems to make the conversion from iterator to const_iterator + // and Windows doesn't. Not sure why. + // Test Const_Generic_Sequence_Iterator with non-const sequence. + status += test_sequence<v_sequence::const_iterator> (); + + // Test Const_Generic_Sequence_Iterator with const sequence. + status += test_const_sequence<v_sequence::const_iterator> (); + + // Test Generic_Sequence_Reverse_Iterator. + status += test_sequence_reverse<v_sequence::reverse_iterator> (); + + // Test Const_Generic_Sequence_Reverse_Iterator with non-const sequence. + status += test_sequence_reverse<v_sequence::const_reverse_iterator> (); + + // Test Const_Generic_Sequence_Reverse_Iterator with const sequence. + status += test_const_sequence_reverse<v_sequence::const_reverse_iterator> (); +#endif + + return status; +} diff --git a/TAO/tests/Sequence_Iterators/mock_reference.cpp b/TAO/tests/Sequence_Iterators/mock_reference.cpp new file mode 100644 index 00000000000..a1115c0f094 --- /dev/null +++ b/TAO/tests/Sequence_Iterators/mock_reference.cpp @@ -0,0 +1,90 @@ +/** + * @file + * + * $Id$ + * + * @author Carlos O'Ryan <coryan@atdesk.com> + */ +#include "mock_reference.hpp" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +mock_reference:: +~mock_reference() +{ +} + +mock_reference * mock_reference:: +allocate(int id) +{ + return new mock_reference(id); +} + +mock_reference * mock_reference:: +_nil() +{ + return 0; +} + +mock_reference * mock_reference:: +_duplicate(mock_reference * rhs) +{ + if (rhs == 0) + { + return 0; + } + return new mock_reference(*rhs); +} + +void mock_reference:: +_tao_release(mock_reference * rhs) +{ + delete rhs; +} + +void CORBA::release(mock_reference * r) +{ + mock_reference::_tao_release(r); +} + +mock_reference * +TAO::Objref_Traits<mock_reference>::duplicate ( + mock_reference_ptr p + ) +{ + return mock_reference::_duplicate (p); +} + +void +TAO::Objref_Traits<mock_reference>::release ( + mock_reference_ptr p + ) +{ + CORBA::release (p); +} + +mock_reference_ptr +TAO::Objref_Traits<mock_reference>::nil (void) +{ + return mock_reference::_nil (); +} + +CORBA::Boolean +TAO::Objref_Traits<mock_reference>::marshal ( + const mock_reference_ptr, + TAO_OutputCDR & + ) +{ + return true; +} + +CORBA::Boolean operator<< (TAO_OutputCDR &, const mock_reference *) +{ + return true; +} +CORBA::Boolean operator>> (TAO_InputCDR &, mock_reference *&) +{ + return true; +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tests/Sequence_Iterators/mock_reference.hpp b/TAO/tests/Sequence_Iterators/mock_reference.hpp new file mode 100644 index 00000000000..ecac1eb6eb1 --- /dev/null +++ b/TAO/tests/Sequence_Iterators/mock_reference.hpp @@ -0,0 +1,102 @@ +#ifndef guard_mock_reference_hpp +#define guard_mock_reference_hpp +/** + * @file + * + * @brief Mock an object reference so we can test the sequences in + * isolation. + * + * $Id$ + * + * @author Carlos O'Ryan + */ +#include "ace/config-all.h" + +#include "tao/Basic_Types.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL +// Forward declare the class a CORBA::release function for it. That +// avoids having to introduce CORBA::Object into the tests. +// Ideally the T_var and T_out types should accept mock objects +// too, but that is too much to bite in the current iteration. +class mock_reference; +namespace CORBA +{ +void release(mock_reference*); +} + +class mock_stream; + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include "tao/Objref_VarOut_T.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +typedef mock_reference *mock_reference_ptr; +typedef TAO_Objref_Var_T<mock_reference> mock_reference_var; +typedef TAO_Objref_Out_T<mock_reference> mock_reference_out; + +/** + * @class mock_reference + * + * @brief Implement a concrete class with the right interface for an + * object reference. + */ +class mock_reference +{ +public: + virtual ~mock_reference(); + + typedef mock_reference_var _var_type; + typedef mock_reference_out _out_type; + + static mock_reference * allocate(int id); + static mock_reference * _nil(); + + static mock_reference * _duplicate(mock_reference * rhs); + static void _tao_release(mock_reference * rhs); + + inline bool operator==(mock_reference const & rhs) const + { + return id_ == rhs.id_; + } + + inline bool operator!=(mock_reference const & rhs) const + { + return !(*this == rhs); + } + + inline int id() const + { + return id_; + } + +private: + mock_reference (); + + inline mock_reference(int id) + : id_(id) + {} + +private: + int id_; +}; + +CORBA::Boolean operator<< (TAO_OutputCDR &, const mock_reference *); +CORBA::Boolean operator>> (TAO_InputCDR &, mock_reference *&); + +namespace TAO +{ + template<> + struct Objref_Traits< mock_reference> + { + static mock_reference_ptr duplicate (mock_reference_ptr); + static void release (mock_reference_ptr); + static mock_reference_ptr nil (void); + static CORBA::Boolean marshal (const mock_reference_ptr p, TAO_OutputCDR & cdr); + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL +#endif // guard_mock_reference_hpp diff --git a/TAO/tests/Sequence_Iterators/run_test.pl b/TAO/tests/Sequence_Iterators/run_test.pl new file mode 100755 index 00000000000..8adb8be1389 --- /dev/null +++ b/TAO/tests/Sequence_Iterators/run_test.pl @@ -0,0 +1,46 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; +use strict; + +my $final_result = 0; + +my @testsToRun = qw( + StringSeq + Bounded_String + Unbounded_Value + Unbounded_Objectref + ); + +foreach my $process (@testsToRun) { + + my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; + my $P = $server->CreateProcess ($process); + print "Running $process ...\n"; + my $result = $P->Spawn; + if ($result != 0) { + print "FAILED $process\n"; + $final_result = 1; + next; + } + $result = $P->WaitKill($server->ProcessStartWaitInterval()); + if ($result != 0) { + print "FAILED $process\n"; + $final_result = 1; + next; + } + print "SUCCESS\n"; +} + +exit $final_result; + + + + + diff --git a/TAO/tests/Sequence_Iterators/testing_counters.hpp b/TAO/tests/Sequence_Iterators/testing_counters.hpp new file mode 100644 index 00000000000..3c8d6e5b7ec --- /dev/null +++ b/TAO/tests/Sequence_Iterators/testing_counters.hpp @@ -0,0 +1,106 @@ +#ifndef guard_testing_counters_hpp +#define guard_testing_counters_hpp +/** + * @file + * + * @brief Some unit tests need to count how many times a function is + * called. Here we implement some simple helper classes for that + * purpose. + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +#include "testing_exception.hpp" + +#include <boost/utility.hpp> + +#include <iostream> + +/** + * @brief Used to count how many times a function gets called. The + * unit test should create one instance per function. + */ +class call_counter +{ +public: + inline call_counter() + : count_(0) + , failure_countdown_(0) + {} + + inline long current_count() const + { + return count_; + } + + inline void failure_countdown(long countdown) + { + failure_countdown_ = countdown; + } + + inline void operator()() + { + ++count_; + if (--failure_countdown_ == 0) + { + throw testing_exception(); + } + } + +private: + long count_; + long failure_countdown_; +}; + +/** + * @brief Used to detect if a testing_counter is "called" the right + * number of times. + */ +class expected_calls + : private boost::noncopyable +{ +public: + inline expected_calls(call_counter const & counter) + : current_count_(counter.current_count()) + , previous_count_(counter.current_count()) + , counter_(counter) + { } + + inline bool expect(long n) + { + reset(); + return (previous_count_ + n == current_count_); + } + + inline void reset() + { + previous_count_ = current_count_; + current_count_ = counter_.current_count(); + } + + inline long current_count() const + { + return current_count_; + } + + inline long previous_count() const + { + return previous_count_; + } + +private: + long current_count_; + long previous_count_; + call_counter const & counter_; +}; + +inline std::ostream & operator<<(std::ostream & os, expected_calls const & x) +{ + return os << "current=" << x.current_count() + << ",previous=" << x.previous_count(); + +} + +#endif // guard_testing_counters_hpp diff --git a/TAO/tests/Sequence_Iterators/testing_exception.hpp b/TAO/tests/Sequence_Iterators/testing_exception.hpp new file mode 100644 index 00000000000..2fc4c540197 --- /dev/null +++ b/TAO/tests/Sequence_Iterators/testing_exception.hpp @@ -0,0 +1,15 @@ +#ifndef guard_testing_exception_hpp +#define guard_testing_exception_hpp +/** + * @file + * + * @brief Simple exception to raise in the tests. + * + * $Id$ + * + * @author Carlos O'Ryan + */ + +struct testing_exception {}; + +#endif // guard_testing_exception_hpp diff --git a/TAO/tests/Sequence_Unit_Tests/Makefile.am b/TAO/tests/Sequence_Unit_Tests/Makefile.am index fe4accdd028..c5ed091dd25 100644 --- a/TAO/tests/Sequence_Unit_Tests/Makefile.am +++ b/TAO/tests/Sequence_Unit_Tests/Makefile.am @@ -411,9 +411,9 @@ endif BUILD_BOOST if BUILD_BOOST if BUILD_EXCEPTIONS -noinst_PROGRAMS += unbounded_octet_sequence_no_copy_ut +noinst_PROGRAMS += unbounded_octet_sequence_nocopy_ut -unbounded_octet_sequence_no_copy_ut_CPPFLAGS = \ +unbounded_octet_sequence_nocopy_ut_CPPFLAGS = \ -I$(ACE_ROOT) \ -I$(ACE_BUILDDIR) \ -I$(TAO_ROOT) \ @@ -421,15 +421,15 @@ unbounded_octet_sequence_no_copy_ut_CPPFLAGS = \ -I$(BOOST_ROOT)/include/$(BOOST_VERSION) \ -I$(BOOST_ROOT)/. -unbounded_octet_sequence_no_copy_ut_SOURCES = \ +unbounded_octet_sequence_nocopy_ut_SOURCES = \ mock_reference.cpp \ unbounded_octet_sequence_nocopy_ut.cpp \ mock_reference.hpp -unbounded_octet_sequence_no_copy_ut_LDFLAGS = \ +unbounded_octet_sequence_nocopy_ut_LDFLAGS = \ -L$(BOOST_ROOT)/lib -unbounded_octet_sequence_no_copy_ut_LDADD = \ +unbounded_octet_sequence_nocopy_ut_LDADD = \ $(TAO_BUILDDIR)/tao/libTAO.la \ $(ACE_BUILDDIR)/ace/libACE.la \ -l$(BOOST_STATIC_LIB_PREFIX)boost_unit_test_framework$(BOOST_CFG) diff --git a/TAO/tests/Sequence_Unit_Tests/Sequence_Unit_Tests.mpc b/TAO/tests/Sequence_Unit_Tests/Sequence_Unit_Tests.mpc index 4c71d40e683..6e76ff7bee5 100644 --- a/TAO/tests/Sequence_Unit_Tests/Sequence_Unit_Tests.mpc +++ b/TAO/tests/Sequence_Unit_Tests/Sequence_Unit_Tests.mpc @@ -31,7 +31,7 @@ project(*Bounded_String) : taoexe { } } -project(*UB_Arr_Seq): taoexe, boost_unit_test_framework { +project(*UB_Arr_Seq): taoexe { // Temporarily disabled this test, need to change the mock_array a lot requires += dummy_label exename = unbounded_array_sequence_ut @@ -41,7 +41,7 @@ project(*UB_Arr_Seq): taoexe, boost_unit_test_framework { } } -project(*Obj_Ref_Seq_Elem): taoexe, boost_unit_test_framework { +project(*Obj_Ref_Seq_Elem): taoexe { exename = object_reference_sequence_element_ut Source_Files { mock_reference.cpp @@ -49,7 +49,7 @@ project(*Obj_Ref_Seq_Elem): taoexe, boost_unit_test_framework { } } -project(*UB_Obj_Ref_Seq): taoexe, boost_unit_test_framework { +project(*UB_Obj_Ref_Seq): taoexe { exename = unbounded_object_reference_sequence_ut Source_Files { mock_reference.cpp @@ -57,7 +57,7 @@ project(*UB_Obj_Ref_Seq): taoexe, boost_unit_test_framework { } } -project(*UB_Sequence_CDR): taoexe, boost_unit_test_framework { +project(*UB_Sequence_CDR): taoexe { exename = unbounded_sequence_cdr_ut Source_Files { mock_reference.cpp @@ -65,7 +65,7 @@ project(*UB_Sequence_CDR): taoexe, boost_unit_test_framework { } } -project(*B_Sequence_CDR): taoexe, boost_unit_test_framework { +project(*B_Sequence_CDR): taoexe { exename = bounded_sequence_cdr_ut Source_Files { mock_reference.cpp @@ -73,7 +73,7 @@ project(*B_Sequence_CDR): taoexe, boost_unit_test_framework { } } -project(*UB_Fwd_Ob_Ref_Seq): taoexe, boost_unit_test_framework { +project(*UB_Fwd_Ob_Ref_Seq): taoexe { exename = unbounded_fwd_object_reference_sequence_ut Source_Files { fwd_mock_reference.cpp @@ -81,7 +81,7 @@ project(*UB_Fwd_Ob_Ref_Seq): taoexe, boost_unit_test_framework { } } -project(*UB_Octet_Sequence): taoexe, boost_unit_test_framework { +project(*UB_Octet_Sequence): taoexe { exename = unbounded_octet_sequence_ut Source_Files { mock_reference.cpp @@ -89,15 +89,15 @@ project(*UB_Octet_Sequence): taoexe, boost_unit_test_framework { } } -project(*UB_Oct_Seq_No_Cpy): taoexe, boost_unit_test_framework { - exename = unbounded_octet_sequence_no_copy_ut +project(*UB_Oct_Seq_No_Cpy): taoexe { + exename = unbounded_octet_sequence_nocopy_ut Source_Files { mock_reference.cpp unbounded_octet_sequence_nocopy_ut.cpp } } -project(*B_Obj_Ref_Seq): taoexe, boost_unit_test_framework { +project(*B_Obj_Ref_Seq): taoexe { exename = bounded_object_reference_sequence_ut Source_Files { mock_reference.cpp @@ -105,42 +105,42 @@ project(*B_Obj_Ref_Seq): taoexe, boost_unit_test_framework { } } -project(*String_Seq_Elem): taoexe, boost_unit_test_framework { +project(*String_Seq_Elem): taoexe { exename = string_sequence_element_ut Source_Files { string_sequence_element_ut.cpp } } -project(*UB_String_Seq): taoexe, boost_unit_test_framework { +project(*UB_String_Seq): taoexe { exename = unbounded_string_sequence_ut Source_Files { unbounded_string_sequence_ut.cpp } } -project(*B_String_Seq): taoexe, boost_unit_test_framework { +project(*B_String_Seq): taoexe { exename = bounded_string_sequence_ut Source_Files { bounded_string_sequence_ut.cpp } } -project(*Test_Alloc_Traits): taoexe, boost_unit_test_framework { +project(*Test_Alloc_Traits): taoexe { exename = testing_allocation_traits_ut Source_Files { testing_allocation_traits_ut.cpp } } -project(*UB_Value_Sequence): taoexe, boost_unit_test_framework { +project(*UB_Value_Sequence): taoexe { exename = unbounded_value_sequence_ut Source_Files { unbounded_value_sequence_ut.cpp } } -project(*B_Value_Sequence): taoexe, boost_unit_test_framework { +project(*B_Value_Sequence): taoexe { exename = bounded_value_sequence_ut Source_Files { bounded_value_sequence_ut.cpp diff --git a/TAO/tests/Sequence_Unit_Tests/bounded_object_reference_sequence_ut.cpp b/TAO/tests/Sequence_Unit_Tests/bounded_object_reference_sequence_ut.cpp index 21a8fb14451..c5fd630ab97 100644 --- a/TAO/tests/Sequence_Unit_Tests/bounded_object_reference_sequence_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/bounded_object_reference_sequence_ut.cpp @@ -16,11 +16,9 @@ #include "tao/Bounded_Object_Reference_Sequence_T.h" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" + -using namespace boost::unit_test_framework; using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; CORBA::ULong const TMAX = 64; @@ -35,7 +33,7 @@ struct Tester typedef tested_sequence::allocation_traits tested_allocation_traits; typedef TAO::details::range_checking<value_type,true> range; - void test_default_constructor() + int test_default_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -43,16 +41,17 @@ struct Tester { tested_sequence x; - BOOST_CHECK_EQUAL(TMAX, x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(TMAX, x.maximum()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); + CHECK_EQUAL(false, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } - void test_buffer_constructor_release_true() + int test_buffer_constructor_release_true() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -63,17 +62,20 @@ struct Tester a.reset(); tested_sequence x(maximum / 2, data, true); - BOOST_CHECK_EQUAL(TMAX, x.maximum()); - BOOST_CHECK_EQUAL(x.length(), maximum / 2); - BOOST_CHECK_EQUAL(x.get_buffer(), data); - BOOST_CHECK_EQUAL(x.release(), true); + CHECK_EQUAL(TMAX, x.maximum()); + CHECK_EQUAL(x.length(), maximum / 2); + CHECK_EQUAL(x.get_buffer(), data); + CHECK_EQUAL(x.release(), true); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + // 64 is here because this is a bounded sequence and spec requires + // that maximum() elements are allocated for them by allocbuf. + FAIL_RETURN_IF_NOT(i.expect(64), i); + return 0; } - void test_buffer_constructor_release_false() + int test_buffer_constructor_release_false() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -85,23 +87,25 @@ struct Tester { tested_sequence x(maximum / 2, data, false); - BOOST_CHECK_EQUAL(TMAX, x.maximum()); - BOOST_CHECK_EQUAL(x.length(), maximum / 2); - BOOST_CHECK_EQUAL(x.get_buffer(), data); - BOOST_CHECK_EQUAL(x.release(), false); + CHECK_EQUAL(TMAX, x.maximum()); + CHECK_EQUAL(x.length(), maximum / 2); + CHECK_EQUAL(x.get_buffer(), data); + CHECK_EQUAL(x.release(), false); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + // Same as above. allocbuf default initializes maximum() elements. + FAIL_RETURN_IF_NOT(i.expect(64), i); tested_sequence::freebuf(data); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } - void test_copy_constructor_from_default() + int test_copy_constructor_from_default() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -111,30 +115,33 @@ struct Tester tested_sequence y(x); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(2), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } - void test_copy_constructor() + int test_copy_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls da(tested_allocation_traits::default_buffer_allocation_calls); expected_calls f(tested_allocation_traits::freebuf_calls); - expected_calls i(tested_element_traits::default_initializer_calls); + expected_calls di(tested_element_traits::default_initializer_calls); expected_calls d(mock_reference::duplicate_calls); expected_calls r(mock_reference::release_calls); CORBA::ULong const l = 16; { tested_sequence x; - BOOST_CHECK_MESSAGE(da.expect(1), da); - BOOST_CHECK_MESSAGE(a.expect(0), a); + FAIL_RETURN_IF_NOT(da.expect(1), da); + FAIL_RETURN_IF_NOT(a.expect(0), a); x.length(l); - BOOST_CHECK_MESSAGE(i.expect(l), i); - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_EQUAL(l, x.length()); + // length() allocates a buffer of size maximum() and + // default initializes it. + FAIL_RETURN_IF_NOT(di.expect(TMAX), i); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(l, x.length()); for(CORBA::ULong i = 0; i != l; ++i) { x[i] = mock_reference::allocate(i); @@ -143,23 +150,24 @@ struct Tester d.reset(); r.reset(); tested_sequence y(x); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_EQUAL(l, x.length()); - BOOST_CHECK_MESSAGE(d.expect(l), d); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(l, y.length()); + FAIL_RETURN_IF_NOT(d.expect(l), d); + FAIL_RETURN_IF_NOT(di.expect(TMAX - l), d); for(CORBA::ULong i = 0; i != l; ++i) { - BOOST_CHECK_EQUAL(int(i), y[i]->id()); + CHECK_EQUAL(int(i), y[i]->id()); } } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(2*TMAX), r); - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(2), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(2*TMAX), r); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(2), f); + return 0; } - void test_copy_constructor_throw_duplicate() + int test_copy_constructor_throw_duplicate() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls da(tested_allocation_traits::default_buffer_allocation_calls); @@ -170,38 +178,42 @@ struct Tester CORBA::ULong const l = 16; { tested_sequence x; - BOOST_CHECK_MESSAGE(da.expect(1), da); - BOOST_CHECK_MESSAGE(a.expect(0), a); + FAIL_RETURN_IF_NOT(da.expect(1), da); + FAIL_RETURN_IF_NOT(a.expect(0), a); x.length(l); - BOOST_CHECK_MESSAGE(i.expect(l), i); - - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_EQUAL(l, x.length()); - for(CORBA::ULong i = 0; i != l; ++i) + // length() allocates a buffer of size maximum() and + // default initializes it. + FAIL_RETURN_IF_NOT(i.expect(TMAX), i); + FAIL_RETURN_IF_NOT(a.expect(1), i); + + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(l, x.length()); + for(CORBA::ULong inc = 0; inc != l; ++inc) { - x[i] = mock_reference::allocate(i); + x[inc] = mock_reference::allocate(inc); } d.reset(); r.reset(); mock_reference::duplicate_calls.failure_countdown(8); - BOOST_CHECK_THROW(tested_sequence y(x), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(da.expect(0), da); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(d.expect(8), d); - BOOST_CHECK_MESSAGE(r.expect(TMAX), r); + CHECK_THROW(tested_sequence y(x), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(da.expect(0), da); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(d.expect(8), d); + FAIL_RETURN_IF_NOT(r.expect(TMAX), r); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(TMAX), r); - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(TMAX), r); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + // There are TMAX-16 default initializer calls. + FAIL_RETURN_IF_NOT(i.expect(48), i); + return 0; } - void test_set_length_less_than_maximum() + int test_set_length_less_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls da(tested_allocation_traits::default_buffer_allocation_calls); @@ -211,18 +223,21 @@ struct Tester tested_sequence x; x.length(8); - BOOST_CHECK_EQUAL(TMAX, x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(TMAX, x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); - BOOST_CHECK_MESSAGE(i.expect(8), i); + // length() allocates a buffer of size maximum() and + // default initializes it. + FAIL_RETURN_IF_NOT(i.expect(TMAX), i); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(da.expect(1), da); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(da.expect(1), da); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_set_length_more_than_maximum() + int test_set_length_more_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls da(tested_allocation_traits::default_buffer_allocation_calls); @@ -230,26 +245,29 @@ struct Tester expected_calls i(tested_element_traits::default_initializer_calls); { tested_sequence x; - BOOST_CHECK_MESSAGE(da.expect(1), da); - BOOST_CHECK_MESSAGE(a.expect(0), a); + FAIL_RETURN_IF_NOT(da.expect(1), da); + FAIL_RETURN_IF_NOT(a.expect(0), a); x.length(16); - BOOST_CHECK_MESSAGE(i.expect(16), i); - - BOOST_CHECK_THROW(x.length(2 * TMAX), std::runtime_error); - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); - - BOOST_CHECK_EQUAL(TMAX, x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + // length() allocates a buffer of size maximum() and + // default initializes it. + FAIL_RETURN_IF_NOT(i.expect(TMAX), i); + + CHECK_THROW(x.length(2 * TMAX), std::runtime_error); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + + CHECK_EQUAL(TMAX, x.maximum()); + CHECK_EQUAL(CORBA::ULong(16), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } value_type * alloc_and_init_buffer() { - value_type * buf = tested_sequence::allocbuf(TMAX); + value_type * buf = tested_sequence::allocbuf(); buf[0] = mock_reference::allocate(1); buf[1] = mock_reference::allocate(4); buf[2] = mock_reference::allocate(9); @@ -258,15 +276,16 @@ struct Tester return buf; } - void check_values(tested_sequence const & a) + int check_values(tested_sequence const & a) { - BOOST_CHECK_EQUAL( 1, a[0]->id()); - BOOST_CHECK_EQUAL( 4, a[1]->id()); - BOOST_CHECK_EQUAL( 9, a[2]->id()); - BOOST_CHECK_EQUAL(16, a[3]->id()); + CHECK_EQUAL( 1, a[0]->id()); + CHECK_EQUAL( 4, a[1]->id()); + CHECK_EQUAL( 9, a[2]->id()); + CHECK_EQUAL(16, a[3]->id()); + return 0; } - void test_replace_release_true() + int test_replace_release_true() { value_type * buffer = alloc_and_init_buffer(); @@ -275,24 +294,26 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a; - a.replace(4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(r.expect(TMAX), r); - - BOOST_CHECK_EQUAL(TMAX, a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + a.replace(4, buffer, true); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), r); + + CHECK_EQUAL(TMAX, a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(true, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(TMAX), r); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Since we've given away the ownership the buffer is deallocated by + // the sequence. + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(r.expect(TMAX), r); + return 0; } - void test_replace_release_false() + int test_replace_release_false() { value_type * buffer = alloc_and_init_buffer(); @@ -302,23 +323,24 @@ struct Tester { tested_sequence a; a.replace(4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(r.expect(TMAX), r); - - BOOST_CHECK_EQUAL(TMAX, a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), r); + + CHECK_EQUAL(TMAX, a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(TMAX), r); + FAIL_RETURN_IF_NOT(r.expect(TMAX), r); + return 0; } - void test_replace_release_default() + int test_replace_release_default() { value_type * buffer = alloc_and_init_buffer(); @@ -328,83 +350,40 @@ struct Tester { tested_sequence a; a.replace(4, buffer); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(r.expect(TMAX), r); - - BOOST_CHECK_EQUAL(TMAX, a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), r); + + CHECK_EQUAL(TMAX, a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(TMAX), r); + FAIL_RETURN_IF_NOT(r.expect(TMAX), r); + return 0; } - - void add_all(test_suite * ts) - { - boost::shared_ptr<Tester> shared_this(self_); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_default_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_release_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_copy_constructor_from_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_copy_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_copy_constructor_throw_duplicate, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_less_than_maximum, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_more_than_maximum, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_release_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_release_default, - shared_this)); - } - - static boost::shared_ptr<Tester> allocate() - { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; - } - -private: - Tester() {} - - boost::weak_ptr<Tester> self_; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("unbounded object reference sequence unit test"); - - boost::shared_ptr<Tester> tester(Tester::allocate()); - tester->add_all(ts); - - return ts; + int status = 0; + Tester mytester; + + status += mytester.test_default_constructor(); + status += mytester.test_buffer_constructor_release_true(); + status += mytester.test_buffer_constructor_release_false(); + status += mytester.test_copy_constructor_from_default(); + status += mytester.test_copy_constructor(); + status += mytester.test_copy_constructor_throw_duplicate(); + status += mytester.test_set_length_less_than_maximum(); + status += mytester.test_set_length_more_than_maximum(); + status += mytester.test_replace_release_true(); + status += mytester.test_replace_release_false(); + status += mytester.test_replace_release_default(); + + return status; } - diff --git a/TAO/tests/Sequence_Unit_Tests/bounded_sequence_cdr_ut.cpp b/TAO/tests/Sequence_Unit_Tests/bounded_sequence_cdr_ut.cpp index 85f112d7dc7..7ebdad108ea 100644 --- a/TAO/tests/Sequence_Unit_Tests/bounded_sequence_cdr_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/bounded_sequence_cdr_ut.cpp @@ -23,11 +23,9 @@ #include "tao/Bounded_Sequence_CDR_T.h" #include "tao/CDR.h" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" + -using namespace boost::unit_test_framework; using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; CORBA::ULong const TMAX = 64; @@ -55,7 +53,7 @@ struct Tester value_type * alloc_and_init_buffer() { - value_type * buf = tested_sequence::allocbuf(8); + value_type * buf = tested_sequence::allocbuf(); buf[0] = mock_reference::allocate(1); buf[1] = mock_reference::allocate(4); buf[2] = mock_reference::allocate(9); @@ -64,15 +62,16 @@ struct Tester return buf; } - void check_values(tested_sequence const & a) + int check_values(tested_sequence const & a) { - BOOST_CHECK_EQUAL( 1, a[0]->id()); - BOOST_CHECK_EQUAL( 4, a[1]->id()); - BOOST_CHECK_EQUAL( 9, a[2]->id()); - BOOST_CHECK_EQUAL(16, a[3]->id()); + CHECK_EQUAL( 1, a[0]->id()); + CHECK_EQUAL( 4, a[1]->id()); + CHECK_EQUAL( 9, a[2]->id()); + CHECK_EQUAL(16, a[3]->id()); + return 0; } - void test_stream() + int test_stream() { value_type * buffer = alloc_and_init_buffer(); @@ -81,50 +80,28 @@ struct Tester tested_sequence a; a.replace(4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(64), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(64), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); TAO_OutputCDR stream; stream << a; - BOOST_CHECK_MESSAGE(s.expect(4), s); + FAIL_RETURN_IF_NOT(s.expect(4), s); } tested_sequence::freebuf(buffer); + return 0; } - - void add_all(test_suite * ts) - { - boost::shared_ptr<Tester> shared_this(self_); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_stream, - shared_this)); - } - - static boost::shared_ptr<Tester> allocate() - { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; - } - -private: - Tester() {} - - boost::weak_ptr<Tester> self_; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("unbounded object reference sequence unit test"); + int status = 0; + Tester mytester; - boost::shared_ptr<Tester> tester(Tester::allocate()); - tester->add_all(ts); + status += mytester.test_stream(); - return ts; + return status; } diff --git a/TAO/tests/Sequence_Unit_Tests/bounded_string_sequence_ut.cpp b/TAO/tests/Sequence_Unit_Tests/bounded_string_sequence_ut.cpp index 4cf5ea06a96..372baf585c9 100644 --- a/TAO/tests/Sequence_Unit_Tests/bounded_string_sequence_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/bounded_string_sequence_ut.cpp @@ -21,13 +21,9 @@ #include "ace/OS_NS_string.h" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" -#include <sstream> -using namespace boost::unit_test_framework; using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; CORBA::ULong const MAXIMUM = 32; @@ -44,7 +40,7 @@ struct Tester typedef typename tested_sequence::allocation_traits tested_allocation_traits; typedef TAO::details::range_checking<value_type,true> range; - void test_set_length_less_than_maximum() + int test_set_length_less_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -53,67 +49,80 @@ struct Tester tested_sequence x; x.length(8); - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_EQUAL(CORBA::ULong(MAXIMUM), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); - - BOOST_CHECK_MESSAGE(i.expect(8), i); + // length() after default constructed sequence leads to + // buffer allocation. + FAIL_RETURN_IF_NOT(a.expect(1), a); + CHECK_EQUAL(CORBA::ULong(MAXIMUM), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); + + // 32 is here because allocbuf for bounded sequences + // initializes all elements. + FAIL_RETURN_IF_NOT(i.expect(32), i); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_set_length_more_than_maximum() + int test_set_length_more_than_maximum() { tested_sequence x; - BOOST_CHECK_THROW(x.length(64), std::runtime_error); + CHECK_THROW(x.length(64), std::runtime_error); + return 0; } value_type * alloc_and_init_buffer() { value_type * buf = tested_sequence::allocbuf(); + delete[] buf[0]; buf[0] = helper::to_string(1); + delete[] buf[1]; buf[1] = helper::to_string(4); + delete[] buf[2]; buf[2] = helper::to_string(9); + delete[] buf[3]; buf[3] = helper::to_string(16); return buf; } - void check_values(tested_sequence const & a) + int check_values(tested_sequence const & a) { - BOOST_CHECK(helper::compare(1, a[0])); - BOOST_CHECK(helper::compare(4, a[1])); - BOOST_CHECK(helper::compare(9, a[2])); - BOOST_CHECK(helper::compare(16, a[3])); + CHECK(helper::compare(1, a[0])); + CHECK(helper::compare(4, a[1])); + CHECK(helper::compare(9, a[2])); + CHECK(helper::compare(16, a[3])); + return 0; } - void test_regression_2201() + int test_regression_2201() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); expected_calls r(tested_element_traits::release_calls); { - tested_sequence a(4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); - a.length (3); - BOOST_CHECK_EQUAL(CORBA::ULong(3), a.length()); - a.length (4); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK(helper::compare_empty(a[3])); + tested_sequence x(4, buffer, true); + CHECK_EQUAL(CORBA::ULong(MAXIMUM), x.maximum()); + CHECK_EQUAL(CORBA::ULong(4), x.length()); + CHECK_EQUAL(buffer, x.get_buffer()); + CHECK_EQUAL(true, x.release()); + x.length (3); + CHECK_EQUAL(CORBA::ULong(3), x.length()); + x.length (4); + CHECK_EQUAL(CORBA::ULong(4), x.length()); + CHECK(helper::compare_empty(x[3])); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + // 1 additional release call happens when we shrink + // the sequence to length 3. + FAIL_RETURN_IF_NOT(r.expect(MAXIMUM + 1), r); + return 0; } - void test_buffer_constructor_default() + int test_buffer_constructor_default() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); @@ -121,19 +130,20 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a(4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); + FAIL_RETURN_IF_NOT(r.expect(MAXIMUM), r); + return 0; } - void test_buffer_constructor_false() + int test_buffer_constructor_false() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); @@ -141,19 +151,20 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a(4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); + FAIL_RETURN_IF_NOT(r.expect(MAXIMUM), r); + return 0; } - void test_buffer_constructor_true() + int test_buffer_constructor_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); @@ -161,18 +172,19 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a(4, buffer, true); - BOOST_CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(true, a.release()); + CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(true, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(r.expect(MAXIMUM), r); + return 0; } - void test_replace_default() + int test_replace_default() { value_type * buffer = alloc_and_init_buffer(); @@ -182,23 +194,26 @@ struct Tester { tested_sequence a; a.replace(4, buffer); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); - - BOOST_CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Default constructed sequence doesn't allocate a buffer + // thus nothing to release and free. + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), r); + + CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); + FAIL_RETURN_IF_NOT(r.expect(MAXIMUM), r); + return 0; } - void test_replace_false() + int test_replace_false() { value_type * buffer = alloc_and_init_buffer(); @@ -208,23 +223,25 @@ struct Tester { tested_sequence a; a.replace(4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); - - BOOST_CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Default constructed sequence doesn't allocate a buffer. + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), r); + + CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); + FAIL_RETURN_IF_NOT(r.expect(MAXIMUM), r); + return 0; } - void test_replace_true() + int test_replace_true() { value_type * buffer = alloc_and_init_buffer(); @@ -233,46 +250,52 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a; - a.replace(4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); - - BOOST_CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + a.replace(4, buffer, true); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Default constructed sequence doesn't allocate a buffer. + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), r); + + CHECK_EQUAL(CORBA::ULong(MAXIMUM), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(true, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Since we've given away the ownership the buffer is deallocated by + // the sequence. + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(r.expect(MAXIMUM), r); + return 0; } - void test_get_buffer_default() + int test_get_buffer_default() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_false() + int test_get_buffer_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_true_with_release_false() + int test_get_buffer_true_with_release_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(4, buffer, false); - BOOST_CHECK(0 == a.get_buffer(true)); + CHECK(0 == a.get_buffer(true)); tested_sequence::freebuf(buffer); + return 0; } - void test_get_buffer_true_with_release_true() + int test_get_buffer_true_with_release_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); @@ -280,112 +303,71 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a(4, buffer, true); - BOOST_CHECK_EQUAL(buffer, a.get_buffer(true)); + CHECK_EQUAL(buffer, a.get_buffer(true)); tested_sequence const & b = a; - BOOST_CHECK_EQUAL(CORBA::ULong(MAXIMUM), b.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), b.length()); - BOOST_CHECK(0 != b.get_buffer()); - BOOST_CHECK_EQUAL(true, b.release()); + CHECK_EQUAL(CORBA::ULong(MAXIMUM), b.maximum()); + CHECK_EQUAL(CORBA::ULong(0), b.length()); + CHECK(0 != b.get_buffer()); + CHECK_EQUAL(true, b.release()); - BOOST_CHECK_MESSAGE(c.expect(0), c); + // Ownership was taken by get_buffer(true) and later get_buffer call + // allocated a new buffer. + FAIL_RETURN_IF_NOT(c.expect(1), c); - BOOST_CHECK(buffer != b.get_buffer()); + CHECK(buffer != b.get_buffer()); } - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); - BOOST_CHECK_MESSAGE(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(r.expect(MAXIMUM), r); + FAIL_RETURN_IF_NOT(c.expect(0), c); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(r.expect(MAXIMUM), r); - } - - void add_all(test_suite * ts) - { - typedef string_sequence_tester<tested_sequence> common; - boost::shared_ptr<common> tester(common::allocate(true)); - tester->add_all(ts); - - boost::shared_ptr<Tester> shared_this(self_); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_less_than_maximum, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_more_than_maximum, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_regression_2201, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_true, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_true, - shared_this)); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(r.expect(MAXIMUM), r); + return 0; } - static boost::shared_ptr<Tester> allocate() + int test_all () { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; + int status = 0; - return ptr; + typedef string_sequence_tester<tested_sequence> common; + common X; + status += X.test_all (); + + status += this->test_set_length_less_than_maximum(); + status += this->test_set_length_more_than_maximum(); + status += this->test_regression_2201(); + status += this->test_buffer_constructor_default(); + status += this->test_buffer_constructor_false(); + status += this->test_buffer_constructor_true(); + status += this->test_replace_default(); + status += this->test_replace_false(); + status += this->test_replace_true(); + status += this->test_get_buffer_default(); + status += this->test_get_buffer_false(); + status += this->test_get_buffer_true_with_release_false(); + status += this->test_get_buffer_true_with_release_true(); + return status; } - -private: - Tester() {} - - boost::weak_ptr<Tester> self_; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("bounded string sequence unit test"); + int status = 0; - { - typedef TAO::bounded_basic_string_sequence<char, MAXIMUM> s_sequence; - typedef Tester<s_sequence> nTester; - boost::shared_ptr<nTester> tester(nTester::allocate()); - tester->add_all(ts); - } + typedef TAO::bounded_basic_string_sequence<char, MAXIMUM> s_sequence; + typedef Tester<s_sequence> nTester; + nTester myntester; - { - typedef TAO::bounded_basic_string_sequence<CORBA::WChar, MAXIMUM> w_sequence; - typedef Tester<w_sequence> wTester; - boost::shared_ptr<wTester> tester(wTester::allocate()); - tester->add_all(ts); - } + status += myntester.test_all(); + +#if defined(ACE_HAS_WCHAR) + typedef TAO::bounded_basic_string_sequence<CORBA::WChar, MAXIMUM> w_sequence; + typedef Tester<w_sequence> wTester; + wTester mywtester; + status += mywtester.test_all(); +#endif - return ts; + return status; } diff --git a/TAO/tests/Sequence_Unit_Tests/bounded_value_sequence_ut.cpp b/TAO/tests/Sequence_Unit_Tests/bounded_value_sequence_ut.cpp index 4ed1a2d2041..1a34645b8a6 100644 --- a/TAO/tests/Sequence_Unit_Tests/bounded_value_sequence_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/bounded_value_sequence_ut.cpp @@ -15,11 +15,9 @@ #include "value_sequence_tester.hpp" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" + -using namespace boost::unit_test_framework; using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; CORBA::ULong const MAXIMUM = 32; @@ -33,7 +31,7 @@ struct Tester { typedef tested_sequence::value_type value_type; - void test_set_length_less_than_maximum() + int test_set_length_less_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -41,19 +39,22 @@ struct Tester tested_sequence x; x.length(8); - BOOST_CHECK_EQUAL(CORBA::ULong(MAXIMUM), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(MAXIMUM), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + // Naturally buffer in x is allocated after length() was called. + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_set_length_more_than_maximum() + int test_set_length_more_than_maximum() { tested_sequence x; - BOOST_CHECK_THROW(x.length(64), std::runtime_error); + CHECK_THROW(x.length(64), std::runtime_error); + return 0; } value_type * alloc_and_init_buffer() @@ -64,36 +65,36 @@ struct Tester return buf; } - void test_regression_2201 () + int test_regression_2201 () { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { - tested_sequence a(32, buffer); - BOOST_CHECK_EQUAL(CORBA::ULong(32), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(32), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); - a.length (3); - BOOST_CHECK_EQUAL(CORBA::ULong(32), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(3), a.length()); - a.length (4); - BOOST_CHECK_EQUAL(CORBA::ULong(32), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(int( 0), a[3]); + tested_sequence x(32, buffer, true); + CHECK_EQUAL(CORBA::ULong(32), x.maximum()); + CHECK_EQUAL(CORBA::ULong(32), x.length()); + CHECK_EQUAL(buffer, x.get_buffer()); + CHECK_EQUAL(int( 1), x[0]); + CHECK_EQUAL(int( 4), x[1]); + CHECK_EQUAL(int( 9), x[2]); + CHECK_EQUAL(int(16), x[3]); + CHECK_EQUAL(true, x.release()); + x.length (3); + CHECK_EQUAL(CORBA::ULong(32), x.maximum()); + CHECK_EQUAL(CORBA::ULong(3), x.length()); + x.length (4); + CHECK_EQUAL(CORBA::ULong(32), x.maximum()); + CHECK_EQUAL(CORBA::ULong(4), x.length()); + CHECK_EQUAL(int( 0), x[3]); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - tested_sequence::freebuf(buffer); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_buffer_constructor_default() + int test_buffer_constructor_default() { value_type * buffer = alloc_and_init_buffer(); @@ -101,62 +102,65 @@ struct Tester expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(4, buffer); - BOOST_CHECK_EQUAL(CORBA::ULong(32), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(32), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_buffer_constructor_false() + int test_buffer_constructor_false() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(32), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(32), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_buffer_constructor_true() + int test_buffer_constructor_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(4, buffer, true); - BOOST_CHECK_EQUAL(CORBA::ULong(32), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(true, a.release()); + CHECK_EQUAL(CORBA::ULong(32), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(true, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_replace_default() + int test_replace_default() { value_type * buffer = alloc_and_init_buffer(); @@ -165,24 +169,26 @@ struct Tester { tested_sequence a; a.replace(4, buffer); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(32), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Default constructed sequence doesn't allocate a buffer. + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(32), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_replace_false() + int test_replace_false() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); @@ -191,24 +197,26 @@ struct Tester { tested_sequence a; a.replace(4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(32), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Default constructed sequence doesn't allocate a buffer. + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(32), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_replace_true() + int test_replace_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); @@ -217,144 +225,107 @@ struct Tester { tested_sequence a; a.replace(4, buffer, true); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(32), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(true, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Default constructed sequence doesn't allocate a buffer. + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(32), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(true, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_get_buffer_default() + int test_get_buffer_default() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_false() + int test_get_buffer_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_true_with_release_false() + int test_get_buffer_true_with_release_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(4, buffer, false); - BOOST_CHECK(0 == a.get_buffer(true)); + CHECK(0 == a.get_buffer(true)); tested_sequence::freebuf(buffer); + return 0; } - void test_get_buffer_true_with_release_true() + int test_get_buffer_true_with_release_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::default_buffer_allocation_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(4, buffer, true); - BOOST_CHECK_EQUAL(buffer, a.get_buffer(true)); + CHECK_EQUAL(buffer, a.get_buffer(true)); tested_sequence const & b = a; - BOOST_CHECK_EQUAL(MAXIMUM, b.maximum()); - BOOST_CHECK_EQUAL(0UL, b.length()); - BOOST_CHECK(0 != b.get_buffer()); - BOOST_CHECK_EQUAL(true, b.release()); + CHECK_EQUAL(MAXIMUM, b.maximum()); + CHECK_EQUAL(0UL, b.length()); + CHECK(0 != b.get_buffer()); + CHECK_EQUAL(true, b.release()); - BOOST_CHECK_MESSAGE(c.expect(1), c); + FAIL_RETURN_IF_NOT(c.expect(1), c); - BOOST_CHECK(buffer != b.get_buffer()); + CHECK(buffer != b.get_buffer()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), c); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(1), c); tested_sequence::freebuf(buffer); + return 0; } - void add_all(test_suite * ts) + int test_all() { - boost::shared_ptr<Tester> shared_this(self_); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_less_than_maximum, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_more_than_maximum, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_regression_2201, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_true, - shared_this)); - + int status = 0; + status += this->test_set_length_less_than_maximum(); + status += this->test_set_length_more_than_maximum(); + status += this->test_regression_2201(); + status += this->test_buffer_constructor_default(); + status += this->test_buffer_constructor_false(); + status += this->test_buffer_constructor_true(); + status += this->test_replace_default(); + status += this->test_replace_false(); + status += this->test_replace_true(); + status += this->test_get_buffer_false(); + status += this->test_get_buffer_true_with_release_false(); + status += this->test_get_buffer_true_with_release_true(); + return status; } - - static boost::shared_ptr<Tester> allocate() - { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; - } - -private: Tester() {} - - boost::weak_ptr<Tester> self_; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("unbounded value sequence unit test"); - + int status = 0; { - boost::shared_ptr<Tester> tester(Tester::allocate()); - tester->add_all(ts); + Tester tester; + status += tester.test_all (); } { typedef value_sequence_tester<tested_sequence,tested_allocation_traits> common; - boost::shared_ptr<common> tester(common::allocate(true)); - tester->add_all(ts); + common tester; + status += tester.test_all (); } - return ts; + return status; } - diff --git a/TAO/tests/Sequence_Unit_Tests/object_reference_sequence_element_ut.cpp b/TAO/tests/Sequence_Unit_Tests/object_reference_sequence_element_ut.cpp index 20cfafac6ea..6115f4e13b9 100644 --- a/TAO/tests/Sequence_Unit_Tests/object_reference_sequence_element_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/object_reference_sequence_element_ut.cpp @@ -11,27 +11,16 @@ #include "testing_object_reference_traits.hpp" #include "mock_reference.hpp" #include "tao/Object_Reference_Sequence_Element_T.h" - -#include <sstream> -#include <stdexcept> -#include <iostream> - -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO::details; -using namespace boost::unit_test_framework; - -struct Tester -{ typedef object_reference_traits<mock_reference,mock_reference_var,true> tested_element_traits; typedef object_reference_sequence_element<tested_element_traits> tested_element; typedef mock_reference * reference_type; typedef tested_element_traits::object_type_var reference_var; - void test_assignment_from_var_release_true() + int test_assignment_from_var_release_true() { expected_calls d(tested_element_traits::duplicate_calls); expected_calls r(tested_element_traits::release_calls); @@ -42,30 +31,32 @@ struct Tester tested_element x(xe, true); reference_var y(mock_reference::allocate(2)); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(0), mr); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(0), mr); x = y; - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(1), r); - BOOST_CHECK_MESSAGE(md.expect(1), md); - BOOST_CHECK_MESSAGE(mr.expect(2), mr); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(1), r); + FAIL_RETURN_IF_NOT(md.expect(1), md); + FAIL_RETURN_IF_NOT(mr.expect(2), mr); - BOOST_CHECK_EQUAL(2, x->id()); + CHECK_EQUAL(2, x->id()); tested_element_traits::release(x); - BOOST_CHECK_MESSAGE(r.expect(1), r); - BOOST_CHECK_MESSAGE(mr.expect(1), mr); + FAIL_RETURN_IF_NOT(r.expect(1), r); + FAIL_RETURN_IF_NOT(mr.expect(1), mr); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(1), mr); + FAIL_RETURN_IF_NOT(d.expect(0),d ); + FAIL_RETURN_IF_NOT(r.expect(0),r ); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(1), mr); + + return 0; } - void test_assignment_from_var_release_false() + int test_assignment_from_var_release_false() { expected_calls d(tested_element_traits::duplicate_calls); expected_calls r(tested_element_traits::release_calls); @@ -77,31 +68,32 @@ struct Tester tested_element x(xe, false); reference_var y(mock_reference::allocate(2)); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(0), mr); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(0), mr); x = y; - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); - BOOST_CHECK_MESSAGE(md.expect(1), md); - BOOST_CHECK_MESSAGE(mr.expect(1), mr); + FAIL_RETURN_IF_NOT(d.expect(0), d ); + FAIL_RETURN_IF_NOT(r.expect(0), r); + FAIL_RETURN_IF_NOT(md.expect(1), md); + FAIL_RETURN_IF_NOT(mr.expect(1), mr); - BOOST_CHECK_EQUAL(2, x->id()); + CHECK_EQUAL(2, x->id()); tested_element_traits::release(x); tested_element_traits::release(oldxe); - BOOST_CHECK_MESSAGE(r.expect(2), r); - BOOST_CHECK_MESSAGE(mr.expect(2), mr); + FAIL_RETURN_IF_NOT(r.expect(2), r); + FAIL_RETURN_IF_NOT(mr.expect(2), mr); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(1), mr); + FAIL_RETURN_IF_NOT(d.expect(0),d ); + FAIL_RETURN_IF_NOT(r.expect(0), r); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(1), mr); + return 0; } - void test_assignment_from_var_throw() + int test_assignment_from_var_throw() { expected_calls d(tested_element_traits::duplicate_calls); expected_calls r(tested_element_traits::release_calls); @@ -112,33 +104,34 @@ struct Tester tested_element x(xe, true); reference_var y(mock_reference::allocate(2)); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(0), mr); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(0), mr); mock_reference::duplicate_calls.failure_countdown(1); - BOOST_CHECK_THROW(x = y, testing_exception); + CHECK_THROW(x = y, testing_exception); - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); - BOOST_CHECK_MESSAGE(md.expect(1), md); - BOOST_CHECK_MESSAGE(mr.expect(0), mr); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + FAIL_RETURN_IF_NOT(md.expect(1), md); + FAIL_RETURN_IF_NOT(mr.expect(0), mr); - BOOST_CHECK_EQUAL(1, x->id()); - BOOST_CHECK_EQUAL(2, y->id()); + CHECK_EQUAL(1, x->id()); + CHECK_EQUAL(2, y->id()); tested_element_traits::release(x); - BOOST_CHECK_MESSAGE(r.expect(1), r); - BOOST_CHECK_MESSAGE(mr.expect(1), mr); + FAIL_RETURN_IF_NOT(r.expect(1), r); + FAIL_RETURN_IF_NOT(mr.expect(1), mr); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(1), mr); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(1), mr); + return 0; } - void test_assignment_from_element_release_true() + int test_assignment_from_element_release_true() { expected_calls d(tested_element_traits::duplicate_calls); expected_calls r(tested_element_traits::release_calls); @@ -151,31 +144,32 @@ struct Tester reference_type ye = mock_reference::allocate(2); tested_element y(ye, true); - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0) ,r); x = y; - BOOST_CHECK_MESSAGE(d.expect(1), d); - BOOST_CHECK_MESSAGE(r.expect(1), r); - BOOST_CHECK_MESSAGE(md.expect(1), md); - BOOST_CHECK_MESSAGE(mr.expect(2), mr); + FAIL_RETURN_IF_NOT(d.expect(1), d); + FAIL_RETURN_IF_NOT(r.expect(1), r); + FAIL_RETURN_IF_NOT(md.expect(1), md); + FAIL_RETURN_IF_NOT(mr.expect(2), mr); - BOOST_CHECK_EQUAL(2, x->id()); + CHECK_EQUAL(2, x->id()); tested_element_traits::release(xe); tested_element_traits::release(ye); - BOOST_CHECK_MESSAGE(r.expect(2), r); - BOOST_CHECK_MESSAGE(mr.expect(2), mr); + FAIL_RETURN_IF_NOT(r.expect(2),r ); + FAIL_RETURN_IF_NOT(mr.expect(2), mr); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(0), mr); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(0), mr); + return 0; } - void test_assignment_from_element_release_false() + int test_assignment_from_element_release_false() { expected_calls d(tested_element_traits::duplicate_calls); expected_calls r(tested_element_traits::release_calls); @@ -189,32 +183,33 @@ struct Tester reference_type ye = mock_reference::allocate(2); tested_element y(ye, true); - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); x = y; - BOOST_CHECK_MESSAGE(d.expect(1), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); - BOOST_CHECK_MESSAGE(md.expect(1), md); - BOOST_CHECK_MESSAGE(mr.expect(1), mr); + FAIL_RETURN_IF_NOT(d.expect(1), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + FAIL_RETURN_IF_NOT(md.expect(1), md); + FAIL_RETURN_IF_NOT(mr.expect(1), mr); - BOOST_CHECK_EQUAL(2, x->id()); + CHECK_EQUAL(2, x->id()); tested_element_traits::release(xe); tested_element_traits::release(oldxe); tested_element_traits::release(ye); - BOOST_CHECK_MESSAGE(r.expect(3), r); - BOOST_CHECK_MESSAGE(mr.expect(3), mr); + FAIL_RETURN_IF_NOT(r.expect(3), r); + FAIL_RETURN_IF_NOT(mr.expect(3), mr); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(0), mr); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(0), mr); + return 0; } - void test_assignment_from_reference_release_true() + int test_assignment_from_reference_release_true() { expected_calls d(tested_element_traits::duplicate_calls); expected_calls r(tested_element_traits::release_calls); @@ -226,30 +221,31 @@ struct Tester reference_type y = mock_reference::allocate(2); - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); x = y; - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(1), r); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(2), mr); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(1), r); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(2), mr); - BOOST_CHECK_EQUAL(2, x->id()); + CHECK_EQUAL(2, x->id()); tested_element_traits::release(xe); - BOOST_CHECK_MESSAGE(r.expect(1), r); - BOOST_CHECK_MESSAGE(mr.expect(1), mr); + FAIL_RETURN_IF_NOT(r.expect(1), r); + FAIL_RETURN_IF_NOT(mr.expect(1), mr); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(0), mr); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(0), mr); + return 0; } - void test_assignment_from_reference_release_false() + int test_assignment_from_reference_release_false() { expected_calls d(tested_element_traits::duplicate_calls); expected_calls r(tested_element_traits::release_calls); @@ -262,81 +258,43 @@ struct Tester reference_type y = mock_reference::allocate(2); - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); x = y; - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(1), mr); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(1), mr); - BOOST_CHECK_EQUAL(2, x->id()); + CHECK_EQUAL(2, x->id()); tested_element_traits::release(xe); tested_element_traits::release(oldxe); - BOOST_CHECK_MESSAGE(r.expect(2), r); - BOOST_CHECK_MESSAGE(mr.expect(2), mr); + FAIL_RETURN_IF_NOT(r.expect(2), 2); + FAIL_RETURN_IF_NOT(mr.expect(2), mr); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); - BOOST_CHECK_MESSAGE(md.expect(0), md); - BOOST_CHECK_MESSAGE(mr.expect(0), mr); - } - - void add_all(test_suite * ts) - { - boost::shared_ptr<Tester> shared_this(self_); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_var_release_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_var_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_var_throw, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_element_release_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_element_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_reference_release_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_reference_release_false, - shared_this)); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + FAIL_RETURN_IF_NOT(md.expect(0), md); + FAIL_RETURN_IF_NOT(mr.expect(0), mr); + return 0; } - static boost::shared_ptr<Tester> allocate() - { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; - } - -private: - Tester() {} - - boost::weak_ptr<Tester> self_; -}; - -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("object reference sequence element unit test"); + int status = 0; - boost::shared_ptr<Tester > mock_reference_tester( - Tester::allocate()); - mock_reference_tester->add_all(ts); + status += test_assignment_from_var_release_true (); + status += test_assignment_from_var_release_false (); + status += test_assignment_from_var_throw (); + status += test_assignment_from_element_release_true (); + status += test_assignment_from_element_release_false (); + status += test_assignment_from_reference_release_true (); + status += test_assignment_from_reference_release_false (); - return ts; + return status; } diff --git a/TAO/tests/Sequence_Unit_Tests/run_test.pl b/TAO/tests/Sequence_Unit_Tests/run_test.pl index 3b3ec000483..2de72fc741f 100755 --- a/TAO/tests/Sequence_Unit_Tests/run_test.pl +++ b/TAO/tests/Sequence_Unit_Tests/run_test.pl @@ -6,37 +6,24 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' # -*- perl -*- use lib "$ENV{ACE_ROOT}/bin"; -use PerlACE::Run_Test; +use PerlACE::TestTarget; use strict; -if ($ARGV[0] =~ /^-h/i || $ARGV[0] =~ /^-\?/i) { - print "Usage: run_test.pl [-boost|-noboost]\n". - "\tDefault is to run all tests, specifying -boost or -noboost will\n". - "\teither run the tests that require the boost unit test library or\n". - "\tthe other tests, respectively.\n"; - exit 0; -} - my $final_result = 0; -my @tests = qw(unbounded_value_sequence_ut - unbounded_array_sequence_ut +my @testsToRun = qw(unbounded_value_sequence_ut bounded_value_sequence_ut string_sequence_element_ut unbounded_string_sequence_ut bounded_string_sequence_ut testing_allocation_traits_ut unbounded_octet_sequence_ut - unbounded_octet_sequence_no_copy_ut object_reference_sequence_element_ut unbounded_object_reference_sequence_ut unbounded_fwd_object_reference_sequence_ut bounded_object_reference_sequence_ut bounded_sequence_cdr_ut unbounded_sequence_cdr_ut - ); - -my @testsNoBoost = qw( Unbounded_Octet Unbounded_Simple_Types Bounded_Simple_Types @@ -44,51 +31,28 @@ my @testsNoBoost = qw( Bounded_String ); -my @testsToRun = qw(); - -push(@testsToRun, @tests) if ($#ARGV < 0 || $ARGV[0] eq '-boost'); -push(@testsToRun, @testsNoBoost) if ($#ARGV < 0 || $ARGV[0] eq '-noboost'); - +if ($^O ne "MSWin32") { + push @testsToRun, qw(unbounded_octet_sequence_nocopy_ut); +} foreach my $process (@testsToRun) { - - - my $P = 0; - if (PerlACE::is_vxworks_test()) { - $P = new PerlACE::ProcessVX ($process, - '--log_level=nothing ' - .'--report_level=no'); - } - else { - $P = new PerlACE::Process ($process, - '--log_level=nothing ' - .'--report_level=no'); - } - my $executable = $P->Executable; - - # Not all the binaries are generated in all configurations. - if (PerlACE::is_vxworks_test()) { - next unless -e $executable; - } - else { - next unless -x $executable; - } - - print "Running $process ..."; - my $result = $P->Spawn; - if ($result != 0) { - print "FAILED\n"; - $final_result = 1; - next; - } - $result = $P->WaitKill($PerlACE::wait_interval_for_process_creation); - if ($result != 0) { - print "FAILED\n"; - $final_result = 1; - next; - } - print "SUCCESS\n"; + my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; + my $P = $server->CreateProcess ($process); + print "Running $process ...\n"; + my $result = $P->Spawn; + if ($result != 0) { + print "FAILED $process\n"; + $final_result = 1; + next; + } + $result = $P->WaitKill($server->ProcessStartWaitInterval()); + if ($result != 0) { + print "FAILED $process\n"; + $final_result = 1; + next; + } + print "SUCCESS\n"; } exit $final_result; diff --git a/TAO/tests/Sequence_Unit_Tests/string_sequence_element_ut.cpp b/TAO/tests/Sequence_Unit_Tests/string_sequence_element_ut.cpp index 3bf93b550e4..0512cc36b51 100644 --- a/TAO/tests/Sequence_Unit_Tests/string_sequence_element_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/string_sequence_element_ut.cpp @@ -15,388 +15,395 @@ #include "ace/OS_NS_string.h" -#include <sstream> -#include <stdexcept> -#include <iostream> - -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO::details; -using namespace boost::unit_test_framework; + template<typename charT> -struct helper {}; +struct helper +{ +}; template<> -struct helper<char> +struct helper <char> { - static char const * empty() { + static char const * + empty () + { return ""; } - static char const * sample0() { + static char const * + sample0 () + { return "Hello"; } - static char const * sample1() { + static char const * + sample1 () + { return "World"; } - static char * dup_sample0() { - return string_traits<char,true>::duplicate(sample0()); + static char * + dup_sample0 () + { + return string_traits <char, true>::duplicate (sample0 ()); } - static char * dup_sample1() { - return string_traits<char,true>::duplicate(sample1()); + static char * + dup_sample1 () + { + return string_traits <char, true>::duplicate (sample1 ()); } - static bool equal(char const * lhs, char const * rhs) { - return ACE_OS::strcmp(lhs, rhs) == 0; + static bool + equal (char const *lhs, char const *rhs) + { + return ACE_OS::strcmp (lhs, rhs) == 0; } }; +#if defined(ACE_HAS_WCHAR) template<> -struct helper<CORBA::WChar> +struct helper <CORBA::WChar> { - static CORBA::WChar const * empty() { + static CORBA::WChar const * + empty () + { return L""; } - static CORBA::WChar const * sample0() { + static CORBA::WChar const * + sample0 () + { return L"Hello"; } - static CORBA::WChar const * sample1() { + static CORBA::WChar const * + sample1 () + { return L"World"; } - static CORBA::WChar * dup_sample0() { - return string_traits<CORBA::WChar,true>::duplicate(sample0()); + static CORBA::WChar * + dup_sample0 () + { + return string_traits <CORBA::WChar, true>::duplicate (sample0 ()); } - static CORBA::WChar * dup_sample1() { - return string_traits<CORBA::WChar,true>::duplicate(sample1()); + static CORBA::WChar * + dup_sample1 () + { + return string_traits <CORBA::WChar, true>::duplicate (sample1 ()); } - static bool equal(CORBA::WChar const * lhs, CORBA::WChar const * rhs) { - return ACE_OS::strcmp(lhs, rhs) == 0; + static bool + equal (CORBA::WChar const *lhs, CORBA::WChar const *rhs) + { + return ACE_OS::strcmp (lhs, rhs) == 0; } }; +#endif template<class charT> struct Tester { - typedef string_traits<charT,true> tested_element_traits; - typedef string_sequence_element<tested_element_traits> tested_element; - typedef charT * string_type; - typedef charT const * const_string_type; + typedef string_traits <charT, true> tested_element_traits; + typedef string_sequence_element <tested_element_traits> tested_element; + typedef charT *string_type; + typedef charT const *const_string_type; typedef typename tested_element_traits::string_var string_var; typedef typename tested_element_traits::string_mgr string_mgr; - void test_assignment_from_const_string() + int + test_assignment_from_const_string () { - expected_calls d(tested_element_traits::duplicate_calls); - expected_calls r(tested_element_traits::release_calls); + expected_calls d (tested_element_traits::duplicate_calls); + expected_calls r (tested_element_traits::release_calls); { - string_type xe = helper<charT>::dup_sample0(); - const_string_type y = helper<charT>::sample1(); - d.reset(); r.reset(); + string_type xe = helper <charT>::dup_sample0 (); + const_string_type y = helper <charT>::sample1 (); + d.reset (); + r.reset (); tested_element x(xe, true); - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); x = y; - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(1), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(1), r); - BOOST_CHECK_MESSAGE( - helper<charT>::equal(helper<charT>::sample1(), xe), - "Mismatch after assignment from const. expected=" - << helper<charT>::sample0() - << ", got=" << x); - tested_element_traits::release(xe); - BOOST_CHECK_MESSAGE(r.expect(1), r); + FAIL_RETURN_IF_NOT( + helper<charT>::equal(helper<charT>::sample1(), xe), + "Mismatch after assignment from const. expected=" + << helper<charT>::sample0() + << ", got=" << x); + tested_element_traits::release (xe); + FAIL_RETURN_IF_NOT(r.expect(1), r); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + return 0; } - void test_assignment_from_element() + int + test_assignment_from_element () { - expected_calls d(tested_element_traits::duplicate_calls); - expected_calls r(tested_element_traits::release_calls); + expected_calls d (tested_element_traits::duplicate_calls); + expected_calls r (tested_element_traits::release_calls); { - string_type xe = helper<charT>::dup_sample0(); + string_type xe = helper <charT>::dup_sample0 (); tested_element x(xe, true); - string_type ye = helper<charT>::dup_sample1(); + string_type ye = helper <charT>::dup_sample1 (); tested_element y(ye, true); - d.reset(); r.reset(); + d.reset (); + r.reset (); x = y; - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(1), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(1), r); - BOOST_CHECK_MESSAGE( - helper<charT>::equal(helper<charT>::sample1(), xe), - "Mismatch after assignment from element. expected=" - << helper<charT>::sample1() - << ", got=" << xe); + FAIL_RETURN_IF_NOT( + helper<charT>::equal(helper<charT>::sample1(), xe), + "Mismatch after assignment from element. expected=" + << helper<charT>::sample1() + << ", got=" << xe); - tested_element_traits::release(xe); - tested_element_traits::release(ye); - BOOST_CHECK_MESSAGE(r.expect(2), r); + tested_element_traits::release (xe); + tested_element_traits::release (ye); + FAIL_RETURN_IF_NOT(r.expect(2), r); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + return 0; } - void test_self_assignment() + int + test_self_assignment () { - expected_calls d(tested_element_traits::duplicate_calls); - expected_calls r(tested_element_traits::release_calls); + expected_calls d (tested_element_traits::duplicate_calls); + expected_calls r (tested_element_traits::release_calls); { - string_type xe = helper<charT>::dup_sample0(); + string_type xe = helper <charT>::dup_sample0 (); tested_element x(xe, true); - d.reset(); r.reset(); + d.reset (); + r.reset (); x = x; - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(1), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(1), r); - BOOST_CHECK_MESSAGE( - helper<charT>::equal(helper<charT>::sample0(), xe), - "Mismatch after self assignment. expected=" - << helper<charT>::sample0() - << ", got=" << xe); + FAIL_RETURN_IF_NOT( + helper<charT>::equal(helper<charT>::sample0(), xe), + "Mismatch after self assignment. expected=" + << helper<charT>::sample0() + << ", got=" << xe); - tested_element_traits::release(xe); - BOOST_CHECK_MESSAGE(r.expect(1), r); + tested_element_traits::release (xe); + FAIL_RETURN_IF_NOT(r.expect(1), r); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + return 0; } - void test_assignment_from_non_const_string() + int + test_assignment_from_non_const_string () { - expected_calls d(tested_element_traits::duplicate_calls); - expected_calls r(tested_element_traits::release_calls); + expected_calls d (tested_element_traits::duplicate_calls); + expected_calls r (tested_element_traits::release_calls); { string_type xe = 0; tested_element x(xe, true); string_type y = - tested_element_traits::duplicate(helper<charT>::sample0()); - BOOST_CHECK_MESSAGE(d.expect(1), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + tested_element_traits::duplicate (helper <charT>::sample0 ()); + FAIL_RETURN_IF_NOT(d.expect(1), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); x = y; - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(1), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(1), r); - BOOST_CHECK_MESSAGE( - helper<charT>::equal(helper<charT>::sample0(), xe), - "Mismatch after assignment from non-const. expected=" - << helper<charT>::sample0() - << ", got=" << x); - tested_element_traits::release(xe); - BOOST_CHECK_MESSAGE(r.expect(1), r); + FAIL_RETURN_IF_NOT( + helper<charT>::equal(helper<charT>::sample0(), xe), + "Mismatch after assignment from non-const. expected=" + << helper<charT>::sample0() + << ", got=" << x); + tested_element_traits::release (xe); + FAIL_RETURN_IF_NOT(r.expect(1), r); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + return 0; } - void test_copy_constructor() + int + test_copy_constructor () { - expected_calls d(tested_element_traits::duplicate_calls); - expected_calls r(tested_element_traits::release_calls); + expected_calls d (tested_element_traits::duplicate_calls); + expected_calls r (tested_element_traits::release_calls); { string_type xe = - tested_element_traits::duplicate(helper<charT>::sample0()); + tested_element_traits::duplicate (helper <charT>::sample0 ()); tested_element x(xe, true); - d.reset(); r.reset(); + d.reset (); + r.reset (); - tested_element y(x); + tested_element y (x); - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); - BOOST_CHECK_MESSAGE( - helper<charT>::equal(helper<charT>::sample0(), y), - "Mismatch after copy constructor. expected=" - << helper<charT>::sample0() - << ", got=" << y); + FAIL_RETURN_IF_NOT( + helper<charT>::equal(helper<charT>::sample0(), y), + "Mismatch after copy constructor. expected=" + << helper<charT>::sample0() + << ", got=" << y); - tested_element_traits::release(xe); - BOOST_CHECK_MESSAGE(r.expect(1), r); + tested_element_traits::release (xe); + FAIL_RETURN_IF_NOT(r.expect(1), r); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + return 0; } - void test_assignment_from_copy() + int + test_assignment_from_copy () { - expected_calls d(tested_element_traits::duplicate_calls); - expected_calls r(tested_element_traits::release_calls); + expected_calls d (tested_element_traits::duplicate_calls); + expected_calls r (tested_element_traits::release_calls); { - string_type xe = helper<charT>::dup_sample0(); + string_type xe = helper <charT>::dup_sample0 (); tested_element x(xe, true); - d.reset(); r.reset(); + d.reset (); + r.reset (); - tested_element y(x); + tested_element y (x); x = y; - BOOST_CHECK_MESSAGE(r.expect(1), r); + FAIL_RETURN_IF_NOT(r.expect(1), r); - BOOST_CHECK_MESSAGE( - helper<charT>::equal(helper<charT>::sample0(), xe), - "Mismatch after assignment. expected=" - << helper<charT>::sample0() - << ", got=" << xe); + FAIL_RETURN_IF_NOT( + helper<charT>::equal(helper<charT>::sample0(), xe), + "Mismatch after assignment. expected=" + << helper<charT>::sample0() + << ", got=" << xe); - BOOST_CHECK_MESSAGE( - helper<charT>::equal(helper<charT>::sample0(), y), - "Mismatch after assignment. expected=" - << helper<charT>::sample0() - << ", got=" << y); + FAIL_RETURN_IF_NOT( + helper<charT>::equal(helper<charT>::sample0(), y), + "Mismatch after assignment. expected=" + << helper<charT>::sample0() + << ", got=" << y); - tested_element_traits::release(xe); - BOOST_CHECK_MESSAGE(r.expect(1), r); + tested_element_traits::release (xe); + FAIL_RETURN_IF_NOT(r.expect(1), r); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + return 0; } - void test_assignment_from_var() + int + test_assignment_from_var () { - expected_calls d(tested_element_traits::duplicate_calls); - expected_calls r(tested_element_traits::release_calls); + expected_calls d (tested_element_traits::duplicate_calls); + expected_calls r (tested_element_traits::release_calls); { - string_type xe = helper<charT>::dup_sample1(); + string_type xe = helper <charT>::dup_sample1 (); tested_element x(xe, true); - BOOST_CHECK_MESSAGE(d.expect(1), d); + FAIL_RETURN_IF_NOT(d.expect(1), d); - string_var y(helper<charT>::sample0()); + string_var y (helper <charT>::sample0()); - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); x = y; - BOOST_CHECK_MESSAGE(r.expect(1), r); + FAIL_RETURN_IF_NOT(r.expect(1), r); - BOOST_CHECK_MESSAGE( - helper<charT>::equal(helper<charT>::sample0(), xe), - "Mismatch after assignment from var. expected=" - << helper<charT>::sample0() - << ", got=" << x); + FAIL_RETURN_IF_NOT( + helper<charT>::equal(helper<charT>::sample0(), xe), + "Mismatch after assignment from var. expected=" + << helper<charT>::sample0() + << ", got=" << x); - tested_element_traits::release(xe); - BOOST_CHECK_MESSAGE(r.expect(1), r); + tested_element_traits::release (xe); + FAIL_RETURN_IF_NOT(r.expect(1), r); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + return 0; } - void test_assignment_from_mgr() + int + test_assignment_from_mgr () { - expected_calls d(tested_element_traits::duplicate_calls); - expected_calls r(tested_element_traits::release_calls); + expected_calls d (tested_element_traits::duplicate_calls); + expected_calls r (tested_element_traits::release_calls); { - string_type xe = helper<charT>::dup_sample1(); + string_type xe = helper <charT>::dup_sample1 (); tested_element x(xe, true); - BOOST_CHECK_MESSAGE(d.expect(1), d); + FAIL_RETURN_IF_NOT(d.expect(1), d); string_mgr y; - y = helper<charT>::sample0(); + y = helper <charT>::sample0 (); - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); x = y; - BOOST_CHECK_MESSAGE(r.expect(1), r); + FAIL_RETURN_IF_NOT(r.expect(1), r); - BOOST_CHECK_MESSAGE( - helper<charT>::equal(helper<charT>::sample0(), xe), - "Mismatch after assignment from mgr. expected=" - << helper<charT>::sample0() - << ", got=" << x); + FAIL_RETURN_IF_NOT( + helper<charT>::equal(helper<charT>::sample0(), xe), + "Mismatch after assignment from mgr. expected=" + << helper<charT>::sample0() + << ", got=" << x); - tested_element_traits::release(xe); - BOOST_CHECK_MESSAGE(r.expect(1), r); + tested_element_traits::release (xe); + FAIL_RETURN_IF_NOT(r.expect(1), r); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); + return 0; } - - void add_all(test_suite * ts) + int + test_all () { - boost::shared_ptr<Tester> shared_this(self_); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_const_string, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_element, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_self_assignment, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_non_const_string, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_copy_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_copy, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_var, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_mgr, - shared_this)); - } - - static boost::shared_ptr<Tester> allocate() - { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; + int status = 0; + status += this->test_assignment_from_const_string (); + status += this->test_assignment_from_element (); + status += this->test_self_assignment (); + status += this->test_assignment_from_non_const_string (); + status += this->test_copy_constructor (); + status += this->test_assignment_from_copy (); + status += this->test_assignment_from_var (); + status += this->test_assignment_from_mgr (); + return status; } - -private: - Tester() {} - - boost::weak_ptr<Tester> self_; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) -{ - test_suite * ts = - BOOST_TEST_SUITE("string sequence element unit test"); - - boost::shared_ptr<Tester<char> > char_tester( - Tester<char>::allocate()); - char_tester->add_all(ts); - - boost::shared_ptr<Tester<CORBA::WChar> > wchar_tester( - Tester<CORBA::WChar>::allocate()); - wchar_tester->add_all(ts); - - return ts; -} +int ACE_TMAIN (int, ACE_TCHAR*[]) + { + int status = 0; + Tester <char> char_tester; + status += char_tester.test_all (); + Tester <char> wchar_tester; + status += wchar_tester.test_all (); + return status; + } diff --git a/TAO/tests/Sequence_Unit_Tests/string_sequence_tester.hpp b/TAO/tests/Sequence_Unit_Tests/string_sequence_tester.hpp index 2b4d3d6406f..3eba6d93cad 100644 --- a/TAO/tests/Sequence_Unit_Tests/string_sequence_tester.hpp +++ b/TAO/tests/Sequence_Unit_Tests/string_sequence_tester.hpp @@ -13,9 +13,7 @@ #include "ace/OS_NS_string.h" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" #include <sstream> @@ -64,6 +62,7 @@ struct string_sequence_test_helpers<char> } }; +#if defined(ACE_HAS_WCHAR) template<> struct string_sequence_test_helpers<CORBA::WChar> { @@ -103,8 +102,7 @@ struct string_sequence_test_helpers<CORBA::WChar> return ACE_OS::strcmp(value, L"") == 0; } }; - - +#endif /* ACE_HAS_WCHAR */ template<class tested_sequence> struct string_sequence_tester @@ -116,24 +114,25 @@ struct string_sequence_tester typedef typename tested_sequence::element_traits tested_element_traits; typedef typename tested_sequence::allocation_traits tested_allocation_traits; - void test_default_constructor() + int test_default_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x; - BOOST_CHECK_EQUAL( + CHECK_EQUAL( CORBA::ULong(tested_allocation_traits::default_maximum()), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(bounded_, x.release()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(bounded_ ? 1 : 0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + // Nothing was allocated then there is nothing to free. + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } - void test_copy_constructor_from_default() + int test_copy_constructor_from_default() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -145,30 +144,35 @@ struct string_sequence_tester a.reset(); f.reset(); i.reset(); d.reset(); tested_sequence y(x); - BOOST_CHECK_MESSAGE(a.expect(bounded_ ? 1 : 0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); - BOOST_CHECK_MESSAGE(d.expect(0), d); - - BOOST_CHECK_EQUAL(x.maximum(), y.maximum()); - BOOST_CHECK_EQUAL(x.length(), y.length()); - BOOST_CHECK_EQUAL(x.release(), y.release()); + // Default constructed sequence doesn't have elements, + // thus there is nothing to allocate/copy in copy constructor. + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + FAIL_RETURN_IF_NOT(d.expect(0), d); + + CHECK_EQUAL(x.maximum(), y.maximum()); + CHECK_EQUAL(x.length(), y.length()); + CHECK_EQUAL(x.release(), y.release()); } - BOOST_CHECK_MESSAGE(f.expect(bounded_ ? 2 : 0), f); + // Nothing was allocated then there is nothing to free. + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } - void test_index_accessor() + int test_index_accessor() { tested_sequence x; x.length(8); tested_sequence const & y = x; character_type const * t = y[4]; - BOOST_CHECK_MESSAGE(helper::compare_empty(t), + FAIL_RETURN_IF_NOT(helper::compare_empty(t), "Unexpected string value " << t); + return 0; } - void test_index_modifier() + int test_index_modifier() { tested_sequence x; x.length(8); @@ -180,16 +184,17 @@ struct string_sequence_tester character_type const * t = y[4]; - BOOST_CHECK_MESSAGE(ACE_OS::strcmp(text, x[4]) == 0, + FAIL_RETURN_IF_NOT(ACE_OS::strcmp(text, x[4]) == 0, "Mismatched values expected=" << text << ", got=" << x[4]); - BOOST_CHECK_MESSAGE(ACE_OS::strcmp(text, y[4]) == 0, + FAIL_RETURN_IF_NOT(ACE_OS::strcmp(text, y[4]) == 0, "Mismatched values expected=" << text << ", got=" << y[4]); - BOOST_CHECK(text != t); + CHECK(text != t); + return 0; } - void test_index_checking() + int test_index_checking() { tested_sequence x; x.length(8); @@ -197,11 +202,12 @@ struct string_sequence_tester tested_sequence const & y = x; character_type const * lhs = 0; character_type const * rhs = 0; - BOOST_CHECK_THROW(lhs = y[32], std::range_error); - BOOST_CHECK_THROW(x[32] = rhs, std::range_error); + CHECK_THROW(lhs = y[32], std::range_error); + CHECK_THROW(x[32] = rhs, std::range_error); + return 0; } - void test_copy_constructor_values() + int test_copy_constructor_values() { tested_sequence a; a.length(16); @@ -216,66 +222,67 @@ struct string_sequence_tester CORBA::ULong max; { tested_sequence b(a); - BOOST_CHECK_MESSAGE(d.expect(16), d); + FAIL_RETURN_IF_NOT(d.expect(16), d); max = b.maximum(); - BOOST_CHECK_EQUAL(a.length(), b.length()); + CHECK_EQUAL(a.length(), b.length()); for(CORBA::ULong i = 0; i != a.length(); ++i) { - BOOST_CHECK_MESSAGE(ACE_OS::strcmp(a[i], b[i]) == 0, + FAIL_RETURN_IF_NOT(ACE_OS::strcmp(a[i], b[i]) == 0, "Mismatched elements at index=" << i << ", a=" << a[i] << ", b=" << b[i]); } } - BOOST_CHECK_MESSAGE(r.expect(max), r); + FAIL_RETURN_IF_NOT(r.expect(max), r); + return 0; } - void test_freebuf_releases_elements() + int test_freebuf_releases_elements() { value_type * buffer = tested_sequence::allocbuf(32); - for(int i = 0; i != 32; ++i) - { - buffer[i] = helper::allocate_test_string(); - } expected_calls r(tested_element_traits::release_calls); expected_calls f(tested_allocation_traits::freebuf_calls); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(r.expect(32), r); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(r.expect(32), r); + return 0; } - void test_assignment_from_default() + int test_assignment_from_default() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x; - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_EQUAL( + FAIL_RETURN_IF_NOT(a.expect(0), a); + CHECK_EQUAL( CORBA::ULong(tested_allocation_traits::default_maximum()), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(bounded_ , x.release()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); tested_sequence y; - BOOST_CHECK_MESSAGE(a.expect(0), a); + FAIL_RETURN_IF_NOT(a.expect(0), a); y = x; - BOOST_CHECK_MESSAGE(a.expect(bounded_ ? 1 : 0), a); - BOOST_CHECK_MESSAGE(f.expect(bounded_ ? 1 : 0), f); - BOOST_CHECK_EQUAL(x.maximum(), y.maximum()); - BOOST_CHECK_EQUAL(x.length(), y.length()); - BOOST_CHECK_EQUAL(x.release(), y.release()); + // Default constructed sequence doesn't have elements, + // thus there is nothing to allocate/copy in operator=. + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(x.maximum(), y.maximum()); + CHECK_EQUAL(x.length(), y.length()); + CHECK_EQUAL(x.release(), y.release()); } - BOOST_CHECK_MESSAGE(f.expect(bounded_ ? 2 : 0), f); + // Nothing was allocated then there is nothing to free. + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } - void test_assignment_values() + int test_assignment_values() { tested_sequence a; a.length(16); @@ -290,24 +297,25 @@ struct string_sequence_tester { tested_sequence b; b = a; - BOOST_CHECK_MESSAGE(d.expect(16), d); + FAIL_RETURN_IF_NOT(d.expect(16), d); max = b.maximum(); - BOOST_CHECK_EQUAL(a.maximum(), b.maximum()); - BOOST_CHECK_EQUAL(a.length(), b.length()); - BOOST_CHECK_EQUAL(a.release(), b.release()); + CHECK_EQUAL(a.maximum(), b.maximum()); + CHECK_EQUAL(a.length(), b.length()); + CHECK_EQUAL(a.release(), b.release()); for(CORBA::ULong i = 0; i != a.length(); ++i) { - BOOST_CHECK_MESSAGE(ACE_OS::strcmp(a[i], b[i]) == 0, + FAIL_RETURN_IF_NOT(ACE_OS::strcmp(a[i], b[i]) == 0, "Mismatched elements at index " << i); } r.reset(); } - BOOST_CHECK_MESSAGE(r.expect(max), r); + FAIL_RETURN_IF_NOT(r.expect(max), r); + return 0; } - void test_exception_in_copy_constructor() + int test_exception_in_copy_constructor() { expected_calls f(tested_allocation_traits::freebuf_calls); { @@ -316,13 +324,14 @@ struct string_sequence_tester expected_calls a(tested_allocation_traits::allocbuf_calls); tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(tested_sequence y(x), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); + CHECK_THROW(tested_sequence y(x), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_exception_in_assignment() + int test_exception_in_assignment() { expected_calls f(tested_allocation_traits::freebuf_calls); { @@ -333,17 +342,18 @@ struct string_sequence_tester expected_calls a(tested_allocation_traits::allocbuf_calls); f.reset(); tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(y = x, testing_exception); + CHECK_THROW(y = x, testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); - BOOST_CHECK_EQUAL(CORBA::ULong(3), y.length()); + CHECK_EQUAL(CORBA::ULong(3), y.length()); } - BOOST_CHECK_MESSAGE(f.expect(2), f); + FAIL_RETURN_IF_NOT(f.expect(2), f); + return 0; } - void test_duplicate_exception_in_copy_constructor() + int test_duplicate_exception_in_copy_constructor() { expected_calls f(tested_allocation_traits::freebuf_calls); { @@ -361,16 +371,17 @@ struct string_sequence_tester tested_element_traits::duplicate_calls.failure_countdown(4); - BOOST_CHECK_THROW(tested_sequence y(x), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(d.expect(4), d); - BOOST_CHECK_MESSAGE(r.expect(x.maximum()), r); + CHECK_THROW(tested_sequence y(x), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(d.expect(4), d); + FAIL_RETURN_IF_NOT(r.expect(x.maximum()), r); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_duplicate_exception_in_assignment() + int test_duplicate_exception_in_assignment() { expected_calls f(tested_allocation_traits::freebuf_calls); { @@ -393,33 +404,34 @@ struct string_sequence_tester { y[i] = helper::allocate_test_string(); } - + a.reset(); d.reset(); r.reset(); f.reset(); tested_element_traits::duplicate_calls.failure_countdown(4); - BOOST_CHECK_THROW(y = x, testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(d.expect(4), d); - BOOST_CHECK_MESSAGE(r.expect(x.maximum()), r); + CHECK_THROW(y = x, testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(d.expect(4), d); + FAIL_RETURN_IF_NOT(r.expect(x.maximum()), r); - BOOST_CHECK_EQUAL(CORBA::ULong(4), y.length()); + CHECK_EQUAL(CORBA::ULong(4), y.length()); for(CORBA::ULong i = 0; i != 4; ++i) { - BOOST_CHECK_MESSAGE( + FAIL_RETURN_IF_NOT( helper::compare_test_string(y[i]), "Mismatch in element " << i << ", got=" << y[i]); } } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_get_buffer_const() + int test_get_buffer_const() { tested_sequence a; a.length(8); tested_sequence const & b = a; @@ -427,79 +439,33 @@ struct string_sequence_tester const_value_type const * buffer = b.get_buffer(); a[0] = helper::test_string(); - BOOST_CHECK_EQUAL(buffer, b.get_buffer()); - BOOST_CHECK_MESSAGE(ACE_OS::strcmp(a[0], buffer[0]) == 0, + CHECK_EQUAL(buffer, b.get_buffer()); + FAIL_RETURN_IF_NOT(ACE_OS::strcmp(a[0], buffer[0]) == 0, "Mismatched elements a[0]=" << a[0] << ", buffer[0]=" << buffer[0]); + return 0; } - void add_all(boost::unit_test_framework::test_suite * ts) - { - boost::shared_ptr<string_sequence_tester> shared_this(self_); - - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_default_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_copy_constructor_from_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_index_accessor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_index_modifier, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_index_checking, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_copy_constructor_values, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_freebuf_releases_elements, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_assignment_from_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_assignment_values, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_exception_in_copy_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_exception_in_assignment, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_duplicate_exception_in_copy_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_duplicate_exception_in_assignment, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &string_sequence_tester::test_get_buffer_const, - shared_this)); - - - } - - static boost::shared_ptr<string_sequence_tester> allocate(bool bounded = false) + int test_all () { - boost::shared_ptr<string_sequence_tester> ptr( - new string_sequence_tester(bounded)); - ptr->self_ = ptr; - - return ptr; + int status=0; + status += this->test_default_constructor(); + status += this->test_copy_constructor_from_default(); + status += this->test_index_accessor(); + status += this->test_index_modifier(); + status += this->test_index_checking(); + status += this->test_copy_constructor_values(); + status += this->test_freebuf_releases_elements(); + status += this->test_assignment_from_default(); + status += this->test_assignment_values(); + status += this->test_exception_in_copy_constructor(); + status += this->test_exception_in_assignment(); + status += this->test_duplicate_exception_in_copy_constructor(); + status += this->test_duplicate_exception_in_assignment(); + status += this->test_get_buffer_const(); + + return status; } - -private: - string_sequence_tester(bool bounded) - : bounded_(bounded) - {} - - bool bounded_; - - boost::weak_ptr<string_sequence_tester> self_; }; #endif // guard_string_sequence_tester_hpp diff --git a/TAO/tests/Sequence_Unit_Tests/string_ut.cpp b/TAO/tests/Sequence_Unit_Tests/string_ut.cpp index 5ff67e39e0d..3dac99b2e4c 100644 --- a/TAO/tests/Sequence_Unit_Tests/string_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/string_ut.cpp @@ -12,13 +12,7 @@ #include "ace/OS_NS_string.h" -#include <sstream> -#include <stdexcept> -#include <iostream> - -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" using namespace TAO::details; diff --git a/TAO/tests/Sequence_Unit_Tests/test_macros.h b/TAO/tests/Sequence_Unit_Tests/test_macros.h new file mode 100644 index 00000000000..2db80f1410f --- /dev/null +++ b/TAO/tests/Sequence_Unit_Tests/test_macros.h @@ -0,0 +1,43 @@ +// $Id$ + +#include "ace/Log_Msg.h" + +#define FAIL_RETURN_IF(CONDITION) \ + if (CONDITION) \ + { \ + ACE_ERROR ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ + return 1; \ + } + +#define FAIL_RETURN_IF_NOT(CONDITION, X) \ + if (!(CONDITION)) \ + { \ + ACE_ERROR ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ + return 1; \ + } +#define CHECK_EQUAL(X, Y) \ + if ((X) != (Y)) \ + { \ + ACE_ERROR ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ + return 1; \ + } +#define CHECK(X) \ + if (!(X)) \ + { \ + ACE_ERROR ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ + return 1; \ + } + +#define CHECK_THROW(X, Y) \ + try { \ + X; \ + } \ + catch (Y const &) \ + { \ + } \ + catch (...) \ + { \ + return 1; \ + } \ + + diff --git a/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits.hpp b/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits.hpp index 57d3cb859f7..8ebdeada068 100644 --- a/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits.hpp +++ b/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits.hpp @@ -37,6 +37,13 @@ struct testing_allocation_traits : public base return base::allocbuf(maximum); } + // allocbuf_calls must be updated when allocbuf_noinit is called as well. + inline static value_type * allocbuf_noinit(CORBA::ULong maximum) + { + allocbuf_calls(); + return base::allocbuf_noinit(maximum); + } + static call_counter freebuf_calls; inline static void freebuf(value_type * buffer) { diff --git a/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits_ut.cpp b/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits_ut.cpp index de4426c4f16..ae7445e53b4 100644 --- a/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/testing_allocation_traits_ut.cpp @@ -8,18 +8,15 @@ * @author Carlos O'Ryan */ #include "testing_allocation_traits.hpp" - -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" #define CHECK_NO_THROW(statement) \ try { statement; } catch(...) { \ - BOOST_ERROR("unexpected exception raised"); } + return 1; } using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO::details; -using namespace boost::unit_test_framework; + CORBA::ULong const MAXIMUM = 32; @@ -30,7 +27,7 @@ struct Tester typedef bounded_value_allocation_traits<value_type,MAXIMUM,true> bounded; template<class aspect> - void test_allocbuf() + int test_allocbuf() { expected_calls c(aspect::allocbuf_calls); @@ -38,15 +35,16 @@ struct Tester value_type * s = 0; CHECK_NO_THROW(s = aspect::allocbuf(4)); aspect::freebuf(s); - BOOST_CHECK_THROW(s = aspect::allocbuf(4), testing_exception); + CHECK_THROW(s = aspect::allocbuf(4), testing_exception); CHECK_NO_THROW(s = aspect::allocbuf(4)); aspect::freebuf(s); - BOOST_CHECK_MESSAGE(c.expect(3), c); + FAIL_RETURN_IF_NOT(c.expect(3), c); + return 0; } template<class aspect> - void test_freebuf() + int test_freebuf() { expected_calls c(aspect::freebuf_calls); @@ -54,34 +52,38 @@ struct Tester value_type * s = aspect::allocbuf(4); CHECK_NO_THROW(aspect::freebuf(s)); s = aspect::allocbuf(4); - BOOST_CHECK_THROW(aspect::freebuf(s), testing_exception); + CHECK_THROW(aspect::freebuf(s), testing_exception); aspect::freebuf(s); s = aspect::allocbuf(4); CHECK_NO_THROW(aspect::freebuf(s)); - BOOST_CHECK_MESSAGE(c.expect(4), c); + FAIL_RETURN_IF_NOT(c.expect(4), c); + return 0; } - void test_default_buffer_allocation_value() + int test_default_buffer_allocation_value() { expected_calls u(unbounded::default_buffer_allocation_calls); expected_calls b(bounded::default_buffer_allocation_calls); value_type * s = unbounded::default_buffer_allocation(); - BOOST_CHECK_MESSAGE(u.expect(1), u); - BOOST_CHECK_MESSAGE(b.expect(0), b); - BOOST_CHECK_EQUAL(static_cast<value_type*>(0), s); + FAIL_RETURN_IF_NOT(u.expect(1), u); + FAIL_RETURN_IF_NOT(b.expect(0), b); + CHECK_EQUAL(static_cast<value_type*>(0), s); bounded::freebuf(s); s = bounded::default_buffer_allocation(); - BOOST_CHECK_MESSAGE(u.expect(0), u); - BOOST_CHECK_MESSAGE(b.expect(1), b); - BOOST_CHECK(static_cast<value_type*>(0) != s); + FAIL_RETURN_IF_NOT(u.expect(0), u); + FAIL_RETURN_IF_NOT(b.expect(1), b); + // default_buffer_allocation doesn't allocate a buffer for + // bounded sequences (see bug 3042). + CHECK_EQUAL(static_cast<value_type*>(0), s); bounded::freebuf(s); + return 0; } template<class aspect> - void test_default_buffer_allocation() + int test_default_buffer_allocation() { expected_calls c(aspect::default_buffer_allocation_calls); @@ -90,112 +92,80 @@ struct Tester CHECK_NO_THROW( s = aspect::default_buffer_allocation()); aspect::freebuf(s); - BOOST_CHECK_THROW( + CHECK_THROW( s = aspect::default_buffer_allocation(), testing_exception); CHECK_NO_THROW( s = aspect::default_buffer_allocation()); aspect::freebuf(s); - BOOST_CHECK_MESSAGE(c.expect(3), c); - } - - void test_default_buffer_allocation_unbounded() - { - test_default_buffer_allocation<unbounded>(); + FAIL_RETURN_IF_NOT(c.expect(3), c); + return 0; } - void test_default_buffer_allocation_bounded() + int test_default_buffer_allocation_unbounded() { - test_default_buffer_allocation<bounded>(); + return test_default_buffer_allocation<unbounded>(); } - void test_allocbuf_unbounded() + int test_default_buffer_allocation_bounded() { - test_allocbuf<unbounded>(); + return test_default_buffer_allocation<bounded>(); } - void test_allocbuf_bounded() + int test_allocbuf_unbounded() { - test_allocbuf<bounded>(); + return test_allocbuf<unbounded>(); } - void test_freebuf_unbounded() + int test_allocbuf_bounded() { - test_freebuf<unbounded>(); + return test_allocbuf<bounded>(); } - void test_freebuf_bounded() + int test_freebuf_unbounded() { - test_freebuf<bounded>(); + return test_freebuf<unbounded>(); } - void add_all(test_suite * ts) + int test_freebuf_bounded() { - boost::shared_ptr<Tester> shared_this(self_); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_default_buffer_allocation_value, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_default_buffer_allocation_unbounded, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_default_buffer_allocation_bounded, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_allocbuf_unbounded, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_allocbuf_bounded, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_freebuf_unbounded, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_freebuf_bounded, - shared_this)); + return test_freebuf<bounded>(); } - static boost::shared_ptr<Tester> allocate() + int test_all() { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; + int status = 0; + status += this->test_default_buffer_allocation_value(); + status += this->test_default_buffer_allocation_unbounded(); + status += this->test_default_buffer_allocation_bounded(); + status += this->test_allocbuf_unbounded(); + status += this->test_allocbuf_bounded(); + status += this->test_freebuf_unbounded(); + status += this->test_freebuf_bounded(); + return status; } - -private: Tester() {} - - boost::weak_ptr<Tester> self_; }; struct Foo { int y; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("testing allocation traits unit test"); - + int status = 0; { - boost::shared_ptr<Tester<int> > tester( - Tester<int>::allocate()); - tester->add_all(ts); + Tester<int> tester; + status += tester.test_all (); } { - boost::shared_ptr<Tester<Foo> > tester( - Tester<Foo>::allocate()); - tester->add_all(ts); + Tester<Foo> tester; + status += tester.test_all (); } { - boost::shared_ptr<Tester<char*> > tester( - Tester<char*>::allocate()); - tester->add_all(ts); + Tester<char*> tester; + status += tester.test_all (); } - return ts; + return status; } - diff --git a/TAO/tests/Sequence_Unit_Tests/testing_counters.hpp b/TAO/tests/Sequence_Unit_Tests/testing_counters.hpp index e5f20bb8ee1..7963526de82 100644 --- a/TAO/tests/Sequence_Unit_Tests/testing_counters.hpp +++ b/TAO/tests/Sequence_Unit_Tests/testing_counters.hpp @@ -13,8 +13,7 @@ */ #include "testing_exception.hpp" - -#include <boost/utility.hpp> +#include "ace/Copy_Disabled.h" #include <iostream> @@ -59,7 +58,7 @@ private: * number of times. */ class expected_calls - : private boost::noncopyable + : private ACE_Copy_Disabled { public: inline expected_calls(call_counter const & counter) @@ -100,7 +99,6 @@ inline std::ostream & operator<<(std::ostream & os, expected_calls const & x) { return os << "current=" << x.current_count() << ",previous=" << x.previous_count(); - } #endif // guard_testing_counters_hpp diff --git a/TAO/tests/Sequence_Unit_Tests/testing_object_reference_traits.hpp b/TAO/tests/Sequence_Unit_Tests/testing_object_reference_traits.hpp index 043c85ad06a..c627f477b3a 100644 --- a/TAO/tests/Sequence_Unit_Tests/testing_object_reference_traits.hpp +++ b/TAO/tests/Sequence_Unit_Tests/testing_object_reference_traits.hpp @@ -43,7 +43,7 @@ struct testing_object_reference_traits static void release(object_type * s) { release_calls(); - return real_traits::release(s); + real_traits::release(s); } }; diff --git a/TAO/tests/Sequence_Unit_Tests/testing_string_traits.hpp b/TAO/tests/Sequence_Unit_Tests/testing_string_traits.hpp index 0c316da6dc3..c333e70f932 100644 --- a/TAO/tests/Sequence_Unit_Tests/testing_string_traits.hpp +++ b/TAO/tests/Sequence_Unit_Tests/testing_string_traits.hpp @@ -43,7 +43,7 @@ struct testing_string_traits static void release(char_type * s) { release_calls(); - return real_traits::release(s); + real_traits::release(s); } static void not_released_from_const( diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_array_sequence_ut.cpp b/TAO/tests/Sequence_Unit_Tests/unbounded_array_sequence_ut.cpp index 9648158918a..6f988b979d8 100644 --- a/TAO/tests/Sequence_Unit_Tests/unbounded_array_sequence_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/unbounded_array_sequence_ut.cpp @@ -14,64 +14,37 @@ #include "tao/Unbounded_Array_Sequence_T.h" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> - -using namespace boost::unit_test_framework; -using namespace TAO; - -struct Tester -{ - typedef unbounded_array_sequence<my_array, my_array_slice, my_array_tag> tested_sequence; - typedef tested_sequence::value_type value_type; - typedef tested_sequence::const_value_type const_value_type; - - typedef tested_sequence::element_traits tested_element_traits; - typedef tested_sequence::allocation_traits tested_allocation_traits; - typedef TAO::details::range_checking<value_type,true> range; - - void test_default_constructor() +#define FAIL_RETURN_IF(CONDITION) \ + if (CONDITION) \ + { \ + ACE_DEBUG ((LM_ERROR, ACE_TEXT ("\tFailed at %N:%l\n"))); \ + return 1; \ + } + +typedef unbounded_array_sequence<my_array, my_array_slice, my_array_tag> tested_sequence; +typedef tested_sequence::value_type value_type; +typedef tested_sequence::const_value_type const_value_type; + +typedef tested_sequence::element_traits tested_element_traits; +typedef tested_sequence::allocation_traits tested_allocation_traits; +typedef TAO::details::range_checking<value_type,true> range; + +int test_default_constructor() { { tested_sequence x; - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + FAIL_RETURN_IF(CORBA::ULong(0), x.maximum()); + FAIL_RETURN_IF(CORBA::ULong(0), x.length()); + FAIL_RETURN_IF(true, x.release()); } } - void add_all(test_suite * ts) - { - boost::shared_ptr<Tester> shared_this(self_); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_default_constructor, - shared_this)); - } - static boost::shared_ptr<Tester> allocate() - { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; - } - -private: - Tester() {} - - boost::weak_ptr<Tester> self_; -}; - -test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("unbounded array sequence unit test"); + int status = 0; - boost::shared_ptr<Tester> tester(Tester::allocate()); - tester->add_all(ts); + status += test_default_constructor (); - return ts; + return status; } - diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_fwd_object_reference_sequence_ut.cpp b/TAO/tests/Sequence_Unit_Tests/unbounded_fwd_object_reference_sequence_ut.cpp index 0116dd37dcb..8ca1fca4193 100644 --- a/TAO/tests/Sequence_Unit_Tests/unbounded_fwd_object_reference_sequence_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/unbounded_fwd_object_reference_sequence_ut.cpp @@ -16,11 +16,9 @@ #include "tao/Unbounded_Object_Reference_Sequence_T.h" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" + -using namespace boost::unit_test_framework; using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; struct Tester @@ -33,7 +31,7 @@ struct Tester typedef tested_sequence::allocation_traits tested_allocation_traits; typedef TAO::details::range_checking<value_type,true> range; - void test_default_constructor() + int test_default_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -41,46 +39,22 @@ struct Tester { tested_sequence x; - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(false, x.release()); + CHECK_EQUAL(CORBA::ULong(0), x.maximum()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); + CHECK_EQUAL(false, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); - } - - void add_all(test_suite * ts) - { - boost::shared_ptr<Tester> shared_this(self_); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_default_constructor, - shared_this)); - } - - static boost::shared_ptr<Tester> allocate() - { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } - -private: - Tester() {} - - boost::weak_ptr<Tester> self_; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("unbounded object reference sequence unit test"); - - boost::shared_ptr<Tester> tester(Tester::allocate()); - tester->add_all(ts); + int status = 0; + Tester x; + status += x.test_default_constructor (); - return ts; + return status; } - diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_object_reference_sequence_ut.cpp b/TAO/tests/Sequence_Unit_Tests/unbounded_object_reference_sequence_ut.cpp index 263576143d9..eee6e01f5e3 100644 --- a/TAO/tests/Sequence_Unit_Tests/unbounded_object_reference_sequence_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/unbounded_object_reference_sequence_ut.cpp @@ -16,11 +16,9 @@ #include "tao/Unbounded_Object_Reference_Sequence_T.h" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" + -using namespace boost::unit_test_framework; using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; struct Tester @@ -33,7 +31,7 @@ struct Tester typedef tested_sequence::allocation_traits tested_allocation_traits; typedef TAO::details::range_checking<value_type,true> range; - void test_default_constructor() + int test_default_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -41,16 +39,17 @@ struct Tester { tested_sequence x; - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(false, x.release()); + CHECK_EQUAL(CORBA::ULong(0), x.maximum()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); + CHECK_EQUAL(false, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } - void test_ulong_constructor() + int test_ulong_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -58,30 +57,34 @@ struct Tester { tested_sequence x(16); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + // ulong constructor calls allocbuf and thus there must be + // maximum() default initilized elements. + FAIL_RETURN_IF_NOT(i.expect(16), i); + return 0; } - void test_ulong_constructor_throw() + int test_ulong_constructor_throw() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); expected_calls i(tested_element_traits::default_initializer_calls); { tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(tested_sequence x(16), testing_exception); + CHECK_THROW(tested_sequence x(16), testing_exception); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } - void test_buffer_constructor_release_true() + int test_buffer_constructor_release_true() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -92,17 +95,19 @@ struct Tester a.reset(); tested_sequence x(maximum, maximum / 2, data, true); - BOOST_CHECK_EQUAL(x.maximum(), maximum); - BOOST_CHECK_EQUAL(x.length(), maximum / 2); - BOOST_CHECK_EQUAL(x.get_buffer(), data); - BOOST_CHECK_EQUAL(x.release(), true); + CHECK_EQUAL(x.maximum(), maximum); + CHECK_EQUAL(x.length(), maximum / 2); + CHECK_EQUAL(x.get_buffer(), data); + CHECK_EQUAL(x.release(), true); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + // allocbuf default initializes maximum elements. + FAIL_RETURN_IF_NOT(i.expect(32), i); + return 0; } - void test_buffer_constructor_release_false() + int test_buffer_constructor_release_false() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -114,23 +119,25 @@ struct Tester { tested_sequence x(maximum, maximum / 2, data, false); - BOOST_CHECK_EQUAL(x.maximum(), maximum); - BOOST_CHECK_EQUAL(x.length(), maximum / 2); - BOOST_CHECK_EQUAL(x.get_buffer(), data); - BOOST_CHECK_EQUAL(x.release(), false); + CHECK_EQUAL(x.maximum(), maximum); + CHECK_EQUAL(x.length(), maximum / 2); + CHECK_EQUAL(x.get_buffer(), data); + CHECK_EQUAL(x.release(), false); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + // allocbuf default initializes maximum elements. + FAIL_RETURN_IF_NOT(i.expect(64), i); tested_sequence::freebuf(data); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } - void test_copy_constructor_from_default() + int test_copy_constructor_from_default() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -140,12 +147,13 @@ struct Tester tested_sequence y(x); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } - void test_copy_constructor() + int test_copy_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -156,11 +164,11 @@ struct Tester { tested_sequence x(l); x.length(l); - BOOST_CHECK_MESSAGE(i.expect(l), i); + FAIL_RETURN_IF_NOT(i.expect(l), i); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_EQUAL(l, x.length()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(l, x.length()); for(CORBA::ULong i = 0; i != l; ++i) { x[i] = mock_reference::allocate(i); @@ -169,23 +177,24 @@ struct Tester d.reset(); r.reset(); tested_sequence y(x); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_EQUAL(l, x.length()); - BOOST_CHECK_MESSAGE(d.expect(l), d); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(l, x.length()); + FAIL_RETURN_IF_NOT(d.expect(l), d); for(CORBA::ULong i = 0; i != l; ++i) { - BOOST_CHECK_EQUAL(int(i), y[i]->id()); + CHECK_EQUAL(int(i), y[i]->id()); } } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(2*l), r); - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(2), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(2*l), r); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(2), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } - void test_copy_constructor_throw_duplicate() + int test_copy_constructor_throw_duplicate() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -197,11 +206,11 @@ struct Tester tested_sequence x(l); x.length(l); - BOOST_CHECK_MESSAGE(i.expect(l), i); + FAIL_RETURN_IF_NOT(i.expect(l), i); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_EQUAL(l, x.length()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(l, x.length()); for(CORBA::ULong i = 0; i != l; ++i) { x[i] = mock_reference::allocate(i); @@ -210,20 +219,21 @@ struct Tester d.reset(); r.reset(); mock_reference::duplicate_calls.failure_countdown(8); - BOOST_CHECK_THROW(tested_sequence y(x), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(d.expect(8), d); - BOOST_CHECK_MESSAGE(r.expect(l), r); + CHECK_THROW(tested_sequence y(x), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(d.expect(8), d); + FAIL_RETURN_IF_NOT(r.expect(l), r); } - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(l), r); - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(l), r); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } - void test_set_length_less_than_maximum() + int test_set_length_less_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -232,116 +242,124 @@ struct Tester tested_sequence x(16); x.length(8); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); - BOOST_CHECK_MESSAGE(i.expect(8), i); + // allocbuf default initializes 16 elements. + FAIL_RETURN_IF_NOT(i.expect(16), i); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_set_length_more_than_maximum() + int test_set_length_more_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); expected_calls i(tested_element_traits::default_initializer_calls); { tested_sequence x(16); - BOOST_CHECK_MESSAGE(a.expect(1), a); + FAIL_RETURN_IF_NOT(a.expect(1), a); x.length(32); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(32), i); + // ulong constructor calls allocbuf and thus there must be + // maximum() default initilized elements + length() leads to buffer + // reallocation maximum() gets set to a new value. + FAIL_RETURN_IF_NOT(i.expect(48), i); - BOOST_CHECK_EQUAL(CORBA::ULong(32), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(32), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(32), x.maximum()); + CHECK_EQUAL(CORBA::ULong(32), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_set_length_copy_elements() + int test_set_length_copy_elements() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); expected_calls i(tested_element_traits::default_initializer_calls); { tested_sequence x(16); - BOOST_CHECK_MESSAGE(a.expect(1), a); + FAIL_RETURN_IF_NOT(a.expect(1), a); x.length(16); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.length()); - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), a); - BOOST_CHECK_MESSAGE(i.expect(16), i); + CHECK_EQUAL(CORBA::ULong(16), x.length()); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), a); + FAIL_RETURN_IF_NOT(i.expect(16), i); for(int j = 0; j != 16; ++j) { - BOOST_CHECK_EQUAL(mock_reference::_nil(), x[j]); + CHECK_EQUAL(mock_reference::_nil(), x[j]); x[j] = mock_reference::allocate(j); } x.length(32); - BOOST_CHECK_EQUAL(CORBA::ULong(32), x.length()); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(16), i); + CHECK_EQUAL(CORBA::ULong(32), x.length()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(i.expect(16), i); tested_sequence const & y = x; for(CORBA::ULong i = 0; i != 16UL; ++i) { - BOOST_REQUIRE(mock_reference::_nil() != y[i]); - BOOST_CHECK_EQUAL(int(i), y[i]->id()); + CHECK(mock_reference::_nil() != y[i]); + CHECK_EQUAL(int(i), y[i]->id()); } for(CORBA::ULong i = 16; i != 32UL; ++i) { - BOOST_CHECK_EQUAL(mock_reference::_nil(), y[i]); + CHECK_EQUAL(mock_reference::_nil(), y[i]); } } - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } - void test_set_length_throw() + int test_set_length_throw() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); expected_calls i(tested_element_traits::default_initializer_calls); { tested_sequence x(16); - BOOST_CHECK_MESSAGE(a.expect(1), a); + FAIL_RETURN_IF_NOT(a.expect(1), a); x.length(16); - BOOST_CHECK_MESSAGE(i.expect(16), i); + FAIL_RETURN_IF_NOT(i.expect(16), i); for(int j = 0; j != 16; ++j) { - BOOST_CHECK_EQUAL(mock_reference::_nil(), x[j]); + CHECK_EQUAL(mock_reference::_nil(), x[j]); x[j] = mock_reference::allocate(j); } tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(x.length(32), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.length()); - BOOST_CHECK_MESSAGE(i.expect(0), i); + CHECK_THROW(x.length(32), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(CORBA::ULong(16), x.length()); + FAIL_RETURN_IF_NOT(i.expect(0), i); tested_sequence const & y = x; for(int j = 0; j != 16; ++j) { - BOOST_REQUIRE(mock_reference::_nil() != y[j]); - BOOST_CHECK_EQUAL(j, y[j]->id()); + CHECK(mock_reference::_nil() != y[j]); + CHECK_EQUAL(j, y[j]->id()); } } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(i.expect(0), i); + return 0; } value_type * alloc_and_init_buffer() @@ -355,15 +373,16 @@ struct Tester return buf; } - void check_values(tested_sequence const & a) + int check_values(tested_sequence const & a) { - BOOST_CHECK_EQUAL( 1, a[0]->id()); - BOOST_CHECK_EQUAL( 4, a[1]->id()); - BOOST_CHECK_EQUAL( 9, a[2]->id()); - BOOST_CHECK_EQUAL(16, a[3]->id()); + CHECK_EQUAL( 1, a[0]->id()); + CHECK_EQUAL( 4, a[1]->id()); + CHECK_EQUAL( 9, a[2]->id()); + CHECK_EQUAL(16, a[3]->id()); + return 0; } - void test_replace_release_true() + int test_replace_release_true() { value_type * buffer = alloc_and_init_buffer(); @@ -372,24 +391,26 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a; - a.replace(8, 4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(r.expect(0), r); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + a.replace(8, 4, buffer, true); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), r); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(true, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(8), r); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Since we've given away the ownership the buffer is deallocated by + // the sequence. + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(r.expect(8), r); + return 0; } - void test_replace_release_false() + int test_replace_release_false() { value_type * buffer = alloc_and_init_buffer(); @@ -399,23 +420,24 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(r.expect(0), 0); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), 0); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(8), r); + FAIL_RETURN_IF_NOT(r.expect(8), r); + return 0; } - void test_replace_release_default() + int test_replace_release_default() { value_type * buffer = alloc_and_init_buffer(); @@ -425,95 +447,54 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(r.expect(0), 0); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), 0); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(8), r); - } - - void add_all(test_suite * ts) - { - boost::shared_ptr<Tester> shared_this(self_); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_default_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_ulong_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_ulong_constructor_throw, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_release_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_copy_constructor_from_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_copy_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_copy_constructor_throw_duplicate, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_less_than_maximum, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_more_than_maximum, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_copy_elements, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_throw, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_release_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_release_default, - shared_this)); + FAIL_RETURN_IF_NOT(r.expect(8), r); + return 0; } - static boost::shared_ptr<Tester> allocate() + int test_all() { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; + int status = 0; + status += this->test_default_constructor(); + status += this->test_ulong_constructor(); + status += this->test_ulong_constructor_throw(); + status += this->test_buffer_constructor_release_true(); + status += this->test_buffer_constructor_release_false(); + status += this->test_copy_constructor_from_default(); + status += this->test_copy_constructor(); + status += this->test_copy_constructor_throw_duplicate(); + status += this->test_set_length_less_than_maximum(); + status += this->test_set_length_more_than_maximum(); + status += this->test_set_length_copy_elements(); + status += this->test_set_length_throw(); + status += this->test_replace_release_true(); + status += this->test_replace_release_false(); + status += this->test_replace_release_default(); + return status; } -private: Tester() {} - - boost::weak_ptr<Tester> self_; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("unbounded object reference sequence unit test"); - - boost::shared_ptr<Tester> tester(Tester::allocate()); - tester->add_all(ts); + int status = 0; + { + Tester tester; + status += tester.test_all(); + } - return ts; + return status; } - diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_octet_sequence_nocopy_ut.cpp b/TAO/tests/Sequence_Unit_Tests/unbounded_octet_sequence_nocopy_ut.cpp index 56162ac842a..0bc62b60efa 100644 --- a/TAO/tests/Sequence_Unit_Tests/unbounded_octet_sequence_nocopy_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/unbounded_octet_sequence_nocopy_ut.cpp @@ -15,16 +15,14 @@ #include "value_sequence_tester.hpp" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" #include "tao/Basic_Types.h" #include "tao/CDR.h" #include "ace/OS_NS_stdio.h" -using namespace boost::unit_test_framework; + using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; typedef unbounded_value_sequence<CORBA::Octet> tested_sequence; @@ -36,81 +34,87 @@ struct Tester { typedef tested_sequence::value_type value_type; - void test_copy_constructor_from_ulong() + int test_copy_constructor_from_ulong() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); - BOOST_CHECK_MESSAGE(a.expect(1), a); + FAIL_RETURN_IF_NOT(a.expect(1), a); x.length(8); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); tested_sequence y(x); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_EQUAL(CORBA::ULong(16), y.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), y.length()); - BOOST_CHECK_EQUAL(true, y.release()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + CHECK_EQUAL(CORBA::ULong(16), y.maximum()); + CHECK_EQUAL(CORBA::ULong(8), y.length()); + CHECK_EQUAL(true, y.release()); } - BOOST_CHECK_MESSAGE(f.expect(2), f); + FAIL_RETURN_IF_NOT(f.expect(2), f); + return 0; } - void test_assignment_from_ulong() + int test_assignment_from_ulong() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); x.length(8); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); tested_sequence y; - BOOST_CHECK_MESSAGE(a.expect(0), a); + FAIL_RETURN_IF_NOT(a.expect(0), a); y = x; - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_EQUAL(CORBA::ULong(16), y.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), y.length()); - BOOST_CHECK_EQUAL(true, y.release()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + // Since above no allocation for y was done then + // no deallocation needed during assignment. + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(CORBA::ULong(16), y.maximum()); + CHECK_EQUAL(CORBA::ULong(8), y.length()); + CHECK_EQUAL(true, y.release()); } - BOOST_CHECK_MESSAGE(f.expect(2), f); + FAIL_RETURN_IF_NOT(f.expect(2), f); + return 0; } - void test_ulong_constructor() + int test_ulong_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_exception_in_ulong_constructor() + int test_exception_in_ulong_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(tested_sequence x(16), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); + CHECK_THROW(tested_sequence x(16), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); } - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } - void test_set_length_less_than_maximum() + int test_set_length_less_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -118,34 +122,36 @@ struct Tester tested_sequence x(16); x.length(8); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_set_length_more_than_maximum() + int test_set_length_more_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); - BOOST_CHECK_MESSAGE(a.expect(1), a); + FAIL_RETURN_IF_NOT(a.expect(1), a); x.length(32); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); - BOOST_CHECK_EQUAL(CORBA::ULong(32), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(32), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(32), x.maximum()); + CHECK_EQUAL(CORBA::ULong(32), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_exception_in_set_length() + int test_exception_in_set_length() { expected_calls f(tested_allocation_traits::freebuf_calls); { @@ -153,10 +159,13 @@ struct Tester expected_calls a(tested_allocation_traits::allocbuf_calls); tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(x.length(8), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); + CHECK_THROW(x.length(8), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + // length() above tried to allocate a buffer but it didn't reach + // new[] and sequence was not changed, thus no need to deallocate. + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } value_type * alloc_and_init_buffer() @@ -178,7 +187,7 @@ struct Tester return mb; } - void test_buffer_constructor_default() + int test_buffer_constructor_default() { value_type * buffer = alloc_and_init_buffer(); @@ -186,62 +195,65 @@ struct Tester expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_buffer_constructor_false() + int test_buffer_constructor_false() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_buffer_constructor_true() + int test_buffer_constructor_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(true, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(true, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_replace_default() + int test_replace_default() { value_type * buffer = alloc_and_init_buffer(); @@ -250,24 +262,26 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Default constructed sequence doesn't allocate a buffer. + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_replace_false() + int test_replace_false() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); @@ -276,24 +290,26 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Default constructed sequence doesn't allocate a buffer. + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_replace_true() + int test_replace_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); @@ -302,187 +318,138 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer, true); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(true, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Default constructed sequence doesn't allocate a buffer. + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(true, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_get_buffer_default() + int test_get_buffer_default() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_false() + int test_get_buffer_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_true_with_release_false() + int test_get_buffer_true_with_release_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, false); - BOOST_CHECK(0 == a.get_buffer(true)); + CHECK(0 == a.get_buffer(true)); tested_sequence::freebuf(buffer); + return 0; } - void test_get_buffer_true_with_release_true() + int test_get_buffer_true_with_release_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(buffer, a.get_buffer(true)); + CHECK_EQUAL(buffer, a.get_buffer(true)); tested_sequence const & b = a; - BOOST_CHECK_EQUAL(0UL, b.maximum()); - BOOST_CHECK_EQUAL(0UL, b.length()); - BOOST_CHECK(0 != b.get_buffer()); - BOOST_CHECK_EQUAL(true, b.release()); + CHECK_EQUAL(0UL, b.maximum()); + CHECK_EQUAL(0UL, b.length()); + CHECK(0 != b.get_buffer()); + CHECK_EQUAL(true, b.release()); - BOOST_CHECK_MESSAGE(c.expect(1), c); + FAIL_RETURN_IF_NOT(c.expect(1), c); - BOOST_CHECK(buffer != b.get_buffer()); + CHECK(buffer != b.get_buffer()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(1), f); tested_sequence::freebuf(buffer); + return 0; } - void test_no_copy_octet() + int test_no_copy_octet() { #if (TAO_NO_COPY_OCTET_SEQUENCES == 1) ACE_Message_Block * mb = alloc_and_init_mb(); tested_sequence a (8, mb); - BOOST_CHECK_EQUAL(CORBA::Octet( 't'), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 'g'), a[6]); + CHECK_EQUAL(CORBA::Octet( 't'), a[0]); + CHECK_EQUAL(CORBA::Octet( 'g'), a[6]); char upperbuf[256]; ACE_OS::sprintf (upperbuf, "%s", "THIS IS A TEST"); size_t n = (ACE_OS::strlen (upperbuf) + 1) * sizeof (char); ACE_Message_Block * upper_mb = 0; - ACE_NEW (upper_mb, - ACE_Message_Block (n)); + ACE_NEW_RETURN (upper_mb, + ACE_Message_Block (n), 1); // Copy buf into the Message_Block and update the wr_ptr (). upper_mb->copy ((char *) upperbuf, n); a.replace (n, upper_mb); - BOOST_CHECK_EQUAL(CORBA::Octet( 'T'), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 'S'), a[6]); + CHECK_EQUAL(CORBA::Octet( 'T'), a[0]); + CHECK_EQUAL(CORBA::Octet( 'S'), a[6]); + delete upper_mb; + delete mb; #endif + return 0; } - void add_all(test_suite * ts) - { - boost::shared_ptr<Tester> shared_this(self_); - - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_no_copy_octet, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_ulong_constructor, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_copy_constructor_from_ulong, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_ulong, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_exception_in_ulong_constructor, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_less_than_maximum, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_more_than_maximum, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_exception_in_set_length, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_true, - shared_this)); - - } - - static boost::shared_ptr<Tester> allocate() + int test_all() { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; + int status = 0; + status += this->test_no_copy_octet(); + status += this->test_ulong_constructor(); + status += this->test_copy_constructor_from_ulong(); + status += this->test_assignment_from_ulong(); + status += this->test_exception_in_ulong_constructor(); + status += this->test_set_length_less_than_maximum(); + status += this->test_set_length_more_than_maximum(); + status += this->test_exception_in_set_length(); + status += this->test_buffer_constructor_default(); + status += this->test_buffer_constructor_false(); + status += this->test_buffer_constructor_true(); + status += this->test_replace_default(); + status += this->test_replace_false(); + status += this->test_replace_true(); + status += this->test_get_buffer_false(); + status += this->test_get_buffer_true_with_release_false(); + status += this->test_get_buffer_true_with_release_true(); + return status; } -private: Tester() {} - - boost::weak_ptr<Tester> self_; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("unbounded no copy octet sequence unit test"); - + int status = 0; { - boost::shared_ptr<Tester> tester(Tester::allocate()); - tester->add_all(ts); + Tester tester; + status += tester.test_all(); } { typedef value_sequence_tester<tested_sequence,tested_allocation_traits> common; - boost::shared_ptr<common> tester(common::allocate()); - tester->add_all(ts); + common tester; + status += tester.test_all (); } - return ts; + return status; } diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_octet_sequence_ut.cpp b/TAO/tests/Sequence_Unit_Tests/unbounded_octet_sequence_ut.cpp index acc347afc39..20146e92b2e 100644 --- a/TAO/tests/Sequence_Unit_Tests/unbounded_octet_sequence_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/unbounded_octet_sequence_ut.cpp @@ -8,10 +8,6 @@ * @author Johnny Willemsen */ -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> - #include "testing_allocation_traits.hpp" #include "testing_range_checking.hpp" @@ -19,11 +15,13 @@ #include "value_sequence_tester.hpp" +#include "test_macros.h" + #include "tao/Basic_Types.h" #include "tao/CDR.h" using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; -using namespace boost::unit_test_framework; + typedef unbounded_value_sequence<CORBA::Octet> tested_sequence; typedef tested_sequence::element_traits tested_element_traits; @@ -34,81 +32,85 @@ struct Tester { typedef tested_sequence::value_type value_type; - void test_copy_constructor_from_ulong() + int test_copy_constructor_from_ulong() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); - BOOST_CHECK_MESSAGE(a.expect(1), a); + FAIL_RETURN_IF_NOT(a.expect(1), a); x.length(8); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); tested_sequence y(x); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_EQUAL(CORBA::ULong(16), y.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), y.length()); - BOOST_CHECK_EQUAL(true, y.release()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + CHECK_EQUAL(CORBA::ULong(16), y.maximum()); + CHECK_EQUAL(CORBA::ULong(8), y.length()); + CHECK_EQUAL(true, y.release()); } - BOOST_CHECK_MESSAGE(f.expect(2), f); + FAIL_RETURN_IF_NOT(f.expect(2), f); + return 0; } - void test_assignment_from_ulong() + int test_assignment_from_ulong() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); x.length(8); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); tested_sequence y; - BOOST_CHECK_MESSAGE(a.expect(0), a); + FAIL_RETURN_IF_NOT(a.expect(0), a); y = x; - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_EQUAL(CORBA::ULong(16), y.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), y.length()); - BOOST_CHECK_EQUAL(true, y.release()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(CORBA::ULong(16), y.maximum()); + CHECK_EQUAL(CORBA::ULong(8), y.length()); + CHECK_EQUAL(true, y.release()); } - BOOST_CHECK_MESSAGE(f.expect(2), f); + FAIL_RETURN_IF_NOT(f.expect(2), f); + return 0; } - void test_ulong_constructor() + int test_ulong_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_exception_in_ulong_constructor() + int test_exception_in_ulong_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(tested_sequence x(16), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); + CHECK_THROW(tested_sequence x(16), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); } - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } - void test_set_length_less_than_maximum() + int test_set_length_less_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -116,34 +118,36 @@ struct Tester tested_sequence x(16); x.length(8); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_set_length_more_than_maximum() + int test_set_length_more_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); - BOOST_CHECK_MESSAGE(a.expect(1), a); + FAIL_RETURN_IF_NOT(a.expect(1), a); x.length(32); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); - BOOST_CHECK_EQUAL(CORBA::ULong(32), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(32), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(32), x.maximum()); + CHECK_EQUAL(CORBA::ULong(32), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_exception_in_set_length() + int test_exception_in_set_length() { expected_calls f(tested_allocation_traits::freebuf_calls); { @@ -151,10 +155,11 @@ struct Tester expected_calls a(tested_allocation_traits::allocbuf_calls); tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(x.length(8), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); + CHECK_THROW(x.length(8), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); } - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } value_type * alloc_and_init_buffer() @@ -165,7 +170,7 @@ struct Tester return buf; } - void test_buffer_constructor_default() + int test_buffer_constructor_default() { value_type * buffer = alloc_and_init_buffer(); @@ -173,62 +178,65 @@ struct Tester expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_buffer_constructor_false() + int test_buffer_constructor_false() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_buffer_constructor_true() + int test_buffer_constructor_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(true, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(true, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_replace_default() + int test_replace_default() { value_type * buffer = alloc_and_init_buffer(); @@ -237,24 +245,25 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_replace_false() + int test_replace_false() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); @@ -263,24 +272,25 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_replace_true() + int test_replace_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); @@ -289,162 +299,114 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer, true); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(CORBA::Octet( 1), a[0]); - BOOST_CHECK_EQUAL(CORBA::Octet( 4), a[1]); - BOOST_CHECK_EQUAL(CORBA::Octet( 9), a[2]); - BOOST_CHECK_EQUAL(CORBA::Octet(16), a[3]); - BOOST_CHECK_EQUAL(true, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(CORBA::Octet( 1), a[0]); + CHECK_EQUAL(CORBA::Octet( 4), a[1]); + CHECK_EQUAL(CORBA::Octet( 9), a[2]); + CHECK_EQUAL(CORBA::Octet(16), a[3]); + CHECK_EQUAL(true, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Since we've given away the ownership the buffer is deallocated by + // the sequence. + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_get_buffer_default() + int test_get_buffer_default() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_false() + int test_get_buffer_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_true_with_release_false() + int test_get_buffer_true_with_release_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, false); - BOOST_CHECK(0 == a.get_buffer(true)); + CHECK(0 == a.get_buffer(true)); tested_sequence::freebuf(buffer); + return 0; } - void test_get_buffer_true_with_release_true() + int test_get_buffer_true_with_release_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(buffer, a.get_buffer(true)); + CHECK_EQUAL(buffer, a.get_buffer(true)); tested_sequence const & b = a; - BOOST_CHECK_EQUAL(0UL, b.maximum()); - BOOST_CHECK_EQUAL(0UL, b.length()); - BOOST_CHECK(0 != b.get_buffer()); - BOOST_CHECK_EQUAL(true, b.release()); + CHECK_EQUAL(0UL, b.maximum()); + CHECK_EQUAL(0UL, b.length()); + CHECK(0 != b.get_buffer()); + CHECK_EQUAL(true, b.release()); - BOOST_CHECK_MESSAGE(c.expect(1), c); + FAIL_RETURN_IF_NOT(c.expect(1), c); - BOOST_CHECK(buffer != b.get_buffer()); + CHECK(buffer != b.get_buffer()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(1), f); tested_sequence::freebuf(buffer); + return 0; } - void add_all(test_suite * ts) + int test_all() { - boost::shared_ptr<Tester> shared_this(self_); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_ulong_constructor, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_copy_constructor_from_ulong, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_ulong, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_exception_in_ulong_constructor, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_less_than_maximum, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_more_than_maximum, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_exception_in_set_length, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_true, - shared_this)); - + int status = 0; + + status += this->test_ulong_constructor(); + status += this->test_copy_constructor_from_ulong(); + status += this->test_assignment_from_ulong(); + status += this->test_exception_in_ulong_constructor(); + status += this->test_set_length_less_than_maximum(); + status += this->test_set_length_more_than_maximum(); + status += this->test_exception_in_set_length(); + status += this->test_buffer_constructor_default(); + status += this->test_buffer_constructor_false(); + status += this->test_buffer_constructor_true(); + status += this->test_replace_default(); + status += this->test_replace_false(); + status += this->test_replace_true(); + status += this->test_get_buffer_false(); + status += this->test_get_buffer_true_with_release_false(); + status += this->test_get_buffer_true_with_release_true(); + return status; } - static boost::shared_ptr<Tester> allocate() - { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; - } - -private: Tester() {} - - boost::weak_ptr<Tester> self_; }; -using namespace boost::unit_test_framework; - -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("unbounded octet sequence unit test"); - + int status = 0; { - boost::shared_ptr<Tester> tester(Tester::allocate()); - tester->add_all(ts); + Tester tester; + status += tester.test_all (); } { typedef value_sequence_tester<tested_sequence,tested_allocation_traits> common; - boost::shared_ptr<common> tester(common::allocate()); - tester->add_all(ts); + common tester; + status += tester.test_all (); } - return ts; + return status; } diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_sequence_cdr_ut.cpp b/TAO/tests/Sequence_Unit_Tests/unbounded_sequence_cdr_ut.cpp index 99043e4bd97..6d320b5254d 100644 --- a/TAO/tests/Sequence_Unit_Tests/unbounded_sequence_cdr_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/unbounded_sequence_cdr_ut.cpp @@ -22,11 +22,9 @@ #include "tao/Unbounded_Sequence_CDR_T.h" #include "tao/CDR.h" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" + -using namespace boost::unit_test_framework; using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; typedef unbounded_object_reference_sequence<mock_reference, mock_reference_var> tested_sequence; @@ -61,15 +59,16 @@ struct Tester return buf; } - void check_values(tested_sequence const & a) + int check_values(tested_sequence const & a) { - BOOST_CHECK_EQUAL( 1, a[0]->id()); - BOOST_CHECK_EQUAL( 4, a[1]->id()); - BOOST_CHECK_EQUAL( 9, a[2]->id()); - BOOST_CHECK_EQUAL(16, a[3]->id()); + CHECK_EQUAL( 1, a[0]->id()); + CHECK_EQUAL( 4, a[1]->id()); + CHECK_EQUAL( 9, a[2]->id()); + CHECK_EQUAL(16, a[3]->id()); + return 0; } - void test_stream() + int test_stream() { value_type * buffer = alloc_and_init_buffer(); @@ -78,50 +77,26 @@ struct Tester tested_sequence a; a.replace(8, 4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); TAO_OutputCDR stream; stream << a; - BOOST_CHECK_MESSAGE(s.expect(4), s); + FAIL_RETURN_IF_NOT(s.expect(4), s); } tested_sequence::freebuf(buffer); + return 0; } - - void add_all(test_suite * ts) - { - boost::shared_ptr<Tester> shared_this(self_); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_stream, - shared_this)); - } - - static boost::shared_ptr<Tester> allocate() - { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; - } - -private: - Tester() {} - - boost::weak_ptr<Tester> self_; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("unbounded object reference sequence unit test"); - - boost::shared_ptr<Tester> tester(Tester::allocate()); - tester->add_all(ts); + int status = 0; + Tester x; + status += x.test_stream (); - return ts; + return status; } - diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence_ut.cpp b/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence_ut.cpp index 0293fb0a4f0..f2639091b7d 100644 --- a/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/unbounded_string_sequence_ut.cpp @@ -17,11 +17,9 @@ #include "string_sequence_tester.hpp" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" + -using namespace boost::unit_test_framework; using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; template<class tested_sequence> @@ -36,7 +34,7 @@ struct Tester typedef typename tested_sequence::allocation_traits tested_allocation_traits; typedef TAO::details::range_checking<value_type,true> range; - void test_ulong_constructor() + int test_ulong_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -44,46 +42,60 @@ struct Tester { tested_sequence x(16); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + // ulong constructor calls allocbuf and thus there must be + // maximum() default initilized elements. + FAIL_RETURN_IF_NOT(i.expect(16), i); + return 0; } - void test_copy_constructor_from_ulong() + int test_copy_constructor_from_ulong() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); expected_calls i(tested_element_traits::default_initializer_calls); + expected_calls r(tested_element_traits::release_calls); expected_calls d(tested_element_traits::duplicate_calls); { tested_sequence x(16); - BOOST_CHECK_MESSAGE(a.expect(1), a); + FAIL_RETURN_IF_NOT(a.expect(1), a); + // ulong constructor calls allocbuf and thus there must be + // maximum() default initilized elements. + FAIL_RETURN_IF_NOT(i.expect(16), i); x.length(8); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); - BOOST_CHECK_MESSAGE(i.expect(8), i); + // length() doesn't default initialize anything since initialization + // was done in ulong constructor. + FAIL_RETURN_IF_NOT(i.expect(0), i); tested_sequence y(x); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_EQUAL(CORBA::ULong(16), y.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), y.length()); - BOOST_CHECK_EQUAL(true, y.release()); - - BOOST_CHECK_MESSAGE(d.expect(8), d); + FAIL_RETURN_IF_NOT(a.expect(1), a); + CHECK_EQUAL(CORBA::ULong(16), y.maximum()); + CHECK_EQUAL(CORBA::ULong(8), y.length()); + CHECK_EQUAL(true, y.release()); + + FAIL_RETURN_IF_NOT(d.expect(8), d); + // Copy constructor must duplicate length() elements and default + // initilize rest maximum()-length(). + FAIL_RETURN_IF_NOT(i.expect(8), d); } - BOOST_CHECK_MESSAGE(f.expect(2), f); - BOOST_CHECK_MESSAGE(i.expect(0), i); + FAIL_RETURN_IF_NOT(f.expect(2), f); + // There must be 32 elements released since maximum() is 16. + FAIL_RETURN_IF_NOT(r.expect(32), i); + return 0; } - void test_set_length_less_than_maximum() + int test_set_length_less_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -92,51 +104,59 @@ struct Tester tested_sequence x(16); x.length(8); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); - BOOST_CHECK_MESSAGE(i.expect(8), i); + // ulong constructor calls allocbuf and thus there must be + // maximum() default initilized elements. + FAIL_RETURN_IF_NOT(i.expect(16), i); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_set_length_more_than_maximum() + int test_set_length_more_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); expected_calls i(tested_element_traits::default_initializer_calls); { tested_sequence x(16); - BOOST_CHECK_MESSAGE(a.expect(1), a); + FAIL_RETURN_IF_NOT(a.expect(1), a); x.length(32); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); - BOOST_CHECK_MESSAGE(i.expect(32), i); + // ulong constructor calls allocbuf and thus there must be + // maximum() default initilized elements + length() leads to buffer + // reallocation maximum() gets set to a new value. + FAIL_RETURN_IF_NOT(i.expect(48), i); - BOOST_CHECK_EQUAL(CORBA::ULong(32), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(32), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(32), x.maximum()); + CHECK_EQUAL(CORBA::ULong(32), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_exception_in_ulong_constructor() + int test_exception_in_ulong_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(tested_sequence x(16), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); + CHECK_THROW(tested_sequence x(16), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); } - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } - void test_exception_in_length() + int test_exception_in_length() { expected_calls f(tested_allocation_traits::freebuf_calls); expected_calls a(tested_allocation_traits::allocbuf_calls); @@ -154,29 +174,30 @@ struct Tester r.reset(); f.reset(); tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(y.length(8), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(d.expect(0), d); - BOOST_CHECK_MESSAGE(r.expect(0), r); + CHECK_THROW(y.length(8), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(d.expect(0), d); + FAIL_RETURN_IF_NOT(r.expect(0), r); - BOOST_CHECK_EQUAL(CORBA::ULong(4), y.length()); + CHECK_EQUAL(CORBA::ULong(4), y.length()); for(CORBA::ULong i = 0; i != 4; ++i) { - BOOST_CHECK_MESSAGE( + FAIL_RETURN_IF_NOT( helper::compare_test_string(y[i]), "Mismatch in element " << i << ", got=" << y[i]); } } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_duplicate_exception_in_length() + int test_default_initializer_exception_in_length() { expected_calls f(tested_allocation_traits::freebuf_calls); expected_calls a(tested_allocation_traits::allocbuf_calls); - expected_calls d(tested_element_traits::duplicate_calls); + expected_calls d(tested_element_traits::default_initializer_calls); expected_calls r(tested_element_traits::release_calls); { tested_sequence y; y.length(4); @@ -189,45 +210,51 @@ struct Tester d.reset(); r.reset(); f.reset(); - tested_element_traits::duplicate_calls.failure_countdown(3); - BOOST_CHECK_THROW(y.length(8), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(d.expect(3), d); - BOOST_CHECK_MESSAGE(r.expect(8), r); - - BOOST_CHECK_EQUAL(CORBA::ULong(4), y.length()); + tested_element_traits::default_initializer_calls.failure_countdown(3); + CHECK_THROW(y.length(8), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(d.expect(3), d); + FAIL_RETURN_IF_NOT(r.expect(8), r); + + CHECK_EQUAL(CORBA::ULong(4), y.length()); for(CORBA::ULong i = 0; i != 4; ++i) { - BOOST_CHECK_MESSAGE( + FAIL_RETURN_IF_NOT( helper::compare_test_string(y[i]), "Mismatch in element " << i << ", got=" << y[i]); } } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } value_type * alloc_and_init_buffer() { value_type * buf = tested_sequence::allocbuf(8); + delete[] buf[0]; buf[0] = helper::to_string(1); + delete[] buf[1]; buf[1] = helper::to_string(4); + delete[] buf[2]; buf[2] = helper::to_string(9); + delete[] buf[3]; buf[3] = helper::to_string(16); return buf; } - void check_values(tested_sequence const & a) + int check_values(tested_sequence const & a) { - BOOST_CHECK(helper::compare(1, a[0])); - BOOST_CHECK(helper::compare(4, a[1])); - BOOST_CHECK(helper::compare(9, a[2])); - BOOST_CHECK(helper::compare(16, a[3])); + CHECK(helper::compare(1, a[0])); + CHECK(helper::compare(4, a[1])); + CHECK(helper::compare(9, a[2])); + CHECK(helper::compare(16, a[3])); + return 0; } - void test_buffer_constructor_default() + int test_buffer_constructor_default() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); @@ -235,19 +262,20 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a(8, 4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(8), r); + FAIL_RETURN_IF_NOT(r.expect(8), r); + return 0; } - void test_buffer_constructor_false() + int test_buffer_constructor_false() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); @@ -255,19 +283,20 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a(8, 4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(8), r); + FAIL_RETURN_IF_NOT(r.expect(8), r); + return 0; } - void test_buffer_constructor_true() + int test_buffer_constructor_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); @@ -275,18 +304,19 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(true, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(true, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); - BOOST_CHECK_MESSAGE(r.expect(8), r); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(r.expect(8), r); + return 0; } - void test_replace_default() + int test_replace_default() { value_type * buffer = alloc_and_init_buffer(); @@ -296,23 +326,24 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(r.expect(0), 0); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), 0); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(8), r); + FAIL_RETURN_IF_NOT(r.expect(8), r); + return 0; } - void test_replace_false() + int test_replace_false() { value_type * buffer = alloc_and_init_buffer(); @@ -322,23 +353,24 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(r.expect(0), 0); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), 0); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(false, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(8), r); + FAIL_RETURN_IF_NOT(r.expect(8), r); + return 0; } - void test_replace_true() + int test_replace_true() { value_type * buffer = alloc_and_init_buffer(); @@ -347,46 +379,51 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a; - a.replace(8, 4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_MESSAGE(r.expect(0), r); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); + a.replace(8, 4, buffer, true); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + FAIL_RETURN_IF_NOT(r.expect(0), r); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(true, a.release()); check_values(a); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(8), r); + FAIL_RETURN_IF_NOT(c.expect(0), c); + // Since we've given away the ownership the buffer is deallocated by + // the sequence. + FAIL_RETURN_IF_NOT(f.expect(1), f); + FAIL_RETURN_IF_NOT(r.expect(8), r); + return 0; } - void test_get_buffer_default() + int test_get_buffer_default() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_false() + int test_get_buffer_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_true_with_release_false() + int test_get_buffer_true_with_release_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, false); - BOOST_CHECK(0 == a.get_buffer(true)); + CHECK(0 == a.get_buffer(true)); tested_sequence::freebuf(buffer); + return 0; } - void test_get_buffer_true_with_release_true() + int test_get_buffer_true_with_release_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); @@ -394,149 +431,99 @@ struct Tester expected_calls r(tested_element_traits::release_calls); { tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(buffer, a.get_buffer(true)); + CHECK_EQUAL(buffer, a.get_buffer(true)); tested_sequence const & b = a; - BOOST_CHECK_EQUAL(0UL, b.maximum()); - BOOST_CHECK_EQUAL(0UL, b.length()); - BOOST_CHECK(0 != b.get_buffer()); - BOOST_CHECK_EQUAL(true, b.release()); + CHECK_EQUAL(0UL, b.maximum()); + CHECK_EQUAL(0UL, b.length()); + CHECK(0 != b.get_buffer()); + CHECK_EQUAL(true, b.release()); - BOOST_CHECK_MESSAGE(c.expect(1), c); + FAIL_RETURN_IF_NOT(c.expect(1), c); - BOOST_CHECK(buffer != b.get_buffer()); + CHECK(buffer != b.get_buffer()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(1), f); tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(8), r); + FAIL_RETURN_IF_NOT(r.expect(8), r); + return 0; } - void test_regression_2201() + int test_regression_2201() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); expected_calls r(tested_element_traits::release_calls); { - tested_sequence a(8, 4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(false, a.release()); - check_values(a); - a.length (3); - BOOST_CHECK_EQUAL(CORBA::ULong(3), a.length()); - a.length (4); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK(helper::compare_empty(a[3])); + tested_sequence x(8, 4, buffer, true); + CHECK_EQUAL(CORBA::ULong(8), x.maximum()); + CHECK_EQUAL(CORBA::ULong(4), x.length()); + CHECK_EQUAL(buffer, x.get_buffer()); + CHECK_EQUAL(true, x.release()); + check_values(x); + x.length (3); + CHECK_EQUAL(CORBA::ULong(3), x.length()); + x.length (4); + CHECK_EQUAL(CORBA::ULong(4), x.length()); + CHECK(helper::compare_empty(x[3])); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - tested_sequence::freebuf(buffer); - BOOST_CHECK_MESSAGE(r.expect(8), r); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + // 1 additional release call happens when we shrink + // the sequence to length 3. + FAIL_RETURN_IF_NOT(r.expect(9), r); + return 0; } - void add_all(test_suite * ts) + int test_all() { + int status = 0; typedef string_sequence_tester<tested_sequence> common; - boost::shared_ptr<common> tester(common::allocate()); - tester->add_all(ts); - - boost::shared_ptr<Tester> shared_this(self_); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_ulong_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_copy_constructor_from_ulong, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_less_than_maximum, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_more_than_maximum, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_exception_in_ulong_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_exception_in_length, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_duplicate_exception_in_length, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_true, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_regression_2201, - shared_this)); + common tester; + status += tester.test_all (); + + status += this->test_ulong_constructor(); + status += this->test_copy_constructor_from_ulong(); + status += this->test_set_length_less_than_maximum(); + status += this->test_set_length_more_than_maximum(); + status += this->test_exception_in_ulong_constructor(); + status += this->test_exception_in_length(); + status += this->test_default_initializer_exception_in_length(); + status += this->test_buffer_constructor_default(); + status += this->test_buffer_constructor_false(); + status += this->test_buffer_constructor_true(); + status += this->test_replace_default(); + status += this->test_replace_false(); + status += this->test_replace_true(); + status += this->test_get_buffer_default(); + status += this->test_get_buffer_false(); + status += this->test_get_buffer_true_with_release_false(); + status += this->test_get_buffer_true_with_release_true(); + status += this->test_regression_2201(); + return status; } - - static boost::shared_ptr<Tester> allocate() - { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; - } - -private: Tester() {} - - boost::weak_ptr<Tester> self_; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("unbounded string sequence unit test"); - + int status = 0; { typedef Tester<unbounded_basic_string_sequence <char> > nTester; - boost::shared_ptr<nTester> tester(nTester::allocate()); - tester->add_all(ts); + nTester ntester; + status += ntester.test_all (); } +#if defined(ACE_HAS_WCHAR) { typedef Tester<unbounded_basic_string_sequence <CORBA::WChar> > wTester; - boost::shared_ptr<wTester> tester(wTester::allocate()); - tester->add_all(ts); + wTester wtester; + status += wtester.test_all (); } +#endif - return ts; + return status; } - diff --git a/TAO/tests/Sequence_Unit_Tests/unbounded_value_sequence_ut.cpp b/TAO/tests/Sequence_Unit_Tests/unbounded_value_sequence_ut.cpp index 2c42548cd69..8edf040fb69 100644 --- a/TAO/tests/Sequence_Unit_Tests/unbounded_value_sequence_ut.cpp +++ b/TAO/tests/Sequence_Unit_Tests/unbounded_value_sequence_ut.cpp @@ -15,11 +15,9 @@ #include "value_sequence_tester.hpp" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" + -using namespace boost::unit_test_framework; using namespace TAO_VERSIONED_NAMESPACE_NAME::TAO; typedef unbounded_value_sequence<int> tested_sequence; @@ -31,81 +29,85 @@ struct Tester { typedef tested_sequence::value_type value_type; - void test_copy_constructor_from_ulong() + int test_copy_constructor_from_ulong() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); - BOOST_CHECK_MESSAGE(a.expect(1), a); + FAIL_RETURN_IF_NOT(a.expect(1), a); x.length(8); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); tested_sequence y(x); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_EQUAL(CORBA::ULong(16), y.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), y.length()); - BOOST_CHECK_EQUAL(true, y.release()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + CHECK_EQUAL(CORBA::ULong(16), y.maximum()); + CHECK_EQUAL(CORBA::ULong(8), y.length()); + CHECK_EQUAL(true, y.release()); } - BOOST_CHECK_MESSAGE(f.expect(2), f); + FAIL_RETURN_IF_NOT(f.expect(2), f); + return 0; } - void test_assignment_from_ulong() + int test_assignment_from_ulong() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); x.length(8); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); tested_sequence y; - BOOST_CHECK_MESSAGE(a.expect(0), a); + FAIL_RETURN_IF_NOT(a.expect(0), a); y = x; - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - BOOST_CHECK_EQUAL(CORBA::ULong(16), y.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), y.length()); - BOOST_CHECK_EQUAL(true, y.release()); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(CORBA::ULong(16), y.maximum()); + CHECK_EQUAL(CORBA::ULong(8), y.length()); + CHECK_EQUAL(true, y.release()); } - BOOST_CHECK_MESSAGE(f.expect(2), f); + FAIL_RETURN_IF_NOT(f.expect(2), f); + return 0; } - void test_ulong_constructor() + int test_ulong_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_exception_in_ulong_constructor() + int test_exception_in_ulong_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(tested_sequence x(16), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); + CHECK_THROW(tested_sequence x(16), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); } - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } - void test_set_length_less_than_maximum() + int test_set_length_less_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); @@ -113,34 +115,36 @@ struct Tester tested_sequence x(16); x.length(8); - BOOST_CHECK_EQUAL(CORBA::ULong(16), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(8), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(16), x.maximum()); + CHECK_EQUAL(CORBA::ULong(8), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_set_length_more_than_maximum() + int test_set_length_more_than_maximum() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x(16); - BOOST_CHECK_MESSAGE(a.expect(1), a); + FAIL_RETURN_IF_NOT(a.expect(1), a); x.length(32); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); - BOOST_CHECK_EQUAL(CORBA::ULong(32), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(32), x.length()); - BOOST_CHECK_EQUAL(true, x.release()); + CHECK_EQUAL(CORBA::ULong(32), x.maximum()); + CHECK_EQUAL(CORBA::ULong(32), x.length()); + CHECK_EQUAL(true, x.release()); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_exception_in_set_length() + int test_exception_in_set_length() { expected_calls f(tested_allocation_traits::freebuf_calls); { @@ -148,10 +152,11 @@ struct Tester expected_calls a(tested_allocation_traits::allocbuf_calls); tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(x.length(8), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); + CHECK_THROW(x.length(8), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); } - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } value_type * alloc_and_init_buffer() @@ -162,34 +167,34 @@ struct Tester return buf; } - void test_regression_2201 () + int test_regression_2201 () { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { - tested_sequence a(8, 4, buffer); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); - a.length (3); - BOOST_CHECK_EQUAL(CORBA::ULong(3), a.length()); - a.length (4); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(int(0), a[3]); + tested_sequence x(8, 4, buffer, true); + CHECK_EQUAL(CORBA::ULong(8), x.maximum()); + CHECK_EQUAL(CORBA::ULong(4), x.length()); + CHECK_EQUAL(buffer, x.get_buffer()); + CHECK_EQUAL(int( 1), x[0]); + CHECK_EQUAL(int( 4), x[1]); + CHECK_EQUAL(int( 9), x[2]); + CHECK_EQUAL(int(16), x[3]); + CHECK_EQUAL(true, x.release()); + x.length (3); + CHECK_EQUAL(CORBA::ULong(3), x.length()); + x.length (4); + CHECK_EQUAL(CORBA::ULong(4), x.length()); + CHECK_EQUAL(int(0), x[3]); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); - tested_sequence::freebuf(buffer); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_buffer_constructor_default() + int test_buffer_constructor_default() { value_type * buffer = alloc_and_init_buffer(); @@ -197,62 +202,65 @@ struct Tester expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_buffer_constructor_false() + int test_buffer_constructor_false() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer, false); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_buffer_constructor_true() + int test_buffer_constructor_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(true, a.release()); + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(true, a.release()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_replace_default() + int test_replace_default() { value_type * buffer = alloc_and_init_buffer(); @@ -261,24 +269,25 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_replace_false() + int test_replace_false() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); @@ -287,24 +296,25 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer, false); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(false, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(false, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); tested_sequence::freebuf(buffer); + return 0; } - void test_replace_true() + int test_replace_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); @@ -313,165 +323,107 @@ struct Tester { tested_sequence a; a.replace(8, 4, buffer, true); - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(0), f); - - BOOST_CHECK_EQUAL(CORBA::ULong(8), a.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(4), a.length()); - BOOST_CHECK_EQUAL(buffer, a.get_buffer()); - BOOST_CHECK_EQUAL(int( 1), a[0]); - BOOST_CHECK_EQUAL(int( 4), a[1]); - BOOST_CHECK_EQUAL(int( 9), a[2]); - BOOST_CHECK_EQUAL(int(16), a[3]); - BOOST_CHECK_EQUAL(true, a.release()); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(0), f); + + CHECK_EQUAL(CORBA::ULong(8), a.maximum()); + CHECK_EQUAL(CORBA::ULong(4), a.length()); + CHECK_EQUAL(buffer, a.get_buffer()); + CHECK_EQUAL(int( 1), a[0]); + CHECK_EQUAL(int( 4), a[1]); + CHECK_EQUAL(int( 9), a[2]); + CHECK_EQUAL(int(16), a[3]); + CHECK_EQUAL(true, a.release()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_get_buffer_default() + int test_get_buffer_default() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_false() + int test_get_buffer_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(a.get_buffer(), buffer); + CHECK_EQUAL(a.get_buffer(), buffer); + return 0; } - void test_get_buffer_true_with_release_false() + int test_get_buffer_true_with_release_false() { value_type * buffer = alloc_and_init_buffer(); tested_sequence a(8, 4, buffer, false); - BOOST_CHECK(0 == a.get_buffer(true)); + CHECK(0 == a.get_buffer(true)); tested_sequence::freebuf(buffer); + return 0; } - void test_get_buffer_true_with_release_true() + int test_get_buffer_true_with_release_true() { value_type * buffer = alloc_and_init_buffer(); expected_calls c(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence a(8, 4, buffer, true); - BOOST_CHECK_EQUAL(buffer, a.get_buffer(true)); + CHECK_EQUAL(buffer, a.get_buffer(true)); tested_sequence const & b = a; - BOOST_CHECK_EQUAL(0UL, b.maximum()); - BOOST_CHECK_EQUAL(0UL, b.length()); - BOOST_CHECK(0 != b.get_buffer()); - BOOST_CHECK_EQUAL(true, b.release()); + CHECK_EQUAL(0UL, b.maximum()); + CHECK_EQUAL(0UL, b.length()); + CHECK(0 != b.get_buffer()); + CHECK_EQUAL(true, b.release()); - BOOST_CHECK_MESSAGE(c.expect(1), c); + FAIL_RETURN_IF_NOT(c.expect(1), c); - BOOST_CHECK(buffer != b.get_buffer()); + CHECK(buffer != b.get_buffer()); } - BOOST_CHECK_MESSAGE(c.expect(0), c); - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(c.expect(0), c); + FAIL_RETURN_IF_NOT(f.expect(1), f); tested_sequence::freebuf(buffer); + return 0; } - void add_all(test_suite * ts) - { - boost::shared_ptr<Tester> shared_this(self_); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_ulong_constructor, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_copy_constructor_from_ulong, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_assignment_from_ulong, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_exception_in_ulong_constructor, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_less_than_maximum, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_set_length_more_than_maximum, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_exception_in_set_length, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_regression_2201 , - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_buffer_constructor_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_replace_true, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_false, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &Tester::test_get_buffer_true_with_release_true, - shared_this)); - - } - - static boost::shared_ptr<Tester> allocate() + int test_all() { - boost::shared_ptr<Tester> ptr(new Tester); - ptr->self_ = ptr; - - return ptr; + int status = 0; + status += this->test_ulong_constructor(); + status += this->test_copy_constructor_from_ulong(); + status += this->test_assignment_from_ulong(); + status += this->test_exception_in_ulong_constructor(); + status += this->test_set_length_less_than_maximum(); + status += this->test_set_length_more_than_maximum(); + status += this->test_exception_in_set_length(); + status += this->test_regression_2201 (); + status += this->test_buffer_constructor_default(); + status += this->test_buffer_constructor_false(); + status += this->test_buffer_constructor_true(); + status += this->test_replace_default(); + status += this->test_replace_false(); + status += this->test_replace_true(); + status += this->test_get_buffer_false(); + status += this->test_get_buffer_true_with_release_false(); + status += this->test_get_buffer_true_with_release_true(); + return status; } - -private: Tester() {} - - boost::weak_ptr<Tester> self_; }; -ACE_Proper_Export_Flag test_suite * -init_unit_test_suite(int, char*[]) +int ACE_TMAIN(int,ACE_TCHAR*[]) { - test_suite * ts = - BOOST_TEST_SUITE("unbounded value sequence unit test"); - - { - boost::shared_ptr<Tester> tester(Tester::allocate()); - tester->add_all(ts); - } + int status = 0; + Tester tester; + status += tester.test_all (); - { - typedef value_sequence_tester<tested_sequence,tested_allocation_traits> common; - boost::shared_ptr<common> tester(common::allocate()); - tester->add_all(ts); - } + typedef value_sequence_tester<tested_sequence,tested_allocation_traits> common; + common tester2; + status += tester2.test_all (); - return ts; + return status; } - diff --git a/TAO/tests/Sequence_Unit_Tests/value_sequence_tester.hpp b/TAO/tests/Sequence_Unit_Tests/value_sequence_tester.hpp index 7e502dc966d..0ed88485cf9 100644 --- a/TAO/tests/Sequence_Unit_Tests/value_sequence_tester.hpp +++ b/TAO/tests/Sequence_Unit_Tests/value_sequence_tester.hpp @@ -11,9 +11,7 @@ */ #include "tao/Basic_Types.h" -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <boost/weak_ptr.hpp> +#include "test_macros.h" TAO_BEGIN_VERSIONED_NAMESPACE_DECL @@ -24,57 +22,62 @@ struct value_sequence_tester typedef typename tested_sequence::value_type value_type; typedef typename tested_sequence::const_value_type const_value_type; - void test_default_constructor() + int test_default_constructor() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x; - BOOST_CHECK_EQUAL( + CHECK_EQUAL( CORBA::ULong(tested_allocation_traits::default_maximum()), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(bounded_, x.release()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); } - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_MESSAGE(f.expect(bounded_ ? 1 : 0), f); + FAIL_RETURN_IF_NOT(a.expect(0), a); + // Nothing was allocated then there is nothing to free. + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } - void test_copy_constructor_from_default() + int test_copy_constructor_from_default() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x; - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_EQUAL( + FAIL_RETURN_IF_NOT(a.expect(0), a); + CHECK_EQUAL( CORBA::ULong(tested_allocation_traits::default_maximum()), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(bounded_, x.release()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); tested_sequence y(x); - BOOST_CHECK_MESSAGE(a.expect(bounded_ ? 1 : 0), a); - BOOST_CHECK_EQUAL(x.maximum(), y.maximum()); - BOOST_CHECK_EQUAL(x.length(), y.length()); - BOOST_CHECK_EQUAL(x.release(), y.release()); + // Default constructed sequence doesn't have elements, + // thus there is nothing to allocate/copy in copy constructor. + FAIL_RETURN_IF_NOT(a.expect(0), a); + CHECK_EQUAL(x.maximum(), y.maximum()); + CHECK_EQUAL(x.length(), y.length()); + CHECK_EQUAL(x.release(), y.release()); } - BOOST_CHECK_MESSAGE(f.expect(bounded_ ? 2 : 0), f); + // Nothing was allocated then there is nothing to free. + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } - void test_index_accessor() + int test_index_accessor() { tested_sequence x; x.length(8); tested_sequence const & y = x; const_value_type & z = y[4]; - BOOST_CHECK_EQUAL(z, y[4]); + CHECK_EQUAL(z, y[4]); + return 0; } - void test_index_modifier() + int test_index_modifier() { tested_sequence x; x.length(8); @@ -82,12 +85,13 @@ struct value_sequence_tester tested_sequence const & y = x; const_value_type & z = y[4]; x[4] = 4; - BOOST_CHECK_EQUAL(4, x[4]); - BOOST_CHECK_EQUAL(4, y[4]); - BOOST_CHECK_EQUAL(4, z); + CHECK_EQUAL(4, x[4]); + CHECK_EQUAL(4, y[4]); + CHECK_EQUAL(4, z); + return 0; } - void test_index_checking() + int test_index_checking() { tested_sequence x; x.length(8); @@ -95,52 +99,57 @@ struct value_sequence_tester tested_sequence const & y = x; int z = 0; - BOOST_CHECK_THROW(z = y[32], std::range_error); - BOOST_CHECK_THROW(x[32] = z, std::range_error); + CHECK_THROW(z = y[32], std::range_error); + CHECK_THROW(x[32] = z, std::range_error); + return 0; } - void test_copy_constructor_values() + int test_copy_constructor_values() { tested_sequence a; a.length(16); for(CORBA::ULong i = 0; i != 16; ++i) a[i] = i*i; tested_sequence b(a); - BOOST_CHECK_EQUAL(a.length(), b.length()); + CHECK_EQUAL(a.length(), b.length()); for(CORBA::ULong i = 0; i != a.length(); ++i) { - BOOST_CHECK_MESSAGE(a[i] == b[i], + FAIL_RETURN_IF_NOT(a[i] == b[i], "Mismatched elements at index " << i); } + return 0; } - void test_assignment_from_default() + int test_assignment_from_default() { expected_calls a(tested_allocation_traits::allocbuf_calls); expected_calls f(tested_allocation_traits::freebuf_calls); { tested_sequence x; - BOOST_CHECK_MESSAGE(a.expect(0), a); - BOOST_CHECK_EQUAL( + FAIL_RETURN_IF_NOT(a.expect(0), a); + CHECK_EQUAL( CORBA::ULong(tested_allocation_traits::default_maximum()), x.maximum()); - BOOST_CHECK_EQUAL(CORBA::ULong(0), x.length()); - BOOST_CHECK_EQUAL(bounded_, x.release()); + CHECK_EQUAL(CORBA::ULong(0), x.length()); tested_sequence y; - BOOST_CHECK_MESSAGE(a.expect(0), a); + FAIL_RETURN_IF_NOT(a.expect(0), a); y = x; - BOOST_CHECK_MESSAGE(a.expect(bounded_ ? 1 : 0), a); - BOOST_CHECK_MESSAGE(f.expect(bounded_ ? 1 : 0), f); - BOOST_CHECK_EQUAL(x.maximum(), y.maximum()); - BOOST_CHECK_EQUAL(x.length(), y.length()); - BOOST_CHECK_EQUAL(x.release(), y.release()); + // Default constructed sequence doesn't have elements, + // thus there is nothing to allocate/copy in operator=. + FAIL_RETURN_IF_NOT(a.expect(0), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); + CHECK_EQUAL(x.maximum(), y.maximum()); + CHECK_EQUAL(x.length(), y.length()); + CHECK_EQUAL(x.release(), y.release()); } - BOOST_CHECK_MESSAGE(f.expect(bounded_ ? 2 : 0), f); + // Nothing was allocated then there is nothing to free. + FAIL_RETURN_IF_NOT(f.expect(0), f); + return 0; } - void test_assignment_values() + int test_assignment_values() { tested_sequence a; a.length(16); @@ -148,17 +157,18 @@ struct value_sequence_tester tested_sequence b; b = a; - BOOST_CHECK_EQUAL(a.maximum(), b.maximum()); - BOOST_CHECK_EQUAL(a.length(), b.length()); - BOOST_CHECK_EQUAL(a.release(), b.release()); + CHECK_EQUAL(a.maximum(), b.maximum()); + CHECK_EQUAL(a.length(), b.length()); + CHECK_EQUAL(a.release(), b.release()); for(CORBA::ULong i = 0; i != a.length(); ++i) { - BOOST_CHECK_MESSAGE(a[i] == b[i], + FAIL_RETURN_IF_NOT(a[i] == b[i], "Mismatched elements at index " << i); } + return 0; } - void test_exception_in_copy_constructor() + int test_exception_in_copy_constructor() { expected_calls f(tested_allocation_traits::freebuf_calls); { @@ -167,13 +177,14 @@ struct value_sequence_tester expected_calls a(tested_allocation_traits::allocbuf_calls); tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(tested_sequence y(x), testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); + CHECK_THROW(tested_sequence y(x), testing_exception); + FAIL_RETURN_IF_NOT(a.expect(1), a); } - BOOST_CHECK_MESSAGE(f.expect(1), f); + FAIL_RETURN_IF_NOT(f.expect(1), f); + return 0; } - void test_exception_in_assignment() + int test_exception_in_assignment() { expected_calls f(tested_allocation_traits::freebuf_calls); { @@ -184,17 +195,18 @@ struct value_sequence_tester expected_calls a(tested_allocation_traits::allocbuf_calls); f.reset(); tested_allocation_traits::allocbuf_calls.failure_countdown(1); - BOOST_CHECK_THROW(y = x, testing_exception); + CHECK_THROW(y = x, testing_exception); - BOOST_CHECK_MESSAGE(a.expect(1), a); - BOOST_CHECK_MESSAGE(f.expect(0), f); + FAIL_RETURN_IF_NOT(a.expect(1), a); + FAIL_RETURN_IF_NOT(f.expect(0), f); - BOOST_CHECK_EQUAL(CORBA::ULong(3), y.length()); + CHECK_EQUAL(CORBA::ULong(3), y.length()); } - BOOST_CHECK_MESSAGE(f.expect(2), f); + FAIL_RETURN_IF_NOT(f.expect(2), f); + return 0; } - void test_get_buffer_const() + int test_get_buffer_const() { tested_sequence a; a.length(4); tested_sequence const & b = a; @@ -202,70 +214,30 @@ struct value_sequence_tester value_type const * buffer = b.get_buffer(); a[0] = 1; a[1] = 4; a[2] = 9; a[3] = 16; - BOOST_CHECK_EQUAL(1, buffer[0]); - BOOST_CHECK_EQUAL(4, buffer[1]); - BOOST_CHECK_EQUAL(9, buffer[2]); - BOOST_CHECK_EQUAL(16, buffer[3]); + CHECK_EQUAL(1, buffer[0]); + CHECK_EQUAL(4, buffer[1]); + CHECK_EQUAL(9, buffer[2]); + CHECK_EQUAL(16, buffer[3]); + return 0; } - void add_all(boost::unit_test_framework::test_suite * ts) + int test_all() { - boost::shared_ptr<value_sequence_tester> shared_this(self_); - - ts->add(BOOST_CLASS_TEST_CASE( - &value_sequence_tester::test_default_constructor, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &value_sequence_tester::test_copy_constructor_from_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &value_sequence_tester::test_index_accessor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &value_sequence_tester::test_index_modifier, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &value_sequence_tester::test_index_checking, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &value_sequence_tester::test_copy_constructor_values, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &value_sequence_tester::test_assignment_from_default, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &value_sequence_tester::test_assignment_values, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &value_sequence_tester::test_exception_in_copy_constructor, - shared_this)); - ts->add(BOOST_CLASS_TEST_CASE( - &value_sequence_tester::test_exception_in_assignment, - shared_this)); - - ts->add(BOOST_CLASS_TEST_CASE( - &value_sequence_tester::test_get_buffer_const, - shared_this)); + int status = 0; + + status +=this->test_default_constructor(); + status +=this->test_copy_constructor_from_default(); + status +=this->test_index_accessor(); + status +=this->test_index_modifier(); + status +=this->test_index_checking(); + status +=this->test_copy_constructor_values(); + status +=this->test_assignment_from_default(); + status +=this->test_assignment_values(); + status +=this->test_exception_in_copy_constructor(); + status +=this->test_exception_in_assignment(); + status +=this->test_get_buffer_const(); + return status; } - - static boost::shared_ptr<value_sequence_tester> allocate(bool bounded = false) - { - boost::shared_ptr<value_sequence_tester> ptr( - new value_sequence_tester(bounded)); - ptr->self_ = ptr; - - return ptr; - } - -private: - value_sequence_tester(bool bounded) - : bounded_ (bounded) - {} - - bool bounded_; - boost::weak_ptr<value_sequence_tester> self_; }; TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tests/TransportCurrent/lib/Client_Request_Interceptor.cpp b/TAO/tests/TransportCurrent/lib/Client_Request_Interceptor.cpp index 1d173d3423d..8a27b51a923 100644 --- a/TAO/tests/TransportCurrent/lib/Client_Request_Interceptor.cpp +++ b/TAO/tests/TransportCurrent/lib/Client_Request_Interceptor.cpp @@ -87,7 +87,7 @@ namespace Test { ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_); - ACE_OS::sprintf (temp, "%d", this->requestID_); + ACE_OS::sprintf (temp, "%ld", this->requestID_); ++this->requestID_; } diff --git a/TAO/tests/Transport_Cache_Manager/run_test.pl b/TAO/tests/Transport_Cache_Manager/run_test.pl index b9fe5f3fd00..8758546c585 100755 --- a/TAO/tests/Transport_Cache_Manager/run_test.pl +++ b/TAO/tests/Transport_Cache_Manager/run_test.pl @@ -11,14 +11,10 @@ use strict; my $final_result = 0; -my @tests = qw(Bug_3549_Regression +my @testsToRun = qw(Bug_3549_Regression Bug_3558_Regression ); -my @testsToRun = qw(); - -push(@testsToRun, @tests); - foreach my $process (@testsToRun) { my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; diff --git a/TAO/tests/Xt_Stopwatch/Client.h b/TAO/tests/Xt_Stopwatch/Client.h index 3ca196aea06..45162e4daf3 100644 --- a/TAO/tests/Xt_Stopwatch/Client.h +++ b/TAO/tests/Xt_Stopwatch/Client.h @@ -19,7 +19,7 @@ #include "testC.h" -#include "tao/XtResource_Loader.h" +#include "tao/XtResource/XtResource_Loader.h" class Control; class Client diff --git a/TAO/tests/Xt_Stopwatch/Stopwatch_display.cpp b/TAO/tests/Xt_Stopwatch/Stopwatch_display.cpp index 05cdcd2ccc8..35c42b14cbe 100644 --- a/TAO/tests/Xt_Stopwatch/Stopwatch_display.cpp +++ b/TAO/tests/Xt_Stopwatch/Stopwatch_display.cpp @@ -50,7 +50,7 @@ Stopwatch_display::set_time (CORBA::Float time) XmString xmstr = XmStringCreateSimple (buf); // Display the string in the Label widget - XtVaSetValues (this->label_, XmNlabelString, xmstr, 0); + XtVaSetValues (this->label_, XmNlabelString, xmstr, static_cast<void *>(0)); //??Can use XtSetValues with ac and al values.. // The compound string can be freed once passed to the widget diff --git a/TAO/tests/Xt_Stopwatch/server.cpp b/TAO/tests/Xt_Stopwatch/server.cpp index 3400a68bdd5..80fc60a15f4 100644 --- a/TAO/tests/Xt_Stopwatch/server.cpp +++ b/TAO/tests/Xt_Stopwatch/server.cpp @@ -8,7 +8,7 @@ ACE_RCSID (Xt_Stopwatch, server, "$Id$") -#include "tao/XtResource_Loader.h" +#include "tao/XtResource/XtResource_Loader.h" #include <Xm/Xm.h> #include "Stopwatch_display.h" #include "timer.h" diff --git a/TAO/tests/Xt_Stopwatch/timer.cpp b/TAO/tests/Xt_Stopwatch/timer.cpp index ce807616e3e..c4fbf9ce71c 100644 --- a/TAO/tests/Xt_Stopwatch/timer.cpp +++ b/TAO/tests/Xt_Stopwatch/timer.cpp @@ -13,6 +13,10 @@ Timer_imp::Timer_imp (XtAppContext &app, { } +Timer_imp::~Timer_imp () +{ +} + void Timer_imp::start (void) { diff --git a/TAO/tests/Xt_Stopwatch/timer.h b/TAO/tests/Xt_Stopwatch/timer.h index 6c2362cb1a3..1708bbc8428 100644 --- a/TAO/tests/Xt_Stopwatch/timer.h +++ b/TAO/tests/Xt_Stopwatch/timer.h @@ -29,7 +29,10 @@ class Timer_imp Timer_imp (XtAppContext &, CORBA::Long, Stopwatch_display *); - // Constructor.. + // Constructor + + virtual ~Timer_imp (); + // Destructor void start (void); // Resets, and starts the clock ticking diff --git a/TAO/tests/ZIOP/Hello.cpp b/TAO/tests/ZIOP/Hello.cpp index db7ffe13818..ab73744cbe1 100644 --- a/TAO/tests/ZIOP/Hello.cpp +++ b/TAO/tests/ZIOP/Hello.cpp @@ -27,6 +27,12 @@ Hello::get_big_reply () reply_mesg->length (this->length_); + for (unsigned int i = 0; i < this->length_; ++i) + { + int size = 128; + for (int ch = 0; ch < size && i < this->length_ - 1; ++ch) + reply_mesg[++i] = ACE_OS::rand() % size--; + } return reply_mesg._retn (); } diff --git a/TAO/tests/ZIOP/TestCompressor/TAO_TestCompressor.pc.in b/TAO/tests/ZIOP/TestCompressor/TAO_TestCompressor.pc.in new file mode 100644 index 00000000000..dbcaedd3928 --- /dev/null +++ b/TAO/tests/ZIOP/TestCompressor/TAO_TestCompressor.pc.in @@ -0,0 +1,11 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: TAO_TEST_COMPRESSOR +Description: TAO Zlib Compression Library +Requires: TAO_Compression +Version: @VERSION@ +Libs: -L${libdir} -lTAO_TEST_Compressor +Cflags: -I${includedir} diff --git a/TAO/tests/ZIOP/TestCompressor/TAO_TestCompressor.rc b/TAO/tests/ZIOP/TestCompressor/TAO_TestCompressor.rc new file mode 100644 index 00000000000..9ed1be28a2e --- /dev/null +++ b/TAO/tests/ZIOP/TestCompressor/TAO_TestCompressor.rc @@ -0,0 +1,30 @@ +#include "..\..\tao\Version.h" + +1 VERSIONINFO + FILEVERSION TAO_MAJOR_VERSION,TAO_MINOR_VERSION,TAO_BETA_VERSION,0 + PRODUCTVERSION TAO_MAJOR_VERSION,TAO_MINOR_VERSION,TAO_BETA_VERSION,0 + FILEFLAGSMASK 0x3fL + FILEFLAGS 0x0L + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "FileDescription", "TESTCOMPRESSOR\0" + VALUE "FileVersion", TAO_VERSION "\0" + VALUE "InternalName", "TAO_TESTCOMPRESSORDLL\0" + VALUE "LegalCopyright", "\0" + VALUE "LegalTrademarks", "\0" + VALUE "OriginalFilename", "TAO_TESTCOMPRESSOR.DLL\0" + VALUE "ProductName", "TAO\0" + VALUE "ProductVersion", TAO_VERSION "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/TAO/tests/ZIOP/TestCompressor/TestCompressor.cpp b/TAO/tests/ZIOP/TestCompressor/TestCompressor.cpp new file mode 100644 index 00000000000..ef1bba0bc57 --- /dev/null +++ b/TAO/tests/ZIOP/TestCompressor/TestCompressor.cpp @@ -0,0 +1,36 @@ +#include "TestCompressor.h" + +ACE_RCSID (TEST, + TestCompressor, + "$Id$") + + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ +TestCompressor::TestCompressor ( + ::Compression::CompressionLevel compression_level, + ::Compression::CompressorFactory_ptr compressor_factory) : + BaseCompressor (compression_level, compressor_factory) +{ +} + +void +TestCompressor::compress ( + const ::Compression::Buffer &, + ::Compression::Buffer &) +{ + throw ::Compression::CompressionException (0, ""); +} + +void +TestCompressor::decompress ( + const ::Compression::Buffer &, + ::Compression::Buffer &) +{ + throw ::Compression::CompressionException (0, ""); +} +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tests/ZIOP/TestCompressor/TestCompressor.h b/TAO/tests/ZIOP/TestCompressor/TestCompressor.h new file mode 100644 index 00000000000..4cc3b4ee8a0 --- /dev/null +++ b/TAO/tests/ZIOP/TestCompressor/TestCompressor.h @@ -0,0 +1,53 @@ +// -*- C++ -*- + +// =================================================================== +/** + * @file TestCompressor.h + * + * $Id$ + * + * See http://www.zlib.net/manual.html for the zlib interface itself + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +// =================================================================== + +#ifndef TAO_TESTCOMPRESSOR_H +#define TAO_TESTCOMPRESSOR_H + +#include /**/ "ace/pre.h" + +#include "TestCompressor_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Compression/Compression.h" +#include "tao/Compression/Base_Compressor.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + class TAO_TESTCOMPRESSOR_Export TestCompressor : public BaseCompressor + { + public: + TestCompressor (::Compression::CompressionLevel compression_level, + ::Compression::CompressorFactory_ptr compressor_factory); + + virtual void compress ( + const ::Compression::Buffer &, + ::Compression::Buffer &); + + virtual void decompress ( + const ::Compression::Buffer &, + ::Compression::Buffer &); + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_TESTCOMPRESSOR_H */ diff --git a/TAO/tests/ZIOP/TestCompressor/TestCompressor_Factory.cpp b/TAO/tests/ZIOP/TestCompressor/TestCompressor_Factory.cpp new file mode 100644 index 00000000000..276edc0c121 --- /dev/null +++ b/TAO/tests/ZIOP/TestCompressor/TestCompressor_Factory.cpp @@ -0,0 +1,33 @@ +#include "TestCompressor_Factory.h" +#include "TestCompressor.h" + +ACE_RCSID (TEST, + TestCompressor_Factory, + "$Id$") + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + +Test_CompressorFactory::Test_CompressorFactory (void) : + ::TAO::CompressorFactory (COMPRESSORID_FOR_TESTING), + compressor_ (::Compression::Compressor::_nil ()) +{ +} + +::Compression::Compressor_ptr +Test_CompressorFactory::get_compressor ( + ::Compression::CompressionLevel compression_level) +{ + // @todo, make a array based on compression level + if (CORBA::is_nil (compressor_.in ())) + { + compressor_ = new TestCompressor (compression_level, this); + } + + return ::Compression::Compressor::_duplicate (compressor_.in ()); +} +} + +TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tests/ZIOP/TestCompressor/TestCompressor_Factory.h b/TAO/tests/ZIOP/TestCompressor/TestCompressor_Factory.h new file mode 100644 index 00000000000..3fd02e8d68a --- /dev/null +++ b/TAO/tests/ZIOP/TestCompressor/TestCompressor_Factory.h @@ -0,0 +1,50 @@ +// -*- C++ -*- + +// =================================================================== +/** + * @file TestCompressor_Factory.h + * + * $Id$ + * + * @author Johnny Willemsen <jwillemsen@remedy.nl> + */ +// =================================================================== + +#ifndef TAO_TESTCOMPRESSOR_FACTORY_H +#define TAO_TESTCOMPRESSOR_FACTORY_H + +#include /**/ "ace/pre.h" + +#include "TestCompressor_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/Compression/Compression.h" +#include "tao/Compression/Compressor_Factory.h" + +#define COMPRESSORID_FOR_TESTING 10 + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO +{ + class TAO_TESTCOMPRESSOR_Export Test_CompressorFactory : + public ::TAO::CompressorFactory + { + public: + Test_CompressorFactory (void); + + virtual ::Compression::Compressor_ptr get_compressor ( + ::Compression::CompressionLevel compression_level); + private: + ::Compression::Compressor_var compressor_; + }; +} + +TAO_END_VERSIONED_NAMESPACE_DECL + +#include /**/ "ace/post.h" + +#endif /* TAO_TESTCOMPRESSOR_FACTORY_H */ diff --git a/TAO/tests/ZIOP/TestCompressor/TestCompressor_export.h b/TAO/tests/ZIOP/TestCompressor/TestCompressor_export.h new file mode 100644 index 00000000000..47490000514 --- /dev/null +++ b/TAO/tests/ZIOP/TestCompressor/TestCompressor_export.h @@ -0,0 +1,40 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl +// ------------------------------ +#ifndef TAO_TESTCOMPRESSOR_EXPORT_H +#define TAO_TESTCOMPRESSOR_EXPORT_H + +#include "ace/config-all.h" + +#if defined (TAO_AS_STATIC_LIBS) +# if !defined (TAO_TESTCOMPRESSOR_HAS_DLL) +# define TAO_TESTCOMPRESSOR_HAS_DLL 0 +# endif /* ! TAO_TESTCOMPRESSOR_HAS_DLL */ +#else +# if !defined (TAO_TESTCOMPRESSOR_HAS_DLL) +# define TAO_TESTCOMPRESSOR_HAS_DLL 1 +# endif /* ! TAO_TESTCOMPRESSOR_HAS_DLL */ +#endif + +#if defined (TAO_TESTCOMPRESSOR_HAS_DLL) && (TAO_TESTCOMPRESSOR_HAS_DLL == 1) +# if defined (TAO_TESTCOMPRESSOR_BUILD_DLL) +# define TAO_TESTCOMPRESSOR_Export ACE_Proper_Export_Flag +# define TAO_TESTCOMPRESSOR_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define TAO_TESTCOMPRESSOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* TAO_TESTCOMPRESSOR_BUILD_DLL */ +# define TAO_TESTCOMPRESSOR_Export ACE_Proper_Import_Flag +# define TAO_TESTCOMPRESSOR_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define TAO_TESTCOMPRESSOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* TAO_TESTCOMPRESSOR_BUILD_DLL */ +#else /* TAO_TESTCOMPRESSOR_HAS_DLL == 1 */ +# define TAO_TESTCOMPRESSOR_Export +# define TAO_TESTCOMPRESSOR_SINGLETON_DECLARATION(T) +# define TAO_TESTCOMPRESSOR_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* TAO_TESTCOMPRESSOR_HAS_DLL == 1 */ + +#endif /* TAO_TESTCOMPRESSOR_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/tests/ZIOP/ZIOP.mpc b/TAO/tests/ZIOP/ZIOP.mpc index 1028aff1069..46851aab44f 100644 --- a/TAO/tests/ZIOP/ZIOP.mpc +++ b/TAO/tests/ZIOP/ZIOP.mpc @@ -1,6 +1,43 @@ // -*- MPC -*- // $Id$ +project(TestCompressor) : taolib, compression, taoidldefaults { + sharedname = TAO_TestCompressor + dynamicflags = TAO_TESTCOMPRESSOR_BUILD_DLL + + Source_Files { + TestCompressor + } + + Header_Files { + TestCompressor + } + + Inline_Files { + TestCompressor + } + + Template_Files { + TestCompressor + } + + Resource_Files { + TestCompressor + } + + PIDL_Files { + TestCompressor + } + + IDL_Files { + TestCompressor + } + + Pkgconfig_Files { + TestCompressor/TAO_TestCompressor.pc.in + } +} + project(*idl): taoidldefaults { IDL_Files { Test.idl @@ -8,7 +45,7 @@ project(*idl): taoidldefaults { custom_only = 1 } -project(*Server): taoserver, compression, ziop, codecfactory, zlibcompressor { +project(*Server): taoserver, compression, ziop, codecfactory, zlibcompressor, bzip2compressor, testcompressor { after += *idl Source_Files { Hello.cpp @@ -22,7 +59,7 @@ project(*Server): taoserver, compression, ziop, codecfactory, zlibcompressor { } } -project(*Client): taoclient, compression, ziop, codecfactory, zlibcompressor, tc { +project(*Client): taoclient, compression, ziop, codecfactory, zlibcompressor, bzip2compressor, testcompressor, tc { after += *idl Source_Files { client.cpp diff --git a/TAO/tests/ZIOP/client.cpp b/TAO/tests/ZIOP/client.cpp index badddc7e070..0f4304527a1 100644 --- a/TAO/tests/ZIOP/client.cpp +++ b/TAO/tests/ZIOP/client.cpp @@ -5,17 +5,23 @@ #include "tao/ZIOP/ZIOP.h" #include "ace/OS.h" #include "tao/Compression/zlib/ZlibCompressor_Factory.h" -#include "tao/ORB_Constants.h" -#include "tao/TransportCurrent/TCC.h" +#include "tao/Compression/bzip2/Bzip2Compressor_Factory.h" +#include "TestCompressor//TestCompressor_Factory.h" ACE_RCSID(Hello, client, "$Id$") +#define DEFAULT_COMPRESSION_LEVEL 6 +::Compression::CompressionManager_var compression_manager = 0; const ACE_TCHAR *ior = ACE_TEXT("file://test.ior"); +int test = 1; + +int start_tests (Test::Hello_ptr hello, CORBA::ORB_ptr orb); + int parse_args (int argc, ACE_TCHAR *argv[]) { - ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:")); + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:t:")); int c; while ((c = get_opts ()) != -1) @@ -24,6 +30,9 @@ parse_args (int argc, ACE_TCHAR *argv[]) case 'k': ior = get_opts.opt_arg (); break; + case 't': + test = ACE_OS::atoi (get_opts.opt_arg ()); + break; case '?': default: @@ -38,34 +47,250 @@ parse_args (int argc, ACE_TCHAR *argv[]) return 0; } -void log_statistics (ACE_TCHAR* test, - ::TAO::CounterT initial_bytes_send, - ::TAO::CounterT initial_bytes_recv, - ::TAO::CounterT bytes_send_after_test, - ::TAO::CounterT bytes_recv_after_test) +int +register_factories (CORBA::ORB_ptr orb) +{ + CORBA::Object_var compression_manager_obj = + orb->resolve_initial_references("CompressionManager"); + + compression_manager = ::Compression::CompressionManager::_narrow ( + compression_manager_obj.in ()); + + if (CORBA::is_nil(compression_manager.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil compression manager\n"), + 1); + //register Zlib compressor + ::Compression::CompressorFactory_ptr compressor_factory; + ACE_NEW_RETURN (compressor_factory, TAO::Zlib_CompressorFactory (), 1); + ::Compression::CompressorFactory_var compr_fact = compressor_factory; + compression_manager->register_factory(compr_fact.in ()); + + // register bzip2 compressor + ACE_NEW_RETURN (compressor_factory, TAO::Bzip2_CompressorFactory (), 1); + compr_fact = compressor_factory; + compression_manager->register_factory(compr_fact.in ()); + + // register test compressor + ACE_NEW_RETURN (compressor_factory, TAO::Test_CompressorFactory (), 1); + compr_fact = compressor_factory; + compression_manager->register_factory(compr_fact.in ()); + return 0; +} + +CORBA::Policy_ptr +create_compressor_id_level_list_policy (CORBA::ORB_ptr orb, bool add_zlib_for_test_1) +{ + ::Compression::CompressorIdLevelList compressor_id_list; + + switch (test) + { + case 1: + if (add_zlib_for_test_1) + compressor_id_list.length(2); + else + compressor_id_list.length(1); + compressor_id_list[0].compressor_id = ::Compression::COMPRESSORID_LZO; + compressor_id_list[0].compression_level = DEFAULT_COMPRESSION_LEVEL; + if (add_zlib_for_test_1) + { + compressor_id_list[1].compressor_id = ::Compression::COMPRESSORID_ZLIB; + compressor_id_list[1].compression_level = DEFAULT_COMPRESSION_LEVEL; + } + break; + case 2: + compressor_id_list.length(1); + compressor_id_list[0].compressor_id = COMPRESSORID_FOR_TESTING; + compressor_id_list[0].compression_level = DEFAULT_COMPRESSION_LEVEL; + break; + case 3: + case 4: + default: + compressor_id_list.length(2); + compressor_id_list[0].compressor_id = ::Compression::COMPRESSORID_ZLIB; + compressor_id_list[0].compression_level = DEFAULT_COMPRESSION_LEVEL; + compressor_id_list[1].compressor_id = ::Compression::COMPRESSORID_BZIP2; + compressor_id_list[1].compression_level = DEFAULT_COMPRESSION_LEVEL; + break; + } + CORBA::Any compressor_id_any; + compressor_id_any <<= compressor_id_list; + + return orb->create_policy (ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID, compressor_id_any); +} + +CORBA::Policy_ptr +create_low_value_policy (CORBA::ORB_ptr orb) +{ + // Setting policy for minimum amount of bytes that needs to be + // compressed. If a message is smaller than this, it doesn't get + // compressed. + // make sure everything gets compressed. + CORBA::ULong compression_low_value = 10; + if (test == 3) + compression_low_value = 5000000; + + CORBA::Any low_value_any; + low_value_any <<= compression_low_value; + + return orb->create_policy (ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID, low_value_any); +} + +CORBA::Policy_ptr +create_compression_enabled_policy (CORBA::ORB_ptr orb) { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%s statistics:") - ACE_TEXT (" initial bytes sent:%d") - ACE_TEXT (" initial bytes recv:%d") - ACE_TEXT (" bytes sent after test:%d") - ACE_TEXT (" bytes recv after test:%d\n"), - test, - initial_bytes_send, - initial_bytes_recv, - bytes_send_after_test, - bytes_recv_after_test)); + // Setting policy whether compression is used. + CORBA::Boolean compression_enabling = true; + CORBA::Any compression_enabling_any; + compression_enabling_any <<= CORBA::Any::from_boolean(compression_enabling); + + return orb->create_policy (ZIOP::COMPRESSION_ENABLING_POLICY_ID, compression_enabling_any); } -void start_low_value_test(Test::Hello_ptr hello, ::TAO::Transport::Current_ptr) +CORBA::Policy_ptr +create_min_ratio_policy (CORBA::ORB_ptr orb) { -#if defined (TAO_HAS_TRANSPORT_CURRENT) && TAO_HAS_TRANSPORT_CURRENT == 1 -// ::TAO::CounterT initial_bytes_sent = tc->bytes_sent (); -// ::TAO::CounterT initial_bytes_recv = tc->bytes_received (); + CORBA::Any min_compression_ratio_any; + CORBA::Long min_compression_ratio = 50; + min_compression_ratio_any <<= min_compression_ratio; + + return orb->create_policy (ZIOP::COMPRESSION_MIN_RATIO_POLICY_ID, min_compression_ratio_any); +} + +Test::Hello_var +create_policies (CORBA::ORB_ptr orb, bool add_zlib_compressor) +{ + CORBA::PolicyList policies(4); + policies.length(4); + + policies[0] = create_compressor_id_level_list_policy (orb, add_zlib_compressor); + policies[1] = create_low_value_policy (orb); + policies[2] = create_compression_enabled_policy (orb); + policies[3] = create_min_ratio_policy (orb); + + CORBA::Object_var tmp = orb->string_to_object(ior); + CORBA::Object_var tmp2 = tmp->_set_policy_overrides (policies, CORBA::ADD_OVERRIDE); + Test::Hello_var hello = Test::Hello::_narrow(tmp2.in ()); + return hello._retn (); +} + +Test::Hello_var +prepare_tests (CORBA::ORB_ptr orb, bool create_factories=true) +{ + +#if defined TAO_HAS_ZIOP && TAO_HAS_ZIOP == 1 + if (create_factories) + register_factories(orb); + + return create_policies (orb, !create_factories); +#else + ACE_UNUSED_ARG (create_factories); + CORBA::Object_var tmp = orb->string_to_object(ior); + Test::Hello_var hello = Test::Hello::_narrow(tmp.in ()); + return hello._retn (); #endif +} +int +check_results (CORBA::ORB_ptr orb) +{ +#if defined TAO_HAS_ZIOP && TAO_HAS_ZIOP == 1 + switch (test) + { + case 1: + try + { + // should throw an exception + compression_manager->get_compressor (::Compression::COMPRESSORID_LZO, + DEFAULT_COMPRESSION_LEVEL); + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR : check_results, ") + ACE_TEXT ("no exception thrown when applying for ") + ACE_TEXT ("LZO Compressor\n")), + 1); + } + catch (::Compression::UnknownCompressorId) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("check_results, expected exception caught, ") + ACE_TEXT ("(unknown factory)\n"))); + Test::Hello_var hello = prepare_tests (orb, false); + test = -1; + return start_tests (hello.in (), orb); + } + break; + case -1: + { + ::Compression::Compressor_ptr compressor = + compression_manager->get_compressor (::Compression::COMPRESSORID_ZLIB, + DEFAULT_COMPRESSION_LEVEL); + if (!CORBA::is_nil (compressor)) + { + if (compressor->compressed_bytes () == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR : check_results, no compression used ") + ACE_TEXT ("during test 1a\n")), + 1); + else + return 0; + } + else + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR : check_results, zlib compressor not found ") + ACE_TEXT ("during test 1a\n")), + 1); + } + } + break; + case 2: + return 0; + break; + case 3: + case 4: + { + // low value policy test. No compression should be used. + ::Compression::Compressor_ptr compressor = + compression_manager->get_compressor (::Compression::COMPRESSORID_ZLIB, + DEFAULT_COMPRESSION_LEVEL); + if (!CORBA::is_nil (compressor)) + { + if (compressor->compressed_bytes () != 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR : check_results, compression used ") + ACE_TEXT ("during test %d\n"), test), + 1); + else + return 0; + } + else + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR : check_results, zlib compressor not found ") + ACE_TEXT ("during test %d\n"), test), + 1); + } + } + break; + default: + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR : check_results, unknown test ID\n")), + 1); + } + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR : check_results, unexpected\n")), + 1); +#else + ACE_UNUSED_ARG (orb); + return 0; +#endif +} + +int +run_string_test (Test::Hello_ptr hello) +{ ACE_DEBUG((LM_DEBUG, - ACE_TEXT("Start get_string; large compression ratio\n"))); + ACE_TEXT("run_string_test, start\n"))); CORBA::String_var the_string = hello->get_string ("This is a test string" "This is a test string" @@ -78,237 +303,109 @@ void start_low_value_test(Test::Hello_ptr hello, ::TAO::Transport::Current_ptr) "This is a test string"); ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n", the_string.in ())); + if (ACE_OS::strstr (the_string._retn (), ACE_TEXT ("Hello there")) == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR : run_string_test, unexpected string received\n")), + 1); + } -#if defined (TAO_HAS_TRANSPORT_CURRENT) && TAO_HAS_TRANSPORT_CURRENT ==1 -// log_statistics ("low_value_test", initial_bytes_sent, initial_bytes_recv, -// tc->bytes_sent (), tc->bytes_received ()); -#endif -} - -void start_min_ratio_test (Test::Hello_ptr hello, ::TAO::Transport::Current_ptr) -{ -#if defined (TAO_HAS_TRANSPORT_CURRENT) && TAO_HAS_TRANSPORT_CURRENT ==1 -// ::TAO::CounterT initial_bytes_sent = tc->bytes_sent (); -// ::TAO::CounterT initial_bytes_recv = tc->bytes_received (); -#endif - - ACE_DEBUG((LM_DEBUG, - ACE_TEXT("Start get_string; small compression ratio\n"))); - - //shouldn't compress since compress_ratio < min_ratio - CORBA::String_var the_string = hello->get_string ("!@#$#%^#@&^%*$@#GFGSd" - "fgdbdfgwe%^@#$#$%EQRT" - "sfdgdafs56#$@@#$&((%$" - "#4&%3#4%^21@!sdfSADHv" - "dsaAhn~1`2#$#sAFDGHdf"); - - ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n", - the_string.in ())); - -#if defined (TAO_HAS_TRANSPORT_CURRENT) && TAO_HAS_TRANSPORT_CURRENT ==1 -// log_statistics ("min_ratio_test", initial_bytes_sent, initial_bytes_recv, -// tc->bytes_sent (), tc->bytes_received ()); -#endif + return 0; } -void start_big_reply_test (Test::Hello_ptr hello, ::TAO::Transport::Current_ptr) +int +run_big_reply_test (Test::Hello_ptr hello) { -#if defined (TAO_HAS_TRANSPORT_CURRENT) && TAO_HAS_TRANSPORT_CURRENT ==1 -// ::TAO::CounterT initial_bytes_sent = tc->bytes_sent (); -// ::TAO::CounterT initial_bytes_recv = tc->bytes_received (); -#endif - ACE_DEBUG((LM_DEBUG, - ACE_TEXT("Start get_big_reply; large compression ratio\n"))); + ACE_TEXT("start get_big_reply\n"))); //Prepare to send a large number of bytes. Should be compressed Test::Octet_Seq_var dummy = hello->get_big_reply (); - if (dummy.ptr ()->length () > 0) + if (dummy->length () > 0) { ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("Client side BLOB received\n"))); + ACE_TEXT("get_big_reply, received = %d bytes\n"), + dummy->length ())); } else { - ACE_DEBUG ((LM_ERROR, - ACE_TEXT("Error recieving BLOB on Client\n"))); + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR : get_big_reply, ") + ACE_TEXT ("error receiving client side blob\n")), + 1); } - -#if defined (TAO_HAS_TRANSPORT_CURRENT) && TAO_HAS_TRANSPORT_CURRENT ==1 -// log_statistics ("big_reply_test",initial_bytes_sent, initial_bytes_recv, -// tc->bytes_sent (), tc->bytes_received ()); -#endif + return 0; } -void start_big_request_test (Test::Hello_ptr hello, ::TAO::Transport::Current_ptr) +int +run_big_request_test (Test::Hello_ptr hello) { -#if defined (TAO_HAS_TRANSPORT_CURRENT) && TAO_HAS_TRANSPORT_CURRENT ==1 -// ::TAO::CounterT initial_bytes_sent = tc->bytes_sent (); -// ::TAO::CounterT initial_bytes_recv = tc->bytes_received (); -#endif - - ACE_DEBUG((LM_DEBUG, - ACE_TEXT("Start big_request; large compression ratio\n"))); - //ACE_OS::sleep(1); - int length = 2000; + int length = 40000; Test::Octet_Seq send_msg(length); send_msg.length (length); - hello->big_request(send_msg); + ACE_DEBUG((LM_DEBUG, + ACE_TEXT("run_big_request_test, send = %d bytes\n"), length)); -#if defined (TAO_HAS_TRANSPORT_CURRENT) && TAO_HAS_TRANSPORT_CURRENT ==1 -// log_statistics ("big_request_test", initial_bytes_sent, initial_bytes_recv, -// tc->bytes_sent (), tc->bytes_received ()); -#endif + hello->big_request(send_msg); + return 0; } -void start_tests (Test::Hello_ptr hello, ::TAO::Transport::Current_ptr tc) +int +start_tests (Test::Hello_ptr hello, CORBA::ORB_ptr orb) { - //::CORBA::String_var rhost (tc->remote_host ()); - //::CORBA::String_var lhost (tc->local_host ()); - //::CORBA::Long id = tc->id (); - //::TAO::CounterT bs = tc->bytes_sent (); - //::TAO::CounterT br = tc->bytes_received (); - //::TAO::CounterT rs = tc->messages_sent (); - //::TAO::CounterT rr = tc->messages_received (); - - -#if !defined (TAO_HAS_TRANSPORT_CURRENT) || TAO_HAS_TRANSPORT_CURRENT == 0 - ACE_DEBUG((LM_DEBUG, - ACE_TEXT ("No statistical information available since TAO_HAS_TRANSPORT_CURRENT is not set"))); -#endif - - start_low_value_test (hello, tc); - - start_min_ratio_test (hello, tc); - - start_big_reply_test (hello, tc); + int result = 0; + if (test != 4) + { + result += run_string_test (hello); + result += run_big_request_test (hello); + } + result += run_big_reply_test (hello); - start_big_request_test (hello, tc); + result += check_results (orb); + return result; } int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { - int extra_argc = 2; - + int result = 0; try { - ACE_TCHAR **extra = 0; - ACE_NEW_RETURN (extra, ACE_TCHAR *[extra_argc], -1); - extra[0] = ACE::strnew (ACE_TEXT ("-ORBSvcConfDirective")); - extra[1] = ACE::strnew (ACE_TEXT ("dynamic TAO_Transport_Current_Loader Service_Object") - ACE_TEXT (" * TAO_TC:_make_TAO_Transport_Current_Loader() ''")); - - ACE_TCHAR **largv = new ACE_TCHAR *[argc+extra_argc]; - for (int i = 0; i < argc; i++) - largv[i] = argv[i]; - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("client adding args: "))); - for (int i = 0; i < extra_argc; i++) - { - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s "), extra[i])); - largv[argc+i] = extra[i]; - } - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n"))); - - argc += extra_argc; - - CORBA::ORB_var orb = CORBA::ORB_init (argc, largv); + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) return 1; - CORBA::Object_var compression_manager = - orb->resolve_initial_references("CompressionManager"); - - Compression::CompressionManager_var manager = - Compression::CompressionManager::_narrow (compression_manager.in ()); - - if (CORBA::is_nil(manager.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Panic: nil compression manager\n"), - 1); - - Compression::CompressorFactory_ptr compressor_factory; - - ACE_NEW_RETURN (compressor_factory, TAO::Zlib_CompressorFactory (), 1); - - Compression::CompressorFactory_var compr_fact = compressor_factory; - manager->register_factory(compr_fact.in ()); - - Compression::CompressorIdLevelList compressor_id_list(2); - compressor_id_list.length(2); - compressor_id_list[0].compressor_id = Compression::COMPRESSORID_ZLIB; - compressor_id_list[0].compression_level = 5; - compressor_id_list[1].compressor_id = Compression::COMPRESSORID_BZIP2; - compressor_id_list[1].compression_level = 5; - - //Setting policy whether compression is used. - CORBA::Boolean compression_enabling = true; - CORBA::Any compression_enabling_any; - compression_enabling_any <<= CORBA::Any::from_boolean(compression_enabling); - - //Setting policy for minimum amount of bytes that needs to be - //compressed. If a message is smaller than this, it doesn't get - //compressed - CORBA::ULong compression_low_value = 100; - CORBA::Any low_value_any; - low_value_any <<= compression_low_value; - - CORBA::Any min_compression_ratio_any; - CORBA::Long min_compression_ratio = 75; - min_compression_ratio_any <<= min_compression_ratio; - - CORBA::Any compressor_id_any; - compressor_id_any <<= compressor_id_list; - - CORBA::PolicyList policies(4); - policies.length(4); - - policies[0] = orb->create_policy (ZIOP::COMPRESSION_ENABLING_POLICY_ID, compression_enabling_any); - policies[1] = orb->create_policy (ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID, compressor_id_any); - policies[2] = orb->create_policy (ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID, low_value_any); - policies[3] = orb->create_policy (ZIOP::COMPRESSION_MIN_RATIO_POLICY_ID, min_compression_ratio_any); - - CORBA::Object_var tmp = orb->string_to_object(ior); - CORBA::Object_var tmp2 = tmp->_set_policy_overrides (policies, CORBA::ADD_OVERRIDE); - - Test::Hello_var hello = Test::Hello::_narrow(tmp2.in ()); + Test::Hello_var hello = prepare_tests (orb.in ()); if (CORBA::is_nil (hello.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, - "Nil Test::Hello reference <%s>\n", + "ERROR : Nil Test::Hello reference <%C>\n", ior), 1); } - CORBA::Object_var tcobject = - orb->resolve_initial_references ("TAO::Transport::Current"); - - ::TAO::Transport::Current_var tc = - ::TAO::Transport::Current::_narrow (tcobject.in ()); - if (CORBA::is_nil (tc.in ())) - throw ::CORBA::INTERNAL (); - - start_tests(hello.in (), tc.in ()); + try + { + result += start_tests(hello.in (), orb.in ()); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + ++result; + } hello->shutdown (); - - orb->destroy (); - for (int i = 0; i < extra_argc; i++) - ACE::strdelete (extra[i]); - delete [] extra; - delete [] largv; + orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); - return 1; + ++result; } - return 0; + return result; } - diff --git a/TAO/tests/ZIOP/run_test.pl b/TAO/tests/ZIOP/run_test.pl index a036aecd5f3..f770bc27055 100755 --- a/TAO/tests/ZIOP/run_test.pl +++ b/TAO/tests/ZIOP/run_test.pl @@ -23,48 +23,57 @@ my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 fail my $iorbase = "server.ior"; my $server_iorfile = $server->LocalFile ($iorbase); my $client_iorfile = $client->LocalFile ($iorbase); -$server->DeleteFile($iorbase); -$client->DeleteFile($iorbase); - -$SV = $server->CreateProcess ("server", "-o $server_iorfile -ORBdebuglevel $debug_level"); -$CL = $client->CreateProcess ("client", "-k file://$client_iorfile -ORBdebuglevel $debug_level"); -$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; -} - -$client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval()); - -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; +for ($test = 1; $test <= 4 && $status == 0; ++$test) +{ + $server->DeleteFile($iorbase); + $client->DeleteFile($iorbase); + + $SV = $server->CreateProcess ("server", "-o $server_iorfile -t $test -ORBdebuglevel $debug_level"); + $CL = $client->CreateProcess ("client", "-k file://$client_iorfile -t $test -ORBdebuglevel $debug_level"); + $server_status = $SV->Spawn (); + + print "\n\n\n====== START TEST $test/4 ======\n\n\n"; + + 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; + } + + $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval()); + + 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; + } + $server->DeleteFile($iorbase); + $client->DeleteFile($iorbase); } $server->GetStderrLog(); diff --git a/TAO/tests/ZIOP/server.cpp b/TAO/tests/ZIOP/server.cpp index 7af7f1885c0..66ced845c6e 100644 --- a/TAO/tests/ZIOP/server.cpp +++ b/TAO/tests/ZIOP/server.cpp @@ -5,6 +5,8 @@ #include "ace/OS_NS_stdio.h" #include "tao/ZIOP/ZIOP.h" #include "tao/Compression/zlib/ZlibCompressor_Factory.h" +#include "tao/Compression/bzip2/Bzip2Compressor_Factory.h" +#include "TestCompressor/TestCompressor_Factory.h" #include "tao/Policy_ManagerC.h" #include "tao/Policy_CurrentC.h" #include "tao/Transport.h" @@ -14,12 +16,12 @@ ACE_RCSID (Hello, "$Id$") const ACE_TCHAR *ior_output_file = ACE_TEXT("test.ior"); -Compression::CompressionLevel level = 6; +int test = 1; int parse_args (int argc, ACE_TCHAR *argv[]) { - ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:l:")); + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:t:")); int c; while ((c = get_opts ()) != -1) @@ -28,8 +30,8 @@ parse_args (int argc, ACE_TCHAR *argv[]) case 'o': ior_output_file = get_opts.opt_arg (); break; - case 'l': - level = ACE_OS::atoi (get_opts.opt_arg ()); + case 't': + test = ACE_OS::atoi (get_opts.opt_arg ()); break; case '?': @@ -46,117 +48,182 @@ parse_args (int argc, ACE_TCHAR *argv[]) } int -ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +register_factories (CORBA::ORB_ptr orb) { - try + CORBA::Object_var compression_manager = + orb->resolve_initial_references("CompressionManager"); + + ::Compression::CompressionManager_var manager = + ::Compression::CompressionManager::_narrow (compression_manager.in ()); + + if (CORBA::is_nil(manager.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil compression manager\n"), + 1); + //register Zlib compressor + ::Compression::CompressorFactory_ptr compressor_factory; + ACE_NEW_RETURN (compressor_factory, TAO::Zlib_CompressorFactory (), 1); + ::Compression::CompressorFactory_var compr_fact = compressor_factory; + manager->register_factory(compr_fact.in ()); + + // register bzip2 compressor + ACE_NEW_RETURN (compressor_factory, TAO::Bzip2_CompressorFactory (), 1); + compr_fact = compressor_factory; + manager->register_factory(compr_fact.in ()); + + // register test compressor + ACE_NEW_RETURN (compressor_factory, TAO::Test_CompressorFactory (), 1); + compr_fact = compressor_factory; + manager->register_factory(compr_fact.in ()); + + return 0; +} + +CORBA::Policy_ptr +create_compressor_id_level_list_policy (CORBA::ORB_ptr orb) +{ + ::Compression::CompressorIdLevelList compressor_id_list; + + if (test == 2) { - CORBA::ORB_var orb = - CORBA::ORB_init (argc, argv); + compressor_id_list.length(1); + compressor_id_list[0].compressor_id = COMPRESSORID_FOR_TESTING; + compressor_id_list[0].compression_level = 5; + } + else + { + compressor_id_list.length(3); + compressor_id_list[0].compressor_id = ::Compression::COMPRESSORID_BZIP2; + compressor_id_list[0].compression_level = 5; + compressor_id_list[1].compressor_id = ::Compression::COMPRESSORID_ZLIB; + compressor_id_list[1].compression_level = 5; + compressor_id_list[2].compressor_id = COMPRESSORID_FOR_TESTING; + compressor_id_list[2].compression_level = 5; + } - CORBA::Object_var compression_manager = - orb->resolve_initial_references("CompressionManager"); + CORBA::Any compressor_id_any; + compressor_id_any <<= compressor_id_list; - Compression::CompressionManager_var manager = - Compression::CompressionManager::_narrow (compression_manager.in ()); + return orb->create_policy (ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID, compressor_id_any); +} - if (CORBA::is_nil(manager.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Panic: nil compression manager\n"), - 1); +CORBA::Policy_ptr +create_low_value_policy (CORBA::ORB_ptr orb) +{ + // Setting policy for minimum amount of bytes that needs to be + // compressed. If a message is smaller than this, it doesn't get + // compressed + CORBA::ULong compression_low_value = 100; + CORBA::Any low_value_any; + low_value_any <<= compression_low_value; + + return orb->create_policy (ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID, low_value_any); +} - Compression::CompressorFactory_ptr compressor_factory; +CORBA::Policy_ptr +create_compression_enabled_policy (CORBA::ORB_ptr orb) +{ + // Setting policy whether compression is used. + CORBA::Boolean compression_enabling = true; + CORBA::Any compression_enabling_any; + compression_enabling_any <<= CORBA::Any::from_boolean(compression_enabling); - ACE_NEW_RETURN (compressor_factory, TAO::Zlib_CompressorFactory (), 1); + return orb->create_policy (ZIOP::COMPRESSION_ENABLING_POLICY_ID, compression_enabling_any); +} - Compression::CompressorFactory_var compr_fact = compressor_factory; - manager->register_factory(compr_fact.in ()); +CORBA::Policy_ptr +create_min_ratio_policy (CORBA::ORB_ptr orb) +{ + CORBA::Any min_compression_ratio_any; + CORBA::Long min_compression_ratio = 75; + min_compression_ratio_any <<= min_compression_ratio; - CORBA::Object_var poa_object = - orb->resolve_initial_references("RootPOA"); + return orb->create_policy (ZIOP::COMPRESSION_MIN_RATIO_POLICY_ID, min_compression_ratio_any); +} - PortableServer::POA_var root_poa = - PortableServer::POA::_narrow (poa_object.in ()); +Test::Hello_var +prepare_tests (CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa) +{ + register_factories(orb); - if (CORBA::is_nil (root_poa.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Panic: nil RootPOA\n"), - 1); + CORBA::Object_var objectman = + orb->resolve_initial_references ("ORBPolicyManager"); - if (parse_args (argc, argv) != 0) - return 1; + CORBA::PolicyManager_var policy_manager = + CORBA::PolicyManager::_narrow (objectman.in ()); - Compression::CompressorIdLevelList compressor_id_list(2); - compressor_id_list.length(2); - compressor_id_list[0].compressor_id = Compression::COMPRESSORID_ZLIB; - compressor_id_list[0].compression_level = 6; - compressor_id_list[1].compressor_id = Compression::COMPRESSORID_BZIP2; - compressor_id_list[1].compression_level = 6; - - //Setting policy whether compression is used. - CORBA::Boolean compression_enabling = true; - CORBA::Any compression_enabling_any; - compression_enabling_any <<= CORBA::Any::from_boolean(compression_enabling); - - //Setting policy for minimum amount of bytes that needs to be - //compressed. If a message is smaller than this, it doesn't get - //compressed - CORBA::ULong compression_low_value = 100; - CORBA::Any low_value_any; - low_value_any <<= compression_low_value; - - CORBA::Any min_compression_ratio_any; - CORBA::Long min_compression_ratio = 40; - min_compression_ratio_any <<= min_compression_ratio; - - CORBA::Any compressor_id_any; - compressor_id_any <<= compressor_id_list; - - PortableServer::POA_var my_compress_poa = 0; - CORBA::PolicyList policies(4); - policies.length(4); - - try { - policies[0] = orb->create_policy (ZIOP::COMPRESSION_ENABLING_POLICY_ID, compression_enabling_any); - policies[1] = orb->create_policy (ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID, compressor_id_any); - policies[2] = orb->create_policy (ZIOP::COMPRESSION_LOW_VALUE_POLICY_ID, low_value_any); - policies[3] = orb->create_policy (ZIOP::COMPRESSION_MIN_RATIO_POLICY_ID, min_compression_ratio_any); - my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies); - } - catch(const CORBA::PolicyError&) { - policies.length(0); - my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies); - } + PortableServer::POA_var my_compress_poa = 0; + CORBA::PolicyList policies(4); + policies.length(4); - CORBA::Object_var objectman = - orb->resolve_initial_references ("ORBPolicyManager"); + try + { + policies[0] = create_compressor_id_level_list_policy (orb); + policies[1] = create_low_value_policy (orb); + policies[2] = create_compression_enabled_policy (orb); + policies[3] = create_min_ratio_policy (orb); - CORBA::PolicyManager_var policy_manager = - CORBA::PolicyManager::_narrow (objectman.in ()); + my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies); + } + catch(const CORBA::PolicyError&) + { + policies.length(0); + my_compress_poa = root_poa->create_POA("My_Compress_Poa", 0, policies); + } - policy_manager->set_policy_overrides (policies, CORBA::ADD_OVERRIDE); + policy_manager->set_policy_overrides (policies, CORBA::ADD_OVERRIDE); - CORBA::Object_var pcobject = - orb->resolve_initial_references ("PolicyCurrent"); + CORBA::Object_var pcobject = + orb->resolve_initial_references ("PolicyCurrent"); - CORBA::PolicyCurrent_var policy_current = - CORBA::PolicyCurrent::_narrow (pcobject.in ()); + CORBA::PolicyCurrent_var policy_current = + CORBA::PolicyCurrent::_narrow (pcobject.in ()); - policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE); + policy_current->set_policy_overrides (policies, CORBA::ADD_OVERRIDE); - PortableServer::POAManager_var poa_manager = my_compress_poa->the_POAManager (); + PortableServer::POAManager_var poa_manager = my_compress_poa->the_POAManager (); - Hello *hello_impl = 0; - ACE_NEW_RETURN (hello_impl, - Hello (orb.in ()), - 1); - PortableServer::ServantBase_var owner_transfer(hello_impl); + Hello *hello_impl = 0; + ACE_NEW_RETURN (hello_impl, + Hello (orb), + 0); + PortableServer::ServantBase_var owner_transfer(hello_impl); + + PortableServer::ObjectId_var id = + my_compress_poa->activate_object (hello_impl); - PortableServer::ObjectId_var id = - my_compress_poa->activate_object (hello_impl); + CORBA::Object_var object = my_compress_poa->id_to_reference (id.in ()); - CORBA::Object_var object = my_compress_poa->id_to_reference (id.in ()); + Test::Hello_var hello = Test::Hello::_narrow (object.in ()); - Test::Hello_var hello = Test::Hello::_narrow (object.in ()); + poa_manager->activate (); + + return hello._retn (); +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + try + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv); + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA"); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in ()); + + if (CORBA::is_nil (root_poa.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil RootPOA\n"), + 1); + + if (parse_args (argc, argv) != 0) + return 1; + + Test::Hello_var hello = prepare_tests (orb.in (), root_poa.in ()); CORBA::String_var ior = orb->object_to_string (hello.in ()); @@ -170,8 +237,6 @@ ACE_TMAIN(int argc, ACE_TCHAR *argv[]) ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); - poa_manager->activate (); - orb->run (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); diff --git a/TAO/tests/ZIOP/testcompressor.mpb b/TAO/tests/ZIOP/testcompressor.mpb new file mode 100644 index 00000000000..61329e7cdb6 --- /dev/null +++ b/TAO/tests/ZIOP/testcompressor.mpb @@ -0,0 +1,6 @@ +// -*- MPC -*- +// $Id$ + +project : taolib, compression { + libs += TAO_TestCompressor +} |