Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Test: verify that no callbacks are made after closing an fs event wat…
Browse files Browse the repository at this point in the history
…cher
  • Loading branch information
piscisaureus committed Mar 27, 2012
1 parent 89303f3 commit 732cf91
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/test-fs-event.c
Expand Up @@ -308,3 +308,35 @@ TEST_IMPL(fs_event_immediate_close) {

return 0;
}


TEST_IMPL(fs_event_close_with_pending_event) {
uv_loop_t* loop;
uv_fs_t fs_req;
int r;

loop = uv_default_loop();

create_dir(loop, "watch_dir");
create_file(loop, "watch_dir/file");

r = uv_fs_event_init(loop, &fs_event, "watch_dir", fs_event_fail, 0);
ASSERT(r == 0);

/* Generate an fs event. */
touch_file(loop, "watch_dir/file");

uv_close((uv_handle_t*)&fs_event, close_cb);

uv_run(loop);

ASSERT(close_cb_called == 1);

/* Clean up */
r = uv_fs_unlink(loop, &fs_req, "watch_dir/file", NULL);
ASSERT(r == 0);
r = uv_fs_rmdir(loop, &fs_req, "watch_dir", NULL);
ASSERT(r == 0);

return 0;
}
2 changes: 2 additions & 0 deletions test/test-list.h
Expand Up @@ -131,6 +131,7 @@ TEST_DECLARE (fs_event_watch_file)
TEST_DECLARE (fs_event_watch_file_current_dir)
TEST_DECLARE (fs_event_no_callback_on_close)
TEST_DECLARE (fs_event_immediate_close)
TEST_DECLARE (fs_event_close_with_pending_event)
TEST_DECLARE (fs_readdir_empty_dir)
TEST_DECLARE (fs_readdir_file)
TEST_DECLARE (fs_open_dir)
Expand Down Expand Up @@ -315,6 +316,7 @@ TASK_LIST_START
TEST_ENTRY (fs_event_watch_file_current_dir)
TEST_ENTRY (fs_event_no_callback_on_close)
TEST_ENTRY (fs_event_immediate_close)
TEST_ENTRY (fs_event_close_with_pending_event)
TEST_ENTRY (fs_readdir_empty_dir)
TEST_ENTRY (fs_readdir_file)
TEST_ENTRY (fs_open_dir)
Expand Down

0 comments on commit 732cf91

Please sign in to comment.