Skip to content

Commit b63ab54

Browse files
ricardobranco777pevik
authored andcommitted
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. Closes: #1285 Reviewed-by: Martin Doucha <mdoucha@suse.cz> Reviewed-by: Cyril Hrubis <chrubis@suse.cz> Reviewed-by: Petr Vorel <pvorel@suse.cz> Signed-off-by: Ricardo Branco <rbranco@suse.de>
1 parent 6aa4d0e commit b63ab54

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

testcases/kernel/syscalls/userfaultfd/userfaultfd03.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "config.h"
1515
#include <poll.h>
16+
#include <unistd.h>
1617
#include "tst_test.h"
1718
#include "tst_safe_macros.h"
1819
#include "tst_safe_pthread.h"
@@ -23,6 +24,15 @@ static char *page;
2324
static void *copy_page;
2425
static int uffd;
2526

27+
static void setup(void)
28+
{
29+
if (access("/dev/userfaultfd", F_OK) != 0) {
30+
int res = (tst_kvercmp(6, 1, 0) < 0) ? TCONF : TBROK;
31+
32+
tst_brk(res, "/dev/userfaultfd not found");
33+
}
34+
}
35+
2636
static int open_userfaultfd(int flags)
2737
{
2838
int fd, fd2;
@@ -117,6 +127,10 @@ static void run(void)
117127

118128
static struct tst_test test = {
119129
.needs_root = 1,
130+
.setup = setup,
120131
.test_all = run,
121-
.min_kver = "5.11",
132+
.needs_kconfigs = (const char *[]) {
133+
"CONFIG_USERFAULTFD=y",
134+
NULL
135+
}
122136
};

0 commit comments

Comments
 (0)