Skip to content

Commit

Permalink
add different sleeps for better statistics testing
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Feb 2, 2025
1 parent 11cada5 commit db01902
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class TestActuator : public ActuatorInterface
if (get_hardware_info().is_async)
{
std::this_thread::sleep_for(
std::chrono::milliseconds(1000 / (3 * get_hardware_info().rw_rate)));
std::chrono::milliseconds(1000 / (6 * get_hardware_info().rw_rate)));
}
// simulate error on write
if (velocity_command_ == test_constants::WRITE_FAIL_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class TestSystem : public SystemInterface
if (get_hardware_info().is_async)
{
std::this_thread::sleep_for(
std::chrono::milliseconds(1000 / (3 * get_hardware_info().rw_rate)));
std::chrono::milliseconds(1000 / (6 * get_hardware_info().rw_rate)));
}
// simulate error on write
if (velocity_command_[0] == test_constants::WRITE_FAIL_VALUE)
Expand Down
18 changes: 10 additions & 8 deletions hardware_interface_testing/test/test_resource_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1887,10 +1887,11 @@ class ResourceManagerTestReadWriteDifferentReadWriteRate : public ResourceManage
{
if (i > (cm_update_rate_ / rate))
{
const double expec_execution_time = (1.e6 / (3 * rate)) + 200.0;
const double expec_read_execution_time = (1.e6 / (3 * rate)) + 200.0;
const double expec_write_execution_time = (1.e6 / (6 * rate)) + 200.0;
EXPECT_LT(
status_map[component_name].read_statistics->execution_time.get_statistics().average,
expec_execution_time);
expec_read_execution_time);
EXPECT_LT(
status_map[component_name].read_statistics->periodicity.get_statistics().average,
1.2 * rate);
Expand All @@ -1903,7 +1904,7 @@ class ResourceManagerTestReadWriteDifferentReadWriteRate : public ResourceManage

EXPECT_LT(
status_map[component_name].write_statistics->execution_time.get_statistics().average,
expec_execution_time);
expec_write_execution_time);
EXPECT_LT(
status_map[component_name].write_statistics->periodicity.get_statistics().average,
1.2 * rate);
Expand Down Expand Up @@ -2292,29 +2293,30 @@ class ResourceManagerTestAsyncReadWrite : public ResourceManagerTest
if (check_for_updated_values)
{
const unsigned int rw_rate = 100u;
const double expec_execution_time = (1.e6 / (3 * rw_rate)) + 200.0;
const double expec_read_execution_time = (1.e6 / (3 * rw_rate)) + 200.0;
const double expec_write_execution_time = (1.e6 / (6 * rw_rate)) + 200.0;
check_periodicity(TEST_ACTUATOR_HARDWARE_NAME, rw_rate);
check_periodicity(TEST_SYSTEM_HARDWARE_NAME, rw_rate);
EXPECT_LT(
status_map[TEST_ACTUATOR_HARDWARE_NAME]
.read_statistics->execution_time.get_statistics()
.average,
expec_execution_time);
expec_read_execution_time);
EXPECT_LT(
status_map[TEST_ACTUATOR_HARDWARE_NAME]
.write_statistics->execution_time.get_statistics()
.average,
expec_execution_time);
expec_write_execution_time);
EXPECT_LT(
status_map[TEST_SYSTEM_HARDWARE_NAME]
.read_statistics->execution_time.get_statistics()
.average,
expec_execution_time);
expec_read_execution_time);
EXPECT_LT(
status_map[TEST_SYSTEM_HARDWARE_NAME]
.write_statistics->execution_time.get_statistics()
.average,
expec_execution_time);
expec_write_execution_time);
}
}

Expand Down

0 comments on commit db01902

Please sign in to comment.