From 5728bd4549c18060a2c2fb7cecf8c2a631343ddc Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 21 Nov 2011 18:01:01 +0000 Subject: [PATCH] test: touching a file should generate only one fs event --- test/test-fs-event.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/test-fs-event.c b/test/test-fs-event.c index 59bdebc0..9e169caa 100644 --- a/test/test-fs-event.c +++ b/test/test-fs-event.c @@ -99,14 +99,34 @@ static void fs_event_cb_file(uv_fs_event_t* handle, const char* filename, uv_close((uv_handle_t*)handle, close_cb); } +static void timber_cb_close_handle(uv_timer_t* timer, int status) { + uv_handle_t* handle; + + ASSERT(timer != NULL); + ASSERT(status == 0); + handle = timer->data; + + uv_close((uv_handle_t*)timer, NULL); + uv_close((uv_handle_t*)handle, close_cb); +} + static void fs_event_cb_file_current_dir(uv_fs_event_t* handle, const char* filename, int events, int status) { + ASSERT(fs_event_cb_called == 0); ++fs_event_cb_called; + ASSERT(handle == &fs_event); ASSERT(status == 0); ASSERT(events == UV_CHANGE); ASSERT(filename == NULL || strcmp(filename, "watch_file") == 0); - uv_close((uv_handle_t*)handle, close_cb); + + /* Regression test for SunOS: touch should generate just one event. */ + { + static uv_timer_t timer; + uv_timer_init(handle->loop, &timer); + timer.data = handle; + uv_timer_start(&timer, timber_cb_close_handle, 250, 0); + } } static void timer_cb_dir(uv_timer_t* handle, int status) {