aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/test/helper/wait_for.h
blob: b8363900b80eedd7f7ba48600172402fb0d5b220 (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_ABORT_UNLESS(condition, "condition failed after 10 seconds wait");               \
    } while (0)