selftests/mm: skip test if application doesn't has root privileges
authorMuhammad Usama Anjum <usama.anjum@collabora.com>
Mon, 1 Jan 2024 08:36:13 +0000 (13:36 +0500)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 5 Jan 2024 18:17:48 +0000 (10:17 -0800)
The test depends on writing to nr_hugepages which isn't possible without
root privileges.  So skip the test in this case.

Link: https://lkml.kernel.org/r/20240101083614.1076768-2-usama.anjum@collabora.com
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/compaction_test.c

index 707b0809b7179e10ba2948f402ee3512b12fe921..656afba02dbcc099a29ae3d9c8ccb64b0d16fdc6 100644 (file)
@@ -173,7 +173,7 @@ int main(int argc, char **argv)
 
        ksft_print_header();
 
-       if (prereq() != 0)
+       if (prereq() || geteuid())
                return ksft_exit_pass();
 
        ksft_set_plan(1);