linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Justin Stitt <justinstitt@google.com>
To: David Gow <davidgow@google.com>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Guenter Roeck" <linux@roeck-us.net>,
	"Rae Moar" <rmoar@google.com>,
	"Matthew Auld" <matthew.auld@intel.com>,
	"Arunpravin Paneer Selvam" <arunpravin.paneerselvam@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Kees Cook" <keescook@chromium.org>,
	"Maíra Canal" <mcanal@igalia.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Willem de Bruijn" <willemb@google.com>,
	"Florian Westphal" <fw@strlen.de>,
	"Cassio Neri" <cassio.neri@gmail.com>,
	"Javier Martinez Canillas" <javierm@redhat.com>,
	"Arthur Grillo" <arthur.grillo@usp.br>,
	"Brendan Higgins" <brendan.higgins@linux.dev>,
	"Daniel Latypov" <dlatypov@google.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"David Airlie" <airlied@gmail.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	intel-xe@lists.freedesktop.org, linux-rtc@vger.kernel.org,
	linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com,
	linux-hardening@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH 7/9] drm: tests: Fix invalid printf format specifiers in KUnit tests
Date: Wed, 21 Feb 2024 21:29:52 +0000	[thread overview]
Message-ID: <20240221212952.bqw4rdz2i2yf3now@google.com> (raw)
In-Reply-To: <20240221092728.1281499-8-davidgow@google.com>

Hi,

On Wed, Feb 21, 2024 at 05:27:20PM +0800, David Gow wrote:
> 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 warns if a printf format string is empty (apparently), so

clang does too; under -Wformat-zero-length

> give these some more detailed error messages, which should be more
> useful anyway.
>
> Fixes: a64056bb5a32 ("drm/tests/drm_buddy: add alloc_contiguous test")
> Fixes: fca7526b7d89 ("drm/tests/drm_buddy: fix build failure on 32-bit targets")
> Fixes: fc8d29e298cf ("drm: selftest: convert drm_mm selftest to KUnit")
> Signed-off-by: David Gow <davidgow@google.com>

Reviewed-by: Justin Stitt <justinstitt@google.com>
> ---
>  drivers/gpu/drm/tests/drm_buddy_test.c | 14 +++++++-------
>  drivers/gpu/drm/tests/drm_mm_test.c    |  6 +++---
>  2 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c
> index 8a464f7f4c61..3dbfa3078449 100644
> --- a/drivers/gpu/drm/tests/drm_buddy_test.c
> +++ b/drivers/gpu/drm/tests/drm_buddy_test.c
> @@ -55,30 +55,30 @@ static void drm_test_buddy_alloc_contiguous(struct kunit *test)
>  		KUNIT_ASSERT_FALSE_MSG(test,
>  				       drm_buddy_alloc_blocks(&mm, 0, mm_size,
>  							      ps, ps, list, 0),
> -				       "buddy_alloc hit an error size=%d\n",
> +				       "buddy_alloc hit an error size=%lu\n",
>  				       ps);
>  	} while (++i < n_pages);
>
>  	KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
>  							   3 * ps, ps, &allocated,
>  							   DRM_BUDDY_CONTIGUOUS_ALLOCATION),
> -			       "buddy_alloc didn't error size=%d\n", 3 * ps);
> +			       "buddy_alloc didn't error size=%lu\n", 3 * ps);
>
>  	drm_buddy_free_list(&mm, &middle);
>  	KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
>  							   3 * ps, ps, &allocated,
>  							   DRM_BUDDY_CONTIGUOUS_ALLOCATION),
> -			       "buddy_alloc didn't error size=%llu\n", 3 * ps);
> +			       "buddy_alloc didn't error size=%lu\n", 3 * ps);
>  	KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
>  							   2 * ps, ps, &allocated,
>  							   DRM_BUDDY_CONTIGUOUS_ALLOCATION),
> -			       "buddy_alloc didn't error size=%llu\n", 2 * ps);
> +			       "buddy_alloc didn't error size=%lu\n", 2 * ps);
>
>  	drm_buddy_free_list(&mm, &right);
>  	KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
>  							   3 * ps, ps, &allocated,
>  							   DRM_BUDDY_CONTIGUOUS_ALLOCATION),
> -			       "buddy_alloc didn't error size=%llu\n", 3 * ps);
> +			       "buddy_alloc didn't error size=%lu\n", 3 * ps);
>  	/*
>  	 * At this point we should have enough contiguous space for 2 blocks,
>  	 * 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)
>  	KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
>  							    2 * ps, ps, &allocated,
>  							    DRM_BUDDY_CONTIGUOUS_ALLOCATION),
> -			       "buddy_alloc hit an error size=%d\n", 2 * ps);
> +			       "buddy_alloc hit an error size=%lu\n", 2 * ps);
>
>  	drm_buddy_free_list(&mm, &left);
>  	KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, 0, mm_size,
>  							    3 * ps, ps, &allocated,
>  							    DRM_BUDDY_CONTIGUOUS_ALLOCATION),
> -			       "buddy_alloc hit an error size=%d\n", 3 * ps);
> +			       "buddy_alloc hit an error size=%lu\n", 3 * ps);
>
>  	total = 0;
>  	list_for_each_entry(block, &allocated, link)
> diff --git a/drivers/gpu/drm/tests/drm_mm_test.c b/drivers/gpu/drm/tests/drm_mm_test.c
> index 1eb0c304f960..f37c0d765865 100644
> --- a/drivers/gpu/drm/tests/drm_mm_test.c
> +++ b/drivers/gpu/drm/tests/drm_mm_test.c
> @@ -157,7 +157,7 @@ static void drm_test_mm_init(struct kunit *test)
>
>  	/* After creation, it should all be one massive hole */
>  	if (!assert_one_hole(test, &mm, 0, size)) {
> -		KUNIT_FAIL(test, "");
> +		KUNIT_FAIL(test, "mm not one hole on creation");
>  		goto out;
>  	}
>
> @@ -171,14 +171,14 @@ static void drm_test_mm_init(struct kunit *test)
>
>  	/* After filling the range entirely, there should be no holes */
>  	if (!assert_no_holes(test, &mm)) {
> -		KUNIT_FAIL(test, "");
> +		KUNIT_FAIL(test, "mm has holes when filled");
>  		goto out;
>  	}
>
>  	/* And then after emptying it again, the massive hole should be back */
>  	drm_mm_remove_node(&tmp);
>  	if (!assert_one_hole(test, &mm, 0, size)) {
> -		KUNIT_FAIL(test, "");
> +		KUNIT_FAIL(test, "mm does not have single hole after emptying");
>  		goto out;
>  	}
>
> --
> 2.44.0.rc0.258.g7320e95886-goog
>

