[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABVgOSkx7KYNRKCN5h=37zQGR0qu+BDCb6cQeqbCwX8UxC3knw@mail.gmail.com>
Date: Fri, 30 Sep 2022 14:50:43 +0800
From: David Gow <davidgow@...gle.com>
To: Michał Winiarski <michal.winiarski@...el.com>
Cc: Maíra Canal <mcanal@...lia.com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>, Melissa Wen <mwen@...lia.com>,
André Almeida <andrealmeid@...lia.com>,
Javier Martinez Canillas <javierm@...hat.com>,
Daniel Latypov <dlatypov@...gle.com>,
Arthur Grillo <arthur.grillo@....br>,
Isabella Basso <isabbasso@...eup.net>, magalilemes00@...il.com,
Tales Aparecida <tales.aparecida@...il.com>,
dri-devel@...ts.freedesktop.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/2] drm/tests: Split drm_test_dp_mst_sideband_msg_req_decode
into parameterized tests
On Fri, Sep 30, 2022 at 6:33 AM Michał Winiarski
<michal.winiarski@...el.com> wrote:
>
> On Tue, Sep 27, 2022 at 07:12:06PM -0300, Maíra Canal wrote:
> > The drm_test_dp_mst_sideband_msg_req_decode repeats the same test
> > structure with different parameters. This could be better represented
> > by parameterized tests, provided by KUnit.
> >
> > In order to convert the tests to parameterized tests, the test case for
> > the client ID was changed: instead of using get_random_bytes to generate
> > the client ID, the client ID is now hardcoded in the test case.
>
> Generally "random" usage is not incompatible with parameterized tests, we can
> create parameterized tests that use random data.
> The idea is to pass a function that generates the actual param (where we have a
> pointer to function as one of the members in "params" struct).
>
> For example, see "random_dp_query_enc_client_id" usage here:
> https://lore.kernel.org/dri-devel/20220117232259.180459-7-michal.winiarski@intel.com/
>
> In this case, we just compare data going in with data going out (and the data
> itself is not transformed in any way), so it doesn't really matter for coverage
> and we can hardcode.
>
> -Michał
FWIW, while the uses of randomness in DRM tests so far haven't
concerned me much, I think we'll eventually want to have some way of
ensuring the inputs to tests are deterministic.
My thoughts are that (at some point) we'll add a kunit_random()
function or similar, which will use a pseudorandom number generator
which can be set to a deterministic seed before each test case. That
way, there'd be a way to reproduce an error easily if it occurred. (Of
course, there'd be a way of setting different or random seeds to
preserve the extra coverage you'd otherwise get.)
I don't think this is something worth holding up or changing existing
tests at the moment, but having tests behave deterministically is
definitely desirable, so +1 to avoiding get_random_bytes() if it's not
giving you any real benefit.
We've also had a few requests in the past for being able to pass in a
custom set of parameters from userspace, which opens up some other
interesting possibilities, though it's not a priority at the moment.
Cheers,
-- David
Download attachment "smime.p7s" of type "application/pkcs7-signature" (4003 bytes)
Powered by blists - more mailing lists