test/eeed8b54e0df-test: check write(2) return value

Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Jens Axboe
2019-05-01 10:07:37 -06:00
parent eb9d065415
commit 60b330558f

View File

@@ -11,8 +11,11 @@
#include "../src/liburing.h" #include "../src/liburing.h"
#define BLOCK 4096
static int get_file_fd(void) static int get_file_fd(void)
{ {
ssize_t ret;
char *buf; char *buf;
int fd; int fd;
@@ -22,12 +25,20 @@ static int get_file_fd(void)
return -1; return -1;
} }
buf = malloc(4096); buf = malloc(BLOCK);
write(fd, buf, 4096); ret = write(fd, buf, BLOCK);
if (ret != BLOCK) {
if (ret < 0)
perror("write");
else
printf("Short write\n");
goto err;
}
fsync(fd); fsync(fd);
if (posix_fadvise(fd, 0, 4096, POSIX_FADV_DONTNEED)) { if (posix_fadvise(fd, 0, 4096, POSIX_FADV_DONTNEED)) {
perror("fadvise"); perror("fadvise");
err:
close(fd); close(fd);
free(buf); free(buf);
return -1; return -1;