Skip to content

Commit

Permalink
win,test: de-flake fs_event_watch_dir_short_path
Browse files Browse the repository at this point in the history
New versions of Windows ship with 8.3 short-names disabled.
This commit adds 8.3 detection logic in the
fs_event_watch_dir_short_path test.

PR-URL: libuv#2103
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Bartosz Sosnowski <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
  • Loading branch information
refack authored and cjihrig committed Jan 15, 2019
1 parent 6fc797c commit 37da57b
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions test/test-fs-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ TEST_IMPL(fs_event_watch_dir_recursive) {
#ifdef _WIN32
TEST_IMPL(fs_event_watch_dir_short_path) {
uv_loop_t* loop;
uv_fs_t req;
int has_shortnames;
int r;

/* Setup */
Expand All @@ -489,26 +491,37 @@ TEST_IMPL(fs_event_watch_dir_short_path) {
create_dir("watch_dir");
create_file("watch_dir/file1");

r = uv_fs_event_init(loop, &fs_event);
ASSERT(r == 0);
r = uv_fs_event_start(&fs_event, fs_event_cb_dir, "watch_~1", 0);
ASSERT(r == 0);
r = uv_timer_init(loop, &timer);
ASSERT(r == 0);
r = uv_timer_start(&timer, timer_cb_file, 100, 0);
ASSERT(r == 0);
/* Newer version of Windows ship with
HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\NtfsDisable8dot3NameCreation
not equal to 0. So we verify the files we created are addressable by a 8.3
short name */
has_shortnames = uv_fs_stat(NULL, &req, "watch_~1", NULL) != UV_ENOENT;
if (has_shortnames) {
r = uv_fs_event_init(loop, &fs_event);
ASSERT(r == 0);
r = uv_fs_event_start(&fs_event, fs_event_cb_dir, "watch_~1", 0);
ASSERT(r == 0);
r = uv_timer_init(loop, &timer);
ASSERT(r == 0);
r = uv_timer_start(&timer, timer_cb_file, 100, 0);
ASSERT(r == 0);

uv_run(loop, UV_RUN_DEFAULT);
uv_run(loop, UV_RUN_DEFAULT);

ASSERT(fs_event_cb_called == 1);
ASSERT(timer_cb_called == 1);
ASSERT(close_cb_called == 1);
ASSERT(fs_event_cb_called == 1);
ASSERT(timer_cb_called == 1);
ASSERT(close_cb_called == 1);
}

/* Cleanup */
remove("watch_dir/file1");
remove("watch_dir/");

MAKE_VALGRIND_HAPPY();

if (!has_shortnames)
RETURN_SKIP("Was not able to address files with 8.3 short name.");

return 0;
}
#endif
Expand Down

0 comments on commit 37da57b

Please sign in to comment.