diff options
author | Jens Axboe <axboe@kernel.dk> | 2020-04-27 10:51:30 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-04-27 10:51:30 -0600 |
commit | 06b7fa515e8d19943c3e2ed53b6524ce99fa60ca (patch) | |
tree | 633423d984b6cbc8becb74b44fa16e0dc6dcc781 /test | |
parent | ea020b5497954a41a61e352666f0bd0b3afde874 (diff) | |
download | liburing-06b7fa515e8d19943c3e2ed53b6524ce99fa60ca.tar.gz liburing-06b7fa515e8d19943c3e2ed53b6524ce99fa60ca.tar.bz2 |
test/statx: add test case for AT_EMPTY_PATH + valid fd
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'test')
-rw-r--r-- | test/statx.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/statx.c b/test/statx.c index 3163540..a397593 100644 --- a/test/statx.c +++ b/test/statx.c @@ -88,6 +88,61 @@ err: return -1; } +static int test_statx_fd(struct io_uring *ring, const char *path) +{ + struct io_uring_cqe *cqe; + struct io_uring_sqe *sqe; + struct statx x1; +#if defined(__x86_64) + struct statx x2; +#endif + int ret, fd; + + fd = open(path, O_RDONLY); + if (fd < 0) { + perror("open"); + return 1; + } + + memset(&x1, 0, sizeof(x1)); + + sqe = io_uring_get_sqe(ring); + if (!sqe) { + fprintf(stderr, "get sqe failed\n"); + goto err; + } + io_uring_prep_statx(sqe, fd, "", AT_EMPTY_PATH, STATX_ALL, &x1); + + ret = io_uring_submit(ring); + if (ret <= 0) { + fprintf(stderr, "sqe submit failed: %d\n", ret); + goto err; + } + + ret = io_uring_wait_cqe(ring, &cqe); + if (ret < 0) { + fprintf(stderr, "wait completion %d\n", ret); + goto err; + } + ret = cqe->res; + io_uring_cqe_seen(ring, cqe); + if (ret) + return ret; +#if defined(__x86_64) + memset(&x2, 0, sizeof(x2)); + ret = do_statx(fd, "", AT_EMPTY_PATH, STATX_ALL, &x2); + if (ret < 0) + return -1; + if (memcmp(&x1, &x2, sizeof(x1))) { + fprintf(stderr, "Miscompare between io_uring and statx\n"); + goto err; + } +#endif + return 0; +err: + return -1; +} + int main(int argc, char *argv[]) { struct io_uring ring; @@ -119,6 +174,12 @@ int main(int argc, char *argv[]) fprintf(stderr, "test_statx failed: %d\n", ret); goto err; } + + ret = test_statx_fd(&ring, fname); + if (ret) { + fprintf(stderr, "test_statx_fd failed: %d\n", ret); + goto err; + } done: if (fname != argv[1]) unlink(fname); |