@@ -302,7 +302,7 @@ static void timer_cb(uv_timer_t* handle, int status) {
ASSERT(status == 0);

r = uv_fs_event_init(handle->loop, &fs_event, ".", fs_event_fail, 0);
ASSERT(r != -1);
ASSERT(r == 0);

uv_close((uv_handle_t*)&fs_event, close_cb);
uv_close((uv_handle_t*)handle, close_cb);
@@ -328,3 +328,21 @@ TEST_IMPL(fs_event_immediate_close) {

return 0;
}


TEST_IMPL(fs_event_unref) {
uv_loop_t* loop;
int r;

loop = uv_default_loop();

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

uv_unref(loop);

r = uv_run(loop);
ASSERT(r == 0);

return 0;
}
@@ -1476,3 +1476,71 @@ TEST_IMPL(fs_file_open_append) {

return 0;
}


TEST_IMPL(fs_rename_to_existing_file) {
int r;

/* Setup. */
unlink("test_file");
unlink("test_file2");

loop = uv_default_loop();

r = uv_fs_open(loop, &open_req1, "test_file", O_WRONLY | O_CREAT,
S_IWRITE | S_IREAD, NULL);
ASSERT(r != -1);
ASSERT(open_req1.result != -1);
uv_fs_req_cleanup(&open_req1);

r = uv_fs_write(loop, &write_req, open_req1.result, test_buf,
sizeof(test_buf), -1, NULL);
ASSERT(r != -1);
ASSERT(write_req.result != -1);
uv_fs_req_cleanup(&write_req);

r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
ASSERT(r != -1);
ASSERT(close_req.result != -1);
uv_fs_req_cleanup(&close_req);

r = uv_fs_open(loop, &open_req1, "test_file2", O_WRONLY | O_CREAT,
S_IWRITE | S_IREAD, NULL);
ASSERT(r != -1);
ASSERT(open_req1.result != -1);
uv_fs_req_cleanup(&open_req1);

r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
ASSERT(r != -1);
ASSERT(close_req.result != -1);
uv_fs_req_cleanup(&close_req);

r = uv_fs_rename(loop, &rename_req, "test_file", "test_file2", NULL);
ASSERT(r != -1);
ASSERT(rename_req.result != -1);
uv_fs_req_cleanup(&rename_req);

r = uv_fs_open(loop, &open_req1, "test_file2", O_RDONLY, 0, NULL);
ASSERT(r != -1);
ASSERT(open_req1.result != -1);
uv_fs_req_cleanup(&open_req1);

memset(buf, 0, sizeof(buf));
r = uv_fs_read(loop, &read_req, open_req1.result, buf, sizeof(buf), -1,
NULL);
ASSERT(r != -1);
ASSERT(read_req.result != -1);
ASSERT(strcmp(buf, test_buf) == 0);
uv_fs_req_cleanup(&read_req);

r = uv_fs_close(loop, &close_req, open_req1.result, NULL);
ASSERT(r != -1);
ASSERT(close_req.result != -1);
uv_fs_req_cleanup(&close_req);

/* Cleanup */
unlink("test_file");
unlink("test_file2");

return 0;
}
@@ -115,9 +115,11 @@ 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_unref)
TEST_DECLARE (fs_readdir_empty_dir)
TEST_DECLARE (fs_readdir_file)
TEST_DECLARE (fs_open_dir)
TEST_DECLARE (fs_rename_to_existing_file)
TEST_DECLARE (threadpool_queue_work_simple)
TEST_DECLARE (threadpool_multiple_event_loops)
TEST_DECLARE (thread_mutex)
@@ -282,9 +284,11 @@ 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_unref)
TEST_ENTRY (fs_readdir_empty_dir)
TEST_ENTRY (fs_readdir_file)
TEST_ENTRY (fs_open_dir)
TEST_ENTRY (fs_rename_to_existing_file)
TEST_ENTRY (threadpool_queue_work_simple)
TEST_ENTRY (threadpool_multiple_event_loops)
TEST_ENTRY (thread_mutex)