/** get dll file URL.
*/ static OUString getDllURL()
{ #ifdefined(_WIN32) // lib in Unix and lib in Windows are not same in file name.
OUString libPath( "test_Module_DLL.dll" ); #else
OUString libPath( u"libtest_Module_DLL.so"_ustr ); #endif
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test get Module URL from address.",
bRes );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test get Module URL from address.", 0 < aFileURL.lastIndexOf('/') );
}
void getUrlFromAddress_002( )
{ #if !defined( MACOSX ) // TODO: Find out why this fails on macOS
::osl::Module aMod( getDllURL( ) );
FuncPtr pFunc = reinterpret_cast<FuncPtr>(aMod.getSymbol( u"firstfunc"_ustr ));
CPPUNIT_ASSERT_MESSAGE( "#test comment#: load an external library, get its function address and get its URL.",
bRes );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: load an external library, get its function address and get its URL.", 0 < aFileURL.lastIndexOf('/') );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: load an external library, get its function address and get its URL.",
aFileURL.equalsIgnoreAsciiCase( getDllURL( ) ) ); #endif
}
/* tester comments: another case is getFunctionSymbol_001*/
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test if a module is a loaded module.",
!bRes );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test if a module is a loaded module.",
bRes1 );
}
CPPUNIT_TEST_SUITE( is );
CPPUNIT_TEST( is_001 );
CPPUNIT_TEST_SUITE_END( );
}; // class is
/** testing the methods: void*SAL_CALLgetSymbol(constOUString&strSymbolName)
*/ class getSymbol : public CppUnit::TestFixture
{ public: bool bRes;
CPPUNIT_ASSERT_MESSAGE( "#test comment#: the m_Module of a Module instance will be NULL when is not loaded, it will not be NULL after loaded.",
bRes );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: the m_Module of a Module instance will be NULL when is not loaded, it will not be NULL after loaded.",
bRes1 ); #endif
}
void optr_oslModule_002( )
{ #if !defined( MACOSX ) // TODO: Find out why this fails on macOS
::osl::Module aMod( getDllURL( ) );
OUString funcName( u"firstfunc"_ustr );
/** testing the methods: oslGenericFunctionSAL_CALLgetFunctionSymbol(constOUString&ustrFunctionSymbolName)
*/ class getFunctionSymbol : public CppUnit::TestFixture
{ public: bool bRes, bRes1;
void getFunctionSymbol_001( )
{ #if !defined( MACOSX ) // TODO: Find out why this fails on macOS
::osl::Module aMod( getDllURL( ) );
oslGenericFunction oslFunc = aMod.getFunctionSymbol( "firstfunc" );
OUString aLibraryURL;
bRes = ::osl::Module::getUrlFromAddress( oslFunc, aLibraryURL);
aMod.unload();
CPPUNIT_ASSERT_MESSAGE( "#test comment#: load a dll and get its function addr and get its URL.",
bRes );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: load a dll and get its function addr and get its URL.",
aLibraryURL.equalsIgnoreAsciiCase( getDllURL() ) ); #endif
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.