diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 04:52:30 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 04:52:30 +0000 |
commit | 11c8c4dfa4d268bef66f636e126725e46624b7a7 (patch) | |
tree | ebe9c872e416346e4b333e5062da32401c8e0a73 /test/500f9fbadef8.c | |
parent | d53db6851ea17b2d219d084e1afc683b8b62b105 (diff) | |
parent | 1d27ff1934c5c4292dc00fba7f7f8ae411ed42f5 (diff) | |
download | liburing-android14-mainline-media-swcodec-release.tar.gz |
Snap for 10453563 from 1d27ff1934c5c4292dc00fba7f7f8ae411ed42f5 to mainline-media-swcodec-releaseaml_swc_341711000aml_swc_341619000aml_swc_341513600aml_swc_341312300aml_swc_341312020aml_swc_341111000aml_swc_341011020aml_swc_340922010android14-mainline-media-swcodec-release
Change-Id: I7cca6554b0f16e2b5808963242c9da276f36c14d
Diffstat (limited to 'test/500f9fbadef8.c')
-rw-r--r-- | test/500f9fbadef8.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/test/500f9fbadef8.c b/test/500f9fbadef8.c new file mode 100644 index 0000000..dbd5751 --- /dev/null +++ b/test/500f9fbadef8.c @@ -0,0 +1,89 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Description: Single depth submit+wait poll hang test + * + */ +#include <errno.h> +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <fcntl.h> + +#include "helpers.h" +#include "liburing.h" + +#define BLOCKS 4096 + +int main(int argc, char *argv[]) +{ + struct io_uring ring; + struct io_uring_sqe *sqe; + struct io_uring_cqe *cqe; + struct iovec iov; + char buf[32]; + off_t offset; + unsigned blocks; + int ret, fd; + + if (argc > 1) + return 0; + + t_posix_memalign(&iov.iov_base, 4096, 4096); + iov.iov_len = 4096; + + ret = io_uring_queue_init(1, &ring, IORING_SETUP_IOPOLL); + if (ret) { + fprintf(stderr, "ring setup failed\n"); + return 1; + + } + + sprintf(buf, "./XXXXXX"); + fd = mkostemp(buf, O_WRONLY | O_DIRECT | O_CREAT); + if (fd < 0) { + perror("mkostemp"); + return 1; + } + + offset = 0; + blocks = BLOCKS; + do { + sqe = io_uring_get_sqe(&ring); + if (!sqe) { + fprintf(stderr, "get sqe failed\n"); + goto err; + } + io_uring_prep_writev(sqe, fd, &iov, 1, offset); + ret = io_uring_submit_and_wait(&ring, 1); + if (ret < 0) { + fprintf(stderr, "submit_and_wait: %d\n", ret); + goto err; + } + ret = io_uring_wait_cqe(&ring, &cqe); + if (ret < 0) { + fprintf(stderr, "wait completion: %d\n", ret); + goto err; + } + if (cqe->res != 4096) { + if (cqe->res == -EOPNOTSUPP) + goto skipped; + goto err; + } + io_uring_cqe_seen(&ring, cqe); + offset += 4096; + } while (--blocks); + + close(fd); + unlink(buf); + return 0; +err: + close(fd); + unlink(buf); + return 1; +skipped: + fprintf(stderr, "Polling not supported in current dir, test skipped\n"); + close(fd); + unlink(buf); + return 0; +} |