2022-06-13 19:38:52

by José Expósito

[permalink] [raw]
Subject: [PATCH v3 3/3] drm/doc: Add KUnit documentation

Explain how to run the KUnit tests present in the DRM subsystem and
clarify why the UML-only options were not added to the configuration
file present in drivers/gpu/drm/.kunitconfig [1] [2].

[1] https://lore.kernel.org/dri-devel/CABVgOSn8i=LO5p7830h2XU1Jgg0KrN0qTnxkOMhf1oTgxjaKKw@mail.gmail.com/
[2] https://lore.kernel.org/dri-devel/CAGS_qxqpiCim_sy1LDK7PLwVgWf-LKW+uNFTGM=T7ydk-dYcEw@mail.gmail.com/

Reviewed-by: Maxime Ripard <[email protected]>
Signed-off-by: José Expósito <[email protected]>
---
Documentation/gpu/drm-internals.rst | 32 +++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-internals.rst
index 38afed24a75c..f1d97e80ca29 100644
--- a/Documentation/gpu/drm-internals.rst
+++ b/Documentation/gpu/drm-internals.rst
@@ -207,6 +207,38 @@ Utilities
:internal:


+Unit testing
+============
+
+KUnit
+-----
+
+KUnit (Kernel unit testing framework) provides a common framework for unit tests
+within the Linux kernel.
+
+This section covers the specifics for the DRM subsystem. For general information
+about KUnit, please refer to Documentation/dev-tools/kunit/start.rst.
+
+How to run the tests?
+~~~~~~~~~~~~~~~~~~~~~
+
+In order to facilitate running the test suite, a configuration file is present
+in ``drivers/gpu/drm/kunit/.kunitconfig``. It can be used by ``kunit.py`` as
+follows:
+
+.. code-block:: bash
+
+ $ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/kunit \
+ --kconfig_add CONFIG_VIRTIO_UML=y \
+ --kconfig_add CONFIG_UML_PCI_OVER_VIRTIO=y
+
+.. note::
+ The configuration included in ``.kunitconfig`` should be as generic as
+ possible.
+ ``CONFIG_VIRTIO_UML`` and ``CONFIG_UML_PCI_OVER_VIRTIO`` are not
+ included in it because they are only required for User Mode Linux.
+
+
Legacy Support Code
===================

--
2.25.1


2022-06-14 13:10:14

by Javier Martinez Canillas

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] drm/doc: Add KUnit documentation

Hello José,

On 6/13/22 19:17, José Expósito wrote:

[snip]

> +KUnit (Kernel unit testing framework) provides a common framework for unit tests
> +within the Linux kernel.
> +

I think that it will be useful to have a reference to the KUnit kernel doc here,
something like the following:

`KUnit <https://docs.kernel.org/dev-tools/kunit/index.html>`_ (Kernel Unit...

> +This section covers the specifics for the DRM subsystem. For general information
> +about KUnit, please refer to Documentation/dev-tools/kunit/start.rst.
> +
> +How to run the tests?
> +~~~~~~~~~~~~~~~~~~~~~
> +
> +In order to facilitate running the test suite, a configuration file is present
> +in ``drivers/gpu/drm/kunit/.kunitconfig``. It can be used by ``kunit.py`` as
> +follows:
> +
> +.. code-block:: bash
> +
> + $ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/kunit \
> + --kconfig_add CONFIG_VIRTIO_UML=y \
> + --kconfig_add CONFIG_UML_PCI_OVER_VIRTIO=y
> +
> +.. note::
> + The configuration included in ``.kunitconfig`` should be as generic as
> + possible.
> + ``CONFIG_VIRTIO_UML`` and ``CONFIG_UML_PCI_OVER_VIRTIO`` are not
> + included in it because they are only required for User Mode Linux.
> +
> +

Maybe also add something like this ?

For example, the following command can be used to run the test for x86_64:

$ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/kunit \
--arch=x86_64

Regardless, the patch looks good to me:

Reviewed-by: Javier Martinez Canillas <[email protected]>

--
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat

2022-06-14 18:26:45

by José Expósito

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] drm/doc: Add KUnit documentation

