From: Aditya Garg <gargaditya08@live.com>
To: Tamir Duberstein <tamird@gmail.com>
Cc: Kees Cook <kees@kernel.org>, Petr Mladek <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] printf: add tests for generic FourCCs
Date: Fri, 21 Mar 2025 14:23:51 +0000 [thread overview]
Message-ID: <PN3PR01MB95976F630E0E4004CDC5310DB8DB2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <CAJ-ks9=zN0pUAt9ELckna+3GcnDfhjF3jgiM1FHXLji9pWc2wQ@mail.gmail.com>
> On 21 Mar 2025, at 7:47 PM, Tamir Duberstein <tamird@gmail.com> wrote:
>
> On Thu, Mar 13, 2025 at 11:45 PM Aditya Garg <gargaditya08@live.com> wrote:
>>
>> From: Aditya Garg <gargaditya08@live.com>
>>
>> Format specifiers for printing generic 32-bit FourCCs were recently added
>> to vsprintf. They are going through the DRM tree alongwith the appletbdrm
>> driver. Since the printf tests are being converted to kunit, this separate
>> patch for the tests should make it easier to rebase when the merge window
>> opens.
>>
>> Link: https://lore.kernel.org/dri-devel/79FA3F41-FD7A-41D9-852B-D32606AF5EB4@live.com/T/#u
>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>> ---
>> lib/tests/printf_kunit.c | 39 ++++++++++++++++++++++++++++++++-------
>> 1 file changed, 32 insertions(+), 7 deletions(-)
>>
>> diff --git a/lib/tests/printf_kunit.c b/lib/tests/printf_kunit.c
>> index 2c9f6170b..b1fa0dcea 100644
>> --- a/lib/tests/printf_kunit.c
>> +++ b/lib/tests/printf_kunit.c
>> @@ -701,21 +701,46 @@ static void fwnode_pointer(struct kunit *kunittest)
>> software_node_unregister_node_group(group);
>> }
>>
>> +struct fourcc_struct {
>> + u32 code;
>> + const char *str;
>> +};
>> +
>> +static void fourcc_pointer_test(struct kunit *kunittest, const struct fourcc_struct *fc,
>> + size_t n, const char *fmt)
>> +{
>> + size_t i;
>> +
>> + for (i = 0; i < n; i++)
>> + test(fc[i].str, fmt, &fc[i].code);
>> +}
>> +
>> static void fourcc_pointer(struct kunit *kunittest)
>> {
>> - struct {
>> - u32 code;
>> - char *str;
>> - } const try[] = {
>> + static const struct fourcc_struct try_cc[] = {
>> { 0x3231564e, "NV12 little-endian (0x3231564e)", },
>> { 0xb231564e, "NV12 big-endian (0xb231564e)", },
>> { 0x10111213, ".... little-endian (0x10111213)", },
>> { 0x20303159, "Y10 little-endian (0x20303159)", },
>> };
>> - unsigned int i;
>> + static const struct fourcc_struct try_ch[] = {
>> + { 0x41424344, "ABCD (0x41424344)", },
>> + };
>> + static const struct fourcc_struct try_cn[] = {
>> + { 0x41424344, "DCBA (0x44434241)", },
>> + };
>> + static const struct fourcc_struct try_cl[] = {
>> + { (__force u32)cpu_to_le32(0x41424344), "ABCD (0x41424344)", },
>> + };
>> + static const struct fourcc_struct try_cb[] = {
>> + { (__force u32)cpu_to_be32(0x41424344), "ABCD (0x41424344)", },
>> + };
>>
>> - for (i = 0; i < ARRAY_SIZE(try); i++)
>> - test(try[i].str, "%p4cc", &try[i].code);
>> + fourcc_pointer_test(kunittest, try_cc, ARRAY_SIZE(try_cc), "%p4cc");
>> + fourcc_pointer_test(kunittest, try_ch, ARRAY_SIZE(try_ch), "%p4ch");
>> + fourcc_pointer_test(kunittest, try_cn, ARRAY_SIZE(try_cn), "%p4cn");
>> + fourcc_pointer_test(kunittest, try_cl, ARRAY_SIZE(try_cl), "%p4cl");
>> + fourcc_pointer_test(kunittest, try_cb, ARRAY_SIZE(try_cb), "%p4cb");
>> }
>>
>> static void
>> --
>> 2.43.0
>>
>
> This code looks fine to me. I would appreciate a preview of the output
> of these tests when they fail; a lot of effort went into making the
> printf tests produce actionable failure messages, and we should
> continue to invest in that IMO.
Can you give me some docs for running the Kunit tests? The patch is basically a port of the original version.
next prev parent reply other threads:[~2025-03-21 14:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 3:45 Aditya Garg
2025-03-21 14:10 ` Andy Shevchenko
2025-03-21 14:16 ` Tamir Duberstein
2025-03-21 14:23 ` Aditya Garg [this message]
2025-03-21 14:52 ` Tamir Duberstein
2025-03-22 10:04 ` Aditya Garg
2025-03-22 13:30 ` Tamir Duberstein
2025-03-25 19:48 ` Kees Cook
2025-03-26 0:26 ` Aditya Garg
2025-03-27 9:57 ` Petr Mladek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=PN3PR01MB95976F630E0E4004CDC5310DB8DB2@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM \
--to=gargaditya08@live.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=tamird@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®