18 #if defined(ABSL_HAVE_ALARM) 21 #elif defined(__linux__) || defined(__APPLE__) 22 #error all known Linux and Apple targets have alarm 25 #include "gtest/gtest.h" 34 EXPECT_GE(now, before);
35 EXPECT_GE(after, now);
40 #if defined(ABSL_HAVE_ALARM) 41 bool alarm_handler_invoked =
false;
43 void AlarmHandler(
int signo) {
44 ASSERT_EQ(signo, SIGALRM);
45 alarm_handler_invoked =
true;
57 #if defined(ABSL_HAVE_ALARM) 58 sig_t old_alarm = SIG_DFL;
59 if (alarm_policy == AlarmPolicy::kWithAlarm) {
60 alarm_handler_invoked =
false;
61 old_alarm = signal(SIGALRM, AlarmHandler);
65 EXPECT_EQ(alarm_policy, AlarmPolicy::kWithoutAlarm);
71 #if defined(ABSL_HAVE_ALARM) 72 if (alarm_policy == AlarmPolicy::kWithAlarm) {
73 signal(SIGALRM, old_alarm);
74 if (!alarm_handler_invoked)
continue;
77 if (lower_bound <= actual && actual <= upper_bound) {
92 if (SleepForBounded(d, lower_bound, upper_bound, timeout, alarm_policy,
94 return testing::AssertionSuccess();
96 return testing::AssertionFailure()
97 <<
"SleepFor(" << d <<
") did not return within [" << lower_bound
98 <<
":" << upper_bound <<
"] in " << attempts <<
" attempt" 99 << (attempts == 1 ?
"" :
"s") <<
" over " << timeout
100 << (alarm_policy == AlarmPolicy::kWithAlarm ?
" with" :
" without")
110 EXPECT_TRUE(AssertSleepForBounded(d, early, late, timeout,
111 AlarmPolicy::kWithoutAlarm));
112 #if defined(ABSL_HAVE_ALARM) 113 EXPECT_TRUE(AssertSleepForBounded(d, early, late, timeout,
114 AlarmPolicy::kWithAlarm));
void SleepFor(absl::Duration duration)
constexpr Time FromUnixNanos(int64_t ns)
constexpr Duration Milliseconds(int64_t n)
int64_t ToInt64Seconds(Duration d)
int64_t GetCurrentTimeNanos()
TEST(Symbolize, Unimplemented)