diff options
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/bin/tao_orb_tests.lst | 1 | ||||
-rw-r--r-- | TAO/tao/Array_VarOut_T.cpp | 9 | ||||
-rw-r--r-- | TAO/tao/Array_VarOut_T.inl | 12 | ||||
-rw-r--r-- | TAO/tests/CORBA_is_nil/.gitignore | 7 | ||||
-rw-r--r-- | TAO/tests/CORBA_is_nil/CORBA_is_nil.mpc | 33 | ||||
-rw-r--r-- | TAO/tests/CORBA_is_nil/Hello.cpp | 24 | ||||
-rw-r--r-- | TAO/tests/CORBA_is_nil/Hello.h | 29 | ||||
-rw-r--r-- | TAO/tests/CORBA_is_nil/README.md | 20 | ||||
-rw-r--r-- | TAO/tests/CORBA_is_nil/Test.idl | 19 | ||||
-rw-r--r-- | TAO/tests/CORBA_is_nil/client.cpp | 110 | ||||
-rwxr-xr-x | TAO/tests/CORBA_is_nil/run_test.pl | 87 | ||||
-rw-r--r-- | TAO/tests/CORBA_is_nil/server.cpp | 99 | ||||
-rw-r--r-- | TAO/tests/CORBA_is_nil/svc.conf | 1 |
13 files changed, 437 insertions, 14 deletions
diff --git a/TAO/bin/tao_orb_tests.lst b/TAO/bin/tao_orb_tests.lst index 4b1749372f8..67cf0476eec 100644 --- a/TAO/bin/tao_orb_tests.lst +++ b/TAO/bin/tao_orb_tests.lst @@ -210,6 +210,7 @@ TAO/tests/Bug_4059_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MI TAO/tests/Bug_4082_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO TAO/tests/Bug_4097_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO TAO/tests/Bug_4213_Regression/run_test.pl: !Win32 +TAO/tests/CORBA_is_nil/run_test.pl: TAO/tests/DIOP/run_test.pl: !ST !NO_DIOP !ACE_FOR_TAO !CORBA_E_MICRO TAO/tests/DIOP/run_test_ipv6.pl: IPV6 !ST !NO_DIOP !ACE_FOR_TAO !CORBA_E_MICRO TAO/tests/RTCORBA/Activate_Object_Multiple_ORBs/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ST diff --git a/TAO/tao/Array_VarOut_T.cpp b/TAO/tao/Array_VarOut_T.cpp index c898e7a09fd..49c04124aea 100644 --- a/TAO/tao/Array_VarOut_T.cpp +++ b/TAO/tao/Array_VarOut_T.cpp @@ -28,8 +28,7 @@ TAO_FixedArray_Var_T<T,T_slice,TAG>::operator= (T_slice * p) template<typename T, typename T_slice, typename TAG> TAO_FixedArray_Var_T<T,T_slice,TAG> & TAO_FixedArray_Var_T<T,T_slice,TAG>::operator= ( - const TAO_FixedArray_Var_T<T,T_slice,TAG> & p - ) + const TAO_FixedArray_Var_T<T,T_slice,TAG> & p) { if (this != &p) { @@ -62,8 +61,7 @@ TAO_VarArray_Var_T<T,T_slice,TAG>::operator= (T_slice * p) template<typename T, typename T_slice, typename TAG> TAO_VarArray_Var_T<T,T_slice,TAG> & TAO_VarArray_Var_T<T,T_slice,TAG>::operator= ( - const TAO_VarArray_Var_T<T,T_slice,TAG> & p - ) + const TAO_VarArray_Var_T<T,T_slice,TAG> & p) { if (this != &p) { @@ -81,8 +79,7 @@ TAO_VarArray_Var_T<T,T_slice,TAG>::operator= ( template<typename T, typename T_slice, typename TAG> void TAO_Array_Forany_T<T,T_slice,TAG>::_tao_any_destructor ( - void * _tao_void_pointer - ) + void * _tao_void_pointer) { T_slice * tmp = static_cast<T_slice *> (_tao_void_pointer); TAO::Array_Traits<FORANY>::free (tmp); diff --git a/TAO/tao/Array_VarOut_T.inl b/TAO/tao/Array_VarOut_T.inl index a3ab61af4b8..b2be7077f10 100644 --- a/TAO/tao/Array_VarOut_T.inl +++ b/TAO/tao/Array_VarOut_T.inl @@ -189,8 +189,7 @@ TAO_Array_Out_T<T,T_var,T_slice,TAG>::TAO_Array_Out_T (T_var & p) template<typename T, typename T_var, typename T_slice, typename TAG> ACE_INLINE TAO_Array_Out_T<T,T_var,T_slice,TAG>::TAO_Array_Out_T ( - const TAO_Array_Out_T<T,T_var,T_slice,TAG> & p - ) + const TAO_Array_Out_T<T,T_var,T_slice,TAG> & p) : ptr_ (const_cast<THIS_OUT_TYPE &> (p).ptr_) {} @@ -198,8 +197,7 @@ template<typename T, typename T_var, typename T_slice, typename TAG> ACE_INLINE TAO_Array_Out_T<T,T_var,T_slice,TAG> & TAO_Array_Out_T<T,T_var,T_slice,TAG>::operator= ( - const TAO_Array_Out_T<T,T_var,T_slice,TAG> & p - ) + const TAO_Array_Out_T<T,T_var,T_slice,TAG> & p) { this->ptr_ = const_cast<THIS_OUT_TYPE &> (p).ptr_; return *this; @@ -250,8 +248,7 @@ template<typename T, typename T_slice, typename TAG> ACE_INLINE TAO_Array_Forany_T<T,T_slice,TAG>::TAO_Array_Forany_T ( T_slice * p, - CORBA::Boolean nocopy - ) + CORBA::Boolean nocopy) : ptr_ (p), nocopy_ (nocopy) {} @@ -259,8 +256,7 @@ TAO_Array_Forany_T<T,T_slice,TAG>::TAO_Array_Forany_T ( template<typename T, typename T_slice, typename TAG> ACE_INLINE TAO_Array_Forany_T<T,T_slice,TAG>::TAO_Array_Forany_T ( - const TAO_Array_Forany_T<T,T_slice,TAG> & p - ) + const TAO_Array_Forany_T<T,T_slice,TAG> & p) : ptr_ (p.ptr_), nocopy_ (p.nocopy_) { diff --git a/TAO/tests/CORBA_is_nil/.gitignore b/TAO/tests/CORBA_is_nil/.gitignore new file mode 100644 index 00000000000..175dcc85367 --- /dev/null +++ b/TAO/tests/CORBA_is_nil/.gitignore @@ -0,0 +1,7 @@ +.obj +.depend.CORBA_Is_Nil_Client +.depend.CORBA_Is_Nil_Server +.depend.CORBA_Is_Nil_idl +.depend.CORBA_Is_Nil_idl_Idl1 +client +server diff --git a/TAO/tests/CORBA_is_nil/CORBA_is_nil.mpc b/TAO/tests/CORBA_is_nil/CORBA_is_nil.mpc new file mode 100644 index 00000000000..fc2a86b7fe3 --- /dev/null +++ b/TAO/tests/CORBA_is_nil/CORBA_is_nil.mpc @@ -0,0 +1,33 @@ +// -*- MPC -*- +project(*idl): taoidldefaults { + 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/CORBA_is_nil/Hello.cpp b/TAO/tests/CORBA_is_nil/Hello.cpp new file mode 100644 index 00000000000..0c842934437 --- /dev/null +++ b/TAO/tests/CORBA_is_nil/Hello.cpp @@ -0,0 +1,24 @@ +#include "Hello.h" + +Hello::Hello (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +char * +Hello::get_string () +{ + return CORBA::string_dup ("Hello there!"); +} + +Test::Hello_ptr +Hello::get_Hello () +{ + return Test::Hello::_nil(); +} + +void +Hello::shutdown () +{ + this->orb_->shutdown (false); +} diff --git a/TAO/tests/CORBA_is_nil/Hello.h b/TAO/tests/CORBA_is_nil/Hello.h new file mode 100644 index 00000000000..1d57cd9c433 --- /dev/null +++ b/TAO/tests/CORBA_is_nil/Hello.h @@ -0,0 +1,29 @@ + +#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 + char * get_string () override; + Test::Hello_ptr get_Hello () override; + + void shutdown () override; + +private: + /// Use an ORB reference to convert strings to objects and shutdown + /// the application. + CORBA::ORB_var orb_; +}; + +#include /**/ "ace/post.h" +#endif /* HELLO_H */ diff --git a/TAO/tests/CORBA_is_nil/README.md b/TAO/tests/CORBA_is_nil/README.md new file mode 100644 index 00000000000..3735667d1a7 --- /dev/null +++ b/TAO/tests/CORBA_is_nil/README.md @@ -0,0 +1,20 @@ +# This test confirms that CORBA::is_nil works + +TAO implements `CORBA::is_nil` as a function template, which merely +checks the argument for zero. The template is specialized for +`CORBA::Object_ptr`, and this specialization additionally checks +whether a non-NULL argument might be an unevaluated nil object +reference. + +Because template specialization is used and not an ordinary overloaded +function, the specialized variant is *not* called for pointers to +derived classes. This will work only if TAO ensures that all nil +object references that have been narrowed to a derived class are +converted to null pointers, i.e., to ensure that the generic template +produces the correct result. + +This test has the server return a nil object reference and the client +uses lazy resource usage, to confirm that CORBA::is_nil correctly +identifies the nil object reference. See issue #1203, which pointed +out that only CORBA::Object_ptr has a template specialization for +CORBA::is_nil, but not derived interfaces. diff --git a/TAO/tests/CORBA_is_nil/Test.idl b/TAO/tests/CORBA_is_nil/Test.idl new file mode 100644 index 00000000000..f3da71c47c8 --- /dev/null +++ b/TAO/tests/CORBA_is_nil/Test.idl @@ -0,0 +1,19 @@ +/// 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 (); + + /// Return another instance (returns NULL object reference) + Hello get_Hello (); + + /// A method to shutdown the ORB + /** + * This method is used to simplify the test shutdown process + */ + oneway void shutdown (); + }; +}; diff --git a/TAO/tests/CORBA_is_nil/client.cpp b/TAO/tests/CORBA_is_nil/client.cpp new file mode 100644 index 00000000000..64307157c0e --- /dev/null +++ b/TAO/tests/CORBA_is_nil/client.cpp @@ -0,0 +1,110 @@ +#include "TestC.h" +#include "ace/Get_Opt.h" + +const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior"); + +int process_result = 1; + +int parse_args (int argc, ACE_TCHAR *argv[]) +{ +ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("f:")); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'f': + ior = get_opts.opt_arg (); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-f <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 <%C>\n", + ior), + 1); + } + + CORBA::String_var the_string = hello->get_string (); + + ACE_DEBUG ((LM_DEBUG, + "Hello from file IOR: %C\n", + the_string.in())); + + Test::Hello_var helloRef = hello->get_Hello(); + + if (CORBA::is_nil(helloRef.in())) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Correctly detected nil Object reference.\n"))); + CORBA::Object_var var = CORBA::Object::_duplicate(helloRef.in()); + if (CORBA::is_nil(var)) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("Duplicated Object reference works too.\n"))); + process_result = 0; + } + else + { + ACE_ERROR_RETURN ((LM_DEBUG, + "ERROR:\n%C\n$%C\n", + "CORBA::is_nil(Hello_ptr) returned false!" + "CORBA::is_nil(Object_var) returned true!"), + 1); + } + } + else + { + CORBA::Object_ptr obj = helloRef.in(); + if (CORBA::is_nil(obj)) + { + ACE_DEBUG ((LM_DEBUG, + "ERROR (causes exception further down):\n%C\n%C\n", + "CORBA::is_nil(Hello_ptr) returned false!" + "CORBA::is_nil(Object_ptr) returned true!")); + } + CORBA::String_var aString = helloRef->get_string(); + ACE_DEBUG ((LM_DEBUG, + "Received Hello: %C\n", + aString.in())); + } + + hello->shutdown (); + + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return process_result; +} diff --git a/TAO/tests/CORBA_is_nil/run_test.pl b/TAO/tests/CORBA_is_nil/run_test.pl new file mode 100755 index 00000000000..aee70bcec96 --- /dev/null +++ b/TAO/tests/CORBA_is_nil/run_test.pl @@ -0,0 +1,87 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# -*- 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); + +$conf_file = "svc$PerlACE::svcconf_ext"; +$client_conf = $client->LocalFile ($conf_file); + +$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile"); + +# copy the configruation file. +if ($client->PutFile ($conf_file) == -1) { + print STDERR "ERROR: cannot set file <$client_conf>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$CL = $client->CreateProcess ("client", "-ORBSvcConf $client_conf -ORBdebuglevel $debug_level -f 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->GetStderrLog(); +$client->GetStderrLog(); + +$server->DeleteFile($server_iorfile); +$client->DeleteFile($client_iorfile); + +exit $status; diff --git a/TAO/tests/CORBA_is_nil/server.cpp b/TAO/tests/CORBA_is_nil/server.cpp new file mode 100644 index 00000000000..ae09624b8a5 --- /dev/null +++ b/TAO/tests/CORBA_is_nil/server.cpp @@ -0,0 +1,99 @@ +#include "Hello.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" + +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 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); + + 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 (); + + orb->run (); + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); + + root_poa->destroy (true, true); + + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return 0; +} diff --git a/TAO/tests/CORBA_is_nil/svc.conf b/TAO/tests/CORBA_is_nil/svc.conf new file mode 100644 index 00000000000..4634a4cbf95 --- /dev/null +++ b/TAO/tests/CORBA_is_nil/svc.conf @@ -0,0 +1 @@ +static Resource_Factory "-ORBResourceUsage lazy" |