From nobody Mon Apr 27 12:16:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C02EEC43334 for ; Mon, 13 Jun 2022 19:22:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348647AbiFMTV7 (ORCPT ); Mon, 13 Jun 2022 15:21:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348629AbiFMTVW (ORCPT ); Mon, 13 Jun 2022 15:21:22 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26ADC1FA61 for ; Mon, 13 Jun 2022 10:17:49 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id i17-20020a7bc951000000b0039c4760ec3fso4396271wml.0 for ; Mon, 13 Jun 2022 10:17:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oTgKLvjLuTzO7UM/mQsy+9BhRmEEwbTxiHwdzXn+Bis=; b=GCqt0jHDbbSAEtN+nQobnMYuspNmhWO31Jlw3BkNbBf4JuoBPhaTz0IqkCqndu0yTD XEwFvO18vMq2x/zYuP5VPzM6C0GXCH1I+T7FuwfX+Xm/eS0o66cQKMSnc9vGmcbtS3qn kVUxCXGnNvfc20nSneMcBtPI3GxeM/pWq5php6GklT52+D+OYf4wSJ0j8sFvUd0b46UK TB2d/JBO3OhcD1A0VMlyA89+trntVh6ygLkNqYmxKlw3kzPSlyfyry7hzFAm7Z6D7oGF inGWMPjHahuf5WdtUGZsdgXaytjRrsEafpH3TYIMSbmAWjV4EudB7pPINesAvIhvdcth rzqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oTgKLvjLuTzO7UM/mQsy+9BhRmEEwbTxiHwdzXn+Bis=; b=T7MhDy2vySL52Zt29K+XGJTKWPlEcp5MmUtg0AZLl9zzkY7tVwk+Ae4PDQJ3GKoPXC dlszmrtEK826Rpv82yWhjWmJeLs9th152IUEnEgoUPVNH7fWYfiHxEwomGd3BNXq8UVW TMVwjpNS9uac7zgoex4tZdJ0E3N40AD85+I85N7LpuZt36gm8fLds6HVGvVD3lig/p4/ SP24xRiTs+hwlzjPEu2qk4Wbot6ang37vEmubVH5t+exmPd7NEh0KB9l7mcG2WjrC4e8 ghW0qPCYUyG+WDOA3ClMjxxnuYCJvvkFEI86Mo2NNTWOFsPXqTbdzeTiLlIzyy3K34h8 I/mQ== X-Gm-Message-State: AOAM532k2ofkcpLme72cMUl+OmoT9Uk/dJfMkvfm6PaTmaAgaDjgxsnY Dn9o0lXMWHTfjiQDA43VL4Y= X-Google-Smtp-Source: ABdhPJzigC+Zu4VdUjf/vJ/zZ+ckaaLhD1Hmrd5dgKce1PLsqWQFWFA/i0izU2+UeTXMvSspFJJtgQ== X-Received: by 2002:a1c:7901:0:b0:39c:4252:d7f1 with SMTP id l1-20020a1c7901000000b0039c4252d7f1mr537938wme.178.1655140667601; Mon, 13 Jun 2022 10:17:47 -0700 (PDT) Received: from localhost.localdomain ([94.73.36.128]) by smtp.gmail.com with ESMTPSA id a10-20020a056000100a00b0020d106c0386sm9016129wrx.89.2022.06.13.10.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jun 2022 10:17:47 -0700 (PDT) From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= To: javierm@redhat.com Cc: davidgow@google.com, dlatypov@google.com, tzimmermann@suse.de, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@linux.ie, daniel@ffwll.ch, jani.nikula@linux.intel.com, dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Subject: [PATCH v3 1/3] drm/rect: Add DRM_RECT_INIT() macro Date: Mon, 13 Jun 2022 19:17:36 +0200 Message-Id: <20220613171738.111013-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220613171738.111013-1-jose.exposito89@gmail.com> References: <20220613171738.111013-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper macro to initialize a rectangle from x, y, width and height information. Signed-off-by: Jos=C3=A9 Exp=C3=B3sito Acked-by: Thomas Zimmermann Reviewed-by: Jani Nikula --- include/drm/drm_rect.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/drm/drm_rect.h b/include/drm/drm_rect.h index 6f6e19bd4dac..e8d94fca2703 100644 --- a/include/drm/drm_rect.h +++ b/include/drm/drm_rect.h @@ -47,6 +47,22 @@ struct drm_rect { int x1, y1, x2, y2; }; =20 +/** + * DRM_RECT_INIT - initialize a rectangle from x/y/w/h + * @x: x coordinate + * @y: y coordinate + * @w: width + * @h: height + * + * RETURNS: + * A new rectangle of the specified size. + */ +#define DRM_RECT_INIT(x, y, w, h) ((struct drm_rect){ \ + .x1 =3D (x), \ + .y1 =3D (y), \ + .x2 =3D (x) + (w), \ + .y2 =3D (y) + (h) }) + /** * DRM_RECT_FMT - printf string for &struct drm_rect */ --=20 2.25.1 From nobody Mon Apr 27 12:16:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D2A4C433EF for ; Mon, 13 Jun 2022 19:22:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349321AbiFMTWD (ORCPT ); Mon, 13 Jun 2022 15:22:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349112AbiFMTVX (ORCPT ); Mon, 13 Jun 2022 15:21:23 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CCEC27FFD for ; Mon, 13 Jun 2022 10:17:50 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id a15so7981873wrh.2 for ; Mon, 13 Jun 2022 10:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aBTnuGESBCUEiwOafkRvyvkfuq0zr4bR2Y26oGOBUuw=; b=d7KPqbtKuU+6d5cr6ROdZ0C1OP1OWk9Zj5HHKVQ9WEvffYP6U76wEbnNccHijn0/qX xCLb/3a/5DRj9bL4WB50QWYuRV0U0adLscw+pFmXKXkZXmpOpyTJGD9vh/RazRMe8LFs 4pj/CpRXn/ta80Hm02DfDLJv0OyqC1zRgOLHNTsuXezVucCSg4Wt1JfKT/mWugoK4TE/ agRABD90QHJY3lnCIVBs8weSo1+160hZ0L0GwpGowySz4U/Q81zj2n6Ue+S3FuFqG0Ow 7n8PcZpNR2TkaH3Tji3UQfpY7X07/uKgU4F74gpDU+oPqY/QnS50gqgmXcqqmIxmYVrc fFzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aBTnuGESBCUEiwOafkRvyvkfuq0zr4bR2Y26oGOBUuw=; b=yEyR3Kco6DJ/M4pfDSnfG5wtdBoNKhOpMohxVndx3ymHAFmbJgioD2Bscl9/AE7uSz qxH+U3/+xbPrht7nodG/phuWo5/MNfjJc4Q6VttqUkXXpjaqh0dLb/NVm5X6GgcttlHh RdZVNAlfVBiuUj6vhknNaeDCwk3DzMc+BQzRRpO+Uny+EhFxVJCHyki+M5OZ1Edwtmd8 MOogbHfpRDWgiEje2KmokEvvlUtbAAjmpgBlkEr/3yt2OFacOgV0LvoYYZqmPXH2USDl QdUsF3wrOcJZtDfSvpjLFiJ6H3cEbThseD4gpS7KXmHS6lJMxZf0BjeTCSMQ0c2pihDJ 0KPA== X-Gm-Message-State: AJIora8z5wUDwge+68tU1iJhjL12BJeadwjZiX1HCza3tMQUgEMcc1xX nytn2uHbYRARfEkAGEvgE2E= X-Google-Smtp-Source: AGRyM1ujLhG3/Nv93ncuamX3kngdkhXy1jnzaw1R0vCjED5U0raoEe+8B1jZ8Wi1gvGfKLc59yoNMw== X-Received: by 2002:adf:e384:0:b0:213:b1d4:a964 with SMTP id e4-20020adfe384000000b00213b1d4a964mr775957wrm.653.1655140668632; Mon, 13 Jun 2022 10:17:48 -0700 (PDT) Received: from localhost.localdomain ([94.73.36.128]) by smtp.gmail.com with ESMTPSA id a10-20020a056000100a00b0020d106c0386sm9016129wrx.89.2022.06.13.10.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jun 2022 10:17:48 -0700 (PDT) From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= To: javierm@redhat.com Cc: davidgow@google.com, dlatypov@google.com, tzimmermann@suse.de, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@linux.ie, daniel@ffwll.ch, jani.nikula@linux.intel.com, dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Subject: [PATCH v3 2/3] drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb332() Date: Mon, 13 Jun 2022 19:17:37 +0200 Message-Id: <20220613171738.111013-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220613171738.111013-1-jose.exposito89@gmail.com> References: <20220613171738.111013-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Test the conversion from XRGB8888 to RGB332. What is tested? - Different values for the X in XRGB8888 to make sure it is ignored - Different clip values: Single pixel and full and partial buffer - Well known colors: White, black, red, green, blue, magenta, yellow and cyan - Other colors: Randomly picked - Destination pitch How to run the tests? $ ./tools/testing/kunit/kunit.py run --kunitconfig=3Ddrivers/gpu/drm/kunit= \ --kconfig_add CONFIG_VIRTIO_UML=3Dy \ --kconfig_add CONFIG_UML_PCI_OVER_VIRTIO=3Dy Suggested-by: Javier Martinez Canillas Reviewed-by: Javier Martinez Canillas Signed-off-by: Jos=C3=A9 Exp=C3=B3sito Acked-by: Thomas Zimmermann --- drivers/gpu/drm/Kconfig | 16 ++ drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/kunit/.kunitconfig | 3 + drivers/gpu/drm/kunit/Makefile | 3 + .../gpu/drm/kunit/drm_format_helper_test.c | 160 ++++++++++++++++++ 5 files changed, 183 insertions(+) create mode 100644 drivers/gpu/drm/kunit/.kunitconfig create mode 100644 drivers/gpu/drm/kunit/Makefile create mode 100644 drivers/gpu/drm/kunit/drm_format_helper_test.c diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 22e7fa48d693..6c2256e8474b 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -70,6 +70,22 @@ config DRM_DEBUG_SELFTEST =20 If in doubt, say "N". =20 +config DRM_KUNIT_TEST + tristate "KUnit tests for DRM" if !KUNIT_ALL_TESTS + depends on DRM && KUNIT=3Dy + select DRM_KMS_HELPER + default KUNIT_ALL_TESTS + help + This builds unit tests for DRM. This option is not useful for + distributions or general kernels, but only for kernel + developers working on DRM and associated drivers. + + For more information on KUnit and unit tests in general, + please refer to the KUnit documentation in + Documentation/dev-tools/kunit/. + + If in doubt, say "N". + config DRM_KMS_HELPER tristate depends on DRM diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 13ef240b3d2b..3171437d74f8 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -76,6 +76,7 @@ obj-$(CONFIG_DRM_KMS_HELPER) +=3D drm_kms_helper.o # =20 obj-$(CONFIG_DRM_DEBUG_SELFTEST) +=3D selftests/ +obj-$(CONFIG_DRM_KUNIT_TEST) +=3D kunit/ =20 obj-$(CONFIG_DRM_MIPI_DBI) +=3D drm_mipi_dbi.o obj-$(CONFIG_DRM_MIPI_DSI) +=3D drm_mipi_dsi.o diff --git a/drivers/gpu/drm/kunit/.kunitconfig b/drivers/gpu/drm/kunit/.ku= nitconfig new file mode 100644 index 000000000000..6ec04b4c979d --- /dev/null +++ b/drivers/gpu/drm/kunit/.kunitconfig @@ -0,0 +1,3 @@ +CONFIG_KUNIT=3Dy +CONFIG_DRM=3Dy +CONFIG_DRM_KUNIT_TEST=3Dy diff --git a/drivers/gpu/drm/kunit/Makefile b/drivers/gpu/drm/kunit/Makefile new file mode 100644 index 000000000000..2c8273796d9d --- /dev/null +++ b/drivers/gpu/drm/kunit/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_DRM_KUNIT_TEST) +=3D drm_format_helper_test.o diff --git a/drivers/gpu/drm/kunit/drm_format_helper_test.c b/drivers/gpu/d= rm/kunit/drm_format_helper_test.c new file mode 100644 index 000000000000..f8f2351f3449 --- /dev/null +++ b/drivers/gpu/drm/kunit/drm_format_helper_test.c @@ -0,0 +1,160 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../drm_crtc_internal.h" + +#define TEST_BUF_SIZE 50 + +struct xrgb8888_to_rgb332_case { + const char *name; + unsigned int pitch; + unsigned int dst_pitch; + struct drm_rect clip; + const u32 xrgb8888[TEST_BUF_SIZE]; + const u8 expected[4 * TEST_BUF_SIZE]; +}; + +static struct xrgb8888_to_rgb332_case xrgb8888_to_rgb332_cases[] =3D { + { + .name =3D "Single pixel source buffer", + .pitch =3D 1 * 4, + .dst_pitch =3D 0, + .clip =3D DRM_RECT_INIT(0, 0, 1, 1), + .xrgb8888 =3D { 0x01FF0000 }, + .expected =3D { 0xE0 }, + }, + { + .name =3D "Single pixel clip rectangle", + .pitch =3D 2 * 4, + .dst_pitch =3D 0, + .clip =3D DRM_RECT_INIT(1, 1, 1, 1), + .xrgb8888 =3D { + 0x00000000, 0x00000000, + 0x00000000, 0x10FF0000, + }, + .expected =3D { 0xE0 }, + }, + { + /* Well known colors, different values for the X in XRGB8888 to + * make sure it is ignored. Partial clip area. + */ + .name =3D "White, black, red, green, blue, magenta, yellow, cyan", + .pitch =3D 4 * 4, + .dst_pitch =3D 0, + .clip =3D DRM_RECT_INIT(1, 1, 2, 4), + .xrgb8888 =3D { + 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x11FFFFFF, 0x22000000, 0x00000000, + 0x00000000, 0x33FF0000, 0x4400FF00, 0x00000000, + 0x00000000, 0x550000FF, 0x66FF00FF, 0x00000000, + 0x00000000, 0x77FFFF00, 0x8800FFFF, 0x00000000, + }, + .expected =3D { + 0xFF, 0x00, + 0xE0, 0x1C, + 0x03, 0xE3, + 0xFC, 0x1F, + }, + }, + { + /* Randomly picked colors. Full buffer within the clip area. */ + .name =3D "Destination pitch", + .pitch =3D 3 * 4, + .dst_pitch =3D 5, + .clip =3D DRM_RECT_INIT(0, 0, 3, 3), + .xrgb8888 =3D { + 0xA10E449C, 0xB1114D05, 0xC1A80303, + 0xD16C7073, 0xA20E449C, 0xB2114D05, + 0xC2A80303, 0xD26C7073, 0xA30E449C, + }, + .expected =3D { + 0x0A, 0x08, 0xA0, 0x00, 0x00, + 0x6D, 0x0A, 0x08, 0x00, 0x00, + 0xA0, 0x6D, 0x0A, 0x00, 0x00, + }, + }, +}; + +/* + * conversion_buf_size - Return the destination buffer size required to co= nvert + * between formats. + * @dst_format: destination buffer pixel format (DRM_FORMAT_*) + * @dst_pitch: Number of bytes between two consecutive scanlines within dst + * @clip: Clip rectangle area to convert + * + * Returns: + * The size of the destination buffer or negative value on error. + */ +static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch, + const struct drm_rect *clip) +{ + const struct drm_format_info *dst_fi =3D drm_format_info(dst_format); + + if (!dst_fi) + return -EINVAL; + + if (!dst_pitch) + dst_pitch =3D drm_rect_width(clip) * dst_fi->cpp[0]; + + return dst_pitch * drm_rect_height(clip); +} + +static void xrgb8888_to_rgb332_case_desc(struct xrgb8888_to_rgb332_case *t, + char *desc) +{ + strscpy(desc, t->name, KUNIT_PARAM_DESC_SIZE); +} + +KUNIT_ARRAY_PARAM(xrgb8888_to_rgb332, xrgb8888_to_rgb332_cases, + xrgb8888_to_rgb332_case_desc); + +static void xrgb8888_to_rgb332_test(struct kunit *test) +{ + const struct xrgb8888_to_rgb332_case *params =3D test->param_value; + size_t dst_size; + __u8 *dst =3D NULL; + + struct drm_framebuffer fb =3D { + .format =3D drm_format_info(DRM_FORMAT_XRGB8888), + .pitches =3D { params->pitch, 0, 0 }, + }; + + dst_size =3D conversion_buf_size(DRM_FORMAT_RGB332, params->dst_pitch, + ¶ms->clip); + KUNIT_ASSERT_GT(test, dst_size, 0); + + dst =3D kunit_kzalloc(test, dst_size, GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dst); + + drm_fb_xrgb8888_to_rgb332(dst, params->dst_pitch, params->xrgb8888, + &fb, ¶ms->clip); + KUNIT_EXPECT_EQ(test, memcmp(dst, params->expected, dst_size), 0); +} + +static struct kunit_case drm_format_helper_test_cases[] =3D { + KUNIT_CASE_PARAM(xrgb8888_to_rgb332_test, + xrgb8888_to_rgb332_gen_params), + {} +}; + +static struct kunit_suite drm_format_helper_test_suite =3D { + .name =3D "drm-format-helper-test", + .test_cases =3D drm_format_helper_test_cases, +}; + +kunit_test_suite(drm_format_helper_test_suite); + +MODULE_DESCRIPTION("KUnit tests for the drm_format_helper APIs"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Jos=C3=A9 Exp=C3=B3sito "); --=20 2.25.1 From nobody Mon Apr 27 12:16:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1BADC433EF for ; Mon, 13 Jun 2022 19:22:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349480AbiFMTWN (ORCPT ); Mon, 13 Jun 2022 15:22:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348735AbiFMTVY (ORCPT ); Mon, 13 Jun 2022 15:21:24 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E49B2870B for ; Mon, 13 Jun 2022 10:17:51 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id x17so7975541wrg.6 for ; Mon, 13 Jun 2022 10:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6oCYTzwjrLnxnxwyKEfz2WikcR75QzF1FKToWqyNR9I=; b=F51NTLAyPWUJmIcreJGh+nbImazQe30mXy0M1R9WGuNAFL7yNxovOd0I4dYt9TkOYq /oWo/kycfvrF+HhazbbB+32J5kUXFxWTWp/vY4D+6IQnS9UxELCYAXpL0uCnmEooiYw/ RCtD58rL8tsaqMP5UfwZUdlFSlRaB9l24wQpgSQ+Xd+tUM1XqhqgqJeaSqNNshdgc4Ew m+HeNbiKr42hrb2k0Oq0nOUcg8m1PZxxM1h5MHZym3iDUnG+K86b3vq7GltcAY4VNmaN 6KonpQUB3bGRBVD64qQb6DeuxfGJiRDnatmTER/KaMJDN699w5hJ13owDQtQ7QpBqLQU Iazg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6oCYTzwjrLnxnxwyKEfz2WikcR75QzF1FKToWqyNR9I=; b=EBJGh6U8TEaxP8zOzFPwtS7Nh2Xyjlk+vbzKDjUcyLAHS0r/hob1/Xh0voyxYJEj1n E4K1wIVFrw6acgtDstNuG2klS0FNXvd8Wc0sneWnVHeYGxHJHqtQiwySB3C8yjRBs88w FzIT1G873S5KnXq8euUqWhdeaSvHsGU/2pfP2VyHc2s3H7ikBHCy3uDxowS10E/KRSfb TPnQEpk/jd5qSBD/Y22dG4NVqA6J8mQPcr3Ppqaw6BhOEl3FxBN0Joh9sPkWY0VTJKhk CswcTUR4lOKkeTmiTISK92eHxdHogunl8t6Mi3hUQtLFUW7Gt/gj7qnpOG4NlDF658iz +5uA== X-Gm-Message-State: AJIora/BQ3b70itzYmlEhhUlpESr8iqgXVGwxjDziw4PxLIzYHB3okMW FMgND/yMMUrP1stGOl5A+YI= X-Google-Smtp-Source: AGRyM1ukqjdWNtJpNtXwbhf0Bf6agIHIexrRYS1P411Ex0OXC4BusGashejJsEd+0rc1FkF98C2bfg== X-Received: by 2002:adf:f610:0:b0:213:b4e1:7276 with SMTP id t16-20020adff610000000b00213b4e17276mr808828wrp.712.1655140669679; Mon, 13 Jun 2022 10:17:49 -0700 (PDT) Received: from localhost.localdomain ([94.73.36.128]) by smtp.gmail.com with ESMTPSA id a10-20020a056000100a00b0020d106c0386sm9016129wrx.89.2022.06.13.10.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jun 2022 10:17:49 -0700 (PDT) From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= To: javierm@redhat.com Cc: davidgow@google.com, dlatypov@google.com, tzimmermann@suse.de, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@linux.ie, daniel@ffwll.ch, jani.nikula@linux.intel.com, dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Maxime Ripard Subject: [PATCH v3 3/3] drm/doc: Add KUnit documentation Date: Mon, 13 Jun 2022 19:17:38 +0200 Message-Id: <20220613171738.111013-4-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220613171738.111013-1-jose.exposito89@gmail.com> References: <20220613171738.111013-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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=3DLO5p7830h2XU1Jgg0KrN0qTn= xkOMhf1oTgxjaKKw@mail.gmail.com/ [2] https://lore.kernel.org/dri-devel/CAGS_qxqpiCim_sy1LDK7PLwVgWf-LKW+uNFT= GM=3DT7ydk-dYcEw@mail.gmail.com/ Reviewed-by: Maxime Ripard Signed-off-by: Jos=C3=A9 Exp=C3=B3sito Acked-by: Thomas Zimmermann Reviewed-by: Javier Martinez Canillas --- Documentation/gpu/drm-internals.rst | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Documentation/gpu/drm-internals.rst b/Documentation/gpu/drm-in= ternals.rst index 38afed24a75c..f1d97e80ca29 100644 --- a/Documentation/gpu/drm-internals.rst +++ b/Documentation/gpu/drm-internals.rst @@ -207,6 +207,38 @@ Utilities :internal: =20 =20 +Unit testing +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +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 infor= mation +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 pre= sent +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=3Ddrivers/gpu/drm/kuni= t \ + --kconfig_add CONFIG_VIRTIO_UML=3Dy \ + --kconfig_add CONFIG_UML_PCI_OVER_VIRTIO=3Dy + +.. 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 --=20 2.25.1