From b12969c65f60ef61193c7b4217123bcf2dc2605e Mon Sep 17 00:00:00 2001 From: Jonas Vautherin Date: Thu, 28 Nov 2024 23:25:59 +0100 Subject: [PATCH] Make test more resilient to slow runner --- src/system_tests/camera_settings.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/system_tests/camera_settings.cpp b/src/system_tests/camera_settings.cpp index e68e3b4fe..d135537b0 100644 --- a/src/system_tests/camera_settings.cpp +++ b/src/system_tests/camera_settings.cpp @@ -127,10 +127,20 @@ TEST(SystemTest, CameraSettings) camera.reset_settings(camera.camera_list().cameras[0].component_id), Camera::Result::Success); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); + std::pair wb_temp; + + for (size_t i = 0; i < 10; i++) { + // In some setups it takes longer for the param changes to propagate. + // But we want to end the test as early as possible. So we check regularly + // for a period of time and exit early if the check passes. + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + + wb_temp = camera.get_setting(camera.camera_list().cameras[0].component_id, Camera::Setting{"WB_TEMP"}); + if (wb_temp.first == Camera::Result::Success && wb_temp.second.option.option_id == "4000") { + break; + } + } - auto wb_temp = camera.get_setting( - camera.camera_list().cameras[0].component_id, Camera::Setting{"WB_TEMP"}); EXPECT_EQ(wb_temp.first, Camera::Result::Success); EXPECT_EQ(wb_temp.second.option.option_id, "4000"); }