1435eb1bdSPatrick Williams #include <sdbusplus/async.hpp> 2435eb1bdSPatrick Williams 3435eb1bdSPatrick Williams #include <chrono> 4435eb1bdSPatrick Williams 5435eb1bdSPatrick Williams #include <gtest/gtest.h> 6435eb1bdSPatrick Williams 7435eb1bdSPatrick Williams using namespace std::literals; 8435eb1bdSPatrick Williams TEST(Timer,DelaySome)9435eb1bdSPatrick WilliamsTEST(Timer, DelaySome) 10435eb1bdSPatrick Williams { 11435eb1bdSPatrick Williams static constexpr auto timeout = 500ms; 12435eb1bdSPatrick Williams 13435eb1bdSPatrick Williams sdbusplus::async::context ctx; 14435eb1bdSPatrick Williams 15435eb1bdSPatrick Williams auto start = std::chrono::steady_clock::now(); 16435eb1bdSPatrick Williams 173c242ba4SPatrick Williams ctx.spawn(sdbusplus::async::sleep_for(ctx, timeout) | 18*5e7ef083SPatrick Williams stdexec::then([&ctx]() { ctx.request_stop(); })); 193c242ba4SPatrick Williams ctx.run(); 20435eb1bdSPatrick Williams 21435eb1bdSPatrick Williams auto stop = std::chrono::steady_clock::now(); 22435eb1bdSPatrick Williams 23435eb1bdSPatrick Williams EXPECT_GT(stop - start, timeout); 246ea246afSPatrick Williams EXPECT_LT(stop - start, timeout * 3); 25435eb1bdSPatrick Williams } 26