From 6878f68acd3a6c640095f5304298c25b3d6e0c71 Mon Sep 17 00:00:00 2001 From: Yu Shan Date: Mon, 21 Oct 2024 12:46:39 -0700 Subject: [PATCH] Make testHeartBeatEvent more stable. Add a 1s buffer time in case heart beat event is not generated within 3s. Flag: EXEMPT test change Test: atest DefaultVehicleHalTest Bug: 349085162 Change-Id: Id89a3682f60d5c727d6cb9b1c583f19adfd09f07 --- .../vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp b/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp index 4891bf56a9..ad34a4caca 100644 --- a/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp +++ b/automotive/vehicle/aidl/impl/vhal/test/DefaultVehicleHalTest.cpp @@ -1849,6 +1849,12 @@ TEST_F(DefaultVehicleHalTest, testHeartbeatEvent) { std::this_thread::sleep_for(std::chrono::seconds(3)); auto maybeResults = getCallback()->nextOnPropertyEventResults(); + size_t retryCount = 0; + // Add a 1s (100ms * 10) buffer time. + while (!maybeResults.has_value() && retryCount < 10) { + retryCount++; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } ASSERT_TRUE(maybeResults.has_value()) << "no results in callback"; ASSERT_EQ(maybeResults.value().payloads.size(), static_cast(1)); VehiclePropValue gotValue = maybeResults.value().payloads[0];