test: reflect new idle semantics in test
Update the `idle_starvation` test to verify not only that idle callbacks are called, but also that they are called once per loop iteration.
This commit is contained in:
parent
bc56a4e05c
commit
b5cd78ea05
@ -23,10 +23,12 @@
|
|||||||
#include "task.h"
|
#include "task.h"
|
||||||
|
|
||||||
|
|
||||||
static uv_timer_t timer_handle;
|
|
||||||
static uv_idle_t idle_handle;
|
static uv_idle_t idle_handle;
|
||||||
|
static uv_check_t check_handle;
|
||||||
|
static uv_timer_t timer_handle;
|
||||||
|
|
||||||
static int idle_cb_called = 0;
|
static int idle_cb_called = 0;
|
||||||
|
static int check_cb_called = 0;
|
||||||
static int timer_cb_called = 0;
|
static int timer_cb_called = 0;
|
||||||
static int close_cb_called = 0;
|
static int close_cb_called = 0;
|
||||||
|
|
||||||
@ -41,6 +43,7 @@ static void timer_cb(uv_timer_t* handle, int status) {
|
|||||||
ASSERT(status == 0);
|
ASSERT(status == 0);
|
||||||
|
|
||||||
uv_close((uv_handle_t*) &idle_handle, close_cb);
|
uv_close((uv_handle_t*) &idle_handle, close_cb);
|
||||||
|
uv_close((uv_handle_t*) &check_handle, close_cb);
|
||||||
uv_close((uv_handle_t*) &timer_handle, close_cb);
|
uv_close((uv_handle_t*) &timer_handle, close_cb);
|
||||||
|
|
||||||
timer_cb_called++;
|
timer_cb_called++;
|
||||||
@ -57,6 +60,15 @@ static void idle_cb(uv_idle_t* handle, int status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void check_cb(uv_check_t* handle, int status) {
|
||||||
|
ASSERT(handle == &check_handle);
|
||||||
|
ASSERT(status == 0);
|
||||||
|
|
||||||
|
check_cb_called++;
|
||||||
|
LOGF("check_cb %d\n", check_cb_called);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_IMPL(idle_starvation) {
|
TEST_IMPL(idle_starvation) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -65,6 +77,11 @@ TEST_IMPL(idle_starvation) {
|
|||||||
r = uv_idle_start(&idle_handle, idle_cb);
|
r = uv_idle_start(&idle_handle, idle_cb);
|
||||||
ASSERT(r == 0);
|
ASSERT(r == 0);
|
||||||
|
|
||||||
|
r = uv_check_init(uv_default_loop(), &check_handle);
|
||||||
|
ASSERT(r == 0);
|
||||||
|
r = uv_check_start(&check_handle, check_cb);
|
||||||
|
ASSERT(r == 0);
|
||||||
|
|
||||||
r = uv_timer_init(uv_default_loop(), &timer_handle);
|
r = uv_timer_init(uv_default_loop(), &timer_handle);
|
||||||
ASSERT(r == 0);
|
ASSERT(r == 0);
|
||||||
r = uv_timer_start(&timer_handle, timer_cb, 50, 0);
|
r = uv_timer_start(&timer_handle, timer_cb, 50, 0);
|
||||||
@ -75,7 +92,7 @@ TEST_IMPL(idle_starvation) {
|
|||||||
|
|
||||||
ASSERT(idle_cb_called > 0);
|
ASSERT(idle_cb_called > 0);
|
||||||
ASSERT(timer_cb_called == 1);
|
ASSERT(timer_cb_called == 1);
|
||||||
ASSERT(close_cb_called == 2);
|
ASSERT(close_cb_called == 3);
|
||||||
|
|
||||||
MAKE_VALGRIND_HAPPY();
|
MAKE_VALGRIND_HAPPY();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user