Skip to content
Snippets Groups Projects
Commit 9df5874f authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

work on tests

parent a3156a92
No related branches found
No related tags found
1 merge request!25Draft: Resolve "Adapt to new sensor constructors in core"
......@@ -8,16 +8,22 @@ add_subdirectory(gtest)
# #
###########################################################
# capture_inertial_kinematics test
wolf_add_gtest(gtest_capture_inertial_kinematics gtest_capture_inertial_kinematics.cpp)
# capture_leg_odom test
wolf_add_gtest(gtest_capture_leg_odom gtest_capture_leg_odom.cpp)
wolf_add_gtest(gtest_feature_inertial_kinematics gtest_feature_inertial_kinematics.cpp)
# factor_inertial_kinematics test
wolf_add_gtest(gtest_factor_inertial_kinematics gtest_factor_inertial_kinematics.cpp)
# factor_force_torque test
wolf_add_gtest(gtest_factor_force_torque gtest_factor_force_torque.cpp)
# feature_inertial_kinematics test
wolf_add_gtest(gtest_feature_inertial_kinematics gtest_feature_inertial_kinematics.cpp)
# force_torque_delta_tools test
wolf_add_gtest(gtest_force_torque_delta_tools gtest_force_torque_delta_tools.cpp)
# TODO: revive those
......@@ -25,9 +31,15 @@ wolf_add_gtest(gtest_force_torque_delta_tools gtest_force_torque_delta_tools.cpp
# wolf_add_gtest(gtest_processor_inertial_kinematics gtest_processor_inertial_kinematics.cpp)
# wolf_add_gtest(gtest_processor_force_torque_preint gtest_processor_force_torque_preint.cpp)
# processor_point_feet_nomove test
wolf_add_gtest(gtest_processor_point_feet_nomove gtest_processor_point_feet_nomove.cpp)
# schema test
wolf_add_gtest(gtest_schema gtest_schema.cpp)
# sensor_force_torque test
wolf_add_gtest(gtest_sensor_force_torque gtest_sensor_force_torque.cpp)
# sensor_inertial_kinematics test
wolf_add_gtest(gtest_sensor_inertial_kinematics gtest_sensor_inertial_kinematics.cpp)
// WOLF - Copyright (C) 2020,2021,2022,2023
// Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
// Authors: Joan Solà Ortega (jsola@iri.upc.edu) and
// Joan Vallvé Navarro (jvallve@iri.upc.edu)
// All rights reserved.
//
// This file is part of WOLF: http://www.iri.upc.edu/wolf
// WOLF is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "bodydynamics/common/bodydynamics.h"
#include "core/utils/utils_gtest.h"
#include "core/map/map_base.h"
#include "core/sensor/sensor_base.h"
#include "core/solver/solver_manager.h"
#include "core/processor/processor_base.h"
#include "core/tree_manager/tree_manager_base.h"
#include "yaml-schema-cpp/yaml_schema.hpp"
using namespace wolf;
using namespace yaml_schema_cpp;
using namespace Eigen;
std::string wolf_schema_dir = _WOLF_SCHEMA_DIR;
std::string plugin_dir = _WOLF_BODYDYNAMICS_CODE_DIR;
// just force the plugin .so library to be loaded
WOLF_LOAD_CORE;
WOLF_LOAD_BODYDYNAMICS;
bool existsSchema(std::string name_schema)
{
// Check extension
if (filesystem::extension(name_schema).empty())
{
name_schema += SCHEMA_EXTENSION;
}
else if (filesystem::extension(name_schema) != SCHEMA_EXTENSION)
{
WOLF_ERROR("Wrong schema file extension ", name_schema, ", it should be '", SCHEMA_EXTENSION, "'");
return false;
}
// Find schema file
try
{
filesystem::path path_schema = findFileRecursive(name_schema, {plugin_dir + "/schema", wolf_schema_dir});
}
catch (const std::exception& e)
{
WOLF_ERROR(name_schema, " was NOT found.");
return false;
}
WOLF_INFO(name_schema, " found!");
return true;
}
TEST(Schema, check_schema_existence)
{
// Check that there is an schema file for each of the registered creators of all Factories from yaml nodes/files
// (all except FactoryStateBlock)
// FactoryLandmark
auto registered_landmarks = FactoryLandmark::getRegisteredKeys();
for (auto key : registered_landmarks)
{
EXPECT_TRUE(existsSchema(key));
}
// FactoryMapNode
auto registered_maps = FactoryMapNode::getRegisteredKeys();
for (auto key : registered_maps)
{
EXPECT_TRUE(existsSchema(key));
}
// FactoryProcessorNode
auto registered_processors = FactoryProcessorNode::getRegisteredKeys();
for (auto key : registered_processors)
{
EXPECT_TRUE(existsSchema(key));
}
// FactorySensorNode
auto registered_sensors = FactorySensorNode::getRegisteredKeys();
for (auto key : registered_sensors)
{
EXPECT_TRUE(existsSchema(key));
}
// FactorySolverNode
auto registered_solvers = FactorySolverNode::getRegisteredKeys();
for (auto key : registered_solvers)
{
EXPECT_TRUE(existsSchema(key));
}
// FactoryTreeManagerNode
auto registered_tree_managers = FactoryTreeManagerNode::getRegisteredKeys();
for (auto key : registered_tree_managers)
{
EXPECT_TRUE(existsSchema(key));
}
}
TEST(Schema, validate_all_schemas)
{
ASSERT_TRUE(validateAllSchemas({plugin_dir + "/schema", wolf_schema_dir}, true));
}
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment