diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 05:04:01 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 05:04:01 +0000 |
commit | 821578a500691b0c438599fa18e664534aee1ebe (patch) | |
tree | ebe9c872e416346e4b333e5062da32401c8e0a73 /test/b5837bd5311d.c | |
parent | d53db6851ea17b2d219d084e1afc683b8b62b105 (diff) | |
parent | 1d27ff1934c5c4292dc00fba7f7f8ae411ed42f5 (diff) | |
download | liburing-821578a500691b0c438599fa18e664534aee1ebe.tar.gz |
Snap for 10453563 from 1d27ff1934c5c4292dc00fba7f7f8ae411ed42f5 to mainline-permission-releaseaml_per_341711000aml_per_341614000aml_per_341510010aml_per_341410020aml_per_341311000aml_per_341110020aml_per_341110010aml_per_341011100aml_per_341011020aml_per_340916010android14-mainline-permission-release
Change-Id: Iea5b067f051d3000a8529c5712d506aea8f25919
Diffstat (limited to 'test/b5837bd5311d.c')
-rw-r--r-- | test/b5837bd5311d.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/test/b5837bd5311d.c b/test/b5837bd5311d.c new file mode 100644 index 0000000..57a2b58 --- /dev/null +++ b/test/b5837bd5311d.c @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Description: Check to see if wait_nr is being honored. + */ +#include <stdio.h> +#include "liburing.h" + +int main(int argc, char *argv[]) +{ + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + struct io_uring ring; + int ret; + struct __kernel_timespec ts = { + .tv_sec = 0, + .tv_nsec = 10000000 + }; + + if (argc > 1) + return 0; + + if (io_uring_queue_init(4, &ring, 0) != 0) { + fprintf(stderr, "ring setup failed\n"); + return 1; + } + + /* + * First, submit the timeout sqe so we can actually finish the test + * if everything is in working order. + */ + sqe = io_uring_get_sqe(&ring); + if (!sqe) { + fprintf(stderr, "get sqe failed\n"); + return 1; + } + io_uring_prep_timeout(sqe, &ts, (unsigned)-1, 0); + + ret = io_uring_submit(&ring); + if (ret != 1) { + fprintf(stderr, "Got submit %d, expected 1\n", ret); + return 1; + } + + /* + * Next, submit a nop and wait for two events. If everything is working + * as it should, we should be waiting for more than a millisecond and we + * should see two cqes. Otherwise, execution continues immediately + * and we see only one cqe. + */ + sqe = io_uring_get_sqe(&ring); + if (!sqe) { + fprintf(stderr, "get sqe failed\n"); + return 1; + } + io_uring_prep_nop(sqe); + + ret = io_uring_submit_and_wait(&ring, 2); + if (ret != 1) { + fprintf(stderr, "Got submit %d, expected 1\n", ret); + return 1; + } + + if (io_uring_peek_cqe(&ring, &cqe) != 0) { + fprintf(stderr, "Unable to peek cqe!\n"); + return 1; + } + + io_uring_cqe_seen(&ring, cqe); + + if (io_uring_peek_cqe(&ring, &cqe) != 0) { + fprintf(stderr, "Unable to peek cqe!\n"); + return 1; + } + + io_uring_queue_exit(&ring); + return 0; +} |