|
|
@ -30,8 +30,8 @@ static void timer_cb(uv_timer_t* handle, int status); |
|
|
|
static void close_cb(uv_handle_t* handle); |
|
|
|
static void poll_cb(uv_fs_poll_t* handle, |
|
|
|
int status, |
|
|
|
uv_statbuf_t* prev, |
|
|
|
uv_statbuf_t* curr); |
|
|
|
const uv_statbuf_t* prev, |
|
|
|
const uv_statbuf_t* curr); |
|
|
|
|
|
|
|
static uv_fs_poll_t poll_handle; |
|
|
|
static uv_timer_t timer_handle; |
|
|
@ -74,50 +74,49 @@ static void timer_cb(uv_timer_t* handle, int status) { |
|
|
|
|
|
|
|
static void poll_cb(uv_fs_poll_t* handle, |
|
|
|
int status, |
|
|
|
uv_statbuf_t* prev, |
|
|
|
uv_statbuf_t* curr) { |
|
|
|
const uv_statbuf_t* prev, |
|
|
|
const uv_statbuf_t* curr) { |
|
|
|
const static uv_statbuf_t zero_statbuf; |
|
|
|
|
|
|
|
ASSERT(handle == &poll_handle); |
|
|
|
ASSERT(uv_is_active((uv_handle_t*)handle)); |
|
|
|
ASSERT(prev != NULL); |
|
|
|
ASSERT(curr != NULL); |
|
|
|
|
|
|
|
switch (poll_cb_called++) { |
|
|
|
case 0: |
|
|
|
ASSERT(status == -1); |
|
|
|
ASSERT(prev == NULL); |
|
|
|
ASSERT(curr == NULL); |
|
|
|
ASSERT(uv_last_error(loop).code == UV_ENOENT); |
|
|
|
ASSERT(0 == memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); |
|
|
|
ASSERT(0 == memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); |
|
|
|
touch_file(FIXTURE); |
|
|
|
break; |
|
|
|
|
|
|
|
case 1: |
|
|
|
ASSERT(status == 0); |
|
|
|
ASSERT(prev != NULL); |
|
|
|
ASSERT(curr != NULL); |
|
|
|
{ |
|
|
|
uv_statbuf_t buf; |
|
|
|
memset(&buf, 0, sizeof(buf)); |
|
|
|
ASSERT(0 == memcmp(&buf, prev, sizeof(buf))); |
|
|
|
} |
|
|
|
ASSERT(0 == memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); |
|
|
|
ASSERT(0 != memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); |
|
|
|
ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 20, 0)); |
|
|
|
break; |
|
|
|
|
|
|
|
case 2: |
|
|
|
ASSERT(status == 0); |
|
|
|
ASSERT(prev != NULL); |
|
|
|
ASSERT(curr != NULL); |
|
|
|
ASSERT(0 != memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); |
|
|
|
ASSERT(0 != memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); |
|
|
|
ASSERT(0 == uv_timer_start(&timer_handle, timer_cb, 200, 0)); |
|
|
|
break; |
|
|
|
|
|
|
|
case 3: |
|
|
|
ASSERT(status == 0); |
|
|
|
ASSERT(prev != NULL); |
|
|
|
ASSERT(curr != NULL); |
|
|
|
ASSERT(0 != memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); |
|
|
|
ASSERT(0 != memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); |
|
|
|
remove(FIXTURE); |
|
|
|
break; |
|
|
|
|
|
|
|
case 4: |
|
|
|
ASSERT(status == -1); |
|
|
|
ASSERT(prev == NULL); |
|
|
|
ASSERT(curr == NULL); |
|
|
|
ASSERT(0 != memcmp(prev, &zero_statbuf, sizeof(zero_statbuf))); |
|
|
|
ASSERT(0 == memcmp(curr, &zero_statbuf, sizeof(zero_statbuf))); |
|
|
|
ASSERT(uv_last_error(loop).code == UV_ENOENT); |
|
|
|
uv_close((uv_handle_t*)handle, close_cb); |
|
|
|
break; |
|
|
|