Skip to content

Commit

Permalink
add test on the hardware statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Jan 16, 2025
1 parent 6699413 commit 9daa4fa
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions hardware_interface_testing/test/test_resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,45 @@ class ResourceManagerTestReadWriteDifferentReadWriteRate : public ResourceManage
auto [ok_write, failed_hardware_names_write] = rm->write(time, duration);
EXPECT_TRUE(ok_write);
EXPECT_TRUE(failed_hardware_names_write.empty());

if (test_for_changing_values)
{
auto status_map = rm->get_components_status();
auto check_periodicity = [&](const std::string & component_name, unsigned int rate)
{
if (i > (cm_update_rate_ / rate))
{
EXPECT_LT(
status_map[component_name].read_statistics->execution_time.get_statistics().average,
100);
EXPECT_LT(
status_map[component_name].read_statistics->periodicity.get_statistics().average,
1.2 * rate);
EXPECT_THAT(
status_map[component_name].read_statistics->periodicity.get_statistics().min,
testing::AllOf(testing::Ge(0.5 * rate), testing::Lt((1.2 * rate))));
EXPECT_THAT(
status_map[component_name].read_statistics->periodicity.get_statistics().max,
testing::AllOf(testing::Ge(0.75 * rate), testing::Lt((2.0 * rate))));

EXPECT_LT(
status_map[component_name].write_statistics->execution_time.get_statistics().average,
100);
EXPECT_LT(
status_map[component_name].write_statistics->periodicity.get_statistics().average,
1.2 * rate);
EXPECT_THAT(
status_map[component_name].write_statistics->periodicity.get_statistics().min,
testing::AllOf(testing::Ge(0.5 * rate), testing::Lt((1.2 * rate))));
EXPECT_THAT(
status_map[component_name].write_statistics->periodicity.get_statistics().max,
testing::AllOf(testing::Ge(0.75 * rate), testing::Lt((2.0 * rate))));
}
};

check_periodicity(TEST_ACTUATOR_HARDWARE_NAME, actuator_rw_rate_);
check_periodicity(TEST_SYSTEM_HARDWARE_NAME, system_rw_rate_);
}
node_.get_clock()->sleep_until(time + duration);
time = node_.get_clock()->now();
}
Expand Down

0 comments on commit 9daa4fa

Please sign in to comment.