In 444be9072fca ("kunit: Pass parameterized test context to generate_params()") prototype used for gen_params functions was changed to add a struct kunit parameter. However, a few of these used in xe were not updated.
Update these so that the xe_pci tests build and run again.
Fixes: 444be9072fca ("kunit: Pass parameterized test context to generate_params()") Signed-off-by: David Gow davidgow@google.com ---
Sorry, the last fix here caused a warning (thanks to the test robot for finding it).
I'm still happy to sqash and re-send the whole original series if that's preferred.
Changes since v1: https://lore.kernel.org/linux-kselftest/20250819073434.1411114-1-davidgow@go... - Add the missing <kunit/test.h> include for struct kunit
--- drivers/gpu/drm/xe/tests/xe_pci.c | 12 ++++++------ drivers/gpu/drm/xe/tests/xe_pci_test.h | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/xe/tests/xe_pci.c b/drivers/gpu/drm/xe/tests/xe_pci.c index a65705814b9a..f707e0a54295 100644 --- a/drivers/gpu/drm/xe/tests/xe_pci.c +++ b/drivers/gpu/drm/xe/tests/xe_pci.c @@ -44,9 +44,9 @@ KUNIT_ARRAY_PARAM(pci_id, pciidlist, xe_pci_id_kunit_desc); * * Return: pointer to the next parameter or NULL if no more parameters */ -const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc) +const void *xe_pci_graphics_ip_gen_param(struct kunit *test, const void *prev, char *desc) { - return graphics_ip_gen_params(prev, desc); + return graphics_ip_gen_params(test, prev, desc); } EXPORT_SYMBOL_IF_KUNIT(xe_pci_graphics_ip_gen_param);
@@ -61,9 +61,9 @@ EXPORT_SYMBOL_IF_KUNIT(xe_pci_graphics_ip_gen_param); * * Return: pointer to the next parameter or NULL if no more parameters */ -const void *xe_pci_media_ip_gen_param(const void *prev, char *desc) +const void *xe_pci_media_ip_gen_param(struct kunit *test, const void *prev, char *desc) { - return media_ip_gen_params(prev, desc); + return media_ip_gen_params(test, prev, desc); } EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param);
@@ -78,9 +78,9 @@ EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param); * * Return: pointer to the next parameter or NULL if no more parameters */ -const void *xe_pci_id_gen_param(const void *prev, char *desc) +const void *xe_pci_id_gen_param(struct kunit *test, const void *prev, char *desc) { - const struct pci_device_id *pci = pci_id_gen_params(prev, desc); + const struct pci_device_id *pci = pci_id_gen_params(test, prev, desc);
return pci->driver_data ? pci : NULL; } diff --git a/drivers/gpu/drm/xe/tests/xe_pci_test.h b/drivers/gpu/drm/xe/tests/xe_pci_test.h index ce4d2b86b778..6d8bc56f7bde 100644 --- a/drivers/gpu/drm/xe/tests/xe_pci_test.h +++ b/drivers/gpu/drm/xe/tests/xe_pci_test.h @@ -7,6 +7,7 @@ #define _XE_PCI_TEST_H_
#include <linux/types.h> +#include <kunit/test.h>
#include "xe_platform_types.h" #include "xe_sriov_types.h" @@ -25,9 +26,9 @@ struct xe_pci_fake_data {
int xe_pci_fake_device_init(struct xe_device *xe);
-const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc); -const void *xe_pci_media_ip_gen_param(const void *prev, char *desc); -const void *xe_pci_id_gen_param(const void *prev, char *desc); -const void *xe_pci_live_device_gen_param(const void *prev, char *desc); +const void *xe_pci_graphics_ip_gen_param(struct kunit *test, const void *prev, char *desc); +const void *xe_pci_media_ip_gen_param(struct kunit *test, const void *prev, char *desc); +const void *xe_pci_id_gen_param(struct kunit *test, const void *prev, char *desc); +const void *xe_pci_live_device_gen_param(struct kunit *test, const void *prev, char *desc);
#endif
In 6a2a027e254b ("kunit: Enable direct registration of parameter arrays to a KUnit test"), we now output a test plan for parameterised tests which use parameter arrays. This uses the size of the array (via the ARRAY_SIZE macro) to determine the number of subtests, which otherwise was indeterminate.
However some tests (particularly xe_pci.check_platform_gt_count) use their own gen_params function which further filters the array, resulting in the test plan being inaccurate (and hence kunit.py failing).
For now, only print the test plan line if the gen_params function is the provided kunit_array_gen_params. Unfortunately, this catches a lot of tests which would work, but at least makes sure we don't regress anything until we can rework how some of these macros function.
Fixes: 6a2a027e254b ("kunit: Enable direct registration of parameter arrays to a KUnit test") Signed-off-by: David Gow davidgow@google.com ---
No changes since v1: https://lore.kernel.org/linux-kselftest/20250819073434.1411114-2-davidgow@go...
(The change was in patch 1.)
--- lib/kunit/test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/kunit/test.c b/lib/kunit/test.c index b661407ad0a3..bb66ea1a3eac 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -732,10 +732,12 @@ int kunit_run_tests(struct kunit_suite *suite) "KTAP version 1\n"); kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT "# Subtest: %s", test_case->name); - if (test.params_array.params) + if (test.params_array.params && + test_case->generate_params == kunit_array_gen_params) { kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT "1..%zd\n", test.params_array.num_params); + }
while (curr_param) { struct kunit param_test = {
On Thu, Aug 21, 2025 at 8:54 AM David Gow davidgow@google.com wrote:
In 6a2a027e254b ("kunit: Enable direct registration of parameter arrays to a KUnit test"), we now output a test plan for parameterised tests which use parameter arrays. This uses the size of the array (via the ARRAY_SIZE macro) to determine the number of subtests, which otherwise was indeterminate.
However some tests (particularly xe_pci.check_platform_gt_count) use their own gen_params function which further filters the array, resulting in the test plan being inaccurate (and hence kunit.py failing).
For now, only print the test plan line if the gen_params function is the provided kunit_array_gen_params. Unfortunately, this catches a lot of tests which would work, but at least makes sure we don't regress anything until we can rework how some of these macros function.
Fixes: 6a2a027e254b ("kunit: Enable direct registration of parameter arrays to a KUnit test") Signed-off-by: David Gow davidgow@google.com
Hello!
This makes sense to me. Maybe we can work on this feature in the future. Thanks!
Reviewed-by: Rae Moar rmoar@google.com
Thanks! -Rae
No changes since v1: https://lore.kernel.org/linux-kselftest/20250819073434.1411114-2-davidgow@go...
(The change was in patch 1.)
lib/kunit/test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/kunit/test.c b/lib/kunit/test.c index b661407ad0a3..bb66ea1a3eac 100644 --- a/lib/kunit/test.c +++ b/lib/kunit/test.c @@ -732,10 +732,12 @@ int kunit_run_tests(struct kunit_suite *suite) "KTAP version 1\n"); kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT "# Subtest: %s", test_case->name);
if (test.params_array.params)
if (test.params_array.params &&
test_case->generate_params == kunit_array_gen_params) { kunit_log(KERN_INFO, &test, KUNIT_SUBTEST_INDENT KUNIT_SUBTEST_INDENT "1..%zd\n", test.params_array.num_params);
} while (curr_param) { struct kunit param_test = {
-- 2.51.0.rc2.233.g662b1ed5c5-goog
On Thu, Aug 21, 2025 at 8:54 AM David Gow davidgow@google.com wrote:
In 444be9072fca ("kunit: Pass parameterized test context to generate_params()") prototype used for gen_params functions was changed to add a struct kunit parameter. However, a few of these used in xe were not updated.
Update these so that the xe_pci tests build and run again.
Fixes: 444be9072fca ("kunit: Pass parameterized test context to generate_params()") Signed-off-by: David Gow davidgow@google.com
Sorry, the last fix here caused a warning (thanks to the test robot for finding it).
I'm still happy to sqash and re-send the whole original series if that's preferred.
Changes since v1: https://lore.kernel.org/linux-kselftest/20250819073434.1411114-1-davidgow@go...
- Add the missing <kunit/test.h> include for struct kunit
Hello!
Thanks for this change! It looks good to me!
Reviewed-by: Rae Moar rmoar@google.com
Thanks! -Rae
drivers/gpu/drm/xe/tests/xe_pci.c | 12 ++++++------ drivers/gpu/drm/xe/tests/xe_pci_test.h | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/xe/tests/xe_pci.c b/drivers/gpu/drm/xe/tests/xe_pci.c index a65705814b9a..f707e0a54295 100644 --- a/drivers/gpu/drm/xe/tests/xe_pci.c +++ b/drivers/gpu/drm/xe/tests/xe_pci.c @@ -44,9 +44,9 @@ KUNIT_ARRAY_PARAM(pci_id, pciidlist, xe_pci_id_kunit_desc);
- Return: pointer to the next parameter or NULL if no more parameters
*/ -const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc) +const void *xe_pci_graphics_ip_gen_param(struct kunit *test, const void *prev, char *desc) {
return graphics_ip_gen_params(prev, desc);
return graphics_ip_gen_params(test, prev, desc);
} EXPORT_SYMBOL_IF_KUNIT(xe_pci_graphics_ip_gen_param);
@@ -61,9 +61,9 @@ EXPORT_SYMBOL_IF_KUNIT(xe_pci_graphics_ip_gen_param);
- Return: pointer to the next parameter or NULL if no more parameters
*/ -const void *xe_pci_media_ip_gen_param(const void *prev, char *desc) +const void *xe_pci_media_ip_gen_param(struct kunit *test, const void *prev, char *desc) {
return media_ip_gen_params(prev, desc);
return media_ip_gen_params(test, prev, desc);
} EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param);
@@ -78,9 +78,9 @@ EXPORT_SYMBOL_IF_KUNIT(xe_pci_media_ip_gen_param);
- Return: pointer to the next parameter or NULL if no more parameters
*/ -const void *xe_pci_id_gen_param(const void *prev, char *desc) +const void *xe_pci_id_gen_param(struct kunit *test, const void *prev, char *desc) {
const struct pci_device_id *pci = pci_id_gen_params(prev, desc);
const struct pci_device_id *pci = pci_id_gen_params(test, prev, desc); return pci->driver_data ? pci : NULL;
} diff --git a/drivers/gpu/drm/xe/tests/xe_pci_test.h b/drivers/gpu/drm/xe/tests/xe_pci_test.h index ce4d2b86b778..6d8bc56f7bde 100644 --- a/drivers/gpu/drm/xe/tests/xe_pci_test.h +++ b/drivers/gpu/drm/xe/tests/xe_pci_test.h @@ -7,6 +7,7 @@ #define _XE_PCI_TEST_H_
#include <linux/types.h> +#include <kunit/test.h>
#include "xe_platform_types.h" #include "xe_sriov_types.h" @@ -25,9 +26,9 @@ struct xe_pci_fake_data {
int xe_pci_fake_device_init(struct xe_device *xe);
-const void *xe_pci_graphics_ip_gen_param(const void *prev, char *desc); -const void *xe_pci_media_ip_gen_param(const void *prev, char *desc); -const void *xe_pci_id_gen_param(const void *prev, char *desc); -const void *xe_pci_live_device_gen_param(const void *prev, char *desc); +const void *xe_pci_graphics_ip_gen_param(struct kunit *test, const void *prev, char *desc); +const void *xe_pci_media_ip_gen_param(struct kunit *test, const void *prev, char *desc); +const void *xe_pci_id_gen_param(struct kunit *test, const void *prev, char *desc); +const void *xe_pci_live_device_gen_param(struct kunit *test, const void *prev, char *desc);
#endif
2.51.0.rc2.233.g662b1ed5c5-goog
linux-kselftest-mirror@lists.linaro.org