blob: dfa95a68e3132c1a923dc84ba4958924c6629929 [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 * 2);
}