From nobody Wed Apr 29 08:08:55 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 DB35DC433EF for ; Sun, 12 Jun 2022 16:13:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232369AbiFLQNE (ORCPT ); Sun, 12 Jun 2022 12:13:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231784AbiFLQNB (ORCPT ); Sun, 12 Jun 2022 12:13:01 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4FC94A3FE for ; Sun, 12 Jun 2022 09:13:00 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id u8so4371742wrm.13 for ; Sun, 12 Jun 2022 09:13:00 -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=6LL9w+d+H88J/0VBgbeKOwTbMY4B/jVYAAXA85+Hav4=; b=gl5639X+UtUz4/8ZKGB9pGoMNC/i69RQhkFXX4sV2KPNty/Uj+gZYC8+yAvfPMVjQ4 flVMMv+wYJbeaU7Sucs4xH8SmGJRWX0lF6xMBjkdVbS5yqJn7s/sMYsbfglp/lMlsz8D iTSE1qWoCj8OwrfSvDiEIVikBaPyfgc1DrTe19Tsw01bK9szh4Y2w95yBh5FMQUUOMDS RgmFC8+X3mA1VuNAzM2LOyEU+r13r8GMEdzdexYcFcREk/5tjrVhzsznJqAVgQpbiuyA 6P74+Xzhlx1dpmYB/9ewkmxFOu9uUepV6KNlfCgjqVLMpzYGgKZmteKKMT8HEQjDkI0A dTbA== 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=6LL9w+d+H88J/0VBgbeKOwTbMY4B/jVYAAXA85+Hav4=; b=64X3NY+2GZjAsV+AxRh35O0NUcl4BTkvH8RP6Hi7t0v1A3+2oVoDhWpCxSADLExg+C APONFkud+ajyUv1dJyt0quGqrVMAENlh6s9hd0zaNsPBmS5eWQXfBzdiawztS3r8Oh1f LHYCrukZB6VmkEKBhtHDTCs9WLxCOKIuDz2+1yurt6W34dYFHxrDDRwbHeDCHULUuKYL Ix+77NJFJnC7sKwLInpbOMlygvv+Lf38GPHbrc1rh1jox2mTPYXt205Dj/wBwf4I0w/R njbkezaAowjUeGd0ijcgglUQXqUc4tmORdSd/FvAmTe8v4yEwvqp8nUs5rnLFtj+pQ4w PXgw== X-Gm-Message-State: AOAM533qjzW2NdPCbpNngkEn0VDz3vo+BNbKHoevWAKZPftXUdvkUQyS 3IaIaxwcN6D5waRduecoZSo= X-Google-Smtp-Source: ABdhPJz8VDALPE+dJoYWOkkCRUN5A2vLLKhXWgjuHeDFcnN/MUxG/0o2y8ajRYh1LNazs9hIj5r++Q== X-Received: by 2002:a5d:5903:0:b0:210:316f:7f40 with SMTP id v3-20020a5d5903000000b00210316f7f40mr53339486wrd.624.1655050379282; Sun, 12 Jun 2022 09:12:59 -0700 (PDT) Received: from localhost.localdomain ([94.73.36.128]) by smtp.gmail.com with ESMTPSA id y8-20020a5d6208000000b0020d0f111241sm6015925wru.24.2022.06.12.09.12.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jun 2022 09:12:59 -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, 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 v2 1/3] drm/rect: Add DRM_RECT_INIT() macro Date: Sun, 12 Jun 2022 18:12:46 +0200 Message-Id: <20220612161248.271590-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220612161248.271590-1-jose.exposito89@gmail.com> References: <20220612161248.271590-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 --- include/drm/drm_rect.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/drm/drm_rect.h b/include/drm/drm_rect.h index 6f6e19bd4dac..945696323c69 100644 --- a/include/drm/drm_rect.h +++ b/include/drm/drm_rect.h @@ -47,6 +47,18 @@ 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) { (x), (y), (x) + (w), (y) + (h) } + /** * DRM_RECT_FMT - printf string for &struct drm_rect */ --=20 2.25.1 From nobody Wed Apr 29 08:08:55 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 EF794C433EF for ; Sun, 12 Jun 2022 16:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232546AbiFLQNH (ORCPT ); Sun, 12 Jun 2022 12:13:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232073AbiFLQND (ORCPT ); Sun, 12 Jun 2022 12:13:03 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB13849F21 for ; Sun, 12 Jun 2022 09:13:01 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id h19so1181331wrc.12 for ; Sun, 12 Jun 2022 09:13:01 -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=9paBtxXNBD7qiHLbnLJJzVrVOQ+NkLFfVFsFjcnuDQ8=; b=fJlYQjVfVRPI0uH2FebcSvGfd205oSVl7E7EyNq3nIViCBMqkHJw8DFjm8wbOn2T/o qXXTbh2Om8pTMpvWNcoXDlwbw6lCZAxV/2aEfKJwywGClhPUIW10yreCKuRfVpMsX/rk InLsdewApyan6N/TJIiNfBwh0ZDwFXgGw2Quz3GMjy2iV+e+HDIF3c5wD1kkLEl3/gd3 YWNvk6yh0cqS692/8IN5O1F+4JS1lONjUcmjjXIdsBRheEXdWSkPIyMsuuAVxou5mZy1 Hjjklr7yW/q9zTU+ztM++KlbLkfHxk0jJeqWin10MMx8lVVcTJZPWIkZ6s2T1abpJzjr otkw== 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=9paBtxXNBD7qiHLbnLJJzVrVOQ+NkLFfVFsFjcnuDQ8=; b=euOOQZCvwqtJ9GAJMzphZlyKkAKcR+V1E/h79GcEQfp+1P+wWUcDX8fW7ho8Kdfe/g fNI+nK4fESGzjYwE3jE7vB5kZ/cWKqjej2Ko3VYM4b+EU3Rb9HwWktoCoyZwYHeJGmXC aYSxcz/NHD0JNHG8tJLOf0xmZkeLkvOTYEridxeU59M7FWjLPaC9feaCPxyzm9W/B4q5 VamS4gqUirqwgkpXqF7fAG0R2pjOPgEHbxDc/DuZIRKQehIYBAMGg2tRIUO2SCd1fXiJ q5znvlYgw6yHYcI+9brSQgnwL1M0I/omzdyZ7weCelr4RFsKQU5kZ8jNRYIEa+4zG6Sd 9krg== X-Gm-Message-State: AOAM532yU901D1TxrWVYnBJ1SqwHYhPYq9B918PMlP4VZhNaIOBK5D2e 0NOEljCczbtsiG0Y5D67GqU= X-Google-Smtp-Source: ABdhPJxsm76CBCSR//kQF/Gq7dCdenIy3ZsNPOnT5bViF618JMFkxHkLSyXhwJc0rbb1FXLUPULsyw== X-Received: by 2002:adf:a4d8:0:b0:219:ecd4:159b with SMTP id h24-20020adfa4d8000000b00219ecd4159bmr10534011wrb.431.1655050380178; Sun, 12 Jun 2022 09:13:00 -0700 (PDT) Received: from localhost.localdomain ([94.73.36.128]) by smtp.gmail.com with ESMTPSA id y8-20020a5d6208000000b0020d0f111241sm6015925wru.24.2022.06.12.09.12.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jun 2022 09:12:59 -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, 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 v2 2/3] drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb332() Date: Sun, 12 Jun 2022 18:12:47 +0200 Message-Id: <20220612161248.271590-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220612161248.271590-1-jose.exposito89@gmail.com> References: <20220612161248.271590-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 --- 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 | 169 ++++++++++++++++++ 5 files changed, 192 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..c87e7ab69184 --- /dev/null +++ b/drivers/gpu/drm/kunit/drm_format_helper_test.c @@ -0,0 +1,169 @@ +// 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. + * @src_format: source buffer pixel format (DRM_FORMAT_*) + * @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 src_format, u32 dst_format, + unsigned int dst_pitch, + const struct drm_rect *clip) +{ + const struct drm_format_info *src_fi =3D drm_format_info(src_format); + const struct drm_format_info *dst_fi =3D drm_format_info(dst_format); + size_t width =3D drm_rect_width(clip); + size_t src_nbytes; + + if (!src_fi || !dst_fi) + return -EINVAL; + + if (dst_pitch) + width =3D dst_pitch; + + src_nbytes =3D width * drm_rect_height(clip) * src_fi->cpp[0]; + if (!src_nbytes) + return 0; + + return (src_nbytes * dst_fi->cpp[0]) / src_fi->cpp[0]; +} + +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_XRGB8888, 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 Wed Apr 29 08:08:55 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 4DEA8C433EF for ; Sun, 12 Jun 2022 16:13:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbiFLQNJ (ORCPT ); Sun, 12 Jun 2022 12:13:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231784AbiFLQNF (ORCPT ); Sun, 12 Jun 2022 12:13:05 -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 AABDB4A93F for ; Sun, 12 Jun 2022 09:13:02 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id s1so4385680wra.9 for ; Sun, 12 Jun 2022 09:13:02 -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=EhGLCkTkonmCMTQ167DXhA1weWmaXnTSuHbeSYgX94Bbnt8e/zuyEaBLQCXuOeqGwQ ljluV5fPNJ4XJuR94rWf/pVYkcKS8/FQCfSNil9UILvam9R84Q1db9f0oeTUhDtWSGYw VC+Hm8xmx3gUMWVhqhj3Ewzw92irbBXqKmjG0fjRdyRQN2iU7PfmXb1VpWFK4+a/iABo vwLhdBeB0k+F0ISucP0eWTEJnjCvXtZy1rFdBrrM8XlB1N+Uop5m/DCVzyks4qAeAsGC b4J30utrAbopEdfxenAjg0KQbPMPI/0bSl9+l4j9P8SZlGBE/4Z7/iFQC9Zum6G4NLXJ 5ZlA== 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=sLAdd6MHuwGvF35s1LZLhIAevq34707L+QlggeNHAekGYYPPKP0Hho43tRaaKdDQLL 1iHmTpIdIrqER5Hktnan1A/3XCneKYjTNdAdsiRR0CIiSCx5J85SdZIm/NPfhZBr5Npo 0VxaXRW7cq2bmjLuR4L9iIH1E8FOjYfb3st/oX1b0pXESI/Q8hQ9p6KMXMqj7IDmSnJh ouTcTM7l42Qnz94kG9OM7bO6/Dcpw7SjKz8OyHwRq92XKhnTWS5LeYSd/Xe5b9VKytZh +4kakXajDxxQcYnr+bHHdA6VUFW3CDNn8OMNpxW88MDYIHKrHR/MbqGPVw5lcKICsMnC H/Vg== X-Gm-Message-State: AOAM530f58XDpz1D2tYG8boJeL3yE8o3Z09rDLOVqvmWaHBzDCmNF5B2 1Ypv0e6EdV3oAHfqlFqmVcQ= X-Google-Smtp-Source: ABdhPJz4mnmDUV4NLZknyHhTuGTurRoWbSWWgj8MlotV/lRDkKmaHLhTFIcWx+peDflYV5kyeC4q7w== X-Received: by 2002:a05:6000:1849:b0:219:be72:177e with SMTP id c9-20020a056000184900b00219be72177emr16450441wri.150.1655050381282; Sun, 12 Jun 2022 09:13:01 -0700 (PDT) Received: from localhost.localdomain ([94.73.36.128]) by smtp.gmail.com with ESMTPSA id y8-20020a5d6208000000b0020d0f111241sm6015925wru.24.2022.06.12.09.13.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jun 2022 09:13:00 -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, 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 v2 3/3] drm/doc: Add KUnit documentation Date: Sun, 12 Jun 2022 18:12:48 +0200 Message-Id: <20220612161248.271590-4-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220612161248.271590-1-jose.exposito89@gmail.com> References: <20220612161248.271590-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 --- 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