Received: by 2002:a05:6512:404:0:0:0:0 with SMTP id u4csp507604lfk; Wed, 15 Jun 2022 07:34:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tQm0RocQMgfKanWKczdiOjb0tL8/W6TYItzP+VBeAGWWljNXGsG/JYOfJNqkFfI6SzDLfC X-Received: by 2002:a17:902:cccf:b0:168:e13c:5cd9 with SMTP id z15-20020a170902cccf00b00168e13c5cd9mr100222ple.53.1655303649553; Wed, 15 Jun 2022 07:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655303649; cv=none; d=google.com; s=arc-20160816; b=SPBVHBCa8vDZzMWqOdISSAPwMkmAcpFdPfoF8rMzSEBLxHSeaZVUzEZIb5KTliAGvn HGqmoYd45Y/eW+I4Fv96tN+2LWs6K1EFlrFPAj4jDmKd8C8PT23YrdoSCdKrgRrd1Kcf PxUUW+U8XJv4OYoFEDphd96MiOEVaMW9tiFa1zTYVPjxKr0RKL1K/6/fLV7/PvLSkSrd md9kx7t7nVTGptP/iiLnKdudUWSnkVpi1Fddk79fg2ZUv2BRiu2Go9u9LHmJ0/KcyzW6 hfZxrR/EHQ7vGjxMyIPUrRrz8jzQP1exevF9ytoH0NGODanJSvCpNdqni8n6NaplbrCN 7oNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hM+JY40z0Sp//jmnsAggmvbu6S59VsvwNNKMeBMBEXU=; b=OV6XS5jqGthulWhL8pdqB0ljmyEolrXu+uZs1FJH31wjd0eSDGT4J16+I4y3owHOdl wRIFRfoUogxaZVvXhtt3jaOL9GXugLD/+Fyrtk+MyIMYEvUeDWTppdeK22+feyTnI01b jLeGekkk/wGVfEsS8fyADERtNphbsciiTwf0ky/WzL0Nul/4bU4HChfMdOy867VtN5zD qGQScwzG7XnwlAfOnGLs6uuecbkj30CKYRS6bPkaXH/f9cklQsLm5+veL8sL8BI41fJY NgmYWu67CAKe2OVkq4qjB4ofl74WgNdOQgrpOoRXjU5Fce2fTItIEClrDgamhIwg2vId zcPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp.br header.s=usp-google header.b="E/dfccgC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=usp.br Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a056a0024d500b005189b83cdbcsi18096972pfv.61.2022.06.15.07.33.53; Wed, 15 Jun 2022 07:34:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@usp.br header.s=usp-google header.b="E/dfccgC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=usp.br Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355712AbiFOOAf (ORCPT + 99 others); Wed, 15 Jun 2022 10:00:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355476AbiFOOAO (ORCPT ); Wed, 15 Jun 2022 10:00:14 -0400 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2376849F09 for ; Wed, 15 Jun 2022 06:59:59 -0700 (PDT) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-fe15832ce5so16561924fac.8 for ; Wed, 15 Jun 2022 06:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp.br; s=usp-google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hM+JY40z0Sp//jmnsAggmvbu6S59VsvwNNKMeBMBEXU=; b=E/dfccgC/8TdlYB8aK4U8u1Mi3ftEqE5XWxpm/4CSt/+yIVvyW2xoa6NYjw8+wWmA/ /CJ9BRlOZGaQ4trK+zo+XL4JtjmtP7sWYi6xQFXQgTQvQmK03vkDgrGcF7xKpl45I/Hd ei36k2v8u8wpW2VqmJnwnHjOkcJP74EQhQy4zYuuPubNDPGt83zH7fxRB/meZdJdJ65i jcyuPd4GUxOlJqyyfDkweFR7v0xW5Z0x87EmcGGcCv5K0/4Bq/snevbGqoicFxvLjz2A ADjkmGNffPv3kvO/TnD4JNSFr2Dou2eKejiNTMTgtR135MPRpxRFwv194HSxLlXG2iSu UeIw== 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=hM+JY40z0Sp//jmnsAggmvbu6S59VsvwNNKMeBMBEXU=; b=rL0G7GpFmIDMRMQkJjLABYXobrqxrgQDjtyC9mKxFfOrF8/lfiStk9vNXONuAPgktx HIU8D27SSjbOUoHShS2P8hggvlOd6zqCEc/OXVHA/BJdo2X9ts6djSw8K3sr83rCEYr7 G7QEpSV9RlkSr0DQw5URCXkdflkfabhfSlutUo2j9wS2ic1ejJVAK2JS1oBHs7vC8EdC qhP93VQgO8r185Q4xstaC7UFI+nKj12AYujLoqdWIO5OE5/LKOzDW8jC26fufC72ewbK o/fiuzZo8Vh6TIYdijDZwhq8p9VqoWMn7VDknDTIFoRKpCv/7LMQo51N5602nNMBPEDJ dAzQ== X-Gm-Message-State: AJIora+wEha8n/zIZnGqDhpawmx876lXLN3DQ2ceMrKiWLPWGmsjeZeR xutZLaX8AAbdJ/UjJAvwl+mAnQ== X-Received: by 2002:a05:6870:c698:b0:de:8a16:c37 with SMTP id cv24-20020a056870c69800b000de8a160c37mr5604647oab.191.1655301598709; Wed, 15 Jun 2022 06:59:58 -0700 (PDT) Received: from fedora.. ([2804:14d:8084:84c6:fe26:c42d:aab9:fa8a]) by smtp.gmail.com with ESMTPSA id u7-20020a056830248700b0060bfebb96e5sm6056928ots.35.2022.06.15.06.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 06:59:58 -0700 (PDT) From: =?UTF-8?q?Ma=C3=ADra=20Canal?= To: Isabella Basso , magalilemes00@gmail.com, tales.aparecida@gmail.com, mwen@igalia.com, andrealmeid@riseup.net, Trevor Woerner , leandro.ribeiro@collabora.com, n@nfraprado.net, Daniel Vetter , Shuah Khan , David Airlie , Maxime Ripard , Thomas Zimmermann , michal.winiarski@intel.com, Javier Martinez Canillas , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , David Gow , Daniel Latypov , brendanhiggins@google.com Cc: dri-devel@lists.freedesktop.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, =?UTF-8?q?Ma=C3=ADra=20Canal?= Subject: [PATCH 08/10] drm: selftest: convert drm_framebuffer selftest to KUnit Date: Wed, 15 Jun 2022 10:58:22 -0300 Message-Id: <20220615135824.15522-9-maira.canal@usp.br> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220615135824.15522-1-maira.canal@usp.br> References: <20220615135824.15522-1-maira.canal@usp.br> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Considering the current adoption of the KUnit framework, convert the DRM framebuffer selftest to the KUnit API. Signed-off-by: MaĆ­ra Canal --- drivers/gpu/drm/selftests/Makefile | 5 +-- .../gpu/drm/selftests/drm_modeset_selftests.h | 9 ------ .../drm/selftests/test-drm_modeset_common.c | 32 ------------------- .../drm/selftests/test-drm_modeset_common.h | 21 ------------ drivers/gpu/drm/tests/Kconfig | 12 +++++++ drivers/gpu/drm/tests/Makefile | 1 + .../test-drm_framebuffer.c | 25 ++++++++++----- 7 files changed, 31 insertions(+), 74 deletions(-) delete mode 100644 drivers/gpu/drm/selftests/drm_modeset_selftests.h delete mode 100644 drivers/gpu/drm/selftests/test-drm_modeset_common.c delete mode 100644 drivers/gpu/drm/selftests/test-drm_modeset_common.h rename drivers/gpu/drm/{selftests => tests}/test-drm_framebuffer.c (96%) diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/selftests/Makefile index 1539f55db9a7..f7db628b60cb 100644 --- a/drivers/gpu/drm/selftests/Makefile +++ b/drivers/gpu/drm/selftests/Makefile @@ -1,5 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -test-drm_modeset-y := test-drm_modeset_common.o test-drm_framebuffer.o - -obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o \ - test-drm_buddy.o +obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_buddy.o diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h b/drivers/gpu/drm/selftests/drm_modeset_selftests.h deleted file mode 100644 index 40a29b8cf386..000000000000 --- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h +++ /dev/null @@ -1,9 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* List each unit test as selftest(name, function) - * - * The name is used as both an enum and expanded as igt__name to create - * a module parameter. It must be unique and legal for a C identifier. - * - * Tests are executed in order by igt/drm_selftests_helper - */ -selftest(check_drm_framebuffer_create, igt_check_drm_framebuffer_create) diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.c b/drivers/gpu/drm/selftests/test-drm_modeset_common.c deleted file mode 100644 index 2a7f93774006..000000000000 --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.c +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Common file for modeset selftests. - */ - -#include - -#include "test-drm_modeset_common.h" - -#define TESTS "drm_modeset_selftests.h" -#include "drm_selftest.h" - -#include "drm_selftest.c" - -static int __init test_drm_modeset_init(void) -{ - int err; - - err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL); - - return err > 0 ? 0 : err; -} - -static void __exit test_drm_modeset_exit(void) -{ -} - -module_init(test_drm_modeset_init); -module_exit(test_drm_modeset_exit); - -MODULE_AUTHOR("Intel Corporation"); -MODULE_LICENSE("GPL"); diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h deleted file mode 100644 index 3feb2fea1a6b..000000000000 --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -#ifndef __TEST_DRM_MODESET_COMMON_H__ -#define __TEST_DRM_MODESET_COMMON_H__ - -#include -#include - -#define FAIL(test, msg, ...) \ - do { \ - if (test) { \ - pr_err("%s/%u: " msg, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ - return -EINVAL; \ - } \ - } while (0) - -#define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n") - -int igt_check_drm_framebuffer_create(void *ignored); - -#endif diff --git a/drivers/gpu/drm/tests/Kconfig b/drivers/gpu/drm/tests/Kconfig index eea0783f981d..de44385f217e 100644 --- a/drivers/gpu/drm/tests/Kconfig +++ b/drivers/gpu/drm/tests/Kconfig @@ -86,4 +86,16 @@ config DRM_DP_MST_HELPER_KUNIT_TEST If in doubt, say "N". +config DRM_FRAMEBUFFER_KUNIT_TEST + tristate "KUnit tests for DRM framebuffer" if !DRM_KUNIT_TEST + select DRM_KMS_HELPER + default y if DRM_KUNIT_TEST + help + This option provides KUnit modules that can be used to run + various selftests on parts of the DRM framebuffer API. This + option is not useful for distributions or general kernels, but only + for kernel developers working on DRM and associated drivers. + + If in doubt, say "N". + endmenu diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile index 735ca8e4c446..d802ca0f1544 100644 --- a/drivers/gpu/drm/tests/Makefile +++ b/drivers/gpu/drm/tests/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_DRM_RECT_KUNIT_TEST) += test-drm_rect.o obj-$(CONFIG_DRM_FORMAT_KUNIT_TEST) += test-drm_format.o obj-$(CONFIG_DRM_PLANE_HELPER_KUNIT_TEST) += test-drm_plane_helper.o obj-$(CONFIG_DRM_DP_MST_HELPER_KUNIT_TEST) += test-drm_dp_mst_helper.o +obj-$(CONFIG_DRM_FRAMEBUFFER_KUNIT_TEST) += test-drm_framebuffer.o diff --git a/drivers/gpu/drm/selftests/test-drm_framebuffer.c b/drivers/gpu/drm/tests/test-drm_framebuffer.c similarity index 96% rename from drivers/gpu/drm/selftests/test-drm_framebuffer.c rename to drivers/gpu/drm/tests/test-drm_framebuffer.c index f6d66285c5fc..753e161ad57f 100644 --- a/drivers/gpu/drm/selftests/test-drm_framebuffer.c +++ b/drivers/gpu/drm/tests/test-drm_framebuffer.c @@ -3,8 +3,7 @@ * Test cases for the drm_framebuffer functions */ -#include - +#include #include #include #include @@ -12,8 +11,6 @@ #include "../drm_crtc_internal.h" -#include "test-drm_modeset_common.h" - #define MIN_WIDTH 4 #define MAX_WIDTH 4096 #define MIN_HEIGHT 4 @@ -336,15 +333,27 @@ static int execute_drm_mode_fb_cmd2(struct drm_mode_fb_cmd2 *r) return buffer_created; } -int igt_check_drm_framebuffer_create(void *ignored) +static void igt_check_drm_framebuffer_create(struct kunit *test) { int i = 0; for (i = 0; i < ARRAY_SIZE(createbuffer_tests); i++) { - FAIL(createbuffer_tests[i].buffer_created != + KUNIT_EXPECT_EQ_MSG(test, createbuffer_tests[i].buffer_created, execute_drm_mode_fb_cmd2(&createbuffer_tests[i].cmd), "Test %d: \"%s\" failed\n", i, createbuffer_tests[i].name); } - - return 0; } + +static struct kunit_case drm_framebuffer_tests[] = { + KUNIT_CASE(igt_check_drm_framebuffer_create), + { } +}; + +static struct kunit_suite drm_framebuffer_test_suite = { + .name = "drm_framebuffer_tests", + .test_cases = drm_framebuffer_tests, +}; + +kunit_test_suite(drm_framebuffer_test_suite); + +MODULE_LICENSE("GPL"); -- 2.36.1