43 lines
814 B
C
43 lines
814 B
C
#include <ft/test.h>
|
|
#include <ft/all-tests.h>
|
|
#include <ft/util.h>
|
|
|
|
#include <gint/gint.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <string.h>
|
|
|
|
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: Truncation
|