Skip to contentSkip to conversation

userfaultfd: Do not use min_kver as gate for test

PATCH In review Ricardo Branco 2 participants 2 messages Jan 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 userfaultfd: Do not use min_kver as gate for test

Do not use .min_kver to decide whether the test should run and instead check for the presence of /dev/userfaultfd at runtime.

---
 .../kernel/syscalls/userfaultfd/userfaultfd03.c    | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/userfaultfd/userfaultfd03.c +13 -1
index ba87bf6e4..d6e1897db 100644
@@ -13,6 +13,7 @@
 
 #include "config.h"
 #include <poll.h>
+#include <unistd.h>
 #include "tst_test.h"
 #include "tst_safe_macros.h"
 #include "tst_safe_pthread.h"
@@ -23,6 +24,17 @@ static char *page;
 static void *copy_page;
 static int uffd;
 
+static void setup(void)
+{
+	if (access("/dev/userfaultfd", F_OK) == 0)
+		return;
+
+	if (tst_kvercmp(6, 1, 0) < 0)
+		tst_brk(TCONF, "/dev/userfaultfd is missing (kernel < 6.1)");
+
+	tst_brk(TBROK, "/dev/userfaultfd is missing (kernel >= 6.1)");
+}
+
 static int open_userfaultfd(int flags)
 {
 	int fd, fd2;
@@ -117,6 +129,6 @@ static void run(void)
 
 static struct tst_test test = {
 	.needs_root = 1,
+	.setup = setup,
 	.test_all = run,
-	.min_kver = "5.11",
 };
Signature · 5 lines
2.52.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi all,

Quoted 2 lines

Do not use .min_kver to decide whether the test should run and instead check for the presence of /dev/userfaultfd at runtime.

FYI Ricardo continue this effort in GH PR [1], thus close this in patchwork.

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp/pull/1285

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp