#include #include #include #include #include #include #include #include static void _ft_fcntl_open_switch(ft_test *t) { int fd, rc; errno = 0; DO_E(fd, open("ft_open.txt", O_RDONLY), t, "%d"); ft_assert(t, fd == -1 && errno == ENOENT); if(fd != -1) close(fd); DO_E(fd, open("ft_open.txt", O_RDWR | O_CREAT), t, "%d"); ft_assert(t, fd >= 0); if(fd != -1) { DO_E(rc, close(fd), t, "%d"); ft_assert(t, rc == 0); DO_E(rc, unlink("ft_open.txt"), t, "%d"); ft_assert(t, rc == 0); } } static void _ft_fcntl_open(ft_test *t) { gint_world_switch(GINT_CALL(_ft_fcntl_open_switch, (void *)t)); } ft_test ft_fcntl_open = { .name = "Opening files", .function = _ft_fcntl_open, }; // TODO: Opening files with different access modes // TODO: Opening files with O_TRUNC or O_APPEND