Skip to content

Commit

Permalink
test/no-mmap-inval: add test case for invalid SQ ring address
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Oct 18, 2023
1 parent 4b7a98c commit 794d756
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
36 changes: 36 additions & 0 deletions test/no-mmap-inval.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* SPDX-License-Identifier: MIT */
/*
* Description: test that using SETUP_NO_MMAP with an invalid SQ ring
* address fails.
*
*/
#include <stdlib.h>
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>

#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;
}

0 comments on commit 794d756

Please sign in to comment.