diff --git a/runtime/test/display_white_cache_test.cpp b/runtime/test/display_white_cache_test.cpp index f8105b3196..8741f5d9b9 100644 --- a/runtime/test/display_white_cache_test.cpp +++ b/runtime/test/display_white_cache_test.cpp @@ -38,7 +38,12 @@ int main() { leonida::DisplayWhiteCache cache([&] { return windows.load(); }, std::chrono::hours(1)); std::this_thread::sleep_for(20ms); // the worker is in its wait by now ok &= check(cache.reads() == 0, "nothing is read before the first HDR10 present asks"); - ok &= check(cache.get() == 0.0f, "the first get() has no value yet (the caller falls back to 203)"); + // The first get() is what wakes the worker, so by the time it returns the read may already have + // landed: scheduling decides whether value_ is still empty. Accept both outcomes and assert the + // part that does not race - that it never returns anything but "no value" or the fresh read. + const float first = cache.get(); + ok &= check(first == 0.0f || first == 240.0f, + "the first get() returns no value yet, or the value it woke the worker to read"); ok &= check(within(2s, [&] { return cache.reads() == 1; }), "the first get() wakes the worker to read now"); ok &= check(within(2s, [&] { return cache.get() == 240.0f; }), "and the value it read is cached"); windows = 300.0f;