Mapping should be writable and those we can't use read only user memory, check that it fails. It also exercises one of the fail paths. Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> --- test/reg-wait.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/reg-wait.c b/test/reg-wait.c index b7c823a..544cd48 100644 --- a/test/reg-wait.c +++ b/test/reg-wait.c @@ -365,8 +365,22 @@ static int test_regions(void) return T_EXIT_FAIL; } rd.user_addr = (__u64)(unsigned long)buffer; - free(buffer); + + buffer = mmap(NULL, page_size, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (buffer == MAP_FAILED) { + fprintf(stderr, "mmap alloc failed\n"); + return 1; + } + + rd.user_addr = (__u64)(unsigned long)buffer; + ret = test_try_register_region(&mr, true); + if (ret != -EFAULT) { + fprintf(stderr, "test_try_register_region() RO uptr %i\n", ret); + return T_EXIT_FAIL; + } + + munmap(buffer, page_size); return 0; } -- 2.46.0