OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
* [Devel] [PATCH vz10 v2] selftests/iommu: skip when the mock device is not there
@ 2026-08-25 11:50 Eva Kurchatova
  2026-08-25 14:50 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
  2026-08-25 14:50 ` [Devel] [PATCH vz10 v2] " Konstantin Khorenko
  0 siblings, 2 replies; 3+ messages in thread
From: Eva Kurchatova @ 2026-08-25 11:50 UTC (permalink / raw)


Both iommufd tests need the mock device the iommufd module registers
under CONFIG_IOMMUFD_TEST, and they open /dev/iommu in every fixture
without checking, so on a kernel that does not provide it every case
fails on the open.

Checking the open is not enough on its own. /dev/iommu appears as soon
as the iommufd module is loaded, which says nothing about the mock
device: the release config here is CONFIG_IOMMUFD=m with
CONFIG_IOMMUFD_TEST unset, so the open succeeds and the tests fail later
in the ioctls that drive the mock device instead. Only the debug config
sets CONFIG_IOMMUFD_TEST.

/sys/bus/iommufd_mock covers both, it exists only once the module is
loaded and the kernel was built with CONFIG_IOMMUFD_TEST. Check for it
once before handing over to the harness, rather than in each of the
fixtures, and report a skip. test_harness_run() is what TEST_HARNESS_MAIN
calls anyway, so the tests still run exactly as they did.

https://virtuozzo.atlassian.net/browse/VSTOR-142443
Feature: fix selftests
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/iommu/iommufd.c          | 15 ++++++++++++++-
 tools/testing/selftests/iommu/iommufd_fail_nth.c | 15 ++++++++++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/iommu/iommufd.c b/tools/testing/selftests/iommu/iommufd.c
index de348d641279..5e0309a7ec67 100644
--- a/tools/testing/selftests/iommu/iommufd.c
+++ b/tools/testing/selftests/iommu/iommufd.c
@@ -3523,4 +3523,17 @@ TEST_F(iommufd_device_pasid, pasid_attach)
 	test_cmd_mock_domain_replace(self->stdev_id, self->ioas_id);
 }
 
-TEST_HARNESS_MAIN
+static bool iommufd_mock_available(void)
+{
+	return access("/sys/bus/iommufd_mock", F_OK) == 0;
+}
+
+int main(int argc, char **argv)
+{
+	if (!iommufd_mock_available())
+		ksft_exit_skip("no iommufd mock device, the tests need "
+			       "CONFIG_IOMMUFD_TEST=y and the iommufd "
+			       "module loaded\n");
+
+	return test_harness_run(argc, argv);
+}
diff --git a/tools/testing/selftests/iommu/iommufd_fail_nth.c b/tools/testing/selftests/iommu/iommufd_fail_nth.c
index 45c14323a618..a76cd19970c0 100644
--- a/tools/testing/selftests/iommu/iommufd_fail_nth.c
+++ b/tools/testing/selftests/iommu/iommufd_fail_nth.c
@@ -745,4 +745,17 @@ TEST_FAIL_NTH(basic_fail_nth, device)
 	return 0;
 }
 
-TEST_HARNESS_MAIN
+static bool iommufd_mock_available(void)
+{
+	return access("/sys/bus/iommufd_mock", F_OK) == 0;
+}
+
+int main(int argc, char **argv)
+{
+	if (!iommufd_mock_available())
+		ksft_exit_skip("no iommufd mock device, the tests need "
+			       "CONFIG_IOMMUFD_TEST=y and the iommufd "
+			       "module loaded\n");
+
+	return test_harness_run(argc, argv);
+}
-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Devel] [PATCH RHEL10 COMMIT] selftests/iommu: skip when the mock device is not there
  2026-08-25 11:50 [Devel] [PATCH vz10 v2] selftests/iommu: skip when the mock device is not there Eva Kurchatova
@ 2026-08-25 14:50 ` Konstantin Khorenko
  2026-08-25 14:50 ` [Devel] [PATCH vz10 v2] " Konstantin Khorenko
  1 sibling, 0 replies; 3+ messages in thread
From: Konstantin Khorenko @ 2026-08-25 14:50 UTC (permalink / raw)


The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.9.vz10
------>
commit 1e648e17487b16486de22cefcd27672a454a1c3e
Author: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Date:   Tue Aug 25 14:50:17 2026 +0300

    selftests/iommu: skip when the mock device is not there
    
    Both iommufd tests need the mock device the iommufd module registers
    under CONFIG_IOMMUFD_TEST, and they open /dev/iommu in every fixture
    without checking, so on a kernel that does not provide it every case
    fails on the open.
    
    Checking the open is not enough on its own. /dev/iommu appears as soon
    as the iommufd module is loaded, which says nothing about the mock
    device: the release config here is CONFIG_IOMMUFD=m with
    CONFIG_IOMMUFD_TEST unset, so the open succeeds and the tests fail later
    in the ioctls that drive the mock device instead. Only the debug config
    sets CONFIG_IOMMUFD_TEST.
    
    /sys/bus/iommufd_mock covers both, it exists only once the module is
    loaded and the kernel was built with CONFIG_IOMMUFD_TEST. Check for it
    once before handing over to the harness, rather than in each of the
    fixtures, and report a skip. test_harness_run() is what TEST_HARNESS_MAIN
    calls anyway, so the tests still run exactly as they did.
    
    https://virtuozzo.atlassian.net/browse/VSTOR-142443
    Feature: fix selftests
    Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
    Reviewed-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/iommu/iommufd.c          | 15 ++++++++++++++-
 tools/testing/selftests/iommu/iommufd_fail_nth.c | 15 ++++++++++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/iommu/iommufd.c b/tools/testing/selftests/iommu/iommufd.c
index de348d6412791..5e0309a7ec675 100644
--- a/tools/testing/selftests/iommu/iommufd.c
+++ b/tools/testing/selftests/iommu/iommufd.c
@@ -3523,4 +3523,17 @@ TEST_F(iommufd_device_pasid, pasid_attach)
 	test_cmd_mock_domain_replace(self->stdev_id, self->ioas_id);
 }
 
-TEST_HARNESS_MAIN
+static bool iommufd_mock_available(void)
+{
+	return access("/sys/bus/iommufd_mock", F_OK) == 0;
+}
+
+int main(int argc, char **argv)
+{
+	if (!iommufd_mock_available())
+		ksft_exit_skip("no iommufd mock device, the tests need "
+			       "CONFIG_IOMMUFD_TEST=y and the iommufd "
+			       "module loaded\n");
+
+	return test_harness_run(argc, argv);
+}
diff --git a/tools/testing/selftests/iommu/iommufd_fail_nth.c b/tools/testing/selftests/iommu/iommufd_fail_nth.c
index 45c14323a6183..a76cd19970c01 100644
--- a/tools/testing/selftests/iommu/iommufd_fail_nth.c
+++ b/tools/testing/selftests/iommu/iommufd_fail_nth.c
@@ -745,4 +745,17 @@ TEST_FAIL_NTH(basic_fail_nth, device)
 	return 0;
 }
 
-TEST_HARNESS_MAIN
+static bool iommufd_mock_available(void)
+{
+	return access("/sys/bus/iommufd_mock", F_OK) == 0;
+}
+
+int main(int argc, char **argv)
+{
+	if (!iommufd_mock_available())
+		ksft_exit_skip("no iommufd mock device, the tests need "
+			       "CONFIG_IOMMUFD_TEST=y and the iommufd "
+			       "module loaded\n");
+
+	return test_harness_run(argc, argv);
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Devel] [PATCH vz10 v2] selftests/iommu: skip when the mock device is not there
  2026-08-25 11:50 [Devel] [PATCH vz10 v2] selftests/iommu: skip when the mock device is not there Eva Kurchatova
  2026-08-25 14:50 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
@ 2026-08-25 14:50 ` Konstantin Khorenko
  1 sibling, 0 replies; 3+ messages in thread
