aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/test/helper/wait_for.h
blob: 029ab0da48c28ced965a0c8d5030f5487244f9db (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)