summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/libuv/test/test-timer.c
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/libuv/test/test-timer.c')
-rw-r--r--3rdparty/libuv/test/test-timer.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/3rdparty/libuv/test/test-timer.c b/3rdparty/libuv/test/test-timer.c
index aba050fd64c..080a73005ee 100644
--- a/3rdparty/libuv/test/test-timer.c
+++ b/3rdparty/libuv/test/test-timer.c
@@ -301,3 +301,30 @@ TEST_IMPL(timer_null_callback) {
MAKE_VALGRIND_HAPPY();
return 0;
}
+
+
+static uint64_t timer_early_check_expected_time;
+
+
+static void timer_early_check_cb(uv_timer_t* handle) {
+ uint64_t hrtime = uv_hrtime() / 1000000;
+ ASSERT(hrtime >= timer_early_check_expected_time);
+}
+
+
+TEST_IMPL(timer_early_check) {
+ uv_timer_t timer_handle;
+ const uint64_t timeout_ms = 10;
+
+ timer_early_check_expected_time = uv_now(uv_default_loop()) + timeout_ms;
+
+ ASSERT(0 == uv_timer_init(uv_default_loop(), &timer_handle));
+ ASSERT(0 == uv_timer_start(&timer_handle, timer_early_check_cb, timeout_ms, 0));
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
+
+ uv_close((uv_handle_t*) &timer_handle, NULL);
+ ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT));
+
+ MAKE_VALGRIND_HAPPY();
+ return 0;
+}