diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-10-04 16:53:17 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-10-04 16:53:20 -0700 |
commit | 627f379f2273341426ab3d5cb7eb4d5c148d500a (patch) | |
tree | 70e7a29423d2572db04fd16ce664396e9bbf0426 /deps/uv/test/test-fs-event.c | |
parent | bc7cfd7cd7c2e513a9ac9a2820f3b6f7331735b5 (diff) | |
download | node-new-627f379f2273341426ab3d5cb7eb4d5c148d500a.tar.gz |
upgrade libuv to 0303197
Diffstat (limited to 'deps/uv/test/test-fs-event.c')
-rw-r--r-- | deps/uv/test/test-fs-event.c | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/deps/uv/test/test-fs-event.c b/deps/uv/test/test-fs-event.c index d249ec6692..724000db15 100644 --- a/deps/uv/test/test-fs-event.c +++ b/deps/uv/test/test-fs-event.c @@ -25,11 +25,12 @@ #include <string.h> #include <fcntl.h> -uv_fs_event_t fs_event; -uv_timer_t timer; -int timer_cb_called; -int close_cb_called; -int fs_event_cb_called; +static uv_fs_event_t fs_event; +static uv_timer_t timer; +static int timer_cb_called; +static int close_cb_called; +static int fs_event_cb_called; +static int timer_cb_touch_called; static void create_dir(uv_loop_t* loop, const char* name) { int r; @@ -84,7 +85,7 @@ static void fs_event_cb_dir(uv_fs_event_t* handle, const char* filename, ASSERT(handle == &fs_event); ASSERT(status == 0); ASSERT(events == UV_RENAME); - ASSERT(strcmp(filename, "file1") == 0); + ASSERT(filename == NULL || strcmp(filename, "file1") == 0); uv_close((uv_handle_t*)handle, close_cb); } @@ -94,7 +95,7 @@ static void fs_event_cb_file(uv_fs_event_t* handle, const char* filename, ASSERT(handle == &fs_event); ASSERT(status == 0); ASSERT(events == UV_CHANGE); - ASSERT(strcmp(filename, "file2") == 0); + ASSERT(filename == NULL || strcmp(filename, "file2") == 0); uv_close((uv_handle_t*)handle, close_cb); } @@ -104,7 +105,7 @@ static void fs_event_cb_file_current_dir(uv_fs_event_t* handle, ASSERT(handle == &fs_event); ASSERT(status == 0); ASSERT(events == UV_CHANGE); - ASSERT(strcmp(filename, "watch_file") == 0); + ASSERT(filename == NULL || strcmp(filename, "watch_file") == 0); uv_close((uv_handle_t*)handle, close_cb); } @@ -125,6 +126,13 @@ static void timer_cb_file(uv_timer_t* handle, int status) { } } +static void timer_cb_touch(uv_timer_t* timer, int status) { + ASSERT(status == 0); + uv_close((uv_handle_t*)timer, NULL); + touch_file(timer->loop, "watch_file"); + timer_cb_touch_called++; +} + TEST_IMPL(fs_event_watch_dir) { uv_fs_t fs_req; uv_loop_t* loop = uv_default_loop(); @@ -192,10 +200,13 @@ TEST_IMPL(fs_event_watch_file) { } TEST_IMPL(fs_event_watch_file_current_dir) { + uv_timer_t timer; + uv_loop_t* loop; uv_fs_t fs_req; - uv_loop_t* loop = uv_default_loop(); int r; + loop = uv_default_loop(); + /* Setup */ uv_fs_unlink(loop, &fs_req, "watch_file", NULL); create_file(loop, "watch_file"); @@ -203,11 +214,20 @@ TEST_IMPL(fs_event_watch_file_current_dir) { r = uv_fs_event_init(loop, &fs_event, "watch_file", fs_event_cb_file_current_dir); ASSERT(r != -1); - - touch_file(loop, "watch_file"); + + r = uv_timer_init(loop, &timer); + ASSERT(r == 0); + + r = uv_timer_start(&timer, timer_cb_touch, 1, 0); + ASSERT(r == 0); + + ASSERT(timer_cb_touch_called == 0); + ASSERT(fs_event_cb_called == 0); + ASSERT(close_cb_called == 0); uv_run(loop); + ASSERT(timer_cb_touch_called == 1); ASSERT(fs_event_cb_called == 1); ASSERT(close_cb_called == 1); |