diff options
author | Jens Axboe <axboe@kernel.dk> | 2019-05-01 10:07:37 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-05-01 10:07:37 -0600 |
commit | 60b330558f75d2093ae81034f01c263cc672ea65 (patch) | |
tree | 1bab5a4cd39a2ff59e04f7bc7a3063c789203a23 /test | |
parent | eb9d0654152bb1debbcf359184d30229629cdf08 (diff) |
test/eeed8b54e0df-test: check write(2) return value
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'test')
-rw-r--r-- | test/eeed8b54e0df-test.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/test/eeed8b54e0df-test.c b/test/eeed8b54e0df-test.c index f9ddfb3..17018a2 100644 --- a/test/eeed8b54e0df-test.c +++ b/test/eeed8b54e0df-test.c @@ -11,8 +11,11 @@ #include "../src/liburing.h" +#define BLOCK 4096 + static int get_file_fd(void) { + ssize_t ret; char *buf; int fd; @@ -22,12 +25,20 @@ static int get_file_fd(void) return -1; } - buf = malloc(4096); - write(fd, buf, 4096); + buf = malloc(BLOCK); + ret = write(fd, buf, BLOCK); + if (ret != BLOCK) { + if (ret < 0) + perror("write"); + else + printf("Short write\n"); + goto err; + } fsync(fd); if (posix_fadvise(fd, 0, 4096, POSIX_FADV_DONTNEED)) { perror("fadvise"); +err: close(fd); free(buf); return -1; |