Go to the documentation of this file.
28 #if defined(__APPLE__) && !TARGET_OS_IPHONE
29 # include <AvailabilityMacros.h>
33 # if defined(__APPLE__) || \
34 defined(__DragonFly__) || \
35 defined(__FreeBSD__) || \
36 defined(__FreeBSD_kernel__) || \
37 defined(__OpenBSD__) || \
39 # define HAVE_KQUEUE 1
44 # define CREATE_TIMEOUT 100
46 # define CREATE_TIMEOUT 1
52 #if defined(__APPLE__) || defined(_WIN32)
53 static const char file_prefix_in_subdir[] =
"subdir";
54 static int fs_multievent_cb_called;
74 ASSERT(0 &&
"should never be called");
129 ASSERT(0 &&
"fail_cb called");
138 #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
180 for (
i = 0;
i < 16;
i++) {
208 #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
225 #if defined(__APPLE__) || defined(_WIN32)
226 static const char* fs_event_get_filename_in_subdir(
int i) {
229 "watch_dir/subdir/%s%d",
256 for (
i = 0;
i < 16;
i++) {
257 r = remove(fs_event_get_filename_in_subdir(
i));
291 if (strcmp(
filename,
"subdir") == 0)
294 fs_multievent_cb_called++;
298 #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
300 file_prefix_in_subdir,
301 sizeof(file_prefix_in_subdir) - 1) == 0);
305 file_prefix_in_subdir,
306 sizeof(file_prefix_in_subdir) - 1) == 0);
328 #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
355 #if defined(__APPLE__) || defined(_WIN32) || defined(__linux__)
425 #if defined(NO_FS_EVENTS)
427 #elif defined(__MVS__)
428 RETURN_SKIP(
"Directory watching not supported on this platform.");
436 remove(
"watch_dir/file2");
437 remove(
"watch_dir/file1");
438 remove(
"watch_dir/");
457 remove(
"watch_dir/file2");
458 remove(
"watch_dir/file1");
459 remove(
"watch_dir/");
467 #if defined(__APPLE__) || defined(_WIN32)
475 remove(
"watch_dir/file2");
476 remove(
"watch_dir/file1");
477 remove(
"watch_dir/subdir");
478 remove(
"watch_dir/");
485 fs_event_cb_dir_multi_file_in_subdir,
517 fs_event_unlink_files_in_subdir(NULL);
518 remove(
"watch_dir/file2");
519 remove(
"watch_dir/file1");
520 remove(
"watch_dir/subdir");
521 remove(
"watch_dir/");
526 RETURN_SKIP(
"Recursive directory watching not supported on this platform.");
531 TEST_IMPL(fs_event_watch_dir_short_path) {
539 remove(
"watch_dir/file1");
540 remove(
"watch_dir/");
548 has_shortnames =
uv_fs_stat(NULL, &
req,
"watch_~1", NULL) != UV_ENOENT;
549 if (has_shortnames) {
567 remove(
"watch_dir/file1");
568 remove(
"watch_dir/");
573 RETURN_SKIP(
"Was not able to address files with 8.3 short name.");
581 #if defined(NO_FS_EVENTS)
589 remove(
"watch_dir/file2");
590 remove(
"watch_dir/file1");
591 remove(
"watch_dir/");
612 remove(
"watch_dir/file2");
613 remove(
"watch_dir/file1");
614 remove(
"watch_dir/");
626 #if defined(NO_FS_EVENTS)
636 remove(
"watch_dir/file.js");
637 remove(
"watch_dir/file.jsx");
638 remove(
"watch_dir/");
642 #if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_12)
665 remove(
"watch_dir/file.js");
666 remove(
"watch_dir/file.jsx");
667 remove(
"watch_dir/");
674 #if defined(NO_FS_EVENTS)
677 const char path[] =
"test/fixtures/empty_file";
683 timer.data = watchers;
698 #if defined(NO_FS_EVENTS)
708 remove(
"watch_file");
710 #if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_12)
744 remove(
"watch_file");
751 TEST_IMPL(fs_event_watch_file_root_dir) {
755 const char* sys_drive =
getenv(
"SystemDrive");
756 char path[] =
"\\\\?\\X:\\bootsect.bak";
758 ASSERT(sys_drive != NULL);
759 strncpy(
path +
sizeof(
"\\\\?\\") - 1, sys_drive, 1);
767 RETURN_SKIP(
"bootsect.bak doesn't exist in system root.\n");
778 #if defined(NO_FS_EVENTS)
786 remove(
"watch_dir/file1");
787 remove(
"watch_dir/");
808 remove(
"watch_dir/file1");
809 remove(
"watch_dir/");
816 #if defined(NO_FS_EVENTS)
824 remove(
"watch_dir/file1");
825 remove(
"watch_dir/");
845 remove(
"watch_dir/file1");
846 remove(
"watch_dir/");
867 #if defined(NO_FS_EVENTS)
892 #if defined(NO_FS_EVENTS)
918 remove(
"watch_dir/file");
919 remove(
"watch_dir/");
926 #if defined(NO_FS_EVENTS)
928 #elif defined(__MVS__)
929 RETURN_SKIP(
"Directory watching not supported on this platform.");
960 remove(
"watch_dir/");
967 #if defined(NO_FS_EVENTS)
996 remove(
"watch_dir/");
1002 #if defined(NO_FS_EVENTS)
1010 const char*
const watch_dir[] = {
1014 "watch_dir/subfolder/..",
1015 "watch_dir//subfolder//..//",
1049 remove(
"watch_dir/");
1054 #if defined(__APPLE__)
1056 static int fs_event_error_reported;
1063 fs_event_error_reported =
status;
1088 remove(
"watch_dir/");
1104 fs_event_error_report_cb,
1115 if (fs_event_error_reported != 0)
1120 ASSERT(fs_event_error_reported == UV_EMFILE);
1138 remove(
"watch_dir/");
1155 #if defined(NO_FS_EVENTS)
#define ARRAY_SIZE(array)
UV_EXTERN int uv_fs_open(uv_loop_t *loop, uv_fs_t *req, const char *path, int flags, int mode, uv_fs_cb cb)
static void touch_file(const char *name)
const grpc_generator::File * file
static void timer_cb_close_handle(uv_timer_t *timer)
UV_EXTERN int uv_fs_stat(uv_loop_t *loop, uv_fs_t *req, const char *path, uv_fs_cb cb)
static char fs_event_filename[1024]
static int fs_event_cb_called
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
UV_EXTERN int uv_fs_event_stop(uv_fs_event_t *handle)
static void fs_event_cb_file(uv_fs_event_t *handle, const char *filename, int events, int status)
static int close_cb_called
UV_EXTERN int uv_fs_mkdir(uv_loop_t *loop, uv_fs_t *req, const char *path, int mode, uv_fs_cb cb)
UV_EXTERN void uv_unref(uv_handle_t *)
UV_EXTERN void uv_close(uv_handle_t *handle, uv_close_cb close_cb)
UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t *handle, char *buffer, size_t *size)
static void timer_cb_file(uv_timer_t *handle)
UV_EXTERN int uv_loop_close(uv_loop_t *loop)
static void fail_cb(uv_fs_event_t *handle, const char *path, int events, int status)
UV_EXTERN void uv_update_time(uv_loop_t *)
UV_EXTERN uv_loop_t * uv_default_loop(void)
static int timer_cb_exact_called
static int fs_event_created
static void fs_event_create_files(uv_timer_t *handle)
static const int fs_event_file_count
static const char * fs_event_get_filename(int i)
UV_EXTERN int uv_is_active(const uv_handle_t *handle)
static void create_dir(const char *name)
static uv_fs_event_t fs_event
static void timer_cb_watch_twice(uv_timer_t *handle)
static void fs_event_fail(uv_fs_event_t *handle, const char *filename, int events, int status)
static void timer_cb_exact(uv_timer_t *handle)
UV_EXTERN int uv_loop_init(uv_loop_t *loop)
UV_EXTERN void uv_sleep(unsigned int msec)
static void fs_event_cb_file_current_dir(uv_fs_event_t *handle, const char *filename, int events, int status)
UV_EXTERN int uv_fs_close(uv_loop_t *loop, uv_fs_t *req, uv_file file, uv_fs_cb cb)
static int fs_event_removed
static void close_cb(uv_handle_t *handle)
#define MAKE_VALGRIND_HAPPY()
#define TEST_FILE_LIMIT(num)
UV_EXTERN void uv_ref(uv_handle_t *)
static void fs_event_cb_dir(uv_fs_event_t *handle, const char *filename, int events, int status)
static void fs_event_unlink_files(uv_timer_t *handle)
UV_EXTERN int uv_fs_write(uv_loop_t *loop, uv_fs_t *req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb)
static void fs_event_cb_close(uv_fs_event_t *handle, const char *filename, int events, int status)
static void fs_event_cb_dir_multi_file(uv_fs_event_t *handle, const char *filename, int events, int status)
static const char file_prefix[]
UV_EXTERN uv_buf_t uv_buf_init(char *base, unsigned int len)
UV_EXTERN int uv_fs_event_start(uv_fs_event_t *handle, uv_fs_event_cb cb, const char *path, unsigned int flags)
UV_EXTERN void uv_fs_req_cleanup(uv_fs_t *req)
#define RETURN_SKIP(explanation)
static int timer_cb_called
UV_EXTERN int uv_timer_start(uv_timer_t *handle, uv_timer_cb cb, uint64_t timeout, uint64_t repeat)
UV_EXTERN int uv_timer_init(uv_loop_t *, uv_timer_t *handle)
UV_EXTERN int uv_fs_event_init(uv_loop_t *loop, uv_fs_event_t *handle)
static void timer_cb_touch(uv_timer_t *timer)
TEST_IMPL(fs_event_watch_dir)
static int timer_cb_touch_called
static void timer_cb(uv_timer_t *handle)
static void create_file(const char *name)
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:26