blob: 07e7de75ec846381a2f59b001173d53ce3ff406d [file] [log] [blame]
#include <sdbusplus/async.hpp>
#include <chrono>
#include <gtest/gtest.h>
using namespace std::literals;
TEST(Timer, DelaySome)
{
static constexpr auto timeout = 500ms;
sdbusplus::async::context ctx;
auto start = std::chrono::steady_clock::now();
ctx.spawn(sdbusplus::async::sleep_for(ctx, timeout) |
std::execution::then([&ctx]() { ctx.request_stop(); }));
ctx.run();
auto stop = std::chrono::steady_clock::now();
EXPECT_GT(stop - start, timeout);
EXPECT_LT(stop - start, timeout * 3);
}