Skip to content

Commit fc9a615

Browse files
sulixshuahkh
authored andcommitted
drm: tests: Fix invalid printf format specifiers in KUnit tests
The drm_buddy_test's alloc_contiguous test used a u64 for the page size, which was then updated to be an 'unsigned long' to avoid 64-bit multiplication division helpers. However, the variable is logged by some KUNIT_ASSERT_EQ_MSG() using the '%d' or '%llu' format specifiers, the former of which is always wrong, and the latter is no longer correct now that ps is no longer a u64. Fix these to all use '%lu'. Also, drm_mm_test calls KUNIT_FAIL() with an empty string as the message. gcc and clang warns if a printf format string is empty, so give these some more detailed error messages, which should be more useful anyway. Fixes: a64056b ("drm/tests/drm_buddy: add alloc_contiguous test") Fixes: fca7526 ("drm/tests/drm_buddy: fix build failure on 32-bit targets") Fixes: fc8d29e ("drm: selftest: convert drm_mm selftest to KUnit") Reviewed-by: Matthew Auld <matthew.auld@intel.com> Acked-by: Christian König <christian.koenig@amd.com> Tested-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Justin Stitt <justinstitt@google.com> Signed-off-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 689a930 commit fc9a615

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

drivers/gpu/drm/tests/drm_buddy_test.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,30 @@ static void drm_test_buddy_alloc_contiguous(struct kunit *test)
5555
KUNIT_ASSERT_FALSE_MSG(test,
5656
drm_buddy_alloc_blocks(&mm, 0, mm_size,
5757
ps, ps, list, 0),
58-
"buddy_alloc hit an error size=%u\n",
58+
"buddy_alloc hit an error size=%lu\n",
5959
ps);
6060
} while (++i < n_pages);
6161

6262
KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
6363
3 * ps, ps, &allocated,
6464
DRM_BUDDY_CONTIGUOUS_ALLOCATION),
65-
"buddy_alloc didn't error size=%u\n", 3 * ps);
65+
"buddy_alloc didn't error size=%lu\n", 3 * ps);
6666

6767
drm_buddy_free_list(&mm, &middle);
6868
KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
6969
3 * ps, ps, &allocated,
7070
DRM_BUDDY_CONTIGUOUS_ALLOCATION),
71-
"buddy_alloc didn't error size=%u\n", 3 * ps);
71+
"buddy_alloc didn't error size=%lu\n", 3 * ps);
7272
KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
7373
2 * ps, ps, &allocated,
7474
DRM_BUDDY_CONTIGUOUS_ALLOCATION),
75-
"buddy_alloc didn't error size=%u\n", 2 * ps);
75+
"buddy_alloc didn't error size=%lu\n", 2 * ps);
7676

7777
drm_buddy_free_list(&mm, &right);
7878
KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
7979
3 * ps, ps, &allocated,
8080
DRM_BUDDY_CONTIGUOUS_ALLOCATION),
81-
"buddy_alloc didn't error size=%u\n", 3 * ps);
81+
"buddy_alloc didn't error size=%lu\n", 3 * ps);
8282
/*
8383
* At this point we should have enough contiguous space for 2 blocks,
8484
* however they are never buddies (since we freed middle and right) so
@@ -87,13 +87,13 @@ static void drm_test_buddy_alloc_contiguous(struct kunit *test)
8787
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
8888
2 * ps, ps, &allocated,
8989
DRM_BUDDY_CONTIGUOUS_ALLOCATION),
90-
"buddy_alloc hit an error size=%u\n", 2 * ps);
90+
"buddy_alloc hit an error size=%lu\n", 2 * ps);
9191

9292
drm_buddy_free_list(&mm, &left);
9393
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
9494
3 * ps, ps, &allocated,
9595
DRM_BUDDY_CONTIGUOUS_ALLOCATION),
96-
"buddy_alloc hit an error size=%u\n", 3 * ps);
96+
"buddy_alloc hit an error size=%lu\n", 3 * ps);
9797

9898
total = 0;
9999
list_for_each_entry(block, &allocated, link)

drivers/gpu/drm/tests/drm_mm_test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void drm_test_mm_init(struct kunit *test)
157157

158158
/* After creation, it should all be one massive hole */
159159
if (!assert_one_hole(test, &mm, 0, size)) {
160-
KUNIT_FAIL(test, "");
160+
KUNIT_FAIL(test, "mm not one hole on creation");
161161
goto out;
162162
}
163163

@@ -171,14 +171,14 @@ static void drm_test_mm_init(struct kunit *test)
171171

172172
/* After filling the range entirely, there should be no holes */
173173
if (!assert_no_holes(test, &mm)) {
174-
KUNIT_FAIL(test, "");
174+
KUNIT_FAIL(test, "mm has holes when filled");
175175
goto out;
176176
}
177177

178178
/* And then after emptying it again, the massive hole should be back */
179179
drm_mm_remove_node(&tmp);
180180
if (!assert_one_hole(test, &mm, 0, size)) {
181-
KUNIT_FAIL(test, "");
181+
KUNIT_FAIL(test, "mm does not have single hole after emptying");
182182
goto out;
183183
}
184184

0 commit comments

Comments
 (0)