[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220815084213.olcvp6qhmhhykz6t@houat>
Date: Mon, 15 Aug 2022 10:42:13 +0200
From: Maxime Ripard <maxime@...no.tech>
To: Thomas Zimmermann <tzimmermann@...e.de>
Cc: Jernej Skrabec <jernej.skrabec@...il.com>,
Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
Chen-Yu Tsai <wens@...e.org>,
Philipp Zabel <p.zabel@...gutronix.de>,
Jerome Brunet <jbrunet@...libre.com>,
Samuel Holland <samuel@...lland.org>,
Daniel Vetter <daniel@...ll.ch>, Emma Anholt <emma@...olt.net>,
David Airlie <airlied@...ux.ie>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Noralf Trønnes <noralf@...nnes.org>,
Kevin Hilman <khilman@...libre.com>,
Neil Armstrong <narmstrong@...libre.com>,
Dom Cobley <dom@...pberrypi.com>,
Dave Stevenson <dave.stevenson@...pberrypi.com>,
linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
Mateusz Kwiatkowski <kfyatek+publicgit@...il.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
linux-amlogic@...ts.infradead.org, linux-sunxi@...ts.linux.dev,
Phil Elwell <phil@...pberrypi.com>,
linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v1 08/35] drm/client: Add some tests for
drm_connector_pick_cmdline_mode()
Hi Thomas,
On Tue, Aug 02, 2022 at 12:14:29PM +0200, Thomas Zimmermann wrote:
> Am 29.07.22 um 18:34 schrieb Maxime Ripard:
> > drm_connector_pick_cmdline_mode() is in charge of finding a proper
> > drm_display_mode from the definition we got in the video= command line
> > argument.
> >
> > Let's add some unit tests to make sure we're not getting any regressions
> > there.
> >
> > Signed-off-by: Maxime Ripard <maxime@...no.tech>
> >
> > diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
> > index bbc535cc50dd..ee6b8f193c24 100644
> > --- a/drivers/gpu/drm/drm_client_modeset.c
> > +++ b/drivers/gpu/drm/drm_client_modeset.c
> > @@ -1237,3 +1237,7 @@ int drm_client_modeset_dpms(struct drm_client_dev *client, int mode)
> > return ret;
> > }
> > EXPORT_SYMBOL(drm_client_modeset_dpms);
> > +
> > +#ifdef CONFIG_DRM_KUNIT_TEST
> > +#include "tests/drm_mode_test.c"
> > +#endif
>
> Including source files is somewhat ugly, prolongs compile times and could
> even interfere with the actual source code. Can we do this in some other
> way?
Yeah, this irks me a bit as well, but it's the preferred way of doing it
according to the kunit doc:
https://www.kernel.org/doc/html/latest/dev-tools/kunit/usage.html#testing-static-functions
> I suggest to add the tests here and export them for use in the test case.
> Something like
>
> #ifdef CONFIG_DRM_KUNIT_TEST
> static drm_mode_res_1920_1080_60()
> {
> ...
> }
>
> struct kunit_case drm_mode_tests[] = {
> drm_mode_res_1920_1080_60
> };
> EXPORT_SYMBOL(drm_mode_tests);
> #endif
>
> This would add the tests next to the tested code, but leave the test driver
> in drm_mode_test.c.
The test suite is fairly small for now, but if we end up with dozens of
tests like what is there for the command line parser (which could happen
for that kind of functions), I'm very afraid that the original source
file will become unreadable, while this has the advantage to keep the
original file readability.
Maxime
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists