summaryrefslogtreecommitdiff
path: root/src/cppunit/TestPlugInSuite.cpp
blob: a8fea7a12ab490fbd6f0f5d553f9d58fdff9e34f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <cppunit/plugin/TestPlugInSuite.h>

#if !defined(CPPUNIT_NO_TESTPLUGIN)

#include <cppunit/plugin/DynamicLibraryManager.h>


namespace CppUnit
{


TestPlugInSuite::TestPlugInSuite( const std::string &libraryFileName )
    : m_library( new DynamicLibraryManager( libraryFileName ) )
    , m_librarySuite( NULL )
    , m_interface( NULL )
{
  try
  {
    CppUnitTestPlugInSignature plug = (CppUnitTestPlugInSignature)m_library->findSymbol( 
          CPPUNIT_STRINGIZE( CPPUNIT_PLUGIN_EXPORTED_NAME ) );
    m_interface = (*plug)();
    m_interface->initialize();
    m_librarySuite = m_interface->getTestSuite();
  }
  catch( ... )
  {
    delete m_library;
    m_library = NULL;
    throw;
  }
}


TestPlugInSuite::~TestPlugInSuite()
{
  if ( m_interface )
    m_interface->uninitialize();
  delete m_library;
}


int 
TestPlugInSuite::getChildTestCount() const
{
  return m_librarySuite->getChildTestCount();
}


Test *
TestPlugInSuite::doGetChildTestAt( int index ) const
{
  return m_librarySuite->getChildTestAt( index );
}


} //  namespace CppUnit


#endif // !defined(CPPUNIT_NO_TESTPLUGIN)