drm/xe/tests: Fix some additional gen_params signatures
Subsystems (5)
PATCH v2 1/2 drm/xe/tests: Fix some additional gen_params signatures
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.
---
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/[email protected]/
- 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(-)
drivers/gpu/drm/xe/tests/xe_pci.c +6 -6
@@ -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 ; }
drivers/gpu/drm/xe/tests/xe_pci_test.h +5 -4
@@ -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
Signature · 1 line
2.51.0.rc2.233.g662b1ed5c5-goog
PATCH v2 2/2 kunit: Only output a test plan if we're using kunit_array_gen_params
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.
---
No changes since v1:
https://lore.kernel.org/linux-kselftest/[email protected]/
(The change was in patch 1.)
--- lib/kunit/test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/kunit/test.c +3 -1
@@ -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_INDENTKUNIT_SUBTEST_INDENT "1..%zd\n" , test.params_array.num_params); + }while (curr_param) {struct kunit param_test = {
Signature · 1 line
2.51.0.rc2.233.g662b1ed5c5-goog
Re: [PATCH v2 2/2] kunit: Only output a test plan if we're using kunit_array_gen_params
Quoted 10 lines · David Gow
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 theARRAY_SIZEmacro) to determine the number of subtests, which otherwise was indeterminate.However some tests (particularly xe_pci.check_platform_gt_count) use their own
gen_paramsfunction which further filters the array, resulting in the test plan being inaccurate (and hencekunit.pyfailing).
Quoted 7 lines
For now, only print the test plan line if the
gen_paramsfunction is the providedkunit_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 <[email protected]>
Hello!
This makes sense to me. Maybe we can work on this feature in the future. Thanks!
Thanks!
-Rae
Quoted 32 lines
---
No changes since v1:
https://lore.kernel.org/linux-kselftest/[email protected]/(The change was in patch 1.)
--- lib/kunit/test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)lib/kunit/test.c +3
-2@@ -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_INDENTKUNIT_SUBTEST_INDENT "1..%zd\n" , test.params_array.num_params); + }while (curr_param) {struct kunit param_test = { --2.51.0.rc2.233.g662b1ed5c5-goog
Quoted 14 lines · David Gow
In
444be9072fca("kunit: Pass parameterized test context togenerate_params()") prototype used forgen_paramsfunctions 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_pcitests build and run again.Fixes 444be9072fca ("kunit: Pass parameterized test context to generate_params()")Signed-off-by David Gow <[email protected]>---
Sorry, the last fix here caused a warning (thanks to the test robot for finding it).
Quoted 7 lines
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/[email protected]/
- Add the missing <kunit/test.h> include for struct kunit
Hello!
Thanks for this change! It looks good to me!
Thanks!
-Rae
Quoted 74 lines
--- 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(-)drivers/gpu/drm/xe/tests/xe_pci.c +6
-6@@ -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 ; }drivers/gpu/drm/xe/tests/xe_pci_test.h +5
-5@@ -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