aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/test/helper/wait_for.h
blob: f09958d4c0473e0a518c348883648a5c29de4631 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#pragma once

#include <util/datetime/base.h>
#include <util/system/yassert.h>

#define UNIT_WAIT_FOR(condition)                                                     \
    do {                                                                             \
        TInstant start(TInstant::Now());                                             \
        while (!(condition) && (TInstant::Now() - start < TDuration::Seconds(10))) { \
            Sleep(TDuration::MilliSeconds(1));                                       \
        }                                                                            \
        /* TODO: use UNIT_ASSERT if in unittest thread */                            \
        Y_VERIFY(condition, "condition failed after 10 seconds wait");               \
    } while (0)