Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp907821imw; Fri, 8 Jul 2022 14:09:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sZGDt1SwSUaoRwW+0aXBBhuqR5r07Rszm7tJNMDwPgvM3F/8BDX/+Y7LNLL563tTGUSO5o X-Received: by 2002:a63:1607:0:b0:412:8fc0:756b with SMTP id w7-20020a631607000000b004128fc0756bmr4825169pgl.142.1657314564299; Fri, 08 Jul 2022 14:09:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657314564; cv=none; d=google.com; s=arc-20160816; b=HZM3gp2zVgEjQXBcvMhulE7xS2c9ec4HKZwwCmLToFBwE6GjlmeX6V9xU/aXQQkhhP 3IaS/vc0608Vfqu9uOrAHCBhhZwsg8qteD7kWj7GD3uUwLTsMOsy16RH8MmCTZpgyRtW ns66GXkmW4vwWXBb/sPNuomAF7hrYok6peaiohZL+hIGasDHtQv6c/6/cN058NC5TKij xmJKza6Ca6LkayUuyNrYuIP3UOGGC9jDNbUznOLZK11237VlBKLifv9ZYhpf7hS4EitC Iw4LQgZ3b1btsmiXcB3UcBpa55gnMDgh0YLcDmmfFp9oED3VHxWzGnDgurO5zay3IVc/ b1Fw== 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=syBCLXlDdIqeFLcMBQWKgKCXogFqzHw8Q9N6jKrm+iA=; b=loqse4Bt5dZj95POjEvYocnsNFOUi2hdBBbW8f/m89u1ggtmaAO6FkhHODcTU3sodK OePJp20YDTONOq0rDtpqtT5irMGaDBH1mNn2APrG3wBpLuMWehw0TGhjJ0m1tvHBK2He /k3Un6q1Gbdx9Mt33kJ8y1OSydkTppCpsyX8jPKLiByG01vFH0WUj+6usjifsIaLJ4AH 3Ql29IbU2FYQfHOSweh3sH6TO0bGAXzMR8FXL9FaJpjd1unAY/SR8JvWt0UNArETi9y8 1ByVvJlOJWOn6tryyAHcjaRQHnKuAffQlQ/AxEikMWUckGY6gee0v1LbkFg5lVkTSzaj XX1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@usp.br header.s=usp-google header.b=lNvdzWzb; 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 q1-20020a056a00084100b005107be11e23si64048pfk.137.2022.07.08.14.09.11; Fri, 08 Jul 2022 14:09:24 -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=lNvdzWzb; 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 S240117AbiGHUch (ORCPT + 99 others); Fri, 8 Jul 2022 16:32:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240157AbiGHUcP (ORCPT ); Fri, 8 Jul 2022 16:32:15 -0400 Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17890A024E for ; Fri, 8 Jul 2022 13:32:07 -0700 (PDT) Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-fe023ab520so31238fac.10 for ; Fri, 08 Jul 2022 13:32:07 -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=syBCLXlDdIqeFLcMBQWKgKCXogFqzHw8Q9N6jKrm+iA=; b=lNvdzWzb90yUeC9wREvMML1OoZRVaYYeMvgXvOHIU5OhMZoQkewuhbys50shjeWlzY 0b7GKgm7l21L93u0ZZ5wZDFK/b7GkdiZFu6a3HnYNOrTX/cjt8X1dav4/THIHPt/vDL+ MxnF05vV0BOxeoeyRMjPNznkdcI6JB9Exrrmm0wU+dG5F64IwF8wt63lCAzzSGiLkuM7 J8WfndXwRRe8J9HXi1njXIuwpwiNE9SivJT6BTb7l9uzZ4qTHk2Dwget5OgVSWUzEpdH bN7EoG9R7QGoXg8D1kxT6759Bv/VDZ3Av6vmcFVUYKnU3Z2Mp/LFd33OZpXtbgoqJYVJ AFwA== 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=syBCLXlDdIqeFLcMBQWKgKCXogFqzHw8Q9N6jKrm+iA=; b=54TIgVFhcEnNN+CWF36ERudZ1u3az4vOBbZ9qvnwF+ydKnToDe2xAOHDruP6OuuYxe NZb+wOLNC+rOO0AEm08mcAwDwTrQyxh1ML3+LIoHy0+NqAQaDP8L3aXp6T07j4A8CBAC Q55AqvLiCs93ga3JutmlDcevaGd6c4E2nF76gFfLg2x80kP4A0AFyqGEeDSAUCfE5Xgf DwJnRcBz+mVqlJxLlBwriehf4Zh0ppP0GcnFI2Znz/NO/wXfGY1qGIFj25mf+rVBTgoH VnkyOXVtIq8IyxlAco6c6yyq3BD171X6fikt0qxKID34aTulIYC4GVYZ7eONzSyvW93A J0cg== X-Gm-Message-State: AJIora+Erd19Z51b+soXvnzaKhz1EORyfVvDxd/qwwiiwta2Vxs9CtIe NtXBnEXnu7Pq021H9mKRRNHwAA== X-Received: by 2002:a05:6870:418d:b0:10c:1a0b:75ea with SMTP id y13-20020a056870418d00b0010c1a0b75eamr992162oac.287.1657312326277; Fri, 08 Jul 2022 13:32:06 -0700 (PDT) Received: from fedora.. ([143.107.182.242]) by smtp.gmail.com with ESMTPSA id ci10-20020a05683063ca00b0061c309b1dc2sm742225otb.39.2022.07.08.13.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 13:32:05 -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, siqueirajordao@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: kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Ma=C3=ADra=20Canal?= , "Djakson C . G . Filho" , Anderson Fraga Subject: [PATCH v5 5/9] drm: selftest: convert drm_plane_helper selftest to KUnit Date: Fri, 8 Jul 2022 17:30:48 -0300 Message-Id: <20220708203052.236290-6-maira.canal@usp.br> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220708203052.236290-1-maira.canal@usp.br> References: <20220708203052.236290-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=unavailable 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 plane helper selftest to the KUnit API. Co-developed-by: Djakson C. G. Filho Signed-off-by: Djakson C. G. Filho Co-developed-by: Anderson Fraga Signed-off-by: Anderson Fraga Tested-by: David Gow Acked-by: Daniel Latypov Reviewed-by: Javier Martinez Canillas Signed-off-by: Maíra Canal --- drivers/gpu/drm/selftests/Makefile | 4 +- .../gpu/drm/selftests/drm_modeset_selftests.h | 1 - .../drm/selftests/test-drm_modeset_common.h | 1 - drivers/gpu/drm/tests/Makefile | 2 +- .../drm_plane_helper_test.c} | 122 ++++++++++-------- 5 files changed, 71 insertions(+), 59 deletions(-) rename drivers/gpu/drm/{selftests/test-drm_plane_helper.c => tests/drm_plane_helper_test.c} (57%) diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/selftests/Makefile index b7f252d886d0..9e0ccb482841 100644 --- a/drivers/gpu/drm/selftests/Makefile +++ b/drivers/gpu/drm/selftests/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -test-drm_modeset-y := test-drm_modeset_common.o test-drm_plane_helper.o \ - test-drm_framebuffer.o test-drm_dp_mst_helper.o +test-drm_modeset-y := test-drm_modeset_common.o test-drm_framebuffer.o \ + test-drm_dp_mst_helper.o obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.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 index 63061ef55eff..22e467f6465a 100644 --- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h +++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h @@ -6,7 +6,6 @@ * * Tests are executed in order by igt/drm_selftests_helper */ -selftest(check_plane_state, igt_check_plane_state) selftest(check_drm_framebuffer_create, igt_check_drm_framebuffer_create) selftest(dp_mst_calc_pbn_mode, igt_dp_mst_calc_pbn_mode) selftest(dp_mst_sideband_msg_req_decode, igt_dp_mst_sideband_msg_req_decode) diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h index 5709d967a5c4..790f3cf31f0d 100644 --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h @@ -16,7 +16,6 @@ #define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n") -int igt_check_plane_state(void *ignored); int igt_check_drm_framebuffer_create(void *ignored); int igt_dp_mst_calc_pbn_mode(void *ignored); int igt_dp_mst_sideband_msg_req_decode(void *ignored); diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile index 1aa1627cb5e6..4d44006a4f23 100644 --- a/drivers/gpu/drm/tests/Makefile +++ b/drivers/gpu/drm/tests/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_DRM_KUNIT_TEST) += drm_format_helper_test.o drm_damage_helper_test.o \ - drm_cmdline_parser_test.o drm_rect_test.o drm_format_test.o + drm_cmdline_parser_test.o drm_rect_test.o drm_format_test.o drm_plane_helper_test.o diff --git a/drivers/gpu/drm/selftests/test-drm_plane_helper.c b/drivers/gpu/drm/tests/drm_plane_helper_test.c similarity index 57% rename from drivers/gpu/drm/selftests/test-drm_plane_helper.c rename to drivers/gpu/drm/tests/drm_plane_helper_test.c index 64e8938ab194..e298766cd41f 100644 --- a/drivers/gpu/drm/selftests/test-drm_plane_helper.c +++ b/drivers/gpu/drm/tests/drm_plane_helper_test.c @@ -1,20 +1,20 @@ // SPDX-License-Identifier: GPL-2.0 /* * Test cases for the drm_plane_helper functions + * + * Copyright (c) 2022 Maíra Canal */ -#define pr_fmt(fmt) "drm_plane_helper: " fmt +#include #include #include #include #include -#include "test-drm_modeset_common.h" - static void set_src(struct drm_plane_state *plane_state, - unsigned src_x, unsigned src_y, - unsigned src_w, unsigned src_h) + unsigned int src_x, unsigned int src_y, + unsigned int src_w, unsigned int src_h) { plane_state->src_x = src_x; plane_state->src_y = src_y; @@ -23,8 +23,8 @@ static void set_src(struct drm_plane_state *plane_state, } static bool check_src_eq(struct drm_plane_state *plane_state, - unsigned src_x, unsigned src_y, - unsigned src_w, unsigned src_h) + unsigned int src_x, unsigned int src_y, + unsigned int src_w, unsigned int src_h) { if (plane_state->src.x1 < 0) { pr_err("src x coordinate %x should never be below 0.\n", plane_state->src.x1); @@ -50,7 +50,7 @@ static bool check_src_eq(struct drm_plane_state *plane_state, static void set_crtc(struct drm_plane_state *plane_state, int crtc_x, int crtc_y, - unsigned crtc_w, unsigned crtc_h) + unsigned int crtc_w, unsigned int crtc_h) { plane_state->crtc_x = crtc_x; plane_state->crtc_y = crtc_y; @@ -60,7 +60,7 @@ static void set_crtc(struct drm_plane_state *plane_state, static bool check_crtc_eq(struct drm_plane_state *plane_state, int crtc_x, int crtc_y, - unsigned crtc_w, unsigned crtc_h) + unsigned int crtc_w, unsigned int crtc_h) { if (plane_state->dst.x1 != crtc_x || plane_state->dst.y1 != crtc_y || @@ -74,7 +74,7 @@ static bool check_crtc_eq(struct drm_plane_state *plane_state, return true; } -int igt_check_plane_state(void *ignored) +static void igt_check_plane_state(struct kunit *test) { int ret; @@ -83,9 +83,8 @@ int igt_check_plane_state(void *ignored) .enable = true, .active = true, .mode = { - DRM_MODE("1024x768", 0, 65000, 1024, 1048, - 1184, 1344, 0, 768, 771, 777, 806, 0, - DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) + DRM_MODE("1024x768", 0, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, + 777, 806, 0, DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC) }, }; static struct drm_plane plane = { @@ -109,10 +108,10 @@ int igt_check_plane_state(void *ignored) DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, false, false); - FAIL(ret < 0, "Simple clipping check should pass\n"); - FAIL_ON(!plane_state.visible); - FAIL_ON(!check_src_eq(&plane_state, 0, 0, 1024 << 16, 768 << 16)); - FAIL_ON(!check_crtc_eq(&plane_state, 0, 0, 1024, 768)); + KUNIT_EXPECT_FALSE_MSG(test, ret, 0, "Simple clipping check should pass\n"); + KUNIT_EXPECT_TRUE(test, plane_state.visible); + KUNIT_EXPECT_TRUE(test, check_src_eq(&plane_state, 0, 0, 1024 << 16, 768 << 16)); + KUNIT_EXPECT_TRUE(test, check_crtc_eq(&plane_state, 0, 0, 1024, 768)); /* Rotated clipping + reflection, no scaling. */ plane_state.rotation = DRM_MODE_ROTATE_90 | DRM_MODE_REFLECT_X; @@ -120,10 +119,10 @@ int igt_check_plane_state(void *ignored) DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, false, false); - FAIL(ret < 0, "Rotated clipping check should pass\n"); - FAIL_ON(!plane_state.visible); - FAIL_ON(!check_src_eq(&plane_state, 0, 0, 768 << 16, 1024 << 16)); - FAIL_ON(!check_crtc_eq(&plane_state, 0, 0, 1024, 768)); + KUNIT_EXPECT_FALSE_MSG(test, ret, 0, "Rotated clipping check should pass\n"); + KUNIT_EXPECT_TRUE(test, plane_state.visible); + KUNIT_EXPECT_TRUE(test, check_src_eq(&plane_state, 0, 0, 768 << 16, 1024 << 16)); + KUNIT_EXPECT_TRUE(test, check_crtc_eq(&plane_state, 0, 0, 1024, 768)); plane_state.rotation = DRM_MODE_ROTATE_0; /* Check whether positioning works correctly. */ @@ -133,16 +132,17 @@ int igt_check_plane_state(void *ignored) DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, false, false); - FAIL(!ret, "Should not be able to position on the crtc with can_position=false\n"); + KUNIT_EXPECT_TRUE_MSG(test, ret, + "Should not be able to position on the crtc with can_position=false\n"); ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, true, false); - FAIL(ret < 0, "Simple positioning should work\n"); - FAIL_ON(!plane_state.visible); - FAIL_ON(!check_src_eq(&plane_state, 0, 0, 1023 << 16, 767 << 16)); - FAIL_ON(!check_crtc_eq(&plane_state, 0, 0, 1023, 767)); + KUNIT_EXPECT_FALSE_MSG(test, ret, 0, "Simple positioning should work\n"); + KUNIT_EXPECT_TRUE(test, plane_state.visible); + KUNIT_EXPECT_TRUE(test, check_src_eq(&plane_state, 0, 0, 1023 << 16, 767 << 16)); + KUNIT_EXPECT_TRUE(test, check_crtc_eq(&plane_state, 0, 0, 1023, 767)); /* Simple scaling tests. */ set_src(&plane_state, 0, 0, 512 << 16, 384 << 16); @@ -151,28 +151,28 @@ int igt_check_plane_state(void *ignored) 0x8001, DRM_PLANE_HELPER_NO_SCALING, false, false); - FAIL(!ret, "Upscaling out of range should fail.\n"); + KUNIT_EXPECT_TRUE_MSG(test, ret, "Upscaling out of range should fail.\n"); ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, 0x8000, DRM_PLANE_HELPER_NO_SCALING, false, false); - FAIL(ret < 0, "Upscaling exactly 2x should work\n"); - FAIL_ON(!plane_state.visible); - FAIL_ON(!check_src_eq(&plane_state, 0, 0, 512 << 16, 384 << 16)); - FAIL_ON(!check_crtc_eq(&plane_state, 0, 0, 1024, 768)); + KUNIT_EXPECT_FALSE_MSG(test, ret, 0, "Upscaling exactly 2x should work\n"); + KUNIT_EXPECT_TRUE(test, plane_state.visible); + KUNIT_EXPECT_TRUE(test, check_src_eq(&plane_state, 0, 0, 512 << 16, 384 << 16)); + KUNIT_EXPECT_TRUE(test, check_crtc_eq(&plane_state, 0, 0, 1024, 768)); set_src(&plane_state, 0, 0, 2048 << 16, 1536 << 16); ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, DRM_PLANE_HELPER_NO_SCALING, 0x1ffff, false, false); - FAIL(!ret, "Downscaling out of range should fail.\n"); + KUNIT_EXPECT_TRUE_MSG(test, ret, "Downscaling out of range should fail.\n"); ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, DRM_PLANE_HELPER_NO_SCALING, 0x20000, false, false); - FAIL(ret < 0, "Should succeed with exact scaling limit\n"); - FAIL_ON(!plane_state.visible); - FAIL_ON(!check_src_eq(&plane_state, 0, 0, 2048 << 16, 1536 << 16)); - FAIL_ON(!check_crtc_eq(&plane_state, 0, 0, 1024, 768)); + KUNIT_EXPECT_FALSE_MSG(test, ret, 0, "Should succeed with exact scaling limit\n"); + KUNIT_EXPECT_TRUE(test, plane_state.visible); + KUNIT_EXPECT_TRUE(test, check_src_eq(&plane_state, 0, 0, 2048 << 16, 1536 << 16)); + KUNIT_EXPECT_TRUE(test, check_crtc_eq(&plane_state, 0, 0, 1024, 768)); /* Testing rounding errors. */ set_src(&plane_state, 0, 0, 0x40001, 0x40001); @@ -181,10 +181,10 @@ int igt_check_plane_state(void *ignored) DRM_PLANE_HELPER_NO_SCALING, 0x10001, true, false); - FAIL(ret < 0, "Should succeed by clipping to exact multiple"); - FAIL_ON(!plane_state.visible); - FAIL_ON(!check_src_eq(&plane_state, 0, 0, 2 << 16, 2 << 16)); - FAIL_ON(!check_crtc_eq(&plane_state, 1022, 766, 2, 2)); + KUNIT_EXPECT_FALSE_MSG(test, ret, 0, "Should succeed by clipping to exact multiple"); + KUNIT_EXPECT_TRUE(test, plane_state.visible); + KUNIT_EXPECT_TRUE(test, check_src_eq(&plane_state, 0, 0, 2 << 16, 2 << 16)); + KUNIT_EXPECT_TRUE(test, check_crtc_eq(&plane_state, 1022, 766, 2, 2)); set_src(&plane_state, 0x20001, 0x20001, 0x4040001, 0x3040001); set_crtc(&plane_state, -2, -2, 1028, 772); @@ -192,10 +192,11 @@ int igt_check_plane_state(void *ignored) DRM_PLANE_HELPER_NO_SCALING, 0x10001, false, false); - FAIL(ret < 0, "Should succeed by clipping to exact multiple"); - FAIL_ON(!plane_state.visible); - FAIL_ON(!check_src_eq(&plane_state, 0x40002, 0x40002, 1024 << 16, 768 << 16)); - FAIL_ON(!check_crtc_eq(&plane_state, 0, 0, 1024, 768)); + KUNIT_EXPECT_FALSE_MSG(test, ret, 0, "Should succeed by clipping to exact multiple"); + KUNIT_EXPECT_TRUE(test, plane_state.visible); + KUNIT_EXPECT_TRUE(test, check_src_eq(&plane_state, 0x40002, 0x40002, + 1024 << 16, 768 << 16)); + KUNIT_EXPECT_TRUE(test, check_crtc_eq(&plane_state, 0, 0, 1024, 768)); set_src(&plane_state, 0, 0, 0x3ffff, 0x3ffff); set_crtc(&plane_state, 1022, 766, 4, 4); @@ -203,11 +204,11 @@ int igt_check_plane_state(void *ignored) 0xffff, DRM_PLANE_HELPER_NO_SCALING, true, false); - FAIL(ret < 0, "Should succeed by clipping to exact multiple"); - FAIL_ON(!plane_state.visible); + KUNIT_EXPECT_FALSE_MSG(test, ret, 0, "Should succeed by clipping to exact multiple"); + KUNIT_EXPECT_TRUE(test, plane_state.visible); /* Should not be rounded to 0x20001, which would be upscaling. */ - FAIL_ON(!check_src_eq(&plane_state, 0, 0, 2 << 16, 2 << 16)); - FAIL_ON(!check_crtc_eq(&plane_state, 1022, 766, 2, 2)); + KUNIT_EXPECT_TRUE(test, check_src_eq(&plane_state, 0, 0, 2 << 16, 2 << 16)); + KUNIT_EXPECT_TRUE(test, check_crtc_eq(&plane_state, 1022, 766, 2, 2)); set_src(&plane_state, 0x1ffff, 0x1ffff, 0x403ffff, 0x303ffff); set_crtc(&plane_state, -2, -2, 1028, 772); @@ -215,10 +216,23 @@ int igt_check_plane_state(void *ignored) 0xffff, DRM_PLANE_HELPER_NO_SCALING, false, false); - FAIL(ret < 0, "Should succeed by clipping to exact multiple"); - FAIL_ON(!plane_state.visible); - FAIL_ON(!check_src_eq(&plane_state, 0x3fffe, 0x3fffe, 1024 << 16, 768 << 16)); - FAIL_ON(!check_crtc_eq(&plane_state, 0, 0, 1024, 768)); - - return 0; + KUNIT_EXPECT_FALSE_MSG(test, ret, 0, "Should succeed by clipping to exact multiple"); + KUNIT_EXPECT_TRUE(test, plane_state.visible); + KUNIT_EXPECT_TRUE(test, check_src_eq(&plane_state, 0x3fffe, 0x3fffe, + 1024 << 16, 768 << 16)); + KUNIT_EXPECT_TRUE(test, check_crtc_eq(&plane_state, 0, 0, 1024, 768)); } + +static struct kunit_case drm_plane_helper_test[] = { + KUNIT_CASE(igt_check_plane_state), + {} +}; + +static struct kunit_suite drm_plane_helper_test_suite = { + .name = "drm_plane_helper", + .test_cases = drm_plane_helper_test, +}; + +kunit_test_suite(drm_plane_helper_test_suite); + +MODULE_LICENSE("GPL"); -- 2.35.3