From patchwork Mon Jan 17 23:22:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 12715723 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 437FEC433EF for ; Mon, 17 Jan 2022 23:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243797AbiAQXYt (ORCPT ); Mon, 17 Jan 2022 18:24:49 -0500 Received: from mga12.intel.com ([192.55.52.136]:55081 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243793AbiAQXYs (ORCPT ); Mon, 17 Jan 2022 18:24:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642461888; x=1673997888; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=quUmjOVA9Wz2OOMMVV+W8akBlwHVso4xSDK0aYlLTGI=; b=OlXOnKlV6ugWD5ARL2tN9kNMTQUyfenrjREDeWgA6z5+IrNeeuH/bUkW oUkcG7dIX96Dla0V7Eu+Id1CupFf6pBESBNroQAZSgN7tlAU1ZBB1RzJ0 fUk7vuYod1q/uG0CwmL9DpajhW5ePOJb7HQ5eqDvZ7Vxl2Mz+K0SRcADJ x3yPC6bdw1uJDz1+THb/KQsJazC4cc817sxre8T67xv7C5pLv0a3pTdl7 97RLhcLGXW1HmnQwImQZtrc8SIPRjqV9VNwcscjKrcGzOfeoQ1dFuraSy VmRLc9nsh1sSul4RZJE0qt32sv/tY9W3P17iyocVwedvtSgwq1ccLD5TW g==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="224683773" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="224683773" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2022 15:24:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="517554427" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga007.jf.intel.com with ESMTP; 17 Jan 2022 15:24:48 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 17 Jan 2022 15:24:47 -0800 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Mon, 17 Jan 2022 15:24:47 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx608.amr.corp.intel.com (10.18.126.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Mon, 17 Jan 2022 15:24:47 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Mon, 17 Jan 2022 15:24:46 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MLLmztMb7BhOJ6vS30/zz6+faR0H7kzaMMWcF1czJOB8w75pRCMAY2y5SEoOgJv9O5koyyj9V7tRepLgkY8NFmJgUxQ9LdxH0ZLvnwRZhjDfW/tVf0yDa3wcT1kufx0aYXgqarVcINx7RFDxySiAYdFl+OlQH+84At5z7xl/tt5tPQ3t5EQ6WQLc9E+YIx1OGn1XefMDGK2BdWyvy5s4of01kvGZCqQ3KZRlhNCYhSxC1/37LZjatR9h/AYLFoX7R/CseLsidSozwU2uF58MeW8fNP/QDpn6dk/+Uh/Lut7VTlhcDvu7Rki7WJB2EYjHKGwTVGBTCirbSbH9NGYHdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZeXNZdnDA2vS/Z+sC48PAkzUL7vTuZlZ96DW0e/2av4=; b=D8DQdm5mwQeBRThi4vUacMTekNH4f8vCaBTNqE/pEKe2Oae7g6UXxOSuEDArDgd6hFGhFaNrE48ae/lUINiippDSLv2F5mIFuHqZjSv38jx1EjbE/FDNx5S3cUfveHye+BHonXeb2vw7clTP+ytDU2fFx1KOD37awNxNcoyfPpuIVP7hlDgxiseGqhVpTWedT1ld3bocTgapf/PTknRDYC+bYm1su0bRTDw8s9WH38ga4sRAjRoFdr0yVrWUKCEWaRl1mHdmFjdDZxKkpWynciNfR/p/SFgxnmCbOTO3B3TSwlPGEpfymcjXWfkiVDinGVNsZO5QDiFhXTdakNkCGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) by DM4PR11MB5550.namprd11.prod.outlook.com (2603:10b6:5:38b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9; Mon, 17 Jan 2022 23:24:43 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::fc15:bd26:128a:f5f5]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::fc15:bd26:128a:f5f5%8]) with mapi id 15.20.4888.014; Mon, 17 Jan 2022 23:24:43 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: , CC: Brendan Higgins , Daniel Latypov , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Petri Latvala , Arkadiusz Hiler , =?utf-8?q?Micha=C5=82_Winiarski?= Subject: [RFC 07/10] drm: test-drm_rect: Convert to KUnit Date: Tue, 18 Jan 2022 00:22:56 +0100 Message-ID: <20220117232259.180459-8-michal.winiarski@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220117232259.180459-1-michal.winiarski@intel.com> References: <20220117232259.180459-1-michal.winiarski@intel.com> X-ClientProxiedBy: AS8P251CA0016.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::11) To DM4PR11MB5373.namprd11.prod.outlook.com (2603:10b6:5:394::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fcea89ac-3b72-43c0-3401-08d9da108adf X-MS-TrafficTypeDiagnostic: DM4PR11MB5550:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:549; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u5Hzi/IG4KCGfvStsW6TLkay3yvPHjzUXKvjo942EBv7/21VSEHSsmUqLkrDE7C+cR32Sip359MHEvySdnKf1/AUz/sR9kE2MycDTU22C0VJ7gbifXVkVmqQuHd9640tsV/0nI4oCLQZVhvZvgQ7VfNxDlqTy9BNsgLMVcyCojE2aONsgHGamwnXEPh4u9LgAM5hqrqTDt+wKsZXNypQr4EGRiaNb5l4NVNU2UMh7PEFbYi+LK4V/Q57/L1cFrfmcfgEMjphkJXUievR923WS2KMjnr4cRBVGPUPE80654W9WZLuraOUSPBfstavStcpswp+Cy463BqzBMVA2z/00ayp+VW0gIh0etvBGxxkR6j//IyOoo36exn8iucU+RoCymbhcRQurodcLcoFuq2Sn3b7b9XluIZADFNQOWD3aNOJO/BfW1SHNhvTBXObOfTT9aohSEvXPKUjkTpZJ0p+HR9eTpfPLRfo38znrDxzb57tF5+Fo46NcLOHAnsPhz0vASfyvDDK9gjFxb89XEe1T00dhTF/sUpWYdnVdaRZO1BYPUebGCTBhnKMDe2ix5SooSBTEp7wczIgZLau83u2FzXN7GzG1i6XpF1o0hlb9KMH6VNU8Pu9BQz0QR3FAeI8IXG1pjVstOBJmuWpcmKFlQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR11MB5373.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(86362001)(82960400001)(4326008)(5660300002)(36756003)(186003)(6506007)(7416002)(1076003)(54906003)(6512007)(83380400001)(26005)(66946007)(66476007)(66556008)(316002)(6486002)(38100700002)(8936002)(508600001)(2906002)(30864003)(6666004)(8676002)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?wkDdnZsAC4ojgAlljgXLYAcShcAt?= =?utf-8?q?g1NXh8ujtIEU7Ag11zsuI9kBE/yY4bE0VXKLNiDtC9ZEgQeaIGbj748EXa0eh9E/X?= =?utf-8?q?yXz9m2g32qSzOK74MzijiVsD8yZGLxVBCGyWkl1Nxsl3ngP2BjrC8v7V32UzGSRPi?= =?utf-8?q?6BcUcrLEtvskj86A8l2A0FiLGOLwgP52qqO0Y9vPLEeIhBp6QLDh2ZAcrmvdoEJWl?= =?utf-8?q?rBnrrhoe9hKgM7kjPtJj1RGbRRmS979hhmODN6zZ/kAa8WzKMA+D+KYaTtiMkETKD?= =?utf-8?q?/FMXPLdKr+fGFXg0efX2nSOSHPoCNYjpVafHPqQDRQFFgq5E0UXH8Oxk9QucXDF9i?= =?utf-8?q?b9msxWKAYAy4TG1WcoFrGuNgRWI/lvUHcH/l6eLyxg7jNUPBFHddNebRF0qnPHzu1?= =?utf-8?q?ifv+BmeI6bJBSM6gbRkRoYgVeRaNuqLV0YRBl4MJzt/AnJdSGoA0r7tyaOPkLG5pO?= =?utf-8?q?pCKiBPErvAuBTfQuijbp5IDq3kxqFw0EBq6xnRQqe/s+akZjmeUuogXXlfgsK+jO9?= =?utf-8?q?yDTvK6hGT3qmoYRLR8ABlYixBlGLI5P0ec0odBEqyagbBQTaIlPgnEst6YwSbffMm?= =?utf-8?q?d5peac7YBdUuenwYhi2ieKNd3PWHsclHWZp2ekxhN6HmQvFFwu+40HVR3ZIs4/hP7?= =?utf-8?q?Ejq9vQqB0vR6Guph81uFFr4gnEXpRyktfSchIBUNA9HlgthHWu2w8krxkYrluiJCP?= =?utf-8?q?ANlzqE7gIzM1zdHISPpYxr5XMVL3gmaAatBovu5O8tG+VG/YanieuA67RrrtL0oJd?= =?utf-8?q?QkRJWZBdnbbbvOU4U5IGQa2VqhoEPNT0yl+Jyp/WwlAZGwd2jrCZn3jdl9QBRl50p?= =?utf-8?q?kFwHD2TEVPV7cRnUFZSuCv1YgL9cqLq0uszGBgBv+yxKi+In6GpazaJZ/S8rAlrAs?= =?utf-8?q?fmK50Z8YAq9NUC3XGcdD4RAkt3akbdGwFrm9vEnLqRU0oXoWPw2ynra21C/GLmTHc?= =?utf-8?q?1ufTwResbIzT/QGfCGP7XRHv7ckv6cnociK6Yzqt5Iy9Pk4ywQcCW11O44txSFMJh?= =?utf-8?q?Yd2y2BIvoFJwiuhFzADjxwOhi+f+XP9TQsVg1XN34VXG6zcs3J68tb0miMA6RxNSf?= =?utf-8?q?BDdiGsDKY/Rb8vKIB+zdPTQlVgKjRstIF7glGZaQx8Mhq2tNVx6COfxquCNJqCBPq?= =?utf-8?q?V661iIaCOjgX4SLlMvAi4MGZHxx0gt2+wbXiiUZuZNczHa/qivyxsxGkmLrdRz8d3?= =?utf-8?q?mbxoIa/MShxEl81V8aRRsyjtwVINW9/2hWLBlrRzKKfMVY4LxDBGnd0F86ssH8czB?= =?utf-8?q?Riw8y9d0iVNs8meshlDTbJuxUv2sMWRHss92WVL2ZJgUbmRJSeP4aSRxx9ATBjSds?= =?utf-8?q?7BKde/0aSX/xXLPXJF93HSA9xjluQYa/qwXHSQidfEpT/XF403kiCtIkYsmjeBSmc?= =?utf-8?q?guaQRbHSuvvR/iBtL3Hm6IqbuwSsNVfC01ebQn0aTfykwTngfKAIaoLYGyucIWPVb?= =?utf-8?q?pQJgwiJbsEvIySj8KG/6SwnR+EHhc1v2xbli3w3NEoUrJ2LEfAYC5jPEiqrPJljwN?= =?utf-8?q?PfUkBURoln/sRVU03ds2egwHYF4X5kkjdJJakbuJPTZcA6yLBNt7rrnQksg3YxcyO?= =?utf-8?q?H7rqJIxAOqAb/Q1u52vzWY72l5IWSTVfw=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: fcea89ac-3b72-43c0-3401-08d9da108adf X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2022 23:24:43.5709 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GE/y6zwZdaXuLHlwAa8iKXkyV71L7OOH+bLXHYya68FHAjeAmMjghZI47+VoHN8EOrzpszJ1TBfXIkZ5P0BzK3iIHbnbIT02Nug26ULEjrI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5550 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org One-to-one conversion, no functional changes. Now that all of the modeset selftests were converted, remove the helpers that are no longer used. Signed-off-by: MichaƂ Winiarski --- drivers/gpu/drm/selftests/Makefile | 8 +- .../gpu/drm/selftests/drm_modeset_selftests.h | 12 - .../drm/selftests/test-drm_modeset_common.c | 32 --- .../drm/selftests/test-drm_modeset_common.h | 24 -- drivers/gpu/drm/selftests/test-drm_rect.c | 212 ++++++++++-------- 5 files changed, 122 insertions(+), 166 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 diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/selftests/Makefile index 77e37eebf099..2d524eddb4e3 100644 --- a/drivers/gpu/drm/selftests/Makefile +++ b/drivers/gpu/drm/selftests/Makefile @@ -1,11 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-only -test-drm_modeset-$(CONFIG_DRM_DEBUG_SELFTEST) := \ - test-drm_modeset_common.o \ - test-drm_rect.o -obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o +obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o obj-$(CONFIG_DRM_KUNIT_TEST) := \ test-drm_cmdline_parser.o test-drm_plane_helper.o \ test-drm_format.o test-drm_framebuffer.o \ - test-drm_damage_helper.o test-drm_dp_mst_helper.o + test-drm_damage_helper.o test-drm_dp_mst_helper.o \ + test-drm_rect.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 630770d30aba..000000000000 --- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h +++ /dev/null @@ -1,12 +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(drm_rect_clip_scaled_div_by_zero, igt_drm_rect_clip_scaled_div_by_zero) -selftest(drm_rect_clip_scaled_not_clipped, igt_drm_rect_clip_scaled_not_clipped) -selftest(drm_rect_clip_scaled_clipped, igt_drm_rect_clip_scaled_clipped) -selftest(drm_rect_clip_scaled_signed_vs_unsigned, igt_drm_rect_clip_scaled_signed_vs_unsigned) 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 c7cc5edc65f1..000000000000 --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h +++ /dev/null @@ -1,24 +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_drm_rect_clip_scaled_div_by_zero(void *ignored); -int igt_drm_rect_clip_scaled_not_clipped(void *ignored); -int igt_drm_rect_clip_scaled_clipped(void *ignored); -int igt_drm_rect_clip_scaled_signed_vs_unsigned(void *ignored); - -#endif diff --git a/drivers/gpu/drm/selftests/test-drm_rect.c b/drivers/gpu/drm/selftests/test-drm_rect.c index 3a5ff38321f4..f3d26c31ee66 100644 --- a/drivers/gpu/drm/selftests/test-drm_rect.c +++ b/drivers/gpu/drm/selftests/test-drm_rect.c @@ -3,15 +3,12 @@ * Test cases for the drm_rect functions */ -#define pr_fmt(fmt) "drm_rect: " fmt - +#include #include #include -#include "test-drm_modeset_common.h" - -int igt_drm_rect_clip_scaled_div_by_zero(void *ignored) +static void drm_rect_clip_scaled_div_by_zero(struct kunit *test) { struct drm_rect src, dst, clip; bool visible; @@ -23,21 +20,23 @@ int igt_drm_rect_clip_scaled_div_by_zero(void *ignored) drm_rect_init(&src, 0, 0, 0, 0); drm_rect_init(&dst, 0, 0, 0, 0); drm_rect_init(&clip, 1, 1, 1, 1); + visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(visible, "Destination not be visible\n"); - FAIL(drm_rect_visible(&src), "Source should not be visible\n"); + + KUNIT_EXPECT_FALSE_MSG(test, visible, "Destination not be visible"); + KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible"); drm_rect_init(&src, 0, 0, 0, 0); drm_rect_init(&dst, 3, 3, 0, 0); drm_rect_init(&clip, 1, 1, 1, 1); + visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(visible, "Destination not be visible\n"); - FAIL(drm_rect_visible(&src), "Source should not be visible\n"); - return 0; + KUNIT_EXPECT_FALSE_MSG(test, visible, "Destination not be visible"); + KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible"); } -int igt_drm_rect_clip_scaled_not_clipped(void *ignored) +static void drm_rect_clip_scaled_not_clipped(struct kunit *test) { struct drm_rect src, dst, clip; bool visible; @@ -49,14 +48,16 @@ int igt_drm_rect_clip_scaled_not_clipped(void *ignored) visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(src.x1 != 0 || src.x2 != 1 << 16 || - src.y1 != 0 || src.y2 != 1 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 1 || - dst.y1 != 0 || dst.y2 != 1, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 1 << 16 && + src.y1 == 0 && src.y2 == 1 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 1 && + dst.y1 == 0 && dst.y2 == 1, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible"); /* 2:1 scaling */ drm_rect_init(&src, 0, 0, 2 << 16, 2 << 16); @@ -65,14 +66,16 @@ int igt_drm_rect_clip_scaled_not_clipped(void *ignored) visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(src.x1 != 0 || src.x2 != 2 << 16 || - src.y1 != 0 || src.y2 != 2 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 1 || - dst.y1 != 0 || dst.y2 != 1, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 2 << 16 && + src.y1 == 0 && src.y2 == 2 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 1 && + dst.y1 == 0 && dst.y2 == 1, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible"); /* 1:2 scaling */ drm_rect_init(&src, 0, 0, 1 << 16, 1 << 16); @@ -81,19 +84,19 @@ int igt_drm_rect_clip_scaled_not_clipped(void *ignored) visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(src.x1 != 0 || src.x2 != 1 << 16 || - src.y1 != 0 || src.y2 != 1 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 2 || - dst.y1 != 0 || dst.y2 != 2, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); - - return 0; + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 1 << 16 && + src.y1 == 0 && src.y2 == 1 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 2 && + dst.y1 == 0 && dst.y2 == 2, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible"); } -int igt_drm_rect_clip_scaled_clipped(void *ignored) +static void drm_rect_clip_scaled_clipped(struct kunit *test) { struct drm_rect src, dst, clip; bool visible; @@ -105,14 +108,16 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored) visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(src.x1 != 0 || src.x2 != 1 << 16 || - src.y1 != 0 || src.y2 != 1 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 1 || - dst.y1 != 0 || dst.y2 != 1, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 1 << 16 && + src.y1 == 0 && src.y2 == 1 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 1 && + dst.y1 == 0 && dst.y2 == 1, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible"); /* 1:1 scaling bottom/right clip */ drm_rect_init(&src, 0, 0, 2 << 16, 2 << 16); @@ -121,14 +126,16 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored) visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(src.x1 != 1 << 16 || src.x2 != 2 << 16 || - src.y1 != 1 << 16 || src.y2 != 2 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 1 || dst.x2 != 2 || - dst.y1 != 1 || dst.y2 != 2, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 1 << 16 && src.x2 == 2 << 16 && + src.y1 == 1 << 16 && src.y2 == 2 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 1 && dst.x2 == 2 && + dst.y1 == 1 && dst.y2 == 2, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible"); /* 2:1 scaling top/left clip */ drm_rect_init(&src, 0, 0, 4 << 16, 4 << 16); @@ -137,14 +144,16 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored) visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(src.x1 != 0 || src.x2 != 2 << 16 || - src.y1 != 0 || src.y2 != 2 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 1 || - dst.y1 != 0 || dst.y2 != 1, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 2 << 16 && + src.y1 == 0 && src.y2 == 2 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 1 && + dst.y1 == 0 && dst.y2 == 1, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible"); /* 2:1 scaling bottom/right clip */ drm_rect_init(&src, 0, 0, 4 << 16, 4 << 16); @@ -153,14 +162,16 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored) visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(src.x1 != 2 << 16 || src.x2 != 4 << 16 || - src.y1 != 2 << 16 || src.y2 != 4 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 1 || dst.x2 != 2 || - dst.y1 != 1 || dst.y2 != 2, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 2 << 16 && src.x2 == 4 << 16 && + src.y1 == 2 << 16 && src.y2 == 4 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 1 && dst.x2 == 2 && + dst.y1 == 1 && dst.y2 == 2, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible"); /* 1:2 scaling top/left clip */ drm_rect_init(&src, 0, 0, 2 << 16, 2 << 16); @@ -169,14 +180,16 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored) visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(src.x1 != 0 || src.x2 != 1 << 16 || - src.y1 != 0 || src.y2 != 1 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 0 || dst.x2 != 2 || - dst.y1 != 0 || dst.y2 != 2, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 0 && src.x2 == 1 << 16 && + src.y1 == 0 && src.y2 == 1 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 0 && dst.x2 == 2 && + dst.y1 == 0 && dst.y2 == 2, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible"); /* 1:2 scaling bottom/right clip */ drm_rect_init(&src, 0, 0, 2 << 16, 2 << 16); @@ -185,19 +198,19 @@ int igt_drm_rect_clip_scaled_clipped(void *ignored) visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(src.x1 != 1 << 16 || src.x2 != 2 << 16 || - src.y1 != 1 << 16 || src.y2 != 2 << 16, - "Source badly clipped\n"); - FAIL(dst.x1 != 2 || dst.x2 != 4 || - dst.y1 != 2 || dst.y2 != 4, - "Destination badly clipped\n"); - FAIL(!visible, "Destination should be visible\n"); - FAIL(!drm_rect_visible(&src), "Source should be visible\n"); - - return 0; + KUNIT_EXPECT_TRUE_MSG(test, + src.x1 == 1 << 16 && src.x2 == 2 << 16 && + src.y1 == 1 << 16 && src.y2 == 2 << 16, + "Source badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, + dst.x1 == 2 && dst.x2 == 4 && + dst.y1 == 2 && dst.y2 == 4, + "Destination badly clipped"); + KUNIT_EXPECT_TRUE_MSG(test, visible, "Destination should be visible"); + KUNIT_EXPECT_TRUE_MSG(test, drm_rect_visible(&src), "Source should be visible"); } -int igt_drm_rect_clip_scaled_signed_vs_unsigned(void *ignored) +static void drm_rect_clip_scaled_signed_vs_unsigned(struct kunit *test) { struct drm_rect src, dst, clip; bool visible; @@ -216,8 +229,21 @@ int igt_drm_rect_clip_scaled_signed_vs_unsigned(void *ignored) visible = drm_rect_clip_scaled(&src, &dst, &clip); - FAIL(visible, "Destination should not be visible\n"); - FAIL(drm_rect_visible(&src), "Source should not be visible\n"); - - return 0; + KUNIT_EXPECT_FALSE_MSG(test, visible, "Destination should not be visible"); + KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible"); } + +static struct kunit_case drm_rect_tests[] = { + KUNIT_CASE(drm_rect_clip_scaled_div_by_zero), + KUNIT_CASE(drm_rect_clip_scaled_not_clipped), + KUNIT_CASE(drm_rect_clip_scaled_clipped), + KUNIT_CASE(drm_rect_clip_scaled_signed_vs_unsigned), + {} +}; + +static struct kunit_suite drm_rect_test_suite = { + .name = "drm_rect_tests", + .test_cases = drm_rect_tests, +}; + +kunit_test_suite(drm_rect_test_suite);