Skip to content

Commit 57f0988

Browse files
committed
iommufd: Add a selftest
Cover the essential functionality of the iommufd with a directed test from userspace. This aims to achieve reasonable functional coverage using the in-kernel self test framework. A second test does a failure injection sweep of the success paths to study error unwind behaviors. This allows achieving high coverage of the corner cases in pages.c. The selftest requires CONFIG_IOMMUFD_TEST to be enabled, and several huge pages which may require: echo 4 > /proc/sys/vm/nr_hugepages Link: https://lore.kernel.org/r/[email protected] Tested-by: Nicolin Chen <[email protected]> Tested-by: Matthew Rosato <[email protected]> # s390 Tested-by: Yi Liu <[email protected]> Tested-by: Eric Auger <[email protected]> # aarch64 Signed-off-by: Nicolin Chen <[email protected]> Signed-off-by: Yi Liu <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 52f5285 commit 57f0988

File tree

7 files changed

+2530
-0
lines changed

7 files changed

+2530
-0
lines changed

tools/testing/selftests/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ TARGETS += ftrace
2727
TARGETS += futex
2828
TARGETS += gpio
2929
TARGETS += intel_pstate
30+
TARGETS += iommu
3031
TARGETS += ipc
3132
TARGETS += ir
3233
TARGETS += kcmp
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
/iommufd
3+
/iommufd_fail_nth
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-License-Identifier: GPL-2.0-only
2+
CFLAGS += -Wall -O2 -Wno-unused-function
3+
CFLAGS += -I../../../../include/uapi/
4+
CFLAGS += -I../../../../include/
5+
6+
CFLAGS += -D_GNU_SOURCE
7+
8+
TEST_GEN_PROGS :=
9+
TEST_GEN_PROGS += iommufd
10+
TEST_GEN_PROGS += iommufd_fail_nth
11+
12+
include ../lib.mk
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_IOMMUFD
2+
CONFIG_IOMMUFD_TEST

0 commit comments

Comments
 (0)