win,test: de-flake fs_event_watch_dir_short_path
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: https://github.com/libuv/libuv/pull/2103 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
6fc797c3fe
commit
37da57b695
@ -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 */
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user