iommufd: Add a selftest
authorJason Gunthorpe <jgg@nvidia.com>
Tue, 29 Nov 2022 20:29:42 +0000 (16:29 -0400)
committerJason Gunthorpe <jgg@nvidia.com>
Thu, 1 Dec 2022 00:16:49 +0000 (20:16 -0400)
commit57f0988706fec1b8dbc3fe00965828a47e2235a1
tree9a738e5139d7d63aa675c21e7640cdcf6416fde2
parent52f528583bb395495f7dd35e6e4d548bccbf8a73
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/19-v6-a196d26f289e+11787-iommufd_jgg@nvidia.com
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Tested-by: Matthew Rosato <mjrosato@linux.ibm.com> # s390
Tested-by: Yi Liu <yi.l.liu@intel.com>
Tested-by: Eric Auger <eric.auger@redhat.com> # aarch64
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
tools/testing/selftests/Makefile
tools/testing/selftests/iommu/.gitignore [new file with mode: 0644]
tools/testing/selftests/iommu/Makefile [new file with mode: 0644]
tools/testing/selftests/iommu/config [new file with mode: 0644]
tools/testing/selftests/iommu/iommufd.c [new file with mode: 0644]
tools/testing/selftests/iommu/iommufd_fail_nth.c [new file with mode: 0644]
tools/testing/selftests/iommu/iommufd_utils.h [new file with mode: 0644]