From: Konstantin Khorenko @ 2026-08-25 14:50 UTC (permalink / raw)


ack

--
Best regards,

Konstantin Khorenko,
Virtuozzo Linux Kernel Team

On 8/25/26 13:50, Eva Kurchatova wrote:
> Both iommufd tests need the mock device the iommufd module registers
> under CONFIG_IOMMUFD_TEST, and they open /dev/iommu in every fixture
> without checking, so on a kernel that does not provide it every case
> fails on the open.
> 
> Checking the open is not enough on its own. /dev/iommu appears as soon
> as the iommufd module is loaded, which says nothing about the mock
> device: the release config here is CONFIG_IOMMUFD=m with
> CONFIG_IOMMUFD_TEST unset, so the open succeeds and the tests fail later
> in the ioctls that drive the mock device instead. Only the debug config
> sets CONFIG_IOMMUFD_TEST.
> 
> /sys/bus/iommufd_mock covers both, it exists only once the module is
> loaded and the kernel was built with CONFIG_IOMMUFD_TEST. Check for it
> once before handing over to the harness, rather than in each of the
> fixtures, and report a skip. test_harness_run() is what TEST_HARNESS_MAIN
> calls anyway, so the tests still run exactly as they did.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-142443
> Feature: fix selftests
> Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
> ---
>  tools/testing/selftests/iommu/iommufd.c          | 15 ++++++++++++++-
>  tools/testing/selftests/iommu/iommufd_fail_nth.c | 15 ++++++++++++++-
>  2 files changed, 28 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/iommu/iommufd.c b/tools/testing/selftests/iommu/iommufd.c
> index de348d641279..5e0309a7ec67 100644
> --- a/tools/testing/selftests/iommu/iommufd.c
> +++ b/tools/testing/selftests/iommu/iommufd.c
> @@ -3523,4 +3523,17 @@ TEST_F(iommufd_device_pasid, pasid_attach)
>  	test_cmd_mock_domain_replace(self->stdev_id, self->ioas_id);
>  }
>  
> -TEST_HARNESS_MAIN
> +static bool iommufd_mock_available(void)
> +{
> +	return access("/sys/bus/iommufd_mock", F_OK) == 0;
> +}
> +
> +int main(int argc, char **argv)
> +{
> +	if (!iommufd_mock_available())
> +		ksft_exit_skip("no iommufd mock device, the tests need "
> +			       "CONFIG_IOMMUFD_TEST=y and the iommufd "
> +			       "module loaded\n");
> +
> +	return test_harness_run(argc, argv);
> +}
> diff --git a/tools/testing/selftests/iommu/iommufd_fail_nth.c b/tools/testing/selftests/iommu/iommufd_fail_nth.c
> index 45c14323a618..a76cd19970c0 100644
> --- a/tools/testing/selftests/iommu/iommufd_fail_nth.c
> +++ b/tools/testing/selftests/iommu/iommufd_fail_nth.c
> @@ -745,4 +745,17 @@ TEST_FAIL_NTH(basic_fail_nth, device)
>  	return 0;
>  }
>  
> -TEST_HARNESS_MAIN
> +static bool iommufd_mock_available(void)
> +{
> +	return access("/sys/bus/iommufd_mock", F_OK) == 0;
> +}
> +
> +int main(int argc, char **argv)
> +{
> +	if (!iommufd_mock_available())
> +		ksft_exit_skip("no iommufd mock device, the tests need "
> +			       "CONFIG_IOMMUFD_TEST=y and the iommufd "
> +			       "module loaded\n");
> +
> +	return test_harness_run(argc, argv);
> +}


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-25 14:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-25 11:50 [Devel] [PATCH vz10 v2] selftests/iommu: skip when the mock device is not there Eva Kurchatova
2026-08-25 14:50 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-25 14:50 ` [Devel] [PATCH vz10 v2] " Konstantin Khorenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox