EXPECT_TRUE(os.str() == plugin );
}
-// Unload shared library
-static void unloadShared(std::string plugin_path)
-{
- void *handle = dlopen(plugin_path.c_str(), RTLD_LAZY);
- assert(handle);
-
- // try to close library until it is closed
- for ( int i = 0; !dlclose(handle) && i < 10; i++ ) ;
-
-} // unloadShared
-
-// Test PluginManager that destructor throws exception correctly
-TEST(SUPPORT_NNC, verifyPluginManager4UnloadPlugin)
+// Test PluginManager that destructor doesn't throw exception
+TEST(SUPPORT_NNC, verifyPluginManagerForLoadPlugin)
{
std::string plugin_path{STRING(CMAKE_SAMPLE_PLUGIN_ABS_PATH)};
- bool is_thrown = false;
- // test that destructor throws exception
try
{
// load the library
PluginManager pluginManager(plugin_path);
-
- // unload the library directly
- unloadShared(plugin_path);
}
catch ( const PluginException &e )
{
- // the exception must be thrown from destructor because the library is already unloaded
- is_thrown = true;
+ FAIL();
}
- ASSERT_EQ(is_thrown, true);
-
- // test that destructor doesn't throw exception while stack is unwinding
try
{
// load the library
PluginManager pluginManager(plugin_path);
- // unload the library directly
- unloadShared(plugin_path);
-
throw PluginException("test exception");
}
catch (const PluginException &e)