8 #ifndef OCM_DAQ_TEST_UTILS_HPP_
9 #define OCM_DAQ_TEST_UTILS_HPP_
14 #include <boost/asio/io_context.hpp>
15 #include <gtest/gtest.h>
20 template<
class Predicate>
22 timeout = std::chrono::seconds(3)) {
23 auto until = std::chrono::steady_clock::now() + timeout;
25 while(std::chrono::steady_clock::now() < until) {
32 FAIL() <<
"MakeTestProgressUntil timed out";
41 template <
class Future =
void>
43 using namespace std::chrono;
44 using namespace ::testing;
46 auto work = std::make_unique<boost::asio::io_context::work>(io_ctx);
55 }
catch (std::exception
const& e) {
56 FAIL() <<
"MakeTestProgress caught std::exception: " << e.what();
58 FAIL() <<
"MakeTestProgress caught unknown exception";
61 std::this_thread::yield();
62 if constexpr (!std::is_same_v<Future, void>) {
64 EXPECT_NO_THROW(fut->wait_for(boost::chrono::seconds(3)));
73 ASSERT_TRUE(fut->is_ready()) <<
"Future is not ready after 1s, aborting";
83 #endif // #ifndef OCM_DAQ_TEST_UTILS_HPP_