diff --git a/test/common_test/world_features.cc b/test/common_test/world_features.cc index b4d3b784d..e9aa3436a 100644 --- a/test/common_test/world_features.cc +++ b/test/common_test/world_features.cc @@ -179,6 +179,47 @@ TEST_F(WorldFeaturesTestGravity, GravityFeatures) } } +using ConstructModelFeatures = gz::physics::FeatureList< + gz::physics::GetEngineInfo, + gz::physics::sdf::ConstructSdfWorld, + gz::physics::sdf::ConstructSdfModel, + gz::physics::GetModelFromWorld, + gz::physics::ForwardStep +>; + +using WorldFeaturesTestConstructModel = + WorldFeaturesTest; + +///////////////////////////////////////////////// +TEST_F(WorldFeaturesTestConstructModel, ConstructModelUnsortedLinks) +{ + for (const std::string &name : this->pluginNames) + { + std::cout << "Testing plugin: " << name << std::endl; + gz::plugin::PluginPtr plugin = this->loader.Instantiate(name); + + auto engine = + gz::physics::RequestEngine3d::From(plugin); + ASSERT_NE(nullptr, engine); + EXPECT_TRUE(engine->GetName().find(this->PhysicsEngineName(name)) != + std::string::npos); + + sdf::Root root; + const sdf::Errors errors = root.Load( + gz::common::joinPaths(TEST_WORLD_DIR, "world_unsorted_links.world")); + EXPECT_TRUE(errors.empty()) << errors; + const sdf::World *sdfWorld = root.WorldByIndex(0); + EXPECT_NE(nullptr, sdfWorld); + + // Per https://github.com/gazebosim/gz-physics/pull/562, there is a + // seg-fault in the bullet-featherstone implementation of ConstructSdfModel + // (called by ConstructSdfWorld). So loading the world successfully + // is enough for this test. + auto world = engine->ConstructWorld(*root.WorldByIndex(0)); + EXPECT_NE(nullptr, world); + } +} + using WorldModelFeatureList = gz::physics::FeatureList< GravityFeatures, gz::physics::WorldModelFeature, diff --git a/test/common_test/worlds/world_unsorted_links.world b/test/common_test/worlds/world_unsorted_links.world new file mode 100644 index 000000000..667b62559 --- /dev/null +++ b/test/common_test/worlds/world_unsorted_links.world @@ -0,0 +1,40 @@ + + + + + + + + + + + + world + parent_link + + + parent_link + child_linkA + + 0 0 1 + + + + child_linkA + child_linkB + + 0 0 1 + + + + child_linkB + child_linkC + + 0 0 1 + + + + +