Thanks
Justin

  parent reply	other threads:[~2024-02-21 21:29 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21  9:27 [PATCH 0/9] kunit: Fix printf format specifier issues in KUnit assertions David Gow
2024-02-21  9:27 ` [PATCH 1/9] kunit: test: Log the correct filter string in executor_test David Gow
2024-02-21 13:25   ` Guenter Roeck
2024-02-21 20:04   ` Justin Stitt
2024-02-21 20:29   ` Daniel Latypov
2024-02-22 20:58   ` Rae Moar
2024-02-21  9:27 ` [PATCH 2/9] lib/cmdline: Fix an invalid format specifier in an assertion msg David Gow
2024-02-21 13:25   ` Guenter Roeck
2024-02-21 20:10   ` Justin Stitt
2024-02-22  6:22     ` David Gow
2024-02-22 17:36       ` Daniel Latypov
2024-02-22 17:56         ` Linus Torvalds
2024-02-21  9:27 ` [PATCH 3/9] lib: memcpy_kunit: " David Gow
2024-02-21 13:25   ` Guenter Roeck
2024-02-21 21:05   ` Justin Stitt
2024-02-21  9:27 ` [PATCH 4/9] time: test: Fix incorrect format specifier David Gow
2024-02-21 13:25   ` Guenter Roeck
2024-02-21 21:06   ` Justin Stitt
2024-02-21  9:27 ` [PATCH 5/9] rtc: test: Fix invalid " David Gow
2024-02-21 13:26   ` Guenter Roeck
2024-02-21 21:06   ` Justin Stitt
2024-02-27 20:32   ` Alexandre Belloni
2024-02-27 21:23     ` Shuah Khan
2024-02-27 22:48       ` Alexandre Belloni
2024-02-21  9:27 ` [PATCH 6/9] net: test: Fix printf format specifier in skb_segment kunit test David Gow
2024-02-21 13:26   ` Guenter Roeck
2024-02-21 21:26   ` Justin Stitt
2024-02-21  9:27 ` [PATCH 7/9] drm: tests: Fix invalid printf format specifiers in KUnit tests David Gow
2024-02-21 10:21   ` Matthew Auld
2024-02-21 10:45   ` Christian König
2024-02-21 13:26   ` Guenter Roeck
2024-02-21 21:29   ` Justin Stitt [this message]
2024-02-27 23:24     ` Shuah Khan
2024-02-21  9:27 ` [PATCH 8/9] drm/xe/tests: Fix printf format specifiers in xe_migrate test David Gow
2024-02-21 13:26   ` Guenter Roeck
2024-02-22  5:05   ` Lucas De Marchi
2024-02-22  5:59     ` Linus Torvalds
2024-02-22  9:52   ` Thomas Hellström
2024-02-21  9:27 ` [PATCH 9/9] kunit: Annotate _MSG assertion variants with gnu printf specifiers David Gow
2024-02-21 13:26   ` Guenter Roeck
2024-02-21 20:02   ` Justin Stitt
2024-02-22 14:23 ` [PATCH 0/9] kunit: Fix printf format specifier issues in KUnit assertions Shuah Khan
2024-02-27 23:32 ` Shuah Khan

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=20240221212952.bqw4rdz2i2yf3now@google.com \
    --to=justinstitt@google.com \
    --cc=airlied@gmail.com \
    --cc=arthur.grillo@usp.br \
    --cc=arunpravin.paneerselvam@amd.com \
    --cc=brendan.higgins@linux.dev \
    --cc=cassio.neri@gmail.com \
    --cc=christian.koenig@amd.com \
    --cc=davem@davemloft.net \
    --cc=davidgow@google.com \
    --cc=dlatypov@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fw@strlen.de \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=keescook@chromium.org \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=mcanal@igalia.com \
    --cc=mripard@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rmoar@google.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=sboyd@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=torvalds@linux-foundation.org \
    --cc=willemb@google.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;
as well as URLs for NNTP newsgroup(s).