[Devel] [PATCH vz10] selftests/iommu: skip when /dev/iommu is not available

Eva Kurchatova eva.kurchatova at virtuozzo.com
Fri Aug 21 18:05:55 MSK 2026


Without iommufd all 237 subtests fail in FIXTURE_SETUP on the open().

https://virtuozzo.atlassian.net/browse/VSTOR-142443
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova at virtuozzo.com>
---
 tools/testing/selftests/iommu/iommufd.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tools/testing/selftests/iommu/iommufd.c b/tools/testing/selftests/iommu/iommufd.c
index de348d641279..0625e1596bbf 100644
--- a/tools/testing/selftests/iommu/iommufd.c
+++ b/tools/testing/selftests/iommu/iommufd.c
@@ -66,6 +66,8 @@ FIXTURE(iommufd)
 FIXTURE_SETUP(iommufd)
 {
 	self->fd = open("/dev/iommu", O_RDWR);
+	if (self->fd < 0)
+		SKIP(return, "/dev/iommu is not available");
 	ASSERT_NE(-1, self->fd);
 }
 
@@ -254,6 +256,8 @@ FIXTURE_VARIANT(change_process)
 FIXTURE_SETUP(change_process)
 {
 	self->fd = open("/dev/iommu", O_RDWR);
+	if (self->fd < 0)
+		SKIP(return, "/dev/iommu is not available");
 	ASSERT_NE(-1, self->fd);
 
 	drop_cap_ipc_lock(_metadata);
@@ -360,6 +364,8 @@ FIXTURE_SETUP(iommufd_ioas)
 
 
 	self->fd = open("/dev/iommu", O_RDWR);
+	if (self->fd < 0)
+		SKIP(return, "/dev/iommu is not available");
 	ASSERT_NE(-1, self->fd);
 	test_ioctl_ioas_alloc(&self->ioas_id);
 
@@ -1641,6 +1647,8 @@ FIXTURE_SETUP(iommufd_mock_domain)
 	unsigned int i;
 
 	self->fd = open("/dev/iommu", O_RDWR);
+	if (self->fd < 0)
+		SKIP(return, "/dev/iommu is not available");
 	ASSERT_NE(-1, self->fd);
 	test_ioctl_ioas_alloc(&self->ioas_id);
 
@@ -2114,6 +2122,8 @@ FIXTURE_SETUP(iommufd_dirty_tracking)
 	}
 
 	self->fd = open("/dev/iommu", O_RDWR);
+	if (self->fd < 0)
+		SKIP(return, "/dev/iommu is not available");
 	ASSERT_NE(-1, self->fd);
 
 	mmap_flags = MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED;
@@ -2484,6 +2494,8 @@ FIXTURE_SETUP(vfio_compat_mock_domain)
 	};
 
 	self->fd = open("/dev/iommu", O_RDWR);
+	if (self->fd < 0)
+		SKIP(return, "/dev/iommu is not available");
 	ASSERT_NE(-1, self->fd);
 
 	/* Create what VFIO would consider a group */
@@ -2773,6 +2785,8 @@ FIXTURE_VARIANT(iommufd_viommu)
 FIXTURE_SETUP(iommufd_viommu)
 {
 	self->fd = open("/dev/iommu", O_RDWR);
+	if (self->fd < 0)
+		SKIP(return, "/dev/iommu is not available");
 	ASSERT_NE(-1, self->fd);
 	test_ioctl_ioas_alloc(&self->ioas_id);
 	test_ioctl_set_default_memory_limit();
@@ -3236,6 +3250,8 @@ FIXTURE_VARIANT(iommufd_device_pasid)
 FIXTURE_SETUP(iommufd_device_pasid)
 {
 	self->fd = open("/dev/iommu", O_RDWR);
+	if (self->fd < 0)
+		SKIP(return, "/dev/iommu is not available");
 	ASSERT_NE(-1, self->fd);
 	test_ioctl_ioas_alloc(&self->ioas_id);
 
-- 
2.55.0



More information about the Devel mailing list