From f9da24263db43da12f1e105cb8ac5e02c66f12d0 Mon Sep 17 00:00:00 2001 From: Peter Xu Date: Wed, 12 Apr 2023 12:45:20 -0400 Subject: selftests/mm: allow uffd test to skip properly with no privilege Allow skip a unit test properly due to no privilege (e.g. sigbus and events tests). [colin.i.king@gmail.com: fix spelling mistake "priviledge" -> "privilege"] Link: https://lkml.kernel.org/r/20230414081506.1678998-1-colin.i.king@gmail.com Link: https://lkml.kernel.org/r/20230412164520.329163-1-peterx@redhat.com Signed-off-by: Peter Xu Signed-off-by: Colin Ian King Cc: Axel Rasmussen Cc: David Hildenbrand Cc: Dmitry Safonov <0x7f454c46@gmail.com> Cc: Mike Kravetz Cc: Mike Rapoport (IBM) Cc: Zach O'Keefe Signed-off-by: Andrew Morton --- tools/testing/selftests/mm/uffd-unit-tests.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tools/testing/selftests/mm/uffd-unit-tests.c') diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index a33d6c928eeb..b0acf558e8cb 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -172,7 +172,8 @@ out: * This function initializes the global variables. TODO: remove global * vars and then remove this. */ -static int uffd_setup_environment(uffd_test_case_t *test, mem_type_t *mem_type) +static int uffd_setup_environment(uffd_test_case_t *test, mem_type_t *mem_type, + const char **errmsg) { map_shared = mem_type->shared; uffd_test_ops = mem_type->mem_ops; @@ -186,7 +187,7 @@ static int uffd_setup_environment(uffd_test_case_t *test, mem_type_t *mem_type) /* TODO: remove this global var.. it's so ugly */ nr_cpus = 1; - return uffd_test_ctx_init(test->uffd_feature_required); + return uffd_test_ctx_init(test->uffd_feature_required, errmsg); } static bool uffd_feature_supported(uffd_test_case_t *test) @@ -835,6 +836,7 @@ int main(int argc, char *argv[]) uffd_test_case_t *test; mem_type_t *mem_type; char test_name[128]; + const char *errmsg; int has_uffd; int i, j; @@ -860,8 +862,8 @@ int main(int argc, char *argv[]) uffd_test_skip("feature missing"); continue; } - if (uffd_setup_environment(test, mem_type)) { - uffd_test_skip("environment setup failed"); + if (uffd_setup_environment(test, mem_type, &errmsg)) { + uffd_test_skip(errmsg); continue; } test->uffd_fn(); -- cgit v1.2.3