diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-04-19 13:38:07 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-04-19 13:38:07 +0000 |
| commit | 6f18ffa547247dfdc1e764dd876eabc35d187d8f (patch) | |
| tree | 33ef17777b02e054bd3b9046012411b6753e182b /src/msvc6/testpluginrunner/TestPlugIn.cpp | |
| parent | 132990f7754ed88caf4d03da395db4fe4947230f (diff) | |
| download | cppunit-6f18ffa547247dfdc1e764dd876eabc35d187d8f.tar.gz | |
release 1.9.4
Diffstat (limited to 'src/msvc6/testpluginrunner/TestPlugIn.cpp')
| -rw-r--r-- | src/msvc6/testpluginrunner/TestPlugIn.cpp | 55 |
1 files changed, 13 insertions, 42 deletions
diff --git a/src/msvc6/testpluginrunner/TestPlugIn.cpp b/src/msvc6/testpluginrunner/TestPlugIn.cpp index 6ab8487..7c46fb1 100644 --- a/src/msvc6/testpluginrunner/TestPlugIn.cpp +++ b/src/msvc6/testpluginrunner/TestPlugIn.cpp @@ -7,13 +7,13 @@ #include "StdAfx.h" #include "TestPlugIn.h" #include <cppunit/TestCase.h> +#include <cppunit/plugin/DynamicLibraryManagerException.h> +#include <cppunit/extensions/TestFactoryRegistry.h> #include "TestPlugInException.h" TestPlugIn::TestPlugIn( const std::string fileName ) : - m_fileName( fileName ), - m_dllHandle( NULL ), - m_interfaceFunction( NULL ) + m_fileName( fileName ) { m_copyFileName = m_fileName + "-hotrunner"; } @@ -21,22 +21,11 @@ TestPlugIn::TestPlugIn( const std::string fileName ) : TestPlugIn::~TestPlugIn() { - releaseDll(); deleteDllCopy(); } void -TestPlugIn::releaseDll() -{ - if ( m_dllHandle != NULL ) - ::FreeLibrary( m_dllHandle ); - m_dllHandle = NULL; - m_interfaceFunction = NULL; -} - - -void TestPlugIn::deleteDllCopy() { ::DeleteFile( m_copyFileName.c_str() ); @@ -65,27 +54,16 @@ CppUnit::Test * TestPlugIn::makeTest() { reloadDll(); - TestPlugInInterface *theInterface = (*m_interfaceFunction)(); - - try - { - return theInterface->makeTest(); - } - catch ( ... ) - { - throw TestPlugInException( "Failed to make test using GetTestPlugInInterface", - TestPlugInException::failedToMakeTest ); - } + return CppUnit::TestFactoryRegistry::getRegistry().makeTest(); } void TestPlugIn::reloadDll() { - releaseDll(); + m_manager.unload( m_copyFileName ); makeDllCopy(); loadDll(); - getDllInterface(); } @@ -103,20 +81,13 @@ TestPlugIn::makeDllCopy() void TestPlugIn::loadDll() { - m_dllHandle = ::LoadLibrary( m_copyFileName.c_str() ); - if ( m_dllHandle == NULL ) - throw TestPlugInException( "Failed to load DLL " + m_copyFileName, + try + { + m_manager.load( m_copyFileName ); + } + catch ( CppUnit::DynamicLibraryManagerException &e ) + { + throw TestPlugInException( e.what(), TestPlugInException::failedToLoadDll ); -} - - -void -TestPlugIn::getDllInterface() -{ - m_interfaceFunction = (GetTestPlugInInterfaceFunction ) - ::GetProcAddress( m_dllHandle, "GetTestPlugInInterface" ); - if ( m_interfaceFunction == NULL ) - throw TestPlugInException( "Failed to locate function GetTestPlugInInterface " - " in DLL " + m_fileName, - TestPlugInException::failedToGetInterfaceFunction ); + } } |
