1020
1021
if(inotify_add_watch(fd, dir, IN_CLOSE_WRITE | IN_MOVED_TO
1021
| IN_MOVED_FROM| IN_DELETE | IN_EXCL_UNLINK)
1022
| IN_MOVED_FROM| IN_DELETE | IN_EXCL_UNLINK
1023
1025
error(0, errno, "Failed to create inotify watch on %s", dir);
3452
3454
g_assert_cmpuint((unsigned int)queue->length, ==, 0);
3457
static void test_add_inotify_dir_watch_nondir(__attribute__((unused))
3458
test_fixture *fixture,
3459
__attribute__((unused))
3462
__attribute__((cleanup(cleanup_close)))
3463
const int epoll_fd = epoll_create1(EPOLL_CLOEXEC);
3464
g_assert_cmpint(epoll_fd, >=, 0);
3465
__attribute__((cleanup(cleanup_queue)))
3466
task_queue *queue = create_queue();
3467
g_assert_nonnull(queue);
3468
__attribute__((cleanup(string_set_clear)))
3469
string_set cancelled_filenames = {};
3470
const mono_microsecs current_time = 0;
3472
bool quit_now = false;
3473
buffer password = {};
3474
bool mandos_client_exited = false;
3475
bool password_is_read = false;
3477
const char not_a_directory[] = "/dev/tty";
3479
FILE *real_stderr = stderr;
3480
FILE *devnull = fopen("/dev/null", "we");
3481
g_assert_nonnull(devnull);
3483
g_assert_false(add_inotify_dir_watch(queue, epoll_fd, &quit_now,
3484
&password, not_a_directory,
3485
&cancelled_filenames,
3487
&mandos_client_exited,
3488
&password_is_read));
3489
stderr = real_stderr;
3490
g_assert_cmpint(fclose(devnull), ==, 0);
3492
g_assert_cmpuint((unsigned int)queue->length, ==, 0);
3455
3495
static void test_add_inotify_dir_watch_EAGAIN(__attribute__((unused))
3456
3496
test_fixture *fixture,
3457
3497
__attribute__((unused))
7905
7945
test_add_inotify_dir_watch);
7906
7946
test_add_st("/task-creators/add_inotify_dir_watch/fail",
7907
7947
test_add_inotify_dir_watch_fail);
7948
test_add_st("/task-creators/add_inotify_dir_watch/not-a-directory",
7949
test_add_inotify_dir_watch_nondir);
7908
7950
test_add_st("/task-creators/add_inotify_dir_watch/EAGAIN",
7909
7951
test_add_inotify_dir_watch_EAGAIN);
7910
7952
test_add_st("/task-creators/add_inotify_dir_watch/IN_CLOSE_WRITE",