Re: [PATCH v2] drm/tests: Add back seed value information

From: Maíra Canal
Date: Thu Oct 27 2022 - 12:34:20 EST


Hi Arthur,

On 10/27/22 11:29, Arthur Grillo wrote:
As reported by Michał the drm_mm and drm_buddy unit tests lost the
printk with seed value after they where refactored into KUnit. This
patch add back this important information to assure reproducibility and
convert them to the KUnit API.

Some grammar nits:
- s/where/were
- s/add/adds

Moreover, you could write the commit message as André indicated, that is: in imperative form.


Reported-by: Michał Winiarski <michal.winiarski@xxxxxxxxx>
Signed-off-by: Arthur Grillo <arthurgrillo@xxxxxxxxxx>
---
v1->v2: https://lore.kernel.org/all/20221026211458.68432-1-arthurgrillo@xxxxxxxxxx/
- Correct compilation issues
- Change tags order
- Remove useless line change
- Write commit message in imperative form
- Remove redundant message part
- Correct some grammars nits
- Correct checkpatch issues

---
drivers/gpu/drm/tests/drm_buddy_test.c | 4 ++++
drivers/gpu/drm/tests/drm_mm_test.c | 4 ++++
2 files changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c
index 62f69589a72d..258137e9c047 100644
--- a/drivers/gpu/drm/tests/drm_buddy_test.c
+++ b/drivers/gpu/drm/tests/drm_buddy_test.c
@@ -731,6 +731,10 @@ static int drm_buddy_init_test(struct kunit *test)
while (!random_seed)
random_seed = get_random_u32();
+ kunit_info(test,
+ "Testing DRM buddy manager, with random_seed=0x%x\n",
+ random_seed);
+
return 0;
}

As I was checking the log, I realized that the random_seed only needs to be generated by the start of the test suite, so this drm_buddy_init_test could be a suite_init function, instead of an init function. This way the random_seed will be generated by the start of the suite and the log will be printed just once.

diff --git a/drivers/gpu/drm/tests/drm_mm_test.c b/drivers/gpu/drm/tests/drm_mm_test.c
index c4b66eeae203..bec006e044a4 100644
--- a/drivers/gpu/drm/tests/drm_mm_test.c
+++ b/drivers/gpu/drm/tests/drm_mm_test.c
@@ -2214,6 +2214,10 @@ static int drm_mm_init_test(struct kunit *test)
while (!random_seed)
random_seed = get_random_u32();
+ kunit_info(test,
+ "Testing DRM range manager, with random_seed=0x%x max_iterations=%u max_prime=%u\n",
+ random_seed, max_iterations, max_prime);
+

Same here.

Best Regards,
- Maíra Canal

return 0;
}