diff options
author | hillj <hillj@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-11-11 22:24:17 +0000 |
---|---|---|
committer | hillj <hillj@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-11-11 22:24:17 +0000 |
commit | 33338225a9929b99ba922a9ce47f84047a1b8efc (patch) | |
tree | 0834d6af1932b1f010fc75d18ad923f31ab31616 /TAO/tests/Bug_3499_Regression | |
parent | b83f63a813b3a2488a1d40e47d1527f22ee80100 (diff) | |
download | ATCD-33338225a9929b99ba922a9ce47f84047a1b8efc.tar.gz |
Tue Nov 11 22:23:31 UTC 2008 James H. Hill <hillj@isis.vanderbilt.edu>
Diffstat (limited to 'TAO/tests/Bug_3499_Regression')
-rw-r--r-- | TAO/tests/Bug_3499_Regression/DLL_Service.cpp | 28 | ||||
-rw-r--r-- | TAO/tests/Bug_3499_Regression/DLL_Service.h | 32 | ||||
-rw-r--r-- | TAO/tests/Bug_3499_Regression/DLL_Service.mpc | 52 | ||||
-rw-r--r-- | TAO/tests/Bug_3499_Regression/DLL_Service_Host.cpp | 85 | ||||
-rw-r--r-- | TAO/tests/Bug_3499_Regression/DLL_Service_export.h | 58 | ||||
-rw-r--r-- | TAO/tests/Bug_3499_Regression/DLL_TAO_Service.cpp | 68 | ||||
-rw-r--r-- | TAO/tests/Bug_3499_Regression/DLL_TAO_Service.h | 27 | ||||
-rw-r--r-- | TAO/tests/Bug_3499_Regression/DLL_TAO_Service_export.h | 58 | ||||
-rw-r--r-- | TAO/tests/Bug_3499_Regression/README | 22 | ||||
-rwxr-xr-x | TAO/tests/Bug_3499_Regression/run_test.pl | 43 |
10 files changed, 473 insertions, 0 deletions
diff --git a/TAO/tests/Bug_3499_Regression/DLL_Service.cpp b/TAO/tests/Bug_3499_Regression/DLL_Service.cpp new file mode 100644 index 00000000000..3ff5a35b39f --- /dev/null +++ b/TAO/tests/Bug_3499_Regression/DLL_Service.cpp @@ -0,0 +1,28 @@ +// $Id$ + +#include "DLL_Service.h" + +ACE_DLL_Service::ACE_DLL_Service (void) +{ + +} + +ACE_DLL_Service::~ACE_DLL_Service (void) +{ + +} + +int ACE_DLL_Service::init (int argc, char * argv []) +{ + return 0; +} + +int ACE_DLL_Service::fini (void) +{ + return 0; +} + +void ACE_DLL_Service::destroy (void) +{ + delete this; +} diff --git a/TAO/tests/Bug_3499_Regression/DLL_Service.h b/TAO/tests/Bug_3499_Regression/DLL_Service.h new file mode 100644 index 00000000000..89b86c8b2d3 --- /dev/null +++ b/TAO/tests/Bug_3499_Regression/DLL_Service.h @@ -0,0 +1,32 @@ +#ifndef _DLL_SERVICE_H_ +#define _DLL_SERVICE_H_ + +#include "DLL_Service_export.h" + +class ACE_DLL_SERVICE_Export ACE_DLL_Service +{ +public: + ACE_DLL_Service (void); + + virtual ~ACE_DLL_Service (void); + + virtual int init (int argc, char * argv []); + + virtual int fini (void); + + /// This is only here for destruction purposes + virtual void destroy (void); +}; + +#define ACE_DLL_SERVICE_DECL(export_macro, symbol) \ + extern "C" export_macro ACE_DLL_Service * symbol (void) + +#define ACE_DLL_SERVICE_IMPL(classname, symbol) \ + ACE_DLL_Service * symbol (void) \ + { \ + classname * service = 0; \ + ACE_NEW_RETURN (service, classname (), 0); \ + return service; \ + } + +#endif diff --git a/TAO/tests/Bug_3499_Regression/DLL_Service.mpc b/TAO/tests/Bug_3499_Regression/DLL_Service.mpc new file mode 100644 index 00000000000..b954a0a624b --- /dev/null +++ b/TAO/tests/Bug_3499_Regression/DLL_Service.mpc @@ -0,0 +1,52 @@ +// $Id$ + +project (Bug_3499_Regression) : aceexe { + exename = Bug_3499_Regression + + install = . + + Source_Files { + DLL_Service_Host.cpp + } +} + +project (Bug_3499_Regression_ACE_DLL_Service) : acelib { + sharedname = Bug_3499_Regression_ACE_DLL_Service + + dynamicflags += ACE_DLL_SERVICE_BUILD_DLL + + dllout = . + libout = . + + Source_Files { + DLL_Service.cpp + } + + Header_Files { + DLL_Service_export.h + } + + Inline_Files { + + } +} + +project (Bug_3499_Regression_ACE_DLL_TAO_Service) : portableserver, taolib { + sharedname = Bug_3499_Regression_ACE_DLL_TAO_Service + + dynamicflags += ACE_DLL_TAO_SERVICE_BUILD_DLL + + after += Bug_3499_Regression_ACE_DLL_Service + libs += Bug_3499_Regression_ACE_DLL_Service + + dllout = . + libout = . + + Source_Files { + DLL_TAO_Service.cpp + } + + Header_Files { + DLL_TAO_Service_export.h + } +} diff --git a/TAO/tests/Bug_3499_Regression/DLL_Service_Host.cpp b/TAO/tests/Bug_3499_Regression/DLL_Service_Host.cpp new file mode 100644 index 00000000000..5c799492fdb --- /dev/null +++ b/TAO/tests/Bug_3499_Regression/DLL_Service_Host.cpp @@ -0,0 +1,85 @@ +// $Id$ + +#include "DLL_Service.h" +#include "ace/DLL.h" +#include "ace/Service_Gestalt.h" +#include "ace/Service_Config.h" +#include "ace/CORBA_macros.h" +#include "ace/OS_NS_unistd.h" +// +// main +// +int ACE_TMAIN (int argc, ACE_TCHAR * argv []) +{ + try + { + ACE_DLL module; + + ACE_Service_Gestalt * gestalt = 0; + ACE_NEW_THROW_EX (gestalt, + ACE_Service_Gestalt (), + ACE_bad_alloc ()); + + ACE_Intrusive_Auto_Ptr <ACE_Service_Gestalt> auto_clean (gestalt); + + // Without the following line, the application will crash while ACE + // is *cleaning* the ACE_Service_Config::global () object. We want + // to force all services to be loaded under this configuration. + ACE_Service_Config_Guard guard (gestalt); + + if (module.open (ACE_TEXT ("Bug_3499_Regression_ACE_DLL_TAO_Service")) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("failed to load ACE_DLL_TAO_Service\n")), + -1); + } + + void * symbol = module.symbol (ACE_TEXT ("_make_ACE_DLL_TAO_Service")); + + if (symbol == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("failed to load symbol _make_ACE_DLL_TAO_Service\n")), + -1); + } + + typedef ACE_DLL_Service * (*factory_type) (void); + factory_type f = reinterpret_cast <factory_type> (symbol); + + ACE_DLL_Service * svc = (*f) (); + + if (svc != 0) + { + // Initialize the service. + // + // If '-ORBGestalt CURRENT' does not appear in the command-line options, + // which is a fix for the bug in question, then the service will fail + // when trying to resolve to RootPOA. + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%t) %T - %M - initializing the loaded service\n"))); + svc->init (argc, argv); + + // Sleep for a few seconds + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%t) %T - %M - sleeping for 5 seconds\n"))); + ACE_OS::sleep (5); + + // Finalize the service. + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%t) %T - %M - finalizing the service\n"))); + svc->fini (); + + // Destroy the service. + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%t) %T - %M - destroying the service\n"))); + svc->destroy (); + } + } + catch (...) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%t) %T - %M - caught unknown exception\n"))); + } + + return -1; +} diff --git a/TAO/tests/Bug_3499_Regression/DLL_Service_export.h b/TAO/tests/Bug_3499_Regression/DLL_Service_export.h new file mode 100644 index 00000000000..76950d32e1f --- /dev/null +++ b/TAO/tests/Bug_3499_Regression/DLL_Service_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl ACE_DLL_SERVICE +// ------------------------------ +#ifndef ACE_DLL_SERVICE_EXPORT_H +#define ACE_DLL_SERVICE_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (ACE_DLL_SERVICE_HAS_DLL) +# define ACE_DLL_SERVICE_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && ACE_DLL_SERVICE_HAS_DLL */ + +#if !defined (ACE_DLL_SERVICE_HAS_DLL) +# define ACE_DLL_SERVICE_HAS_DLL 1 +#endif /* ! ACE_DLL_SERVICE_HAS_DLL */ + +#if defined (ACE_DLL_SERVICE_HAS_DLL) && (ACE_DLL_SERVICE_HAS_DLL == 1) +# if defined (ACE_DLL_SERVICE_BUILD_DLL) +# define ACE_DLL_SERVICE_Export ACE_Proper_Export_Flag +# define ACE_DLL_SERVICE_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define ACE_DLL_SERVICE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* ACE_DLL_SERVICE_BUILD_DLL */ +# define ACE_DLL_SERVICE_Export ACE_Proper_Import_Flag +# define ACE_DLL_SERVICE_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define ACE_DLL_SERVICE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* ACE_DLL_SERVICE_BUILD_DLL */ +#else /* ACE_DLL_SERVICE_HAS_DLL == 1 */ +# define ACE_DLL_SERVICE_Export +# define ACE_DLL_SERVICE_SINGLETON_DECLARATION(T) +# define ACE_DLL_SERVICE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* ACE_DLL_SERVICE_HAS_DLL == 1 */ + +// Set ACE_DLL_SERVICE_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (ACE_DLL_SERVICE_NTRACE) +# if (ACE_NTRACE == 1) +# define ACE_DLL_SERVICE_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define ACE_DLL_SERVICE_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !ACE_DLL_SERVICE_NTRACE */ + +#if (ACE_DLL_SERVICE_NTRACE == 1) +# define ACE_DLL_SERVICE_TRACE(X) +#else /* (ACE_DLL_SERVICE_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define ACE_DLL_SERVICE_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (ACE_DLL_SERVICE_NTRACE == 1) */ + +#endif /* ACE_DLL_SERVICE_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/tests/Bug_3499_Regression/DLL_TAO_Service.cpp b/TAO/tests/Bug_3499_Regression/DLL_TAO_Service.cpp new file mode 100644 index 00000000000..94689aa7d14 --- /dev/null +++ b/TAO/tests/Bug_3499_Regression/DLL_TAO_Service.cpp @@ -0,0 +1,68 @@ +// $Id$ + +#include "DLL_TAO_Service.h" + +ACE_DLL_SERVICE_IMPL (ACE_DLL_TAO_Service, _make_ACE_DLL_TAO_Service); + +ACE_DLL_TAO_Service::ACE_DLL_TAO_Service (void) +{ + ACE_DLL_TAO_SERVICE_TRACE (ACE_TEXT ("ACE_DLL_TAO_Service::ACE_DLL_TAO_Service (void)")); +} + +ACE_DLL_TAO_Service::~ACE_DLL_TAO_Service (void) +{ + ACE_DLL_TAO_SERVICE_TRACE (ACE_TEXT ("ACE_DLL_TAO_Service::~ACE_DLL_TAO_Service (void)")); +} + +int ACE_DLL_TAO_Service::init (int argc, char * argv []) +{ + ACE_DLL_TAO_SERVICE_TRACE (ACE_TEXT ("ACE_DLL_TAO_Service::init (int, char * [])")); + + try + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%t) %T - %M - initializing the CORBA ORB\n"))); + this->orb_ = CORBA::ORB_init (argc, argv); + + // This call should fail unless '-ORBGestalt CURRENT' is passed as a command-line + // option during ORB_init (...). + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%t) %T - %M - resolving the RootPOA\n"))); + + CORBA::Object_var obj = + this->orb_->resolve_initial_references (ACE_TEXT ("RootPOA")); + this->root_poa_ = PortableServer::POA::_narrow (obj.in ()); + + return 0; + } + catch (const CORBA::Exception & ex) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%t) %T - %M - %s\n"), + ex._info ().c_str ())); + } + + return -1; +} + +int ACE_DLL_TAO_Service::fini (void) +{ + ACE_DLL_TAO_SERVICE_TRACE (ACE_TEXT ("ACE_DLL_TAO_Service::fini (void)")); + + try + { + this->orb_->shutdown (1); + + this->root_poa_->destroy (1, 1); + this->orb_->destroy (); + return 0; + } + catch (const CORBA::Exception & ex) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("(%t) %T - %M - %s\n"), + ex._info ().c_str ())); + } + + return -1; +} diff --git a/TAO/tests/Bug_3499_Regression/DLL_TAO_Service.h b/TAO/tests/Bug_3499_Regression/DLL_TAO_Service.h new file mode 100644 index 00000000000..025dc2a28d3 --- /dev/null +++ b/TAO/tests/Bug_3499_Regression/DLL_TAO_Service.h @@ -0,0 +1,27 @@ +#ifndef _ACE_DLL_TAO_SERVICE_H_ +#define _ACE_DLL_TAO_SERVICE_H_ + +#include "DLL_TAO_Service_export.h" +#include "DLL_Service.h" +#include "tao/PortableServer/PortableServer.h" + +class ACE_DLL_TAO_Service : public ACE_DLL_Service +{ +public: + ACE_DLL_TAO_Service (void); + + virtual ~ACE_DLL_TAO_Service (void); + + virtual int init (int argc, char * argv []); + + virtual int fini (void); + +private: + CORBA::ORB_var orb_; + + PortableServer::POA_var root_poa_; +}; + +ACE_DLL_SERVICE_DECL (ACE_DLL_TAO_SERVICE_Export, _make_ACE_DLL_TAO_Service); + +#endif // !defined _ACE_DLL_TAO_SERVICE_H_ diff --git a/TAO/tests/Bug_3499_Regression/DLL_TAO_Service_export.h b/TAO/tests/Bug_3499_Regression/DLL_TAO_Service_export.h new file mode 100644 index 00000000000..e8db40b989a --- /dev/null +++ b/TAO/tests/Bug_3499_Regression/DLL_TAO_Service_export.h @@ -0,0 +1,58 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl ACE_DLL_TAO_SERVICE +// ------------------------------ +#ifndef ACE_DLL_TAO_SERVICE_EXPORT_H +#define ACE_DLL_TAO_SERVICE_EXPORT_H + +#include "ace/config-all.h" + +#if defined (ACE_AS_STATIC_LIBS) && !defined (ACE_DLL_TAO_SERVICE_HAS_DLL) +# define ACE_DLL_TAO_SERVICE_HAS_DLL 0 +#endif /* ACE_AS_STATIC_LIBS && ACE_DLL_TAO_SERVICE_HAS_DLL */ + +#if !defined (ACE_DLL_TAO_SERVICE_HAS_DLL) +# define ACE_DLL_TAO_SERVICE_HAS_DLL 1 +#endif /* ! ACE_DLL_TAO_SERVICE_HAS_DLL */ + +#if defined (ACE_DLL_TAO_SERVICE_HAS_DLL) && (ACE_DLL_TAO_SERVICE_HAS_DLL == 1) +# if defined (ACE_DLL_TAO_SERVICE_BUILD_DLL) +# define ACE_DLL_TAO_SERVICE_Export ACE_Proper_Export_Flag +# define ACE_DLL_TAO_SERVICE_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define ACE_DLL_TAO_SERVICE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* ACE_DLL_TAO_SERVICE_BUILD_DLL */ +# define ACE_DLL_TAO_SERVICE_Export ACE_Proper_Import_Flag +# define ACE_DLL_TAO_SERVICE_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define ACE_DLL_TAO_SERVICE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* ACE_DLL_TAO_SERVICE_BUILD_DLL */ +#else /* ACE_DLL_TAO_SERVICE_HAS_DLL == 1 */ +# define ACE_DLL_TAO_SERVICE_Export +# define ACE_DLL_TAO_SERVICE_SINGLETON_DECLARATION(T) +# define ACE_DLL_TAO_SERVICE_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* ACE_DLL_TAO_SERVICE_HAS_DLL == 1 */ + +// Set ACE_DLL_TAO_SERVICE_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (ACE_DLL_TAO_SERVICE_NTRACE) +# if (ACE_NTRACE == 1) +# define ACE_DLL_TAO_SERVICE_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define ACE_DLL_TAO_SERVICE_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !ACE_DLL_TAO_SERVICE_NTRACE */ + +#if (ACE_DLL_TAO_SERVICE_NTRACE == 1) +# define ACE_DLL_TAO_SERVICE_TRACE(X) +#else /* (ACE_DLL_TAO_SERVICE_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define ACE_DLL_TAO_SERVICE_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (ACE_DLL_TAO_SERVICE_NTRACE == 1) */ + +#endif /* ACE_DLL_TAO_SERVICE_EXPORT_H */ + +// End of auto generated file. diff --git a/TAO/tests/Bug_3499_Regression/README b/TAO/tests/Bug_3499_Regression/README new file mode 100644 index 00000000000..3fd3e89b070 --- /dev/null +++ b/TAO/tests/Bug_3499_Regression/README @@ -0,0 +1,22 @@ +This test uses newly implemented '-ORBGestalt CURRENT' feature of ORB_init. Using +this feature allows developers to control explicity control where an ORB services +are located, especially when loading modules that initialize an ORB. + +__Regression Output__ + +[hillj@tango Bug_3499_Regression]$ ./run_test.pl +(1892) 16:17:45.849000 - LM_DEBUG - initializing the loaded service +(1892) 16:17:45.849000 - LM_DEBUG - initializing the CORBA ORB +(1892) 16:17:45.912000 - LM_DEBUG - resolving the RootPOA +(1892) 16:17:45.927000 - LM_ERROR - caught unknown exception +[followed by a segfault] + +__Successful Output__ + +[hillj@tango Bug_3499_Regression]$ ./run_test.pl +(832) 16:16:16.818000 - LM_DEBUG - initializing the loaded service +(832) 16:16:16.818000 - LM_DEBUG - initializing the CORBA ORB +(832) 16:16:16.865000 - LM_DEBUG - resolving the RootPOA +(832) 16:16:16.896000 - LM_DEBUG - sleeping for 5 seconds +(832) 16:16:21.896000 - LM_DEBUG - finalizing the service +(832) 16:16:21.896000 - LM_DEBUG - destroying the service diff --git a/TAO/tests/Bug_3499_Regression/run_test.pl b/TAO/tests/Bug_3499_Regression/run_test.pl new file mode 100755 index 00000000000..12d24a97399 --- /dev/null +++ b/TAO/tests/Bug_3499_Regression/run_test.pl @@ -0,0 +1,43 @@ +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::Run_Test; +use PerlACE::TestTarget; + +$debug_level = '0'; + +foreach $i (@ARGV) { + if ($i eq '-debug') { + $debug_level = '10'; + } +} + +#my $target = PerlACE::TestTarget::create_target ($PerlACE::TestConfig); +my $server = PerlACE::TestTarget::create_target (1); +#my $client = new PerlACE::TestTarget; +my $client = PerlACE::TestTarget::create_target (2); +if (!defined $server || !defined $client) { + exit 1; +} + +my $iorbase = "server.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($server_iorfile); +$client->DeleteFile($client_iorfile); + +if (PerlACE::is_vxworks_test()) { + $SV = new PerlACE::ProcessVX ("Bug_3499_Regression", "-ORBGestalt CURRENT"); +} +else { + $SV = $server->CreateProcess ("Bug_3499_Regression", "-ORBGestalt CURRENT"); +} + +$SV->SpawnWaitKill (1000); + +exit 0; |