Hi Javier,

On Tue, Jun 14, 2022 at 02:58:29PM +0200, Javier Martinez Canillas wrote:
> Hello Jos?,
>
> On 6/13/22 19:17, Jos? Exp?sito wrote:
>
> [snip]
>
> > +KUnit (Kernel unit testing framework) provides a common framework for unit tests
> > +within the Linux kernel.
> > +
>
> I think that it will be useful to have a reference to the KUnit kernel doc here,
> something like the following:
>
> `KUnit <https://docs.kernel.org/dev-tools/kunit/index.html>`_ (Kernel Unit...

There is a link in the next paragraph. Once the documentation is
generated the path "Documentation/dev-tools/kunit/start.rst" is
transformed into a link.

> > +This section covers the specifics for the DRM subsystem. For general information
> > +about KUnit, please refer to Documentation/dev-tools/kunit/start.rst.
> > +
> > +How to run the tests?
> > +~~~~~~~~~~~~~~~~~~~~~
> > +
> > +In order to facilitate running the test suite, a configuration file is present
> > +in ``drivers/gpu/drm/kunit/.kunitconfig``. It can be used by ``kunit.py`` as
> > +follows:
> > +
> > +.. code-block:: bash
> > +
> > + $ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/kunit \
> > + --kconfig_add CONFIG_VIRTIO_UML=y \
> > + --kconfig_add CONFIG_UML_PCI_OVER_VIRTIO=y
> > +
> > +.. note::
> > + The configuration included in ``.kunitconfig`` should be as generic as
> > + possible.
> > + ``CONFIG_VIRTIO_UML`` and ``CONFIG_UML_PCI_OVER_VIRTIO`` are not
> > + included in it because they are only required for User Mode Linux.
> > +
> > +
>
> Maybe also add something like this ?
>
> For example, the following command can be used to run the test for x86_64:
>
> $ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/kunit \
> --arch=x86_64

I didn't want to go into much detail because the KUnit docs are
a very good resource and already explain how to run the tests in your
favorite architecture.

Since running the test on x86_64 should not change the results, I'd
prefer to keep it simple and trust the KUnit docs for the "advanced"
options.

> Regardless, the patch looks good to me:
>
> Reviewed-by: Javier Martinez Canillas <[email protected]>


Thanks a lot for taking the time to review it. I'll add the tag if a v4
is required after chatting with the guys working on the AMDGPU tests.

Jose

> --
> Best regards,
>
> Javier Martinez Canillas
> Linux Engineering
> Red Hat
>

2022-06-14 19:14:51

by Javier Martinez Canillas

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] drm/doc: Add KUnit documentation

On 6/14/22 20:09, José Expósito wrote:
> Hi Javier,
>
> On Tue, Jun 14, 2022 at 02:58:29PM +0200, Javier Martinez Canillas wrote:
>> Hello José,
>>
>> On 6/13/22 19:17, José Expósito wrote:
>>
>> [snip]
>>
>>> +KUnit (Kernel unit testing framework) provides a common framework for unit tests
>>> +within the Linux kernel.
>>> +
>>
>> I think that it will be useful to have a reference to the KUnit kernel doc here,
>> something like the following:
>>
>> `KUnit <https://docs.kernel.org/dev-tools/kunit/index.html>`_ (Kernel Unit...
>
> There is a link in the next paragraph. Once the documentation is
> generated the path "Documentation/dev-tools/kunit/start.rst" is
> transformed into a link.
>
Ah, I wasn't aware of that. Thanks!

--
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat

2022-06-24 21:03:09

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] drm/doc: Add KUnit documentation

On Tue, Jun 14, 2022 at 02:58:29PM +0200, Javier Martinez Canillas wrote:
> Hello Jos?,
>
> On 6/13/22 19:17, Jos? Exp?sito wrote:
>
> [snip]
>
> > +KUnit (Kernel unit testing framework) provides a common framework for unit tests
> > +within the Linux kernel.
> > +
>
> I think that it will be useful to have a reference to the KUnit kernel doc here,
> something like the following:
>
> `KUnit <https://docs.kernel.org/dev-tools/kunit/index.html>`_ (Kernel Unit...
>
> > +This section covers the specifics for the DRM subsystem. For general information
> > +about KUnit, please refer to Documentation/dev-tools/kunit/start.rst.
> > +
> > +How to run the tests?
> > +~~~~~~~~~~~~~~~~~~~~~
> > +
> > +In order to facilitate running the test suite, a configuration file is present
> > +in ``drivers/gpu/drm/kunit/.kunitconfig``. It can be used by ``kunit.py`` as
> > +follows:
> > +
> > +.. code-block:: bash
> > +
> > + $ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/kunit \
> > + --kconfig_add CONFIG_VIRTIO_UML=y \
> > + --kconfig_add CONFIG_UML_PCI_OVER_VIRTIO=y
> > +
> > +.. note::
> > + The configuration included in ``.kunitconfig`` should be as generic as
> > + possible.
> > + ``CONFIG_VIRTIO_UML`` and ``CONFIG_UML_PCI_OVER_VIRTIO`` are not
> > + included in it because they are only required for User Mode Linux.
> > +
> > +
>
> Maybe also add something like this ?
>
> For example, the following command can be used to run the test for x86_64:
>
> $ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/kunit \
> --arch=x86_64
>
> Regardless, the patch looks good to me:
>
> Reviewed-by: Javier Martinez Canillas <[email protected]>

Hey so since you have a bunch of patches merged into drm already but seem
to lack drm-misc commit rights to push these yourself I think it's time to
get those:

https://drm.pages.freedesktop.org/maintainer-tools/commit-access.html#drm-misc

And I guess Javier can help you with any questions you might have and make
sure the request gets through by poking folks on #dri-devel irc?

Cheers, Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

2022-06-24 21:32:26

by Javier Martinez Canillas

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] drm/doc: Add KUnit documentation

Hello Daniel,

On 6/24/22 23:01, Daniel Vetter wrote:
> On Tue, Jun 14, 2022 at 02:58:29PM +0200, Javier Martinez Canillas wrote:
>> Hello José,
>>
>> On 6/13/22 19:17, José Expósito wrote:
>>
>> [snip]
>>
>>> +KUnit (Kernel unit testing framework) provides a common framework for unit tests
>>> +within the Linux kernel.
>>> +
>>
>> I think that it will be useful to have a reference to the KUnit kernel doc here,
>> something like the following:
>>
>> `KUnit <https://docs.kernel.org/dev-tools/kunit/index.html>`_ (Kernel Unit...
>>
>>> +This section covers the specifics for the DRM subsystem. For general information
>>> +about KUnit, please refer to Documentation/dev-tools/kunit/start.rst.
>>> +
>>> +How to run the tests?
>>> +~~~~~~~~~~~~~~~~~~~~~
>>> +
>>> +In order to facilitate running the test suite, a configuration file is present
>>> +in ``drivers/gpu/drm/kunit/.kunitconfig``. It can be used by ``kunit.py`` as
>>> +follows:
>>> +
>>> +.. code-block:: bash
>>> +
>>> + $ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/kunit \
>>> + --kconfig_add CONFIG_VIRTIO_UML=y \
>>> + --kconfig_add CONFIG_UML_PCI_OVER_VIRTIO=y
>>> +
>>> +.. note::
>>> + The configuration included in ``.kunitconfig`` should be as generic as
>>> + possible.
>>> + ``CONFIG_VIRTIO_UML`` and ``CONFIG_UML_PCI_OVER_VIRTIO`` are not
>>> + included in it because they are only required for User Mode Linux.
>>> +
>>> +
>>
>> Maybe also add something like this ?
>>
>> For example, the following command can be used to run the test for x86_64:
>>
>> $ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm/kunit \
>> --arch=x86_64
>>
>> Regardless, the patch looks good to me:
>>
>> Reviewed-by: Javier Martinez Canillas <[email protected]>
>
> Hey so since you have a bunch of patches merged into drm already but seem
> to lack drm-misc commit rights to push these yourself I think it's time to
> get those:
>
> https://drm.pages.freedesktop.org/maintainer-tools/commit-access.html#drm-misc
>
> And I guess Javier can help you with any questions you might have and make
> sure the request gets through by poking folks on #dri-devel irc?
>

Yes, he already requested commit access and got the acks, so I think is
just a matter of time until he has this sorted out.

José, please don't hesitate to ask if you need any help or clarification
once you have a setup to push your patches. The dim documentation [0] is
superb but I know that it can be somewhat stressful the first time :)

[0]: https://drm.pages.freedesktop.org/maintainer-tools/dim.html
--
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat

2022-06-27 12:38:06

by José Expósito

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] drm/doc: Add KUnit documentation

Hi Javier, Daniel,

On Fri, Jun 24, 2022 at 11:18:40PM +0200, Javier Martinez Canillas wrote:
> Hello Daniel,
>
> On 6/24/22 23:01, Daniel Vetter wrote:
> >
> > [...]
> >
> > Hey so since you have a bunch of patches merged into drm already but seem
> > to lack drm-misc commit rights to push these yourself I think it's time to
> > get those:
> >
> > https://drm.pages.freedesktop.org/maintainer-tools/commit-access.html#drm-misc
> >
> > And I guess Javier can help you with any questions you might have and make
> > sure the request gets through by poking folks on #dri-devel irc?
> >
>
> Yes, he already requested commit access and got the acks, so I think is
> just a matter of time until he has this sorted out.
>
> Jos?, please don't hesitate to ask if you need any help or clarification
> once you have a setup to push your patches. The dim documentation [0] is
> superb but I know that it can be somewhat stressful the first time :)

Thanks for creating my ssh account :D

The tool is really well documented, setting it up was a piece of cake.
I pushed the patches to drm-misc-next. The output didn't show any
errors or warnings, hopefully meaning that I didn't mess up.

Jose

> [0]: https://drm.pages.freedesktop.org/maintainer-tools/dim.html
> --
> Best regards,
>
> Javier Martinez Canillas
> Linux Engineering
> Red Hat
>

2022-06-27 13:36:51

by Javier Martinez Canillas

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] drm/doc: Add KUnit documentation

Hello José,

On 6/27/22 14:36, José Expósito wrote:
> Hi Javier, Daniel,
>
> On Fri, Jun 24, 2022 at 11:18:40PM +0200, Javier Martinez Canillas wrote:
>> Hello Daniel,
>>
>> On 6/24/22 23:01, Daniel Vetter wrote:
>>>
>>> [...]
>>>
>>> Hey so since you have a bunch of patches merged into drm already but seem
>>> to lack drm-misc commit rights to push these yourself I think it's time to
>>> get those:
>>>
>>> https://drm.pages.freedesktop.org/maintainer-tools/commit-access.html#drm-misc
>>>
>>> And I guess Javier can help you with any questions you might have and make
>>> sure the request gets through by poking folks on #dri-devel irc?
>>>
>>
>> Yes, he already requested commit access and got the acks, so I think is
>> just a matter of time until he has this sorted out.
>>
>> José, please don't hesitate to ask if you need any help or clarification
>> once you have a setup to push your patches. The dim documentation [0] is
>> superb but I know that it can be somewhat stressful the first time :)
>
> Thanks for creating my ssh account :D
>
> The tool is really well documented, setting it up was a piece of cake.
> I pushed the patches to drm-misc-next. The output didn't show any
> errors or warnings, hopefully meaning that I didn't mess up.
>

Awesome! Yes, everything looks correct. Thanks a lot.
--
Best regards,

Javier Martinez Canillas
Linux Engineering
Red Hat