diff --git a/test/Makefile b/test/Makefile index f16cedc63..c15b2a3f4 100644 --- a/test/Makefile +++ b/test/Makefile @@ -113,6 +113,7 @@ test_srcs := \ msg-ring-flags.c \ msg-ring-overflow.c \ multicqes_drain.c \ + no-mmap-inval.c \ nolibc.c \ nop-all-sizes.c \ nop.c \ diff --git a/test/no-mmap-inval.c b/test/no-mmap-inval.c new file mode 100644 index 000000000..bf4831742 --- /dev/null +++ b/test/no-mmap-inval.c @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Description: test that using SETUP_NO_MMAP with an invalid SQ ring + * address fails. + * + */ +#include +#include +#include +#include + +#include "liburing.h" +#include "helpers.h" + +int main(int argc, char *argv[]) +{ + struct io_uring_params p = { + .sq_entries = 2, + .cq_entries = 4, + .flags = IORING_SETUP_NO_MMAP, + }; + int ret; + + if (argc > 1) + return T_EXIT_SKIP; + + p.cq_off.user_addr = (unsigned long long) valloc(8192); + + ret = io_uring_setup(2, &p); + if (ret != -EFAULT) { + fprintf(stderr, "Got %d, wanted -EFAULT\n", ret); + return T_EXIT_FAIL; + } + + return T_EXIT_PASS; +}