Skip to content

Commit

Permalink
Fail test if no scene can be created
Browse files Browse the repository at this point in the history
Replace current print by a FAIL in Gtest to make the test
that can not create an scene to fail. This should help to
avoid false positives in testing.

Signed-off-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
j-rivero committed Dec 3, 2024
1 parent dd143fb commit 0b76fce
Show file tree
Hide file tree
Showing 36 changed files with 161 additions and 72 deletions.
5 changes: 2 additions & 3 deletions src/ArrowVisual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ void ArrowVisualTest::ArrowVisual(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
}

ScenePtr scene = engine->CreateScene("scene");
Expand Down
2 changes: 1 addition & 1 deletion src/AxisVisual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void AxisVisualTest::AxisVisual(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/BoundingBoxCamera_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void BoundingBoxCameraTest::BoundingBoxCamera(const std::string &_renderEngine)
if (_renderEngine.compare("optix") == 0 ||
_renderEngine.compare("ogre") == 0)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' doesn't support bounding box cameras" << std::endl;
return;
}
Expand All @@ -51,7 +51,7 @@ void BoundingBoxCameraTest::BoundingBoxCamera(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/COMVisual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void COMVisualTest::COMVisual(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Camera_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void CameraTest::ViewProjectionMatrix(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down Expand Up @@ -171,7 +171,7 @@ void CameraTest::RenderTexture(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down Expand Up @@ -229,7 +229,7 @@ void CameraTest::TrackFollow(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down Expand Up @@ -305,7 +305,7 @@ void CameraTest::AddRemoveRenderPass(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down Expand Up @@ -363,7 +363,7 @@ void CameraTest::VisibilityMask(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down Expand Up @@ -400,7 +400,7 @@ void CameraTest::IntrinsicMatrix(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Capsule_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void CapsuleTest::Capsule(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/GaussianNoisePass_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void GaussianNoisePassTest::GaussianNoise(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/GizmoVisual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void GizmoVisualTest::GizmoVisual(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down Expand Up @@ -117,7 +117,7 @@ void GizmoVisualTest::Material(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Grid_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void GridTest::Grid(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Heightmap_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TEST_P(HeightmapTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Heightmap))
auto engine = rendering::engine(renderEngine);
if (!engine)
{
igndbg << "Engine '" << renderEngine
FAIL() << "Engine '" << renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/InertiaVisual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void InertiaVisualTest::InertiaVisual(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/JointVisual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void JointVisualTest::JointVisual(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/LidarVisual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void LidarVisualTest::LidarVisual(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/LightVisual_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void LightVisualTest::LightVisual(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Light_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void LightTest::Light(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
45 changes: 45 additions & 0 deletions src/LoadOgre2_TEST.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2024 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include <gtest/gtest.h>

#include <gz/common/Console.hh>

#include "test_config.h" // NOLINT(build/include)

#include "gz/rendering/RenderingIface.hh"
#include "gz/rendering/RenderEngine.hh"

using namespace gz;
using namespace rendering;

TEST(LoadOgre2Test, LoadOgre2)
{
// Get engine
auto engine = rendering::engine("ogre2");
ASSERT_NE(nullptr, engine) << "Unable to load ogre2 render engine"
<< std::endl;

// Clean up
unloadEngine(engine->Name());
}

int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
45 changes: 45 additions & 0 deletions src/LoadOgre_TEST.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2024 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include <gtest/gtest.h>

#include <gz/common/Console.hh>

#include "test_config.h" // NOLINT(build/include)

#include "gz/rendering/RenderingIface.hh"
#include "gz/rendering/RenderEngine.hh"

using namespace gz;
using namespace rendering;

TEST(LoadOgreTest, LoadOgre)
{
// Get engine
auto engine = rendering::engine("ogre");
ASSERT_NE(nullptr, engine) << "Unable to load ogre render engine"
<< std::endl;

// Clean up
unloadEngine(engine->Name());
}

int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
4 changes: 2 additions & 2 deletions src/Marker_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void MarkerTest::Marker(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down Expand Up @@ -200,7 +200,7 @@ void MarkerTest::Material(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Material_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void MaterialTest::MaterialProperties(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down Expand Up @@ -301,7 +301,7 @@ void MaterialTest::Copy(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/MeshDescriptor_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void MeshDescriptorTest::Descriptor(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Mesh_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void MeshTest::MeshSubMesh(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down Expand Up @@ -134,7 +134,7 @@ void MeshTest::MeshSkeleton(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down Expand Up @@ -237,7 +237,7 @@ void MeshTest::MeshSkeletonAnimation(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down Expand Up @@ -337,7 +337,7 @@ void MeshTest::MeshClone(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/MoveToHelper_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void MoveToHelperTest::MoveTo(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Node_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void NodeTest::Pose(const std::string &_renderEngine)
RenderEngine *engine = rendering::engine(_renderEngine);
if (!engine)
{
igndbg << "Engine '" << _renderEngine
FAIL() << "Engine '" << _renderEngine
<< "' is not supported" << std::endl;
return;
}
Expand Down
Loading

0 comments on commit 0b76fce

Please sign in to comment.