Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RenderingIface_TEST's RegisterEngine test to only load the specified engine #1098

Open
wants to merge 1 commit into
base: gz-rendering9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/RenderEngineManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,18 @@ void RenderEngineManager::UnregisterEngine(const std::string &_name)
std::lock_guard<std::recursive_mutex> lock(this->dataPtr->enginesMutex);
auto iter = this->dataPtr->engines.find(_name);

if (iter == this->dataPtr->engines.end())
{
// Check if the provided name is a name of a default engine, if so,
// translate the name to the shared library name
auto defaultIt = this->dataPtr->defaultEngines.find(_name);
if (defaultIt != this->dataPtr->defaultEngines.end())
iter = this->dataPtr->engines.find(defaultIt->second);

if (iter == this->dataPtr->engines.end())
gzerr << "No render-engine registered with name: " << _name << std::endl;
}

if (iter != this->dataPtr->engines.end())
{
this->dataPtr->UnregisterEngine(iter);
Expand Down
11 changes: 8 additions & 3 deletions test/common_test/RenderingIface_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,19 @@ TEST(RenderingIfaceTest, RegisterEngine)
if (count == 0)
return;

// unregister existing engine by index
RenderEngine *eng = engine(0u);
RenderEngine *eng = nullptr;
std::string engineToTest = "";
if (gz::utils::env(kEngineToTestEnv, engineToTest))
eng = engine(engineToTest);
else
eng = engine(0u);

ASSERT_NE(nullptr, eng);
auto engineName = eng->Name();
ASSERT_FALSE(engineName.empty());

EXPECT_TRUE(hasEngine(engineName));
EXPECT_NO_THROW(unregisterEngine(0u));
EXPECT_NO_THROW(unregisterEngine(engineName));
EXPECT_FALSE(hasEngine(engineName));

// register engine back with a different name
Expand Down
Loading