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