From 6f18ffa547247dfdc1e764dd876eabc35d187d8f Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Fri, 19 Apr 2002 13:38:07 +0000 Subject: release 1.9.4 --- src/msvc6/testpluginrunner/TestPlugIn.cpp | 55 ++++++++----------------------- 1 file changed, 13 insertions(+), 42 deletions(-) (limited to 'src/msvc6/testpluginrunner/TestPlugIn.cpp') 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 +#include +#include #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,21 +21,10 @@ 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() { @@ -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 ); + } } -- cgit v1.2.1