dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Latypov <dlatypov@google.com>
To: "Maíra Canal" <maira.canal@usp.br>
Cc: siqueirajordao@riseup.net, "David Airlie" <airlied@linux.ie>,
	brendanhiggins@google.com, dri-devel@lists.freedesktop.org,
	linux-kselftest@vger.kernel.org, n@nfraprado.net,
	"Isabella Basso" <isabbasso@riseup.net>,
	andrealmeid@riseup.net, magalilemes00@gmail.com,
	"Javier Martinez Canillas" <javierm@redhat.com>,
	mwen@igalia.com, "David Gow" <davidgow@google.com>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	kunit-dev@googlegroups.com, michal.winiarski@intel.com,
	tales.aparecida@gmail.com, linux-kernel@vger.kernel.org,
	leandro.ribeiro@collabora.com,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"José Expósito" <jose.exposito89@gmail.com>
Subject: Re: [PATCH v2 4/9] drm: selftest: convert drm_format selftest to KUnit
Date: Wed, 22 Jun 2022 10:06:42 -0700	[thread overview]
Message-ID: <CAGS_qxrynX=q7ZVmFSm-HO-3r3wGVnXMXVMejM3-ONvyJUrrPg@mail.gmail.com> (raw)
In-Reply-To: <20220621200926.257002-5-maira.canal@usp.br>

On Tue, Jun 21, 2022 at 1:10 PM Maíra Canal <maira.canal@usp.br> wrote:
>
> Considering the current adoption of the KUnit framework, convert the
> DRM format selftest to the KUnit API.
>
> Tested-by: David Gow <davidgow@google.com>
> Signed-off-by: Maíra Canal <maira.canal@usp.br>

Acked-by: Daniel Latypov <dlatypov@google.com>

Overall looks good from the KUnit side, just a few general suggestions below.

FYI, the warning email from kernel-test-robot is basically saying that
the compiler is not optimizing away the temporary variables internally
created in KUNIT_EXPECT_*.
So having too many KUNIT_EXPECT_.* in a single function is the trigger.
The main workaround you'd have is to split up the test into more test functions.
(I don't know if that's actually worth doing)

> +static void igt_check_drm_format_block_width(struct kunit *test)
> +{
> +       const struct drm_format_info *info = NULL;
> +
> +       /* Test invalid arguments */
> +       KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, 0));
> +       KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, -1));
> +       KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, 1));

Hmm, I think one of these two would be clearer here:
KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 0);
KUNIT_EXPECT_EQ(test, 0, drm_format_info_block_width(info, 0));

I think this helps test readability (giving hints about the types) and
gives better error messages, more on that below.

The problem with using the boolean expectations is that given
  int foo = 2;
  KUNIT_EXPECT_FALSE(test, foo);
KUnit will only print out
    Expected foo to be false, but is true

Using EXPECT_EQ(foo, 0), we'd get
    Expected foo == 0, but
        foo == 2

Knowing exactly what the offending return value was can help debug
test failures a bit faster.

> +
> +       /* Test 1 plane format */
> +       info = drm_format_info(DRM_FORMAT_XRGB4444);
> +       KUNIT_EXPECT_TRUE(test, info);

FYI, you can now instead write
  KUNIT_EXPECT_NOT_NULL(test, info);
this new macro was merged into 5.19-rc1.

  parent reply	other threads:[~2022-06-22 17:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21 20:09 [PATCH v2 0/9] drm: selftest: Convert to KUnit Maíra Canal
2022-06-21 20:09 ` [PATCH v2 1/9] drm: selftest: convert drm_damage_helper selftest " Maíra Canal
2022-06-21 20:09 ` [PATCH v2 2/9] drm: selftest: convert drm_cmdline_parser " Maíra Canal
2022-06-21 20:09 ` [PATCH v2 3/9] drm: selftest: convert drm_rect " Maíra Canal
2022-06-21 20:09 ` [PATCH v2 4/9] drm: selftest: convert drm_format " Maíra Canal
2022-06-22 11:08   ` kernel test robot
2022-06-22 17:06   ` Daniel Latypov [this message]
2022-06-21 20:09 ` [PATCH v2 5/9] drm: selftest: convert drm_plane_helper " Maíra Canal
2022-06-21 20:09 ` [PATCH v2 6/9] drm: selftest: convert drm_dp_mst_helper " Maíra Canal
2022-06-21 20:09 ` [PATCH v2 7/9] drm: selftest: convert drm_framebuffer " Maíra Canal
2022-06-21 20:09 ` [PATCH v2 8/9] drm: selftest: convert drm_buddy " Maíra Canal
2022-06-21 20:09 ` [PATCH v2 9/9] drm: selftest: convert drm_mm " Maíra Canal

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='CAGS_qxrynX=q7ZVmFSm-HO-3r3wGVnXMXVMejM3-ONvyJUrrPg@mail.gmail.com' \
    --to=dlatypov@google.com \
    --cc=airlied@linux.ie \
    --cc=andrealmeid@riseup.net \
    --cc=brendanhiggins@google.com \
    --cc=davidgow@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=isabbasso@riseup.net \
    --cc=javierm@redhat.com \
    --cc=jose.exposito89@gmail.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=leandro.ribeiro@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=magalilemes00@gmail.com \
    --cc=maira.canal@usp.br \
    --cc=michal.winiarski@intel.com \
    --cc=mwen@igalia.com \
    --cc=n@nfraprado.net \
    --cc=siqueirajordao@riseup.net \
    --cc=skhan@linuxfoundation.org \
    --cc=tales.aparecida@gmail.com \
    --cc=tzimmermann@suse.de \
    /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).