From patchwork Mon Jan 17 23:22:50 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: 12715717 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 A64BFC433F5 for ; Mon, 17 Jan 2022 23:24:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238473AbiAQXYM (ORCPT ); Mon, 17 Jan 2022 18:24:12 -0500 Received: from mga14.intel.com ([192.55.52.115]:30875 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235370AbiAQXYM (ORCPT ); Mon, 17 Jan 2022 18:24:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642461851; x=1673997851; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=iUbQko9k7Ou5nk3pDqzZkkT1Itgenl5Tkzsne6VbKX4=; b=d9u2CDjhUWkHLwEtUBeddCpGDhZuUmsES4Z5w56/suSi5eRqTj3VcDrW fLPq4RvOynrk77wh39QU//4+nzIfCrtqCeM/jDbk3NWPOhCO9SWhzsZEX eKNSyHOv9+GX0Ne0pzLxoVy5rb6NfCXtXExzmxIPDyvJLwZNyxXTm9nGC uta0ijSEPyeJdpOSiYk91X6z7gszrv7zakgDocfLX36kYqR7HTg9EecfR 6w9FbQ/eHGPaIPhysisxeK6a3a2N1VDpANFcbQd9vUyDgrO5+iFpxO0wA Dk+3Wg6rMTfk2/S5GeOlFZp+24NzvkZCbY9Vw0IrxtCWU0N0ysS9rj7u6 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="244901080" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="244901080" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2022 15:24:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="492487605" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga002.jf.intel.com with ESMTP; 17 Jan 2022 15:24:10 -0800 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx604.amr.corp.intel.com (10.18.126.84) 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:10 -0800 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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 via Frontend Transport; Mon, 17 Jan 2022 15:24:10 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (192.55.55.68) 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:09 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nzfqnOm0OPLQRpUR/hpTZvLjCdt3oyIKCsEeBdRQYEXKT9Z1ylJ6nbpYwuZef3793TMTcpaZH8xjmI8dn52ytfpOOzmh+IK0LQtWuAZ6RJmhQAMx7Pg/0a4OIDm4NzDN6vpVfngFbZpR4/Y3RcVLKpLwvfPCW2B0eQtQRaFSlyp5ImngOwLkZ/81C3PGqcOxaQLTMjsgtck/nIRieXTV2tDJ/run8i7662DOslhB861x2g4drvkenSvv2oIaGhw6k10eFDqr9WIQB5Jbr0AZtmCgz1njt7E9J9xfc1IsrjxrEl80smJOCn6FdEvUeg9bl06t6K1ESbPYEjF6acB1MA== 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=8OsWuxDS+hItVI7fUSlP8MuloHfRQnuixvGZj/X7cbc=; b=GrQ4ioBRO7VIWdWdRXGyTO6i0eYMfh6YV2Axva16HTNLS5EbYJzsdOUEgVivymUy4ddTQ8AgjJYQJYMRELCMoRRAV5pIXGmLOI4751nO9mLoJuUKfZyxNGpglUzYBm2/ONW5CSSfybP1XGkjvPGYgiE7eAwXR5Jzi6lGdjjArJ3hwR5BUYQK05DaKnby09h0FbU3eRJRrZAx6qh1A7twfwfrxsPjjNpY3ZF41sKbUIimDJsq0i2j6qk09VeUMiXzBasWV54aBhhPhLZHI6zlxBuRAlkKiU/qlQth3DX7WtC7d4R9UBKrIZEUuA4H1KSwODVjWIzIf7RXJ8O/WZ4l/w== 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 DM6PR11MB4140.namprd11.prod.outlook.com (2603:10b6:5:19f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Mon, 17 Jan 2022 23:24:05 +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:05 +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 01/10] drm: test-drm_cmdline_parser: Convert to KUnit Date: Tue, 18 Jan 2022 00:22:50 +0100 Message-ID: <20220117232259.180459-2-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: AS8PR04CA0008.eurprd04.prod.outlook.com (2603:10a6:20b:310::13) 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: 65f7d81c-1bc6-4b9e-25fe-08d9da1073e5 X-MS-TrafficTypeDiagnostic: DM6PR11MB4140:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HMjWSyNnENcWuopiEIm0EM0gwdwGXu2qIGHa6zIzFKXgst6SiYQfD6rvGlq5f9WpofTsTtYZE1BxfXcv1RbJxIAZ3oRJpL4vI7SLYg/YjpLPPIiIECXu6Tah+mQjR6oj8ff0gPW6vuHBX4gMnwqkr6/Hpi9XhDAYU3aS+IG+Xi/4LVNpr+cSWCDcCrVp4v2/AViTzOTfBgtZrqMLT4v1EMHsb2EVeivnadpGdChMc/3JQE3GjSFVvv5JlUOX96Eq7YqwV5XJHcsTxzWXqz6jn4sFciKzurrtlumB8Dff3uNuqJqYEPhk74kk0f87WOWbb64YdRH3tyYOOCnAf46EmFwIiEZjwOZ8cLWItbaQiE+LYOle3/NsauJRKQrJRAtJhy2EayRlRaSHWolIv0/RP/6CBmRd/Js92Io1d1X6HGqKK4UZsQ3EICFQfo8fUh/QbTF9NJqKqT444Znl3DLanY3pd18igEdGK3s48xboIz0ZAvLarAGHJ3GAXAUWN7IK0f6VFwAJEjdQJ8Zqfg2Vrinl3xNOvGJ04BNqasnaGNxOszOUqoIm/9ditjgH3uqe/+8P8MK/Q3QP8OH8nkfd4mCO8oqtxD+QtNm6IcT0P3+fex5vtSKpWgbD00s6fWBkwzuIVhaWRRChmQCNT/Q2vw== 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)(508600001)(7416002)(186003)(6506007)(82960400001)(86362001)(8676002)(6512007)(6666004)(83380400001)(38100700002)(8936002)(66556008)(30864003)(54906003)(5660300002)(2906002)(6486002)(316002)(36756003)(2616005)(66946007)(26005)(1076003)(4326008)(66476007)(579004)(559001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?R3wRJU0mQDd72s4su0CLPp97Okit?= =?utf-8?q?vCzJM6D2JM5pXrMPFMem+VgXHE2Gmhkv+PhJa5T+9pY5GOEUTy4t+X96WPjjZXZcg?= =?utf-8?q?J/zGM3YE00tIpqNnUE1jPQGCkWMRRNtOcC122M8aMvZY/V20DciHoI7lgU6gwvLro?= =?utf-8?q?oEfSBknmBWMZyotlzxQf8Sc6tL4C2U2W9xsrh208eSwBHPQi8kjNj3mDQJoGmZ7XM?= =?utf-8?q?pjxlF1L5VhudrThNqR5YIHucaaf+fEG+NxLE0EyL5H0MBvOTf0yyY7sG/VtWQCYHj?= =?utf-8?q?1+CFl6Wml9fWGMmDAzCsjqUzeOJTIMvOzH/PvpfCpde0v1nxCBbVih6SGvNcj5tQg?= =?utf-8?q?Ql4WfpxvynOIXBy/n7oroX/UvGz9HsNdo7FWHbwdbfXRSDXkh3hbaZO0kNRhPsL+C?= =?utf-8?q?XdDN4AE8pGf2RepcELxYIVSOSpkun0+EZR3leoPl2xbVjwPTMM+m+BrWWOBoh/bji?= =?utf-8?q?lSsAsfzpNYB6y7WjRSIyFStmtuM8o7cQNijjWJF7bPilcHOBWA5nHaB6YW6VO06Aa?= =?utf-8?q?yqONQI0V0cYbHb8zUtvdLdnC5XwDnD5QaFd08sk1Zz+E5F2W0qKXgIxL3IJRhdqe1?= =?utf-8?q?erD85qAvtzMEIBq13AgSPOpCcqwAhvG8qEZ78BHyoF0zFhofQeJkNPeXajy4aVb0l?= =?utf-8?q?8TSsR7BtGGU0dd+7R1AfnXhhM+EEsxGKCYFcxPWsl6uCtPpu5MlvUnzY87fRSgOwd?= =?utf-8?q?v8Hi2s+ENafkcxAZUUQDyYGbPBWrRaMrybCwhV//1yjCO3hwILwCr1Q8Om1GKGpJC?= =?utf-8?q?/crxI7eIDnWPHGHz9JNUuCBRLqEe9yG5vp3KMMGuj3ng9npGtII3FeGMFbEQOggDK?= =?utf-8?q?mRLVVIsfeqQXJKKTqVHij9/4iKYLw07cd8R25T/Y1IOQu5MrN351LiqGcD/J+rSrJ?= =?utf-8?q?Rm25we7IezRngjddpSa6ovt65GAjigE8cIEhob9FFHjgpKh8PM5HGyucZ230I0Zb+?= =?utf-8?q?qpSiCvz2Z0LVuIBpdq7qCj137HAPJwG5toOTuYd/8gWbHSqpWWVI42QHGXr0dKliE?= =?utf-8?q?VSN0dSvw/DL+e9O4bH1hPHwBETEMR5O9zUYXCoxUAsPwmCW+J1UQVtgDmuI2Fs9s3?= =?utf-8?q?h9KjrACmuBjCaG7Afp2aRw59Hkneq8ZkdSAvs5qjJTfw8C4/C+HM7umgCDOktnlzw?= =?utf-8?q?hh+meeOFJ2n5eg72X03sun3F0TaEWghbc3+jOrVzQ5wLqfrpEpp+rj+hvo3xKXe54?= =?utf-8?q?ctNXW2DGa8TqCci84oLMJwdJh+NG7NrOcwII0O6SFYi8W7LUUms968A872JxCqMGe?= =?utf-8?q?QckPnQ+VXxvI3x/wCPBcRjQ8eAWGl7CGAThjDdGyVDVat5OAWUfDFsoR3P8Cq4Jkr?= =?utf-8?q?jem96ePmy6z8Fkxl0YIZyOqtPTWiUci3CG/8wdjB0Mmk1vsK5xvFCAzfWg8GFj5Cg?= =?utf-8?q?ICh90iEhJi+tCo8MhGSGicFThblukIwk/WLGxmJTH0oXgJM4eXT6BIRR/xcekgvpz?= =?utf-8?q?WUfzWSezWKnb64XngTZvNO/uTBkK7NFgKJ5Vd9NqKcSyiBDCI3JGMEo80rpAnk8HD?= =?utf-8?q?KluJOqD/UayhWMJDgXRrrKKTEcKKds+F4tlxwKKIxYMeGdHpYvgR5MY+lalRh4mRx?= =?utf-8?q?ZfVsCh71LdSnVby0JzIcig/ANn4hBZptQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 65f7d81c-1bc6-4b9e-25fe-08d9da1073e5 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:05.1802 (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: DTay2zN7gRuQpTq8XSC9hIlMB1WkFGhZlL+81Uf2oJtipGyUXY635L4OVq90VgWOhLwk/Ggf++6jbAXSMbTfcT1J3FoY+1gJko+vN/+wzEY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4140 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org One-to-one conversion, no functional changes. Negative tests were merged into single parameterized test case. Signed-off-by: Michał Winiarski --- drivers/gpu/drm/Kconfig | 12 + drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/selftests/Makefile | 8 +- .../gpu/drm/selftests/drm_cmdline_selftests.h | 68 - .../drm/selftests/test-drm_cmdline_parser.c | 1680 ++++++++--------- 5 files changed, 802 insertions(+), 968 deletions(-) delete mode 100644 drivers/gpu/drm/selftests/drm_cmdline_selftests.h diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index b1f22e457fd0..21e329f32997 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -80,6 +80,18 @@ config DRM_DEBUG_SELFTEST If in doubt, say "N". +config DRM_KUNIT_TEST + bool "DRM tests" if !KUNIT_ALL_TESTS + depends on DRM=y && KUNIT=y + default KUNIT_ALL_TESTS + help + Enables unit tests for DRM. Only useful for kernel devs running KUnit. + + For more information on KUnit and unit tests in general please refer + to the KUnit documentation in Documentation/dev-tools/kunit/. + + If unsure, say N. + config DRM_KMS_HELPER tristate depends on DRM diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 301a44dc18e3..550800e81836 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -65,7 +65,7 @@ drm_kms_helper-$(CONFIG_DRM_DP_AUX_CHARDEV) += drm_dp_aux_dev.o drm_kms_helper-$(CONFIG_DRM_DP_CEC) += drm_dp_cec.o obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o -obj-$(CONFIG_DRM_DEBUG_SELFTEST) += selftests/ +obj-y += selftests/ obj-$(CONFIG_DRM) += drm.o obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/selftests/Makefile index 0856e4b12f70..6411c9a957b3 100644 --- a/drivers/gpu/drm/selftests/Makefile +++ b/drivers/gpu/drm/selftests/Makefile @@ -1,7 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-only -test-drm_modeset-y := test-drm_modeset_common.o test-drm_plane_helper.o \ +test-drm_modeset-$(CONFIG_DRM_DEBUG_SELFTEST) := \ + test-drm_modeset_common.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_rect.o -obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o test-drm_cmdline_parser.o +obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o + +obj-$(CONFIG_DRM_KUNIT_TEST) := \ + test-drm_cmdline_parser.o diff --git a/drivers/gpu/drm/selftests/drm_cmdline_selftests.h b/drivers/gpu/drm/selftests/drm_cmdline_selftests.h deleted file mode 100644 index 29e367db6118..000000000000 --- a/drivers/gpu/drm/selftests/drm_cmdline_selftests.h +++ /dev/null @@ -1,68 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* List each unit test as selftest(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_mm - */ - -#define cmdline_test(test) selftest(test, test) - -cmdline_test(drm_cmdline_test_force_d_only) -cmdline_test(drm_cmdline_test_force_D_only_dvi) -cmdline_test(drm_cmdline_test_force_D_only_hdmi) -cmdline_test(drm_cmdline_test_force_D_only_not_digital) -cmdline_test(drm_cmdline_test_force_e_only) -cmdline_test(drm_cmdline_test_margin_only) -cmdline_test(drm_cmdline_test_interlace_only) -cmdline_test(drm_cmdline_test_res) -cmdline_test(drm_cmdline_test_res_missing_x) -cmdline_test(drm_cmdline_test_res_missing_y) -cmdline_test(drm_cmdline_test_res_bad_y) -cmdline_test(drm_cmdline_test_res_missing_y_bpp) -cmdline_test(drm_cmdline_test_res_vesa) -cmdline_test(drm_cmdline_test_res_vesa_rblank) -cmdline_test(drm_cmdline_test_res_rblank) -cmdline_test(drm_cmdline_test_res_bpp) -cmdline_test(drm_cmdline_test_res_bad_bpp) -cmdline_test(drm_cmdline_test_res_refresh) -cmdline_test(drm_cmdline_test_res_bad_refresh) -cmdline_test(drm_cmdline_test_res_bpp_refresh) -cmdline_test(drm_cmdline_test_res_bpp_refresh_interlaced) -cmdline_test(drm_cmdline_test_res_bpp_refresh_margins) -cmdline_test(drm_cmdline_test_res_bpp_refresh_force_off) -cmdline_test(drm_cmdline_test_res_bpp_refresh_force_on_off) -cmdline_test(drm_cmdline_test_res_bpp_refresh_force_on) -cmdline_test(drm_cmdline_test_res_bpp_refresh_force_on_analog) -cmdline_test(drm_cmdline_test_res_bpp_refresh_force_on_digital) -cmdline_test(drm_cmdline_test_res_bpp_refresh_interlaced_margins_force_on) -cmdline_test(drm_cmdline_test_res_margins_force_on) -cmdline_test(drm_cmdline_test_res_vesa_margins) -cmdline_test(drm_cmdline_test_res_invalid_mode) -cmdline_test(drm_cmdline_test_res_bpp_wrong_place_mode) -cmdline_test(drm_cmdline_test_name) -cmdline_test(drm_cmdline_test_name_bpp) -cmdline_test(drm_cmdline_test_name_refresh) -cmdline_test(drm_cmdline_test_name_bpp_refresh) -cmdline_test(drm_cmdline_test_name_refresh_wrong_mode) -cmdline_test(drm_cmdline_test_name_refresh_invalid_mode) -cmdline_test(drm_cmdline_test_name_option) -cmdline_test(drm_cmdline_test_name_bpp_option) -cmdline_test(drm_cmdline_test_rotate_0) -cmdline_test(drm_cmdline_test_rotate_90) -cmdline_test(drm_cmdline_test_rotate_180) -cmdline_test(drm_cmdline_test_rotate_270) -cmdline_test(drm_cmdline_test_rotate_multiple) -cmdline_test(drm_cmdline_test_rotate_invalid_val) -cmdline_test(drm_cmdline_test_rotate_truncated) -cmdline_test(drm_cmdline_test_hmirror) -cmdline_test(drm_cmdline_test_vmirror) -cmdline_test(drm_cmdline_test_margin_options) -cmdline_test(drm_cmdline_test_multiple_options) -cmdline_test(drm_cmdline_test_invalid_option) -cmdline_test(drm_cmdline_test_bpp_extra_and_option) -cmdline_test(drm_cmdline_test_extra_and_option) -cmdline_test(drm_cmdline_test_freestanding_options) -cmdline_test(drm_cmdline_test_freestanding_force_e_and_options) -cmdline_test(drm_cmdline_test_panel_orientation) diff --git a/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c b/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c index d96cd890def6..ffe5a483320a 100644 --- a/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c +++ b/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c @@ -3,1139 +3,1025 @@ * Copyright (c) 2019 Bootlin */ -#define pr_fmt(fmt) "drm_cmdline: " fmt - -#include -#include +#include #include #include -#define TESTS "drm_cmdline_selftests.h" -#include "drm_selftest.h" -#include "test-drm_modeset_common.h" - static const struct drm_connector no_connector = {}; -static int drm_cmdline_test_force_e_only(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("e", - &no_connector, - &mode)); - FAIL_ON(mode.specified); - FAIL_ON(mode.refresh_specified); - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON); - - return 0; -} - -static int drm_cmdline_test_force_D_only_not_digital(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("D", - &no_connector, - &mode)); - FAIL_ON(mode.specified); - FAIL_ON(mode.refresh_specified); - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON); - - return 0; -} - -static const struct drm_connector connector_hdmi = { - .connector_type = DRM_MODE_CONNECTOR_HDMIB, -}; - -static int drm_cmdline_test_force_D_only_hdmi(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("D", - &connector_hdmi, - &mode)); - FAIL_ON(mode.specified); - FAIL_ON(mode.refresh_specified); - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON_DIGITAL); - - return 0; -} - -static const struct drm_connector connector_dvi = { - .connector_type = DRM_MODE_CONNECTOR_DVII, -}; - -static int drm_cmdline_test_force_D_only_dvi(void *ignored) +static void drm_cmdline_test_force_e_only(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("D", - &connector_dvi, - &mode)); - FAIL_ON(mode.specified); - FAIL_ON(mode.refresh_specified); - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON_DIGITAL); - - return 0; -} - -static int drm_cmdline_test_force_d_only(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("d", - &no_connector, - &mode)); - FAIL_ON(mode.specified); - FAIL_ON(mode.refresh_specified); - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_OFF); - - return 0; + const char *cmdline = "e"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_FALSE(test, mode.specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON); } -static int drm_cmdline_test_margin_only(void *ignored) +static void drm_cmdline_test_force_D_only_not_digital(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("m", - &no_connector, - &mode)); - - return 0; -} - -static int drm_cmdline_test_interlace_only(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("i", - &no_connector, - &mode)); - - return 0; -} - -static int drm_cmdline_test_res(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(mode.refresh_specified); - - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + const char *cmdline = "D"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_FALSE(test, mode.specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON); } -static int drm_cmdline_test_res_missing_x(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - FAIL_ON(drm_mode_parse_command_line_for_connector("x480", - &no_connector, - &mode)); - - return 0; -} - -static int drm_cmdline_test_res_missing_y(void *ignored) +static void drm_cmdline_test_force_D_only_hdmi(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("1024x", - &no_connector, - &mode)); - - return 0; + const struct drm_connector connector_hdmi = { + .connector_type = DRM_MODE_CONNECTOR_HDMIB, + }; + const char *cmdline = "D"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &connector_hdmi, + &mode)); + KUNIT_EXPECT_FALSE(test, mode.specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON_DIGITAL); } -static int drm_cmdline_test_res_bad_y(void *ignored) +static void drm_cmdline_test_force_D_only_dvi(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("1024xtest", - &no_connector, - &mode)); - - return 0; + const struct drm_connector connector_dvi = { + .connector_type = DRM_MODE_CONNECTOR_DVII, + }; + const char *cmdline = "D"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &connector_dvi, + &mode)); + KUNIT_EXPECT_FALSE(test, mode.specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON_DIGITAL); } -static int drm_cmdline_test_res_missing_y_bpp(void *ignored) +static void drm_cmdline_test_force_d_only(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("1024x-24", - &no_connector, - &mode)); - - return 0; + const char *cmdline = "d"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_FALSE(test, mode.specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_OFF); } -static int drm_cmdline_test_res_vesa(void *ignored) +static void drm_cmdline_test_res(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480M", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); - FAIL_ON(mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(mode.bpp_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - FAIL_ON(mode.rb); - FAIL_ON(!mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_res_vesa_rblank(void *ignored) +static void drm_cmdline_test_res_vesa(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480M"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480MR", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(mode.refresh_specified); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); - FAIL_ON(mode.bpp_specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(!mode.rb); - FAIL_ON(!mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_TRUE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_res_rblank(void *ignored) +static void drm_cmdline_test_res_vesa_rblank(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480MR"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480R", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); - FAIL_ON(mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(mode.bpp_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - FAIL_ON(!mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + KUNIT_EXPECT_TRUE(test, mode.rb); + KUNIT_EXPECT_TRUE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_res_bpp(void *ignored) +static void drm_cmdline_test_res_rblank(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480R"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480-24", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(mode.refresh_specified); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - return 0; + KUNIT_EXPECT_TRUE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_res_bad_bpp(void *ignored) +static void drm_cmdline_test_res_bpp(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480-24"; - FAIL_ON(drm_mode_parse_command_line_for_connector("720x480-test", - &no_connector, - &mode)); - - return 0; -} - -static int drm_cmdline_test_res_refresh(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480@60", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(!mode.refresh_specified); - FAIL_ON(mode.refresh != 60); - - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); - return 0; -} - -static int drm_cmdline_test_res_bad_refresh(void *ignored) -{ - struct drm_cmdline_mode mode = { }; + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(drm_mode_parse_command_line_for_connector("720x480@refresh", - &no_connector, - &mode)); + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_res_bpp_refresh(void *ignored) +static void drm_cmdline_test_res_refresh(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480@60"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480-24@60", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); - FAIL_ON(!mode.refresh_specified); - FAIL_ON(mode.refresh != 60); + KUNIT_EXPECT_TRUE(test, mode.refresh_specified); + KUNIT_EXPECT_EQ(test, mode.refresh, 60); - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_res_bpp_refresh_interlaced(void *ignored) +static void drm_cmdline_test_res_bpp_refresh(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480-24@60i", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(!mode.refresh_specified); - FAIL_ON(mode.refresh != 60); - - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(!mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + const char *cmdline = "720x480-24@60"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + + KUNIT_EXPECT_TRUE(test, mode.refresh_specified); + KUNIT_EXPECT_EQ(test, mode.refresh, 60); + + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_res_bpp_refresh_margins(void *ignored) +static void drm_cmdline_test_res_bpp_refresh_interlaced(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480-24@60m", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(!mode.refresh_specified); - FAIL_ON(mode.refresh != 60); - - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(!mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + const char *cmdline = "720x480-24@60i"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + + KUNIT_EXPECT_TRUE(test, mode.refresh_specified); + KUNIT_EXPECT_EQ(test, mode.refresh, 60); + + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_TRUE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_res_bpp_refresh_force_off(void *ignored) +static void drm_cmdline_test_res_bpp_refresh_margins(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480-24@60d", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(!mode.refresh_specified); - FAIL_ON(mode.refresh != 60); - - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_OFF); - - return 0; + const char *cmdline = "720x480-24@60m"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + + KUNIT_EXPECT_TRUE(test, mode.refresh_specified); + KUNIT_EXPECT_EQ(test, mode.refresh, 60); + + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_TRUE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_res_bpp_refresh_force_on_off(void *ignored) +static void drm_cmdline_test_res_bpp_refresh_force_off(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("720x480-24@60de", - &no_connector, - &mode)); - - return 0; + const char *cmdline = "720x480-24@60d"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + + KUNIT_EXPECT_TRUE(test, mode.refresh_specified); + KUNIT_EXPECT_EQ(test, mode.refresh, 60); + + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_OFF); } -static int drm_cmdline_test_res_bpp_refresh_force_on(void *ignored) +static void drm_cmdline_test_res_bpp_refresh_force_on(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480-24@60e", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(!mode.refresh_specified); - FAIL_ON(mode.refresh != 60); - - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON); - - return 0; + const char *cmdline = "720x480-24@60e"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + + KUNIT_EXPECT_TRUE(test, mode.refresh_specified); + KUNIT_EXPECT_EQ(test, mode.refresh, 60); + + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON); } -static int drm_cmdline_test_res_bpp_refresh_force_on_analog(void *ignored) +static void drm_cmdline_test_res_bpp_refresh_force_on_analog(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480-24@60D", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(!mode.refresh_specified); - FAIL_ON(mode.refresh != 60); - - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON); - - return 0; + const char *cmdline = "720x480-24@60D"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + + KUNIT_EXPECT_TRUE(test, mode.refresh_specified); + KUNIT_EXPECT_EQ(test, mode.refresh, 60); + + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON); } -static int drm_cmdline_test_res_bpp_refresh_force_on_digital(void *ignored) +static void drm_cmdline_test_res_bpp_refresh_force_on_digital(struct kunit *test) { struct drm_cmdline_mode mode = { }; - static const struct drm_connector connector = { + const struct drm_connector connector = { .connector_type = DRM_MODE_CONNECTOR_DVII, }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480-24@60D", - &connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(!mode.refresh_specified); - FAIL_ON(mode.refresh != 60); - - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON_DIGITAL); - - return 0; + const char *cmdline = "720x480-24@60D"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + + KUNIT_EXPECT_TRUE(test, mode.refresh_specified); + KUNIT_EXPECT_EQ(test, mode.refresh, 60); + + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON_DIGITAL); } -static int drm_cmdline_test_res_bpp_refresh_interlaced_margins_force_on(void *ignored) +static void drm_cmdline_test_res_bpp_refresh_interlaced_margins_force_on(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480-24@60ime", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(!mode.refresh_specified); - FAIL_ON(mode.refresh != 60); - - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(!mode.interlace); - FAIL_ON(!mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON); - - return 0; + const char *cmdline = "720x480-24@60ime"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + + KUNIT_EXPECT_TRUE(test, mode.refresh_specified); + KUNIT_EXPECT_EQ(test, mode.refresh, 60); + + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_TRUE(test, mode.interlace); + KUNIT_EXPECT_TRUE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON); } -static int drm_cmdline_test_res_margins_force_on(void *ignored) +static void drm_cmdline_test_res_margins_force_on(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480me"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480me", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(mode.refresh_specified); - - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(!mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON); - - return 0; -} - -static int drm_cmdline_test_res_vesa_margins(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480Mm", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - - FAIL_ON(mode.refresh_specified); - - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(!mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(!mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); - return 0; -} - -static int drm_cmdline_test_res_invalid_mode(void *ignored) -{ - struct drm_cmdline_mode mode = { }; + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(drm_mode_parse_command_line_for_connector("720x480f", - &no_connector, - &mode)); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_TRUE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON); } -static int drm_cmdline_test_res_bpp_wrong_place_mode(void *ignored) +static void drm_cmdline_test_res_vesa_margins(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480Mm"; - FAIL_ON(drm_mode_parse_command_line_for_connector("720x480e-24", - &no_connector, - &mode)); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); - return 0; -} - -static int drm_cmdline_test_name(void *ignored) -{ - struct drm_cmdline_mode mode = { }; + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(!drm_mode_parse_command_line_for_connector("NTSC", - &no_connector, - &mode)); - FAIL_ON(strcmp(mode.name, "NTSC")); - FAIL_ON(mode.refresh_specified); - FAIL_ON(mode.bpp_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_TRUE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_TRUE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_name_bpp(void *ignored) +static void drm_cmdline_test_name(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("NTSC-24", - &no_connector, - &mode)); - FAIL_ON(strcmp(mode.name, "NTSC")); - - FAIL_ON(mode.refresh_specified); - - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); - - return 0; + const char *cmdline = "NTSC"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_STREQ(test, mode.name, "NTSC"); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); } -static int drm_cmdline_test_name_bpp_refresh(void *ignored) +static void drm_cmdline_test_name_bpp(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "NTSC-24"; - FAIL_ON(drm_mode_parse_command_line_for_connector("NTSC-24@60", - &no_connector, - &mode)); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_STREQ(test, mode.name, "NTSC"); - return 0; -} + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); -static int drm_cmdline_test_name_refresh(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("NTSC@60", - &no_connector, - &mode)); - - return 0; + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); } -static int drm_cmdline_test_name_refresh_wrong_mode(void *ignored) +static void drm_cmdline_test_name_option(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("NTSC@60m", - &no_connector, - &mode)); - - return 0; + const char *cmdline = "NTSC,rotate=180"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_STREQ(test, mode.name, "NTSC"); + KUNIT_EXPECT_EQ(test, mode.rotation_reflection, DRM_MODE_ROTATE_180); } -static int drm_cmdline_test_name_refresh_invalid_mode(void *ignored) +static void drm_cmdline_test_name_bpp_option(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("NTSC@60f", - &no_connector, - &mode)); - - return 0; + const char *cmdline = "NTSC-24,rotate=180"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_STREQ(test, mode.name, "NTSC"); + KUNIT_EXPECT_EQ(test, mode.rotation_reflection, DRM_MODE_ROTATE_180); + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); } -static int drm_cmdline_test_name_option(void *ignored) +static void drm_cmdline_test_rotate_0(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480,rotate=0"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("NTSC,rotate=180", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(strcmp(mode.name, "NTSC")); - FAIL_ON(mode.rotation_reflection != DRM_MODE_ROTATE_180); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + KUNIT_EXPECT_EQ(test, mode.rotation_reflection, DRM_MODE_ROTATE_0); - return 0; -} - -static int drm_cmdline_test_name_bpp_option(void *ignored) -{ - struct drm_cmdline_mode mode = { }; + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(!drm_mode_parse_command_line_for_connector("NTSC-24,rotate=180", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(strcmp(mode.name, "NTSC")); - FAIL_ON(mode.rotation_reflection != DRM_MODE_ROTATE_180); - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_rotate_0(void *ignored) +static void drm_cmdline_test_rotate_90(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480,rotate=90"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480,rotate=0", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - FAIL_ON(mode.rotation_reflection != DRM_MODE_ROTATE_0); - - FAIL_ON(mode.refresh_specified); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + KUNIT_EXPECT_EQ(test, mode.rotation_reflection, DRM_MODE_ROTATE_90); - FAIL_ON(mode.bpp_specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_rotate_90(void *ignored) +static void drm_cmdline_test_rotate_180(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480,rotate=180"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480,rotate=90", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - FAIL_ON(mode.rotation_reflection != DRM_MODE_ROTATE_90); - - FAIL_ON(mode.refresh_specified); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + KUNIT_EXPECT_EQ(test, mode.rotation_reflection, DRM_MODE_ROTATE_180); - FAIL_ON(mode.bpp_specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_rotate_180(void *ignored) +static void drm_cmdline_test_rotate_270(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480,rotate=270"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480,rotate=180", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - FAIL_ON(mode.rotation_reflection != DRM_MODE_ROTATE_180); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + KUNIT_EXPECT_EQ(test, mode.rotation_reflection, DRM_MODE_ROTATE_270); - FAIL_ON(mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(mode.bpp_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_rotate_270(void *ignored) +static void drm_cmdline_test_hmirror(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480,reflect_x"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480,rotate=270", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - FAIL_ON(mode.rotation_reflection != DRM_MODE_ROTATE_270); - - FAIL_ON(mode.refresh_specified); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + KUNIT_EXPECT_EQ(test, mode.rotation_reflection, (DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_X)); - FAIL_ON(mode.bpp_specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_rotate_multiple(void *ignored) +static void drm_cmdline_test_vmirror(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480,reflect_y"; - FAIL_ON(drm_mode_parse_command_line_for_connector("720x480,rotate=0,rotate=90", - &no_connector, - &mode)); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + KUNIT_EXPECT_EQ(test, mode.rotation_reflection, (DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_Y)); - return 0; -} + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); -static int drm_cmdline_test_rotate_invalid_val(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("720x480,rotate=42", - &no_connector, - &mode)); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_rotate_truncated(void *ignored) +static void drm_cmdline_test_margin_options(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("720x480,rotate=", - &no_connector, - &mode)); - - return 0; + const char *cmdline = + "720x480,margin_right=14,margin_left=24,margin_bottom=36,margin_top=42"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + KUNIT_EXPECT_EQ(test, mode.tv_margins.right, 14); + KUNIT_EXPECT_EQ(test, mode.tv_margins.left, 24); + KUNIT_EXPECT_EQ(test, mode.tv_margins.bottom, 36); + KUNIT_EXPECT_EQ(test, mode.tv_margins.top, 42); + + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_hmirror(void *ignored) +static void drm_cmdline_test_multiple_options(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const char *cmdline = "720x480,rotate=270,reflect_x"; - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480,reflect_x", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - FAIL_ON(mode.rotation_reflection != (DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_X)); - - FAIL_ON(mode.refresh_specified); + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + KUNIT_EXPECT_EQ(test, mode.rotation_reflection, (DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X)); - FAIL_ON(mode.bpp_specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); - return 0; + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_vmirror(void *ignored) +static void drm_cmdline_test_bpp_extra_and_option(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480,reflect_y", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - FAIL_ON(mode.rotation_reflection != (DRM_MODE_ROTATE_0 | DRM_MODE_REFLECT_Y)); - - FAIL_ON(mode.refresh_specified); - - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + const char *cmdline = "720x480-24e,rotate=180"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + KUNIT_EXPECT_EQ(test, mode.rotation_reflection, DRM_MODE_ROTATE_180); + + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + + KUNIT_EXPECT_TRUE(test, mode.bpp_specified); + KUNIT_EXPECT_EQ(test, mode.bpp, 24); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON); } -static int drm_cmdline_test_margin_options(void *ignored) +static void drm_cmdline_test_extra_and_option(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480,margin_right=14,margin_left=24,margin_bottom=36,margin_top=42", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - FAIL_ON(mode.tv_margins.right != 14); - FAIL_ON(mode.tv_margins.left != 24); - FAIL_ON(mode.tv_margins.bottom != 36); - FAIL_ON(mode.tv_margins.top != 42); - - FAIL_ON(mode.refresh_specified); - - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + const char *cmdline = "720x480e,rotate=180"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, 720); + KUNIT_EXPECT_EQ(test, mode.yres, 480); + KUNIT_EXPECT_EQ(test, mode.rotation_reflection, DRM_MODE_ROTATE_180); + + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON); } -static int drm_cmdline_test_multiple_options(void *ignored) +static void drm_cmdline_test_freestanding_options(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480,rotate=270,reflect_x", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - FAIL_ON(mode.rotation_reflection != (DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X)); - - FAIL_ON(mode.refresh_specified); - - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + const char *cmdline = "margin_right=14,margin_left=24,margin_bottom=36,margin_top=42"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_FALSE(test, mode.specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); + + KUNIT_EXPECT_EQ(test, mode.tv_margins.right, 14); + KUNIT_EXPECT_EQ(test, mode.tv_margins.left, 24); + KUNIT_EXPECT_EQ(test, mode.tv_margins.bottom, 36); + KUNIT_EXPECT_EQ(test, mode.tv_margins.top, 42); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_invalid_option(void *ignored) +static void drm_cmdline_test_freestanding_force_e_and_options(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(drm_mode_parse_command_line_for_connector("720x480,test=42", - &no_connector, - &mode)); - - return 0; + const char *cmdline = "e,margin_right=14,margin_left=24,margin_bottom=36,margin_top=42"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_FALSE(test, mode.specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); + + KUNIT_EXPECT_EQ(test, mode.tv_margins.right, 14); + KUNIT_EXPECT_EQ(test, mode.tv_margins.left, 24); + KUNIT_EXPECT_EQ(test, mode.tv_margins.bottom, 36); + KUNIT_EXPECT_EQ(test, mode.tv_margins.top, 42); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON); } -static int drm_cmdline_test_bpp_extra_and_option(void *ignored) +static void drm_cmdline_test_panel_orientation(struct kunit *test) { struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480-24e,rotate=180", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - FAIL_ON(mode.rotation_reflection != DRM_MODE_ROTATE_180); - - FAIL_ON(mode.refresh_specified); - - FAIL_ON(!mode.bpp_specified); - FAIL_ON(mode.bpp != 24); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON); - - return 0; + const char *cmdline = "panel_orientation=upside_down"; + + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + &no_connector, + &mode)); + KUNIT_EXPECT_FALSE(test, mode.specified); + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); + + KUNIT_EXPECT_EQ(test, mode.panel_orientation, DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_FALSE(test, mode.interlace); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static int drm_cmdline_test_extra_and_option(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("720x480e,rotate=180", - &no_connector, - &mode)); - FAIL_ON(!mode.specified); - FAIL_ON(mode.xres != 720); - FAIL_ON(mode.yres != 480); - FAIL_ON(mode.rotation_reflection != DRM_MODE_ROTATE_180); - - FAIL_ON(mode.refresh_specified); - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON); - - return 0; -} +struct drm_cmdline_negative_test { + const char *name; + const char *cmdline; +}; -static int drm_cmdline_test_freestanding_options(void *ignored) +static void drm_cmdline_test_negative(struct kunit *test) { + const struct drm_cmdline_negative_test *params = test->param_value; struct drm_cmdline_mode mode = { }; - FAIL_ON(!drm_mode_parse_command_line_for_connector("margin_right=14,margin_left=24,margin_bottom=36,margin_top=42", - &no_connector, - &mode)); - FAIL_ON(mode.specified); - FAIL_ON(mode.refresh_specified); - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.tv_margins.right != 14); - FAIL_ON(mode.tv_margins.left != 24); - FAIL_ON(mode.tv_margins.bottom != 36); - FAIL_ON(mode.tv_margins.top != 42); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(params->cmdline, + &no_connector, + &mode)); } -static int drm_cmdline_test_freestanding_force_e_and_options(void *ignored) -{ - struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("e,margin_right=14,margin_left=24,margin_bottom=36,margin_top=42", - &no_connector, - &mode)); - FAIL_ON(mode.specified); - FAIL_ON(mode.refresh_specified); - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.tv_margins.right != 14); - FAIL_ON(mode.tv_margins.left != 24); - FAIL_ON(mode.tv_margins.bottom != 36); - FAIL_ON(mode.tv_margins.top != 42); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_ON); - - return 0; -} +static const struct drm_cmdline_negative_test drm_cmdline_negative_tests[] = { + { + .name = "margin_only", + .cmdline = "m", + }, + { + .name = "interlace_only", + .cmdline = "i", + }, + { + .name = "res_missing_x", + .cmdline = "x480", + }, + { + .name = "res_missing_y", + .cmdline = "1024x", + }, + { + .name = "res_bad_y", + .cmdline = "1024xtest", + }, + { + .name = "res_missing_y_bpp", + .cmdline = "1024x-24", + }, + { + .name = "res_bad_bpp", + .cmdline = "720x480-test", + }, + { + .name = "res_bad_refresh", + .cmdline = "720x480@refresh", + }, + { + .name = "res_bpp_refresh_force_on_off", + .cmdline = "720x480-24@60de", + }, + { + .name = "res_invalid_mode", + .cmdline = "720x480f", + }, + { + .name = "res_bpp_wrong_place_mode", + .cmdline = "720x480e-24", + }, + { + .name = "name_bpp_refresh", + .cmdline = "NTSC-24@60", + }, + { + .name = "name_refresh", + .cmdline = "NTSC@60", + }, + { + .name = "name_refresh_wrong_mode", + .cmdline = "NTSC@60m", + }, + { + .name = "name_refresh_invalid_mode", + .cmdline = "NTSC@60f", + }, + { + .name = "rotate_multiple", + .cmdline = "720x480,rotate=0,rotate=90", + }, + { + .name = "rotate_invalid_val", + .cmdline = "720x480,rotate=42", + }, + { + .name = "rotate_truncated", + .cmdline = "720x480,rotate=", + }, + { + .name = "invalid_option", + .cmdline = "720x480,test=42", + }, +}; -static int drm_cmdline_test_panel_orientation(void *ignored) +static void drm_cmdline_negative_desc(const struct drm_cmdline_negative_test *t, + char *desc) { - struct drm_cmdline_mode mode = { }; - - FAIL_ON(!drm_mode_parse_command_line_for_connector("panel_orientation=upside_down", - &no_connector, - &mode)); - FAIL_ON(mode.specified); - FAIL_ON(mode.refresh_specified); - FAIL_ON(mode.bpp_specified); - - FAIL_ON(mode.panel_orientation != DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP); - - FAIL_ON(mode.rb); - FAIL_ON(mode.cvt); - FAIL_ON(mode.interlace); - FAIL_ON(mode.margins); - FAIL_ON(mode.force != DRM_FORCE_UNSPECIFIED); - - return 0; + sprintf(desc, "%s", t->name); } -#include "drm_selftest.c" - -static int __init test_drm_cmdline_init(void) -{ - int err; +KUNIT_ARRAY_PARAM(drm_cmdline_negative, drm_cmdline_negative_tests, drm_cmdline_negative_desc); + +static struct kunit_case drm_cmdline_tests[] = { + KUNIT_CASE(drm_cmdline_test_force_d_only), + KUNIT_CASE(drm_cmdline_test_force_D_only_dvi), + KUNIT_CASE(drm_cmdline_test_force_D_only_hdmi), + KUNIT_CASE(drm_cmdline_test_force_D_only_not_digital), + KUNIT_CASE(drm_cmdline_test_force_e_only), + KUNIT_CASE(drm_cmdline_test_res), + KUNIT_CASE(drm_cmdline_test_res_vesa), + KUNIT_CASE(drm_cmdline_test_res_vesa_rblank), + KUNIT_CASE(drm_cmdline_test_res_rblank), + KUNIT_CASE(drm_cmdline_test_res_bpp), + KUNIT_CASE(drm_cmdline_test_res_refresh), + KUNIT_CASE(drm_cmdline_test_res_bpp_refresh), + KUNIT_CASE(drm_cmdline_test_res_bpp_refresh_interlaced), + KUNIT_CASE(drm_cmdline_test_res_bpp_refresh_margins), + KUNIT_CASE(drm_cmdline_test_res_bpp_refresh_force_off), + KUNIT_CASE(drm_cmdline_test_res_bpp_refresh_force_on), + KUNIT_CASE(drm_cmdline_test_res_bpp_refresh_force_on_analog), + KUNIT_CASE(drm_cmdline_test_res_bpp_refresh_force_on_digital), + KUNIT_CASE(drm_cmdline_test_res_bpp_refresh_interlaced_margins_force_on), + KUNIT_CASE(drm_cmdline_test_res_margins_force_on), + KUNIT_CASE(drm_cmdline_test_res_vesa_margins), + KUNIT_CASE(drm_cmdline_test_name), + KUNIT_CASE(drm_cmdline_test_name_bpp), + KUNIT_CASE(drm_cmdline_test_name_option), + KUNIT_CASE(drm_cmdline_test_name_bpp_option), + KUNIT_CASE(drm_cmdline_test_rotate_0), + KUNIT_CASE(drm_cmdline_test_rotate_90), + KUNIT_CASE(drm_cmdline_test_rotate_180), + KUNIT_CASE(drm_cmdline_test_rotate_270), + KUNIT_CASE(drm_cmdline_test_hmirror), + KUNIT_CASE(drm_cmdline_test_vmirror), + KUNIT_CASE(drm_cmdline_test_margin_options), + KUNIT_CASE(drm_cmdline_test_multiple_options), + KUNIT_CASE(drm_cmdline_test_bpp_extra_and_option), + KUNIT_CASE(drm_cmdline_test_extra_and_option), + KUNIT_CASE(drm_cmdline_test_freestanding_options), + KUNIT_CASE(drm_cmdline_test_freestanding_force_e_and_options), + KUNIT_CASE(drm_cmdline_test_panel_orientation), + KUNIT_CASE_PARAM(drm_cmdline_test_negative, drm_cmdline_negative_gen_params), + {} +}; - err = run_selftests(selftests, ARRAY_SIZE(selftests), NULL); +static struct kunit_suite drm_cmdline_test_suite = { + .name = "drm_cmdline_tests", + .test_cases = drm_cmdline_tests, +}; - return err > 0 ? 0 : err; -} -module_init(test_drm_cmdline_init); +kunit_test_suite(drm_cmdline_test_suite); MODULE_AUTHOR("Maxime Ripard "); MODULE_LICENSE("GPL"); From patchwork Mon Jan 17 23:22:51 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: 12715718 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 5111EC433FE for ; Mon, 17 Jan 2022 23:24:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238509AbiAQXYR (ORCPT ); Mon, 17 Jan 2022 18:24:17 -0500 Received: from mga09.intel.com ([134.134.136.24]:63914 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235370AbiAQXYR (ORCPT ); Mon, 17 Jan 2022 18:24:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642461857; x=1673997857; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=3hUWtiKXjg3cJE6CMKMTkwKwRYB2s1i3CV4QtKLxeyw=; b=Rv54X/cvosusqB7OftykPQn3PsYv5eMad9NOndyHmc8p0x88QJruEyPn iirWsHkY0N9599QRKyHeTH2naEWmmXFvUetILdaPUNeDxaMtBRF0LCH2I A26kNIk+a7nz43BW6rMDgO5DHREnXcyd4TdHMShmX1vARxLqNo9dpwcfP wgQw5c7PSxhTTjpP1Wieu2r84BoNm27Uf1iM2qIa9sML7XVdkTchX+Nag O64A54n0N12B0V6I44rw6t6GypFgAGz4joLjP/b/tmdX1MGwjJDpQiOqu W2MM1Gc2OPhRwMqdLBzvP2qGhbPxqv2iJg83mE4LRUKFq2SAXw8oIBtJG Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="244501822" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="244501822" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2022 15:24:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="474580633" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga003.jf.intel.com with ESMTP; 17 Jan 2022 15:24:16 -0800 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx603.amr.corp.intel.com (10.18.126.83) 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:16 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx601.amr.corp.intel.com (10.18.126.81) 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:16 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.105) by edgegateway.intel.com (192.55.55.70) 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:15 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T3vll1c83sRjeoBdhEWuvzGjYVWjYIgnS1g5PpALLCcWSlsmHouL14VDcqF7AhbYQA2tajPajzTC/cfrDYq+uUw8PIM0obA3ijUdOIl7i/VUXyfKNbrm3IaOKAahtKQCXEDA0yd5XGnF9RhJzcKKzgAzPp8l11B++pjSZab3zpDIjjVvTWlbYUyhBtfqGYj52/++7UQ94MZLw3HSr54OMRUun+Zwl7VtF1on2MmFT6dci5/lRC+MBTEBkw/DwwaqIecxB2u34WgmaqFjLe2oE1TSjq5j7x78tRGpV0gZVDkcr4PnEWhH9GuJ3yLg7RRLmfVT3QC7j8Jgx6SuK5V95g== 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=ejnFkLnjeyaluKXsi+Sc4X3UbMwkT8iuOVvEia2FWvo=; b=RvW8NzDPSykHVjDhUcldnfYsxmwWaIVSqFjaCLpsS0RlolnM2bj4zOPOosZ96TLBC+OXMKR0CR+sbk0wWV4AEnFgHMNaNeNhxTeV5/GBJuDbQeQhNRuRyRKnJCX6gLvE3bQoqodYTDk+SnkpyPgbRFsyxOS0/BlKmmHAmRzUdvnsfs7pkQbwLjZzX1uDiD/EP4E8itMq5KsFw1q7Gs/LhZiSfOCIGvtH+CjaM4Vyp8ULPlTHO5lwDVOfhwRXAgLBhZfglujf1WTp14Uga12So2J+9FoFStZEAhikBuMF3XLinbucwongYmI/1GHodPb2TEbgtkDf8nPk52WxAXyHFA== 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 DM6PR11MB4140.namprd11.prod.outlook.com (2603:10b6:5:19f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Mon, 17 Jan 2022 23:24:11 +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:11 +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 02/10] drm: test-drm_plane_helper: Convert to KUnit Date: Tue, 18 Jan 2022 00:22:51 +0100 Message-ID: <20220117232259.180459-3-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: AS9PR06CA0014.eurprd06.prod.outlook.com (2603:10a6:20b:462::8) 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: bb2fc346-6551-4805-3bfb-08d9da1077ca X-MS-TrafficTypeDiagnostic: DM6PR11MB4140:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eyEw58PhmdEnu4PRdmSwoiUtiiGNUOe5fBBjIodulWfISVWqvkCo6yzeaW07Q52BcMJgIFAbbBdfOVE8zadbDxuVQO6v1PpYlWA1ZujY9brvvSmOGEzd5vVGFLLDE8DqRRq1NkWdvCDG4YtZZv+PbjQYOSJ+62nyl7fq23Wvd+Yr1TWT+Ku90kdqlaTz/07HgFK2Bh2M38hO6oaay53JKSZAnX8pK+L5WmPt3sVp5u2vk9PZZiZs1QCFLUmncHFkwwzwxH5wlgjuYxngbBtNMwt43wuADtjOft+6409/AOWAEtQNfh0uKP4XGDVrjDPnenctLpHgOZHyipX0OkMu92uB6jsxdgv61YP/SxQK85HkDx9rqgcEkbjf3CVHPGr4RNa+RvmV2viOeEoNdBqxuYEWoNiTbm52bsV6BHl61iakU82JQ9A4HAgT+9+Q4xYdpHl6ZbJ2utbxqy0NBIl29URjZ34GnO7btAsT1RYNuqiUC8jz25+ByLjJTc2NC+9fgxgmSvuf83nZB4My9OX/jG3Jiag75xyfKiDlDHrI9uvpXwrBT0HYr1Uj0tc/qjhkpIO7sqwkarP0tDHE2+nb9jxFhYJOcyBBgbV7QAWePzShlEJe0RPB8XcmXDym0EyuX1Qa4gwyjRdF+DLGKwRzGQ== 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)(508600001)(7416002)(186003)(6506007)(82960400001)(86362001)(8676002)(6512007)(6666004)(83380400001)(38100700002)(8936002)(66556008)(30864003)(54906003)(5660300002)(2906002)(6486002)(316002)(36756003)(2616005)(66946007)(26005)(1076003)(4326008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?74dxfr8ENZanjDAVbQ/a+AMqEuF1?= =?utf-8?q?Fe74hXekR3eqPqAqkdBRq6DqXoXNJ4+PMQLCrmRF6uomRQIvcboGiTMZLqJbe00Pr?= =?utf-8?q?/KlGjhL9bWvGF/VwHb2WJgRApXKhJaAOA09RPEBWkUPkk34NBaKSEnV/StPSflJEt?= =?utf-8?q?TA3DCkoYnXqkWtNVhDjcAVHcXUmyTgnSeftl4N22+RBSnucTSj6F3uBnCzWDSROIT?= =?utf-8?q?Hsty1Myhp+KL1eTlunj6xJ7TL4yONE+dXXlU1wqeK6SoM5b3yzedtX5JNzYjJFOc1?= =?utf-8?q?wPb/GB7IsyZLXcLJ05Fl/1lbiEGw8TWAQWaSSas7RCvKL2B2lZ2lhsMmk7ZWFZA4h?= =?utf-8?q?6WGQccePzqrsHvxRhXFSRP2I9YrXigsugzYuMjCvXICq3ApNriBzVB0GUywTGSb2F?= =?utf-8?q?xALQ/BbyUzU9tgXBex7HjsGMx/7m+Cr4fn250j2MX3e+TJ+KVUUT8qahBsO/Egwpr?= =?utf-8?q?tegcONyLYdIssEN+idZLGwzP4WKBvGDY92eO9vM0C3Sub4tG5r8Ve1qHMuw7x8+06?= =?utf-8?q?E+dKuO8JHnzIELO0smltOLz0RHfnLxPzQS/4djP3KY+AKpCX18eObAAJi4i+65PPL?= =?utf-8?q?+szh+ziCbjnBvnEpkks3FX5vI4XREf7TyLNQRg0WOxp0zFMUYtyA5LuKcC4Ii6cRU?= =?utf-8?q?aAnO2F+btFzr7F2H2zgEzSMCMvAu0wTSilhCRJfyuWOL+ItkVtSWn0lOceyzfcSWR?= =?utf-8?q?oMbhr+SFyJWc/S7o945Gnau3b6m01VgNoiYkSfLeEdrjEnn++lLSxHc8ey3UNgb5T?= =?utf-8?q?HPJl/1ROSieaxLkwcu8WKAohjaNCCdUooR3/qMQspp3UHvqOldaP+jZ/dtBgCEXr2?= =?utf-8?q?AD+gdkl785dbGVOEg59r3cWLttT7CV2DoVv6N/CJ0Mu7Y7ZQtkO5P3jPMESMNQGpl?= =?utf-8?q?bFpLs6Hbo4gn/lAsrB0R/ecLP9otMR8vyJkLg6uny1f+2+zn9d2ijFIosTUq+ThX1?= =?utf-8?q?Ip86Se5sIc37hTaCB1SQxwdaGtW1Lzwb9K5HpK7seLWTruvfLp4vI1g1kjA/w41RK?= =?utf-8?q?11d/MOJ2E+A+c8p9abSAi3axnAnzv7D8f7byCKcQ4Xg47sv36i2/NwU3hlDZCR+ch?= =?utf-8?q?rKCSgA4Fm8dJtVUBPI8tBP4JmB4Ce2ubA/g5NWCyp0OWi4X9roBaEBeB2kOOdcQYI?= =?utf-8?q?0scyCRfi8iEeIEcSOLdgfsEa39WI28JQbWzfVf9PUBUXSfZ3JVrVZgj52fr1Rj1UE?= =?utf-8?q?HFTo4ADNDeDIwCTeBlPLlwOqYCV13zF7VO/GMjsuC1nHN392vF7oM7Gr3Q/sHwKsi?= =?utf-8?q?EKWv+bD/5Gk5I1UiZtXKOaqsKn1w6agjtcJ56ctMTiP14AQ0ZJm7AoJG476FpGSYr?= =?utf-8?q?EpQJF+ArSQp+k3TJPAok0NZL4Uf+nNZmr/JUljViVxVpu1BoTPqgsZX/BRFj7uIqf?= =?utf-8?q?wW+zilJFhAcxh7yrygyH9Y/f1U3IVFfNXRoe4v/MR9vmElDM4XnuLaiWn6mftTQaB?= =?utf-8?q?HAlIgQT/Bz80BhgSHMeBYgOfcV+tUo5fDgpGp/FTyB60rALqxjXaiKE2k4q9QoRb1?= =?utf-8?q?6vw7w1bVzugAmmVC/jZaEywvHoCpNy9DdaHTOsprFVhBaMyiXiLSGUFKu1PC2njhT?= =?utf-8?q?VhZ96iORKZT2anIif/Srho+elCpRMfumg=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: bb2fc346-6551-4805-3bfb-08d9da1077ca 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:11.5741 (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: 1nYBgYqBITnPlsBI8YPsfkye92+RW18dVR0ZhyTDA+TZmXA4lbU0g47/BXs8sLqihIkCL4QjvO1Ee15izePK8+QTzIom4smq8mjPHtiZPXs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4140 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Tests were converted into parameterized test cases. Negative tests were separated. Mocking was moved to test->init(). No functional changes. Signed-off-by: Michał Winiarski --- drivers/gpu/drm/Kconfig | 1 + drivers/gpu/drm/selftests/Makefile | 4 +- .../gpu/drm/selftests/drm_modeset_selftests.h | 1 - .../drm/selftests/test-drm_modeset_common.h | 1 - .../gpu/drm/selftests/test-drm_plane_helper.c | 483 +++++++++++------- 5 files changed, 289 insertions(+), 201 deletions(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 21e329f32997..89be0df7b0e9 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -83,6 +83,7 @@ config DRM_DEBUG_SELFTEST config DRM_KUNIT_TEST bool "DRM tests" if !KUNIT_ALL_TESTS depends on DRM=y && KUNIT=y + select DRM_KMS_HELPER default KUNIT_ALL_TESTS help Enables unit tests for DRM. Only useful for kernel devs running KUnit. diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/selftests/Makefile index 6411c9a957b3..82e568665ace 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-$(CONFIG_DRM_DEBUG_SELFTEST) := \ - test-drm_modeset_common.o test-drm_plane_helper.o \ + test-drm_modeset_common.o \ test-drm_format.o test-drm_framebuffer.o \ test-drm_damage_helper.o test-drm_dp_mst_helper.o \ test-drm_rect.o @@ -8,4 +8,4 @@ test-drm_modeset-$(CONFIG_DRM_DEBUG_SELFTEST) := \ obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o obj-$(CONFIG_DRM_KUNIT_TEST) := \ - test-drm_cmdline_parser.o + test-drm_cmdline_parser.o test-drm_plane_helper.o diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h b/drivers/gpu/drm/selftests/drm_modeset_selftests.h index 782e285ca383..19d1142725c6 100644 --- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h +++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h @@ -10,7 +10,6 @@ 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) -selftest(check_plane_state, igt_check_plane_state) selftest(check_drm_format_block_width, igt_check_drm_format_block_width) selftest(check_drm_format_block_height, igt_check_drm_format_block_height) selftest(check_drm_format_min_pitch, igt_check_drm_format_min_pitch) diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h index cfb51d8da2bc..8744fd840406 100644 --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h @@ -20,7 +20,6 @@ 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); -int igt_check_plane_state(void *ignored); int igt_check_drm_format_block_width(void *ignored); int igt_check_drm_format_block_height(void *ignored); int igt_check_drm_format_min_pitch(void *ignored); diff --git a/drivers/gpu/drm/selftests/test-drm_plane_helper.c b/drivers/gpu/drm/selftests/test-drm_plane_helper.c index ceebeede55ea..f2c0cd37a949 100644 --- a/drivers/gpu/drm/selftests/test-drm_plane_helper.c +++ b/drivers/gpu/drm/selftests/test-drm_plane_helper.c @@ -3,221 +3,310 @@ * Test cases for the drm_plane_helper functions */ -#define pr_fmt(fmt) "drm_plane_helper: " fmt +#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) +static void expect_src_eq(struct kunit *test, struct drm_plane_state *plane_state, + 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; - plane_state->src_w = src_w; - plane_state->src_h = src_h; + KUNIT_EXPECT_GE_MSG(test, plane_state->src.x1, 0, + "src x coordinate %x should never be below 0, src: " DRM_RECT_FP_FMT, + plane_state->src.x1, DRM_RECT_FP_ARG(&plane_state->src)); + KUNIT_EXPECT_GE_MSG(test, plane_state->src.y1, 0, + "src y coordinate %x should never be below 0, src: " DRM_RECT_FP_FMT, + plane_state->src.y1, DRM_RECT_FP_ARG(&plane_state->src)); + + KUNIT_EXPECT_TRUE_MSG(test, + plane_state->src.x1 == src_x && + plane_state->src.y1 == src_y && + drm_rect_width(&plane_state->src) == src_w && + drm_rect_height(&plane_state->src) == src_h, + "src: " DRM_RECT_FP_FMT, DRM_RECT_FP_ARG(&plane_state->src)); } -static bool check_src_eq(struct drm_plane_state *plane_state, - unsigned src_x, unsigned src_y, - unsigned src_w, unsigned src_h) +static void expect_crtc_eq(struct kunit *test, struct drm_plane_state *plane_state, + int crtc_x, int crtc_y, + unsigned int crtc_w, unsigned int crtc_h) { - if (plane_state->src.x1 < 0) { - pr_err("src x coordinate %x should never be below 0.\n", plane_state->src.x1); - drm_rect_debug_print("src: ", &plane_state->src, true); - return false; - } - if (plane_state->src.y1 < 0) { - pr_err("src y coordinate %x should never be below 0.\n", plane_state->src.y1); - drm_rect_debug_print("src: ", &plane_state->src, true); - return false; - } - - if (plane_state->src.x1 != src_x || - plane_state->src.y1 != src_y || - drm_rect_width(&plane_state->src) != src_w || - drm_rect_height(&plane_state->src) != src_h) { - drm_rect_debug_print("src: ", &plane_state->src, true); - return false; - } - - return true; + KUNIT_EXPECT_TRUE_MSG(test, + plane_state->dst.x1 == crtc_x && + plane_state->dst.y1 == crtc_y && + drm_rect_width(&plane_state->dst) == crtc_w && + drm_rect_height(&plane_state->dst) == crtc_h, + "dst: " DRM_RECT_FMT, DRM_RECT_ARG(&plane_state->dst)); } -static void set_crtc(struct drm_plane_state *plane_state, - int crtc_x, int crtc_y, - unsigned crtc_w, unsigned crtc_h) +const struct drm_crtc_state crtc_state = { + .crtc = ZERO_SIZE_PTR, + .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) + }, +}; + +struct drm_check_plane_state_test { + const char *name; + const char *msg; + struct { + unsigned int x; + unsigned int y; + unsigned int w; + unsigned int h; + } src, src_expected; + struct { + int x; + int y; + unsigned int w; + unsigned int h; + } crtc, crtc_expected; + unsigned int rotation; + int min_scale; + int max_scale; + bool can_position; +}; + +static int drm_plane_helper_init(struct kunit *test) { - plane_state->crtc_x = crtc_x; - plane_state->crtc_y = crtc_y; - plane_state->crtc_w = crtc_w; - plane_state->crtc_h = crtc_h; + const struct drm_check_plane_state_test *params = test->param_value; + struct drm_plane *plane; + struct drm_framebuffer *fb; + struct drm_plane_state *mock; + + plane = kunit_kzalloc(test, sizeof(*plane), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, plane); + + fb = kunit_kzalloc(test, sizeof(*fb), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fb); + fb->width = 2048; + fb->height = 2048; + + mock = kunit_kzalloc(test, sizeof(*mock), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, mock); + mock->plane = plane; + mock->crtc = ZERO_SIZE_PTR; + mock->fb = fb; + mock->rotation = params->rotation; + mock->src_x = params->src.x; + mock->src_y = params->src.y; + mock->src_w = params->src.w; + mock->src_h = params->src.h; + mock->crtc_x = params->crtc.x; + mock->crtc_y = params->crtc.y; + mock->crtc_w = params->crtc.w; + mock->crtc_h = params->crtc.h; + + test->priv = mock; + + return 0; } -static bool check_crtc_eq(struct drm_plane_state *plane_state, - int crtc_x, int crtc_y, - unsigned crtc_w, unsigned crtc_h) +void drm_check_plane_state(struct kunit *test) { - if (plane_state->dst.x1 != crtc_x || - plane_state->dst.y1 != crtc_y || - drm_rect_width(&plane_state->dst) != crtc_w || - drm_rect_height(&plane_state->dst) != crtc_h) { - drm_rect_debug_print("dst: ", &plane_state->dst, false); - - return false; - } + const struct drm_check_plane_state_test *params = test->param_value; + struct drm_plane_state *plane_state = test->priv; - return true; + KUNIT_ASSERT_EQ_MSG(test, + drm_atomic_helper_check_plane_state(plane_state, &crtc_state, + params->min_scale, + params->max_scale, + params->can_position, false), + 0, params->msg); + KUNIT_EXPECT_TRUE(test, plane_state->visible); + expect_src_eq(test, plane_state, params->src_expected.x, params->src_expected.y, + params->src_expected.w, params->src_expected.h); + expect_crtc_eq(test, plane_state, params->crtc_expected.x, params->crtc_expected.y, + params->crtc_expected.w, params->crtc_expected.h); } -int igt_check_plane_state(void *ignored) +void drm_check_invalid_plane_state(struct kunit *test) { - int ret; - - const struct drm_crtc_state crtc_state = { - .crtc = ZERO_SIZE_PTR, - .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) - }, - }; - struct drm_plane plane = { - .dev = NULL - }; - struct drm_framebuffer fb = { - .width = 2048, - .height = 2048 - }; - struct drm_plane_state plane_state = { - .plane = &plane, - .crtc = ZERO_SIZE_PTR, - .fb = &fb, - .rotation = DRM_MODE_ROTATE_0 - }; - - /* Simple clipping, no scaling. */ - set_src(&plane_state, 0, 0, fb.width << 16, fb.height << 16); - set_crtc(&plane_state, 0, 0, fb.width, fb.height); - ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, - 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)); - - /* Rotated clipping + reflection, no scaling. */ - plane_state.rotation = DRM_MODE_ROTATE_90 | DRM_MODE_REFLECT_X; - ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, - 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)); - plane_state.rotation = DRM_MODE_ROTATE_0; - - /* Check whether positioning works correctly. */ - set_src(&plane_state, 0, 0, 1023 << 16, 767 << 16); - set_crtc(&plane_state, 0, 0, 1023, 767); - ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, - 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"); - - 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)); - - /* Simple scaling tests. */ - set_src(&plane_state, 0, 0, 512 << 16, 384 << 16); - set_crtc(&plane_state, 0, 0, 1024, 768); - ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, - 0x8001, - DRM_PLANE_HELPER_NO_SCALING, - false, false); - FAIL(!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)); - - 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"); - 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)); - - /* Testing rounding errors. */ - set_src(&plane_state, 0, 0, 0x40001, 0x40001); - set_crtc(&plane_state, 1022, 766, 4, 4); - ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, - 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)); - - set_src(&plane_state, 0x20001, 0x20001, 0x4040001, 0x3040001); - set_crtc(&plane_state, -2, -2, 1028, 772); - ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, - 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)); - - set_src(&plane_state, 0, 0, 0x3ffff, 0x3ffff); - set_crtc(&plane_state, 1022, 766, 4, 4); - ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, - 0xffff, - DRM_PLANE_HELPER_NO_SCALING, - true, false); - FAIL(ret < 0, "Should succeed by clipping to exact multiple"); - FAIL_ON(!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)); - - set_src(&plane_state, 0x1ffff, 0x1ffff, 0x403ffff, 0x303ffff); - set_crtc(&plane_state, -2, -2, 1028, 772); - ret = drm_atomic_helper_check_plane_state(&plane_state, &crtc_state, - 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)); + const struct drm_check_plane_state_test *params = test->param_value; + struct drm_plane_state *plane_state = test->priv; - return 0; + KUNIT_ASSERT_LT_MSG(test, + drm_atomic_helper_check_plane_state(plane_state, &crtc_state, + params->min_scale, + params->max_scale, + params->can_position, false), + 0, params->msg); +} + +static const struct drm_check_plane_state_test drm_check_plane_state_tests[] = { + { + .name = "clipping_simple", + .msg = "Simple clipping check should pass", + .src = { 0, 0, + 2048 << 16, + 2048 << 16 }, + .crtc = { 0, 0, 2048, 2048 }, + .rotation = DRM_MODE_ROTATE_0, + .min_scale = DRM_PLANE_HELPER_NO_SCALING, + .max_scale = DRM_PLANE_HELPER_NO_SCALING, + .can_position = false, + .src_expected = { 0, 0, 1024 << 16, 768 << 16 }, + .crtc_expected = { 0, 0, 1024, 768 }, + }, + { + .name = "clipping_rotate_reflect", + .msg = "Rotated clipping check should pass", + .src = { 0, 0, + 2048 << 16, + 2048 << 16 }, + .crtc = { 0, 0, 2048, 2048 }, + .rotation = DRM_MODE_ROTATE_90 | DRM_MODE_REFLECT_X, + .min_scale = DRM_PLANE_HELPER_NO_SCALING, + .max_scale = DRM_PLANE_HELPER_NO_SCALING, + .can_position = false, + .src_expected = { 0, 0, 768 << 16, 1024 << 16 }, + .crtc_expected = { 0, 0, 1024, 768 }, + }, + { + .name = "positioning_simple", + .msg = "Simple positioning should work", + .src = { 0, 0, 1023 << 16, 767 << 16 }, + .crtc = { 0, 0, 1023, 767 }, + .rotation = DRM_MODE_ROTATE_0, + .min_scale = DRM_PLANE_HELPER_NO_SCALING, + .max_scale = DRM_PLANE_HELPER_NO_SCALING, + .can_position = true, + .src_expected = { 0, 0, 1023 << 16, 767 << 16 }, + .crtc_expected = { 0, 0, 1023, 767 }, + }, + { + .name = "upscaling", + .msg = "Upscaling exactly 2x should work", + .src = { 0, 0, 512 << 16, 384 << 16 }, + .crtc = { 0, 0, 1024, 768 }, + .rotation = DRM_MODE_ROTATE_0, + .min_scale = 0x8000, + .max_scale = DRM_PLANE_HELPER_NO_SCALING, + .can_position = false, + .src_expected = { 0, 0, 512 << 16, 384 << 16 }, + .crtc_expected = { 0, 0, 1024, 768 }, + }, + { + .name = "downscaling", + .msg = "Should succeed with exact scaling limit", + .src = { 0, 0, 2048 << 16, 1536 << 16 }, + .crtc = { 0, 0, 1024, 768 }, + .rotation = DRM_MODE_ROTATE_0, + .min_scale = DRM_PLANE_HELPER_NO_SCALING, + .max_scale = 0x20000, + .can_position = false, + .src_expected = { 0, 0, 2048 << 16, 1536 << 16 }, + .crtc_expected = { 0, 0, 1024, 768 }, + }, + { + .name = "rounding1", + .msg = "Should succeed by clipping to exact multiple", + .src = { 0, 0, 0x40001, 0x40001 }, + .crtc = { 1022, 766, 4, 4 }, + .rotation = DRM_MODE_ROTATE_0, + .min_scale = DRM_PLANE_HELPER_NO_SCALING, + .max_scale = 0x10001, + .can_position = true, + .src_expected = { 0, 0, 2 << 16, 2 << 16 }, + .crtc_expected = { 1022, 766, 2, 2 }, + }, + { + .name = "rounding2", + .msg = "Should succeed by clipping to exact multiple", + .src = { 0x20001, 0x20001, 0x4040001, 0x3040001 }, + .crtc = { -2, -2, 1028, 772 }, + .rotation = DRM_MODE_ROTATE_0, + .min_scale = DRM_PLANE_HELPER_NO_SCALING, + .max_scale = 0x10001, + .can_position = false, + .src_expected = { 0x40002, 0x40002, 1024 << 16, 768 << 16 }, + .crtc_expected = { 0, 0, 1024, 768 }, + }, + { + .name = "rounding3", + .msg = "Should succeed by clipping to exact multiple", + .src = { 0, 0, 0x3ffff, 0x3ffff }, + .crtc = { 1022, 766, 4, 4 }, + .rotation = DRM_MODE_ROTATE_0, + .min_scale = 0xffff, + .max_scale = DRM_PLANE_HELPER_NO_SCALING, + .can_position = true, + /* Should not be rounded to 0x20001, which would be upscaling. */ + .src_expected = { 0, 0, 2 << 16, 2 << 16 }, + .crtc_expected = { 1022, 766, 2, 2 }, + }, + { + .name = "rounding4", + .msg = "Should succeed by clipping to exact multiple", + .src = { 0x1ffff, 0x1ffff, 0x403ffff, 0x303ffff }, + .crtc = { -2, -2, 1028, 772 }, + .rotation = DRM_MODE_ROTATE_0, + .min_scale = 0xffff, + .max_scale = DRM_PLANE_HELPER_NO_SCALING, + .can_position = false, + .src_expected = { 0x3fffe, 0x3fffe, 1024 << 16, 768 << 16 }, + .crtc_expected = { 0, 0, 1024, 768 }, + }, +}; + +static const struct drm_check_plane_state_test drm_check_invalid_plane_state_tests[] = { + { + .name = "positioning_invalid", + .msg = "Should not be able to position on the crtc with can_position=false", + .src = { 0, 0, 1023 << 16, 767 << 16 }, + .crtc = { 0, 0, 1023, 767 }, + .rotation = DRM_MODE_ROTATE_0, + .min_scale = DRM_PLANE_HELPER_NO_SCALING, + .max_scale = DRM_PLANE_HELPER_NO_SCALING, + .can_position = false, + }, + { + .name = "upscaling_invalid", + .msg = "Upscaling out of range should fail", + .src = { 0, 0, 512 << 16, 384 << 16 }, + .crtc = { 0, 0, 1024, 768 }, + .rotation = DRM_MODE_ROTATE_0, + .min_scale = 0x8001, + .max_scale = DRM_PLANE_HELPER_NO_SCALING, + .can_position = false, + }, + { + .name = "downscaling_invalid", + .msg = "Downscaling out of range should fail", + .src = { 0, 0, 2048 << 16, 1536 << 16 }, + .crtc = { 0, 0, 1024, 768 }, + .rotation = DRM_MODE_ROTATE_0, + .min_scale = DRM_PLANE_HELPER_NO_SCALING, + .max_scale = 0x1ffff, + .can_position = false, + }, +}; + +static void drm_check_plane_state_desc(const struct drm_check_plane_state_test *t, + char *desc) +{ + sprintf(desc, "%s", t->name); } + +KUNIT_ARRAY_PARAM(drm_check_plane_state, drm_check_plane_state_tests, drm_check_plane_state_desc); +KUNIT_ARRAY_PARAM(drm_check_invalid_plane_state, drm_check_invalid_plane_state_tests, + drm_check_plane_state_desc); + +static struct kunit_case drm_plane_helper_tests[] = { + KUNIT_CASE_PARAM(drm_check_plane_state, drm_check_plane_state_gen_params), + KUNIT_CASE_PARAM(drm_check_invalid_plane_state, drm_check_invalid_plane_state_gen_params), + {} +}; + +static struct kunit_suite drm_plane_helper_test_suite = { + .name = "drm_plane_helper_tests", + .init = drm_plane_helper_init, + .test_cases = drm_plane_helper_tests, +}; + +kunit_test_suite(drm_plane_helper_test_suite); From patchwork Mon Jan 17 23:22:52 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: 12715719 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 8C56BC433F5 for ; Mon, 17 Jan 2022 23:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235370AbiAQXYX (ORCPT ); Mon, 17 Jan 2022 18:24:23 -0500 Received: from mga01.intel.com ([192.55.52.88]:50746 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243793AbiAQXYW (ORCPT ); Mon, 17 Jan 2022 18:24:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642461862; x=1673997862; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=swnG8/c7DsJ5oPG4e35lbHo5YFh8MnajcJlYvRMPnv8=; b=QV+VKvNjVtD6o5Pd1NEj/99ntGDbmjSDMIhEJ/16AymqwOs2VITImc+6 TPDrDBMMdI9nGbrDJhdh7pzeSp5weeI5roATopfTKHhn0UPm7SZVAGGTi Ewr+ZhetJNzCLXKc3BoSZy3z/iOessmdmzluCJU8M4mgokn0tcacZOmz/ heCWRtzU47Ob4VjvriuYFERR5nfb4BaOUCyvImjHY/lqZh1m7rLNesYNw fPdMR8DulW8Htxzk+CB0+Mh8ilddkYi0y+D7WnGboTww7Vj1XQwrvvXor ZUkZIg0OfOTM9rRTvXpHQSQt5ceLLIl+JV1YvgZ5IQdJVDj6g58kQ6QXa g==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="269082567" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="269082567" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2022 15:24:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="517554371" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga007.jf.intel.com with ESMTP; 17 Jan 2022 15:24:21 -0800 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) 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:21 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx604.amr.corp.intel.com (10.18.126.84) 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:21 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.177) by edgegateway.intel.com (192.55.55.70) 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:20 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FFrNGfu0Ak55TZwGFO2W89o0G4XRxXbUFeTtpiPPcAbW4/5n/XBuMbJ2jh53HlUbktpYSibr0+rXGNKXzRmmwCnRkZdN6CXyC5BzkZ6jGJ4aRJZ76q170wlo8ef4hDNTJVXsm8AX33aQNW5kKSuRkNpTa+Ny2x3VUZVxSC9DUcMD/GqzZP+Bl4ueLRsKbyRUtyE95fPEmg9yN82/241OQoa3bhVam7ZPoWlOfCmic/AKH4aHJEe0rofWN5ePzQku0mZ12j3z4qbhJXo9cJvklhCnYnsYXWq6ZempnreRGcoQhvs8DOytrtd0WGc5lUBMgRmGsMxXCH9c5zG9E/dU4w== 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=NHyPfEys4IQHHru+dAQdDzI2mIXlV376xQC14vdPoSk=; b=O6mwV5DlTzMNwJsefk3ZkWMoe0dN5bN1FgDQHsgV6nKPov3LvmyOrI5qzB1v5PG3j2AJJQ5c+m/m8h02OS7gFZFjcy8F1KC+AV5AnL3yEVLLBsITjiwJmZ/LDwNcvRVIqiJhr+C0fzQd7sl8/wOoe9y3hJssToYm4LuzK8VVMy1kDH1SGDBBaamP77nzeb0iLGRQfn3djVqqWwX7GCVXliCEWMGGNIQr/w2GHGDXSwU70NTbbK782OelF/85o9ciwjSjOBn4pndpNg+UEQiLuYb7Z6ZP4A94GEbbo4K9bPo0VhwKpTrd/7Cc1JZfXNnGhV0Qf+Dj1h6OqB+K5PoJ2Q== 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 DM6PR11MB4140.namprd11.prod.outlook.com (2603:10b6:5:19f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Mon, 17 Jan 2022 23:24:17 +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:17 +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 03/10] drm: test-drm_format: Convert to KUnit Date: Tue, 18 Jan 2022 00:22:52 +0100 Message-ID: <20220117232259.180459-4-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: AS9PR06CA0003.eurprd06.prod.outlook.com (2603:10a6:20b:462::9) 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: 7e99b73e-ca08-43ee-a9e3-08d9da107b3c X-MS-TrafficTypeDiagnostic: DM6PR11MB4140:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8ywP3NHXO5Qk9wFnAmhSuGl5sAbtFQGEHIqiT3tBRiGOI0gVeFJa2pK5w1Pwz/v4+TVVkRiy2z6y4pQDXL9SpewsVpCbLiM341zw++hD1NDmUUFo+vbVKAjxP2eBPHDieIPoXsJu+x69XJBcFRflaM7XyqCBHb/vJrJHlGoPIVcgTYjqBH7cMwhG6a2ciQbXTY6gY4OFYzix0l4/fpl8Cn682MI5eqs2DJA21m29QYxGj8r6xRgCmdW9DKbGD+BpZv7i3d5ISlGo7hdvDVO9mSslpVNJI6/OShuWzJ53d7yr6ervQjQXpwxXbiIlGjx+t2wurFNCHM9cHbSYlsVIYooMCYTxkuu1qm5EKBdnLw2nJpNX+0enEvOswuguFbPedVLTYiwJYOKAHvBX2oXYhZ7Vd2c3XyGflUmi0lCwFxVxTlfpwxZjNMsyaCqriIBpy6dQSwg9huzDadpTuH9G3Pztgi9HzrGoRgLOuxbU9b0xg2zaE53HgpVIDEikVfhLrJKSl8lGqDWZ/oDFjrj1LSSYgwYruqML+xedBQdjTM1ZDT6BZkHk+rvy7p9gb/cb9Vuso1g/ch8Q62lIppdove2UGssp4Gh9wzOp+RGw8VnkdwMAMF75/7QMJzN04NImVjFPfEmxXlxcgTeMNkBT/Q== 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)(508600001)(7416002)(186003)(6506007)(82960400001)(86362001)(8676002)(6512007)(6666004)(83380400001)(38100700002)(8936002)(66556008)(30864003)(54906003)(5660300002)(2906002)(6486002)(316002)(36756003)(2616005)(66946007)(26005)(1076003)(4326008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?aOWLw6wZolEJ9dAEQtWyI0o0kJIn?= =?utf-8?q?i20lbLIiJASGu+jiq55EPlyooxhDAmiU5xw1oBU4Oz5nbIwwnkfrwGZal6DnwnvbE?= =?utf-8?q?OobxxYXWYyouS032an4AmBnXofF+bGhpeoQtOy7/gFPqLychGXV3igrKArN83hilN?= =?utf-8?q?G54o8y5fzmgz2oiKI6Bre8gzlojpWFZCOM4q+kK51KSl3HWu/LyttQYhOJnCnSMm7?= =?utf-8?q?Tfscz+z/QG7OCkmaQBBrJ8mnZiLwBeNkn1k5UXYwqxTIpKf79ysGtqOnW9D9C5zzO?= =?utf-8?q?aFBd6Uj6BdIT7nDRpJN1aRj6z7D5fF8yl9/eBQjxSy+sI/ah9EdJEJLRdiFQ1sLGS?= =?utf-8?q?vCPpISfxXQLj9Bmnb+fbK/VecOdYwGsHsOnrkUDTPi9/UBALg4YxTCIffcZ4SXCJX?= =?utf-8?q?3k/z4ZDYTkfUOUDMj3cawkWHkE4lQhPwi8C7ZEV2zLR6NFng6jrQhs3yFCaadVTyl?= =?utf-8?q?cbmjieb7XLyIyC4VbiPdmMzl5/nnLtUCHd+87dwm6QGU6Nv0C5/CkweQ5ZdNWVXgQ?= =?utf-8?q?5tWSk3RRs5N6dJrKYLLSZPCNw9pIe2SEkCRmqFGTho0rxKUkecKv6iThb/1iOX4l/?= =?utf-8?q?IlDNzeXCtMpzO8cXLXhGicUbAePE8p1oLENpDX4Na+WnXVvJQYml2te3c3CtAEpYC?= =?utf-8?q?0mN/qkkvsG9XFm24WOuSGKt1mOW0m8Owt7eI1Up5IYn2QMyZu81QPMDXkzErrwIlh?= =?utf-8?q?/EquVrWkY/U2hPCo6hU8bEtDNxEu4+kujXaAopQn0NFAKmxw5rmKPwUR+i3GdwQzP?= =?utf-8?q?RrHUcw+uHPLIiJwxeVLkF0wPmPY+Mp0Ssus2aKEnHj/cRyNsNW8o/gWqdaxmGXCin?= =?utf-8?q?nlf/5EyM8TA7lHYI/RdxEOxS62ho+ZRUcNMgraeNSlW6trQEDr1zAK3etY4kNrW4/?= =?utf-8?q?nuf8WYHWMhASeQ6qi59UGMGpT0l7zQ6juYxEOXy/Fo/jUd7hft9aE7PFXNdFb3MJW?= =?utf-8?q?kM4HyRanumQjjLW1bT0rnscPn4KwdL+Wp4/RoqPaFrzvn885Q7NQKZRKOEwy8bVht?= =?utf-8?q?jkjpPClnQIo3yZuc1BnQnSFcwhR2AUP6VYk2Qvb11dyIOwY5kHLXFNgwmwW754nTU?= =?utf-8?q?MHP7Cgg2PGjM8+BSgmTihgquEClDy1GpiwAqY9XbfTX2quqLdjC8GwkvPQ+lJala9?= =?utf-8?q?ZW/iTGC3pkPgFxcp+3qX+QrLGn/zPd6QoSq7ucollBF018vsKbssJKG+CfYkBGEgs?= =?utf-8?q?qJ25zeVVR/zFPqwx4O8VK6W8BGZf9HUysUiVKPyRfUvoDQjutG/M9FE7AzW8dydkG?= =?utf-8?q?safWHS9CGkEqlscnijnVpun7Pe2i2BMNUxGJt6/ZWu5NdFFNaTLjFiB7z6XmMlp3y?= =?utf-8?q?vzDq2iMLTTIBdD53ftOcKnaEO08bCeWBv/rfy3VoG25SU4gQADNvgUjoanNvvGxIH?= =?utf-8?q?IROAbDvgJtxP56XbduzTQmdqbgR1whhD8kgzALw94Ia29vz+b1q1JZxMYn5F+7u5C?= =?utf-8?q?pyNkd4O5HdZcTToHL/GqgUFPIZYbWoYuADHM5t2W6PbG7hgvZr5rSboWcK7rs4//9?= =?utf-8?q?olIiTdYklKg+RKly90ZKPk30ahBoU2krKNPczMaJOiZXKsq1UX0R2OoLDGzX+kxzb?= =?utf-8?q?2S0THncvIL2o4Ovf+T7e8bMBzra1QJDPw=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 7e99b73e-ca08-43ee-a9e3-08d9da107b3c 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:17.4509 (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: Mlu3DtV/Tu+n7zTZCxbthkfzgUqTYE359N2J2FBxTdGKamZ4CVVkfaWcao7OKNt2zhM+F41yvFd7BAxKM7Fv2dcb34BFSyn++bU2LswIZRg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4140 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org One-to-one conversion, no functional changes. Signed-off-by: Michał Winiarski --- drivers/gpu/drm/selftests/Makefile | 5 +- .../gpu/drm/selftests/drm_modeset_selftests.h | 3 - drivers/gpu/drm/selftests/test-drm_format.c | 538 ++++++++++-------- .../drm/selftests/test-drm_modeset_common.h | 3 - 4 files changed, 310 insertions(+), 239 deletions(-) diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/selftests/Makefile index 82e568665ace..76c127613d1a 100644 --- a/drivers/gpu/drm/selftests/Makefile +++ b/drivers/gpu/drm/selftests/Makefile @@ -1,11 +1,12 @@ # SPDX-License-Identifier: GPL-2.0-only test-drm_modeset-$(CONFIG_DRM_DEBUG_SELFTEST) := \ test-drm_modeset_common.o \ - test-drm_format.o test-drm_framebuffer.o \ + test-drm_framebuffer.o \ test-drm_damage_helper.o test-drm_dp_mst_helper.o \ test-drm_rect.o obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o obj-$(CONFIG_DRM_KUNIT_TEST) := \ - test-drm_cmdline_parser.o test-drm_plane_helper.o + test-drm_cmdline_parser.o test-drm_plane_helper.o \ + test-drm_format.o diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h b/drivers/gpu/drm/selftests/drm_modeset_selftests.h index 19d1142725c6..5f253d9e573c 100644 --- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h +++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h @@ -10,9 +10,6 @@ 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) -selftest(check_drm_format_block_width, igt_check_drm_format_block_width) -selftest(check_drm_format_block_height, igt_check_drm_format_block_height) -selftest(check_drm_format_min_pitch, igt_check_drm_format_min_pitch) selftest(check_drm_framebuffer_create, igt_check_drm_framebuffer_create) selftest(damage_iter_no_damage, igt_damage_iter_no_damage) selftest(damage_iter_no_damage_fractional_src, igt_damage_iter_no_damage_fractional_src) diff --git a/drivers/gpu/drm/selftests/test-drm_format.c b/drivers/gpu/drm/selftests/test-drm_format.c index c5e212afa27a..2774990768a7 100644 --- a/drivers/gpu/drm/selftests/test-drm_format.c +++ b/drivers/gpu/drm/selftests/test-drm_format.c @@ -3,278 +3,354 @@ * Test cases for the drm_format functions */ -#define pr_fmt(fmt) "drm_format: " fmt - -#include -#include +#include #include -#include "test-drm_modeset_common.h" - -int igt_check_drm_format_block_width(void *ignored) +static void drm_format_block_width_invalid(struct kunit *test) { const struct drm_format_info *info = NULL; /* Test invalid arguments */ - FAIL_ON(drm_format_info_block_width(info, 0) != 0); - FAIL_ON(drm_format_info_block_width(info, -1) != 0); - FAIL_ON(drm_format_info_block_width(info, 1) != 0); - - /* Test 1 plane format */ - info = drm_format_info(DRM_FORMAT_XRGB4444); - FAIL_ON(!info); - FAIL_ON(drm_format_info_block_width(info, 0) != 1); - FAIL_ON(drm_format_info_block_width(info, 1) != 0); - FAIL_ON(drm_format_info_block_width(info, -1) != 0); - - /* Test 2 planes format */ - info = drm_format_info(DRM_FORMAT_NV12); - FAIL_ON(!info); - FAIL_ON(drm_format_info_block_width(info, 0) != 1); - FAIL_ON(drm_format_info_block_width(info, 1) != 1); - FAIL_ON(drm_format_info_block_width(info, 2) != 0); - FAIL_ON(drm_format_info_block_width(info, -1) != 0); - - /* Test 3 planes format */ - info = drm_format_info(DRM_FORMAT_YUV422); - FAIL_ON(!info); - FAIL_ON(drm_format_info_block_width(info, 0) != 1); - FAIL_ON(drm_format_info_block_width(info, 1) != 1); - FAIL_ON(drm_format_info_block_width(info, 2) != 1); - FAIL_ON(drm_format_info_block_width(info, 3) != 0); - FAIL_ON(drm_format_info_block_width(info, -1) != 0); - - /* Test a tiled format */ - info = drm_format_info(DRM_FORMAT_X0L0); - FAIL_ON(!info); - FAIL_ON(drm_format_info_block_width(info, 0) != 2); - FAIL_ON(drm_format_info_block_width(info, 1) != 0); - FAIL_ON(drm_format_info_block_width(info, -1) != 0); - - return 0; + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0); +} + +static void drm_format_block_width_one_plane(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0); +} + +static void drm_format_block_width_two_plane(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 2), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0); } -int igt_check_drm_format_block_height(void *ignored) +static void drm_format_block_width_three_plane(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 2), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 3), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0); +} + +static void drm_format_block_width_tiled(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_X0L0); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 2); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0); +} + +static void drm_format_block_height_invalid(struct kunit *test) { const struct drm_format_info *info = NULL; - /* Test invalid arguments */ - FAIL_ON(drm_format_info_block_height(info, 0) != 0); - FAIL_ON(drm_format_info_block_height(info, -1) != 0); - FAIL_ON(drm_format_info_block_height(info, 1) != 0); - - /* Test 1 plane format */ - info = drm_format_info(DRM_FORMAT_XRGB4444); - FAIL_ON(!info); - FAIL_ON(drm_format_info_block_height(info, 0) != 1); - FAIL_ON(drm_format_info_block_height(info, 1) != 0); - FAIL_ON(drm_format_info_block_height(info, -1) != 0); - - /* Test 2 planes format */ - info = drm_format_info(DRM_FORMAT_NV12); - FAIL_ON(!info); - FAIL_ON(drm_format_info_block_height(info, 0) != 1); - FAIL_ON(drm_format_info_block_height(info, 1) != 1); - FAIL_ON(drm_format_info_block_height(info, 2) != 0); - FAIL_ON(drm_format_info_block_height(info, -1) != 0); - - /* Test 3 planes format */ - info = drm_format_info(DRM_FORMAT_YUV422); - FAIL_ON(!info); - FAIL_ON(drm_format_info_block_height(info, 0) != 1); - FAIL_ON(drm_format_info_block_height(info, 1) != 1); - FAIL_ON(drm_format_info_block_height(info, 2) != 1); - FAIL_ON(drm_format_info_block_height(info, 3) != 0); - FAIL_ON(drm_format_info_block_height(info, -1) != 0); - - /* Test a tiled format */ - info = drm_format_info(DRM_FORMAT_X0L0); - FAIL_ON(!info); - FAIL_ON(drm_format_info_block_height(info, 0) != 2); - FAIL_ON(drm_format_info_block_height(info, 1) != 0); - FAIL_ON(drm_format_info_block_height(info, -1) != 0); - - return 0; + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 0); } -int igt_check_drm_format_min_pitch(void *ignored) +static void drm_format_block_height_one_plane(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0); +} + +static void drm_format_block_height_two_plane(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 2), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0); +} + +static void drm_format_block_height_three_plane(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 2), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 3), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0); +} + +static void drm_format_block_height_tiled(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_X0L0); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 2); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0); +} + +static void drm_format_min_pitch_invalid(struct kunit *test) { const struct drm_format_info *info = NULL; - /* Test invalid arguments */ - FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0); - - /* Test 1 plane 8 bits per pixel format */ - info = drm_format_info(DRM_FORMAT_RGB332); - FAIL_ON(!info); - FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0); - - FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 1); - FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 2); - FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 640); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 1024); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 1920); - FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 4096); - FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 671); - FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); +} + +static void drm_format_min_pitch_one_plane_8bpp(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_RGB332); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 2); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 640); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 1024); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 1920); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 4096); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 671); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), (uint64_t)UINT_MAX); - FAIL_ON(drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)), (uint64_t)(UINT_MAX - 1)); +} - /* Test 1 plane 16 bits per pixel format */ - info = drm_format_info(DRM_FORMAT_XRGB4444); - FAIL_ON(!info); - FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0); - - FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 2); - FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 4); - FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 1280); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 2048); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 3840); - FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 8192); - FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 1342); - FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) != +static void drm_format_min_pitch_one_plane_16bpp(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 2); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 4); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 1280); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 2048); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 3840); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 8192); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 1342); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), (uint64_t)UINT_MAX * 2); - FAIL_ON(drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)), (uint64_t)(UINT_MAX - 1) * 2); +} - /* Test 1 plane 24 bits per pixel format */ - info = drm_format_info(DRM_FORMAT_RGB888); - FAIL_ON(!info); - FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0); - - FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 3); - FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 6); - FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 1920); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 3072); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 5760); - FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 12288); - FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 2013); - FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) != +static void drm_format_min_pitch_one_plane_24bpp(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_RGB888); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 3); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 6); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 1920); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 3072); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 5760); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 12288); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 2013); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), (uint64_t)UINT_MAX * 3); - FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX - 1) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX - 1), (uint64_t)(UINT_MAX - 1) * 3); +} - /* Test 1 plane 32 bits per pixel format */ - info = drm_format_info(DRM_FORMAT_ABGR8888); - FAIL_ON(!info); - FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0); - - FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 4); - FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 8); - FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 2560); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 4096); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 7680); - FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 16384); - FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 2684); - FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) != +static void drm_format_min_pitch_one_plane_32bpp(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_ABGR8888); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 4); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 8); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 2560); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 4096); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 7680); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 16384); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 2684); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), (uint64_t)UINT_MAX * 4); - FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX - 1) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX - 1), (uint64_t)(UINT_MAX - 1) * 4); +} - /* Test 2 planes format */ - info = drm_format_info(DRM_FORMAT_NV12); - FAIL_ON(!info); - FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, 2, 0) != 0); - - FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 1); - FAIL_ON(drm_format_info_min_pitch(info, 1, 1) != 2); - FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 2); - FAIL_ON(drm_format_info_min_pitch(info, 1, 1) != 2); - FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 640); - FAIL_ON(drm_format_info_min_pitch(info, 1, 320) != 640); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 1024); - FAIL_ON(drm_format_info_min_pitch(info, 1, 512) != 1024); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 1920); - FAIL_ON(drm_format_info_min_pitch(info, 1, 960) != 1920); - FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 4096); - FAIL_ON(drm_format_info_min_pitch(info, 1, 2048) != 4096); - FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 671); - FAIL_ON(drm_format_info_min_pitch(info, 1, 336) != 672); - FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) != +static void drm_format_min_pitch_two_plane(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 0), 0); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 1), 2); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 2); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 1), 2); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 640); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 320), 640); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 1024); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 512), 1024); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 1920); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 960), 1920); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 4096); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 2048), 4096); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 671); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 336), 672); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), (uint64_t)UINT_MAX); - FAIL_ON(drm_format_info_min_pitch(info, 1, UINT_MAX / 2 + 1) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, UINT_MAX / 2 + 1), (uint64_t)UINT_MAX + 1); - FAIL_ON(drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)), (uint64_t)(UINT_MAX - 1)); - FAIL_ON(drm_format_info_min_pitch(info, 1, (UINT_MAX - 1) / 2) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, (UINT_MAX - 1) / 2), (uint64_t)(UINT_MAX - 1)); +} - /* Test 3 planes 8 bits per pixel format */ - info = drm_format_info(DRM_FORMAT_YUV422); - FAIL_ON(!info); - FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, 2, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, 3, 0) != 0); - - FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 1); - FAIL_ON(drm_format_info_min_pitch(info, 1, 1) != 1); - FAIL_ON(drm_format_info_min_pitch(info, 2, 1) != 1); - FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 2); - FAIL_ON(drm_format_info_min_pitch(info, 1, 2) != 2); - FAIL_ON(drm_format_info_min_pitch(info, 2, 2) != 2); - FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 640); - FAIL_ON(drm_format_info_min_pitch(info, 1, 320) != 320); - FAIL_ON(drm_format_info_min_pitch(info, 2, 320) != 320); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 1024); - FAIL_ON(drm_format_info_min_pitch(info, 1, 512) != 512); - FAIL_ON(drm_format_info_min_pitch(info, 2, 512) != 512); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 1920); - FAIL_ON(drm_format_info_min_pitch(info, 1, 960) != 960); - FAIL_ON(drm_format_info_min_pitch(info, 2, 960) != 960); - FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 4096); - FAIL_ON(drm_format_info_min_pitch(info, 1, 2048) != 2048); - FAIL_ON(drm_format_info_min_pitch(info, 2, 2048) != 2048); - FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 671); - FAIL_ON(drm_format_info_min_pitch(info, 1, 336) != 336); - FAIL_ON(drm_format_info_min_pitch(info, 2, 336) != 336); - FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) != +static void drm_format_min_pitch_three_plane_8bpp(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 3, 0), 0); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 1), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 1), 1); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 2); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 2), 2); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 2), 2); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 640); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 320), 320); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 320), 320); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 1024); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 512), 512); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 512), 512); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 1920); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 960), 960); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 960), 960); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 4096); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 2048), 2048); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 2048), 2048); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 671); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 336), 336); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 336), 336); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), (uint64_t)UINT_MAX); - FAIL_ON(drm_format_info_min_pitch(info, 1, UINT_MAX / 2 + 1) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, UINT_MAX / 2 + 1), (uint64_t)UINT_MAX / 2 + 1); - FAIL_ON(drm_format_info_min_pitch(info, 2, UINT_MAX / 2 + 1) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, UINT_MAX / 2 + 1), (uint64_t)UINT_MAX / 2 + 1); - FAIL_ON(drm_format_info_min_pitch(info, 0, (UINT_MAX - 1) / 2) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1) / 2), (uint64_t)(UINT_MAX - 1) / 2); - FAIL_ON(drm_format_info_min_pitch(info, 1, (UINT_MAX - 1) / 2) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, (UINT_MAX - 1) / 2), (uint64_t)(UINT_MAX - 1) / 2); - FAIL_ON(drm_format_info_min_pitch(info, 2, (UINT_MAX - 1) / 2) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, (UINT_MAX - 1) / 2), (uint64_t)(UINT_MAX - 1) / 2); +} - /* Test tiled format */ - info = drm_format_info(DRM_FORMAT_X0L2); - FAIL_ON(!info); - FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0); - FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0); - - FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 2); - FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 4); - FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 1280); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 2048); - FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 3840); - FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 8192); - FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 1342); - FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) != +static void drm_format_min_pitch_tiled(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_X0L2); + + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, info); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); + + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 2); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 4); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 1280); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 2048); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 3840); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 8192); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 1342); + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), (uint64_t)UINT_MAX * 2); - FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX - 1) != + KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX - 1), (uint64_t)(UINT_MAX - 1) * 2); - - return 0; } + +static struct kunit_case drm_format_tests[] = { + KUNIT_CASE(drm_format_block_width_invalid), + KUNIT_CASE(drm_format_block_width_one_plane), + KUNIT_CASE(drm_format_block_width_two_plane), + KUNIT_CASE(drm_format_block_width_three_plane), + KUNIT_CASE(drm_format_block_width_tiled), + KUNIT_CASE(drm_format_block_height_invalid), + KUNIT_CASE(drm_format_block_height_one_plane), + KUNIT_CASE(drm_format_block_height_two_plane), + KUNIT_CASE(drm_format_block_height_three_plane), + KUNIT_CASE(drm_format_block_height_tiled), + KUNIT_CASE(drm_format_min_pitch_invalid), + KUNIT_CASE(drm_format_min_pitch_one_plane_8bpp), + KUNIT_CASE(drm_format_min_pitch_one_plane_16bpp), + KUNIT_CASE(drm_format_min_pitch_one_plane_24bpp), + KUNIT_CASE(drm_format_min_pitch_one_plane_32bpp), + KUNIT_CASE(drm_format_min_pitch_two_plane), + KUNIT_CASE(drm_format_min_pitch_three_plane_8bpp), + KUNIT_CASE(drm_format_min_pitch_tiled), + {} +}; + +static struct kunit_suite drm_format_test_suite = { + .name = "drm_format_tests", + .test_cases = drm_format_tests, +}; + +kunit_test_suite(drm_format_test_suite); diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h index 8744fd840406..f6cfce2a5863 100644 --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h @@ -20,9 +20,6 @@ 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); -int igt_check_drm_format_block_width(void *ignored); -int igt_check_drm_format_block_height(void *ignored); -int igt_check_drm_format_min_pitch(void *ignored); int igt_check_drm_framebuffer_create(void *ignored); int igt_damage_iter_no_damage(void *ignored); int igt_damage_iter_no_damage_fractional_src(void *ignored); From patchwork Mon Jan 17 23:22:53 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: 12715720 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 E489DC433EF for ; Mon, 17 Jan 2022 23:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243794AbiAQXYc (ORCPT ); Mon, 17 Jan 2022 18:24:32 -0500 Received: from mga17.intel.com ([192.55.52.151]:36575 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243793AbiAQXYb (ORCPT ); Mon, 17 Jan 2022 18:24:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642461871; x=1673997871; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=6ro2lSA7hpfMrYO7xKE+6JLlzdljkSfgu8tKCG0dnro=; b=A4GR9rxxkMMJzHGqNG2bKgkrLVM9/zXkloUUUhzzWfhhk65uFvISbBBc rmWL3WJmyHRmVy3FWJdrECBJFQWKuz+RQrDFXNF7Gl+oJA6A2j8tiau6M hN0ZQm4sBjTkZwKt2EfNdFpASLoLdSr9p23iJR016B3+BY25UtSp6XsZI CQpacD+aw+yuKHcfItpG70M0uiQ91nd1gIpARV64SsRurG00XiTUhQNHq CK/CcZUtSeKk3GWLGgtx62DGkdjsMJS18mVd7hTnPeyXam2mH1UNmF8eT Xqhxs36js4cX0hP94s6kZBIWdkz+PQZkiXXmXCO2aD0lixnNNAAj6GBJr g==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="225384350" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="225384350" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2022 15:24:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="474580654" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga003.jf.intel.com with ESMTP; 17 Jan 2022 15:24:31 -0800 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx603.amr.corp.intel.com (10.18.126.83) 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:30 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx601.amr.corp.intel.com (10.18.126.81) 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:30 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) 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:30 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a8yZPYS3WG7uNRk02IKjRfwdiS+ZWO6J1i9K7CeljYYlY1x3OsLFnl0+sodVkFCEm59F2vb2+FpjkO0qdMiZknlyJT2vC2GAqDzvAP7IQfrsAckhLAC9Nu2eVifRRngXzXxk+lRctYHbMGxCznL1cG8cJjiivG85wOoasIMR5yO4UXakMY/PRHA6gbn9FXc3Av7KHZQap8MPHmnt08IiU6bokJ5FwYqbtJE4I+PNWJcgsBdeKnd2xA1kt8Bk/7WFwYhP5JoAReFjIYTkGGNIbhqBcD3ATeRXPvncT9VKyiUtWwiL02EAPpU03CnCfJlawDdmQTFB5dYvsfIb+j+lvQ== 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=X+0w12oZdbhV960T8HqB6zptTXT0vzEbEfPf+5/egbs=; b=Iwff3E1mPDtZIgHiOYclZo3FTiA8BSrzWPSi2dq2Gwp5Vpnfu0Lvl+UyKoAn3/wFrE9p3/k5hjM0yuButX3wG6SpvLJIBvy2uQI7mgVcD7zq1Ef4k60ZfgKn2ftG0nK9mfGpLV5JPhF/2dMZxLrjBXE7VkAw26fKQUvb3LKL5P4Z31VgkM6rHLm83Lxrkgjq8MDUVSZSHFr5wSjNOy/umo7NScDfOYYfGv5XMiPVpUsFEOFfoFfdtfoam3UYQC9nVOhSkZvXuxJkUfcdISSmicANBup4x7syMWcRJ3YfYYG+9ycXjaDLVzPkApxPpstwsvWZy4qqNFkBqiwTgMSaBA== 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:22 +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:22 +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 04/10] drm: test-drm_framebuffer: Convert to KUnit Date: Tue, 18 Jan 2022 00:22:53 +0100 Message-ID: <20220117232259.180459-5-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: LO2P265CA0310.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a5::34) 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: 7ac34f83-9d29-44ee-cc29-08d9da107e5b X-MS-TrafficTypeDiagnostic: DM4PR11MB5550:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:381; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mGywa6Xq6oLHE1NwBCYhYAtMGzFUbt0liYVDTMxDyTwaDDohBmEUw1CAVT+jWqiBzJey2CD6drSXk4NfukSZCqAcwcBaMp9zSATI4wkSEc1rcUMgH4/sFJbbLR17w46Y7iexDTldQAR0hsSX1nd81EY1v6iasnQ8/dLeEOTkvixbXOhuo+sh5QdT3zKuux+sNK+hf7gflrxsD1Ap9lyUr9Nc1Cp0Jf5FezH7LSQhY7Egxyxsp6gx7a+DDXYAvH3y1ZA+IirdAA5YtbIwEebnBeaprr8/9PCs4w1+mCbVetvDdBLEphfWMTTxqdmSieGeI/OqpOH6OnfqA1P0VCFGtiZR9tcAvXaVJfU1iD3DvSJDYcNWEXkW+UcSFJ0+fP1lc71q6338t8bWwBg1zwdunCjFpLWq8qHBq3m+H/lFQAWvl/f5AICG0XkUfhdhqiB044Rqrwgu2zzqHl3yHBU3ZqCzlFBotMRCRdiadFjNSAivJeSe1lmxPokZ0JcaZ57fSTC/GytHOFS9HRxvxn7GJ7KHdILXT2MttBgbrStCNF+mhoVHwLyUc+kh+oNtpWfs+GtajyKne/gEz/6oNV8Wz43OTp2cVLuxNJxwZrQWGphBZuZbJXLOxcJRFQNcYrFrGGJUYOax0L3iMBagFOXsPw== 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)(6666004)(8676002)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?FFP/1IU3vymFREFZ5J4XPaLd8sIS?= =?utf-8?q?5/9WKOlgSzPSE8gFTkxKH8nwyefo9T55j3+a1yDB9c4EMKv10mUBM+6Mtpvp+rpBT?= =?utf-8?q?ocDUkxyQlSpH1hlTkVzbuW9HtkEWqvCQ4iKGWvNmHoIdgu3rijyi2vaLShbNqfThJ?= =?utf-8?q?99xKq1mch2v3pvyCfPvXQjjCL6zKDATDUnBmQ62rJqRlA8ltlCv8qJbtLKO3uy2bi?= =?utf-8?q?LUVp1wmcudMcQoYmXEzi5bZMRcR14HM5lqWh/5l+XWYWSK+I1UBGPKL5l0mTcE1vH?= =?utf-8?q?krVPWJFeZR4lGWsyEfYPdAe/XiNQEGzY40ZBOsOXUqKesSKOQxsMitIXny5gH0Umy?= =?utf-8?q?K9tgYTiztesUlJyqmOymbVmOfcA5wp16jwq/sYXOQ0N9C8aqzWzO1+rKqd5PCOpMy?= =?utf-8?q?AMy+JLhiA5RkXio/96pASZesF77PLEpTaEW7EuNDsDXxm+4jMpHDPZBYnnI5egSKd?= =?utf-8?q?NfdrACcDiScLzuAQU1OWPtseVdPfbuvy/fC2r0OUktTAhAYADinuUqhQCawJ6fRko?= =?utf-8?q?sfdUm6ZEkBy+Udr1Umo4phGKIZSgurav53GQz/uo8V4BA7WL/4d0wiVp1iPwKmdj3?= =?utf-8?q?5jQuvkOBmshHx84lAHT3JJxhIbR5IYw83eQmXEL43iPvj/DSZ5d4d1qqRVJfhUhDy?= =?utf-8?q?24RV/CZuX8z9VdRyImnb4W0pBvXszrZ0eXtbeOhkl/y52AUZHSOTuW4TWKTHF++aZ?= =?utf-8?q?kbu26jF3oHfwjEnqrg2xNmGVQ+nz2aUVpjR+XT5J5HPwQlkaKxDjdj0GnFfPeENNQ?= =?utf-8?q?4c8p/jMADLIcoeGx5Z2VBgnBsVykcYQW9Hm8zeRh8NPIgxDaBxJF8T1L2PmGWJf0Q?= =?utf-8?q?fy7wGZ5he9LMNlI17fTLHuG68bk/a6VAgYGG3VhV/Vfn9h5+DjiPBmuL87gkcLdeP?= =?utf-8?q?t0mku1xhq8nfk6m2dRQMGNcrVO7FfJZZO6EfXKY2bKpzeBcjN5z+ziRYFKONY099f?= =?utf-8?q?dorcYO+dLrm3IueMfbOCWPcUoc+5FzC/rMmw6HXPzhnvzxVc5YLNmtBG16vCczA26?= =?utf-8?q?wLBZzp23sa9oqZOT8fWCr+wQoK4N4Atijtp/bjlWRjhAb5xp+EFBj7t61ZPODiaO4?= =?utf-8?q?GCJYR1tsNNwwvr0/wrb4yCgDdzBwuvd7NIkbhyqaGRNW5WVUOaREOEkLCiAsqOW52?= =?utf-8?q?X3/DQ3BrGYbDfSQIsP/iRt8cvMnaO6G479uT9U2niEx+BDdYOqFaCy8JnVXQYL1Tz?= =?utf-8?q?yzopsLSUn+vrlSJ+u4z+wNsu0oGFtOINR1o8uwJHRPKF9wfXbwsHGmanCxlyvUWMn?= =?utf-8?q?AQ532A2THNTLqeiCRqNjqdiCI+jrkviDPr1KYcri6yd7puioyWjIRkyibiRVe4C6S?= =?utf-8?q?WoSGsm7P0nEe41Li4iXC8POpKGiNWI8x18Lpr0omBk+8/xMeMYQenEGCUL/ghAWAY?= =?utf-8?q?he11s57f21DaQAxQ1ddHBPYsZZzEEdQ2SQEk6ewc3yaDJGm3bf/7fAdWrmSOt8uTb?= =?utf-8?q?pKGmXvW5cQ2KkT14lpct1ITZewQz5bmceweHgpPAF0CIhFWM6wmjZDUL6JR5VEOyG?= =?utf-8?q?Cqcb9nKJZZMlFFC5whcDs6iKLNQ5JbrlKK4ltlXWmX5BQo1AHO0N5gLdB2fc11Mjv?= =?utf-8?q?KT8pwayOaFlON6zsW8nhvFdslptH8zMaA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 7ac34f83-9d29-44ee-cc29-08d9da107e5b 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:22.5318 (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: epdm6xJikI54BwTdZLdyQzokKsPOXjBUiENGvyopAn/4Kf/rKe5NdIs5rN6uYt3QpRXAn4inHhH6ohZA8beIJx+OwF1kNaZI4/WqknERXnA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5550 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Mocking was moved to .init() in order to separate it from test logic. No functional changes. Signed-off-by: Michał Winiarski --- drivers/gpu/drm/selftests/Makefile | 3 +- .../gpu/drm/selftests/drm_modeset_selftests.h | 1 - .../gpu/drm/selftests/test-drm_framebuffer.c | 109 +++++++++++------- .../drm/selftests/test-drm_modeset_common.h | 1 - 4 files changed, 68 insertions(+), 46 deletions(-) diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/selftests/Makefile index 76c127613d1a..1235eadca884 100644 --- a/drivers/gpu/drm/selftests/Makefile +++ b/drivers/gpu/drm/selftests/Makefile @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only test-drm_modeset-$(CONFIG_DRM_DEBUG_SELFTEST) := \ test-drm_modeset_common.o \ - test-drm_framebuffer.o \ test-drm_damage_helper.o test-drm_dp_mst_helper.o \ test-drm_rect.o @@ -9,4 +8,4 @@ obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o obj-$(CONFIG_DRM_KUNIT_TEST) := \ test-drm_cmdline_parser.o test-drm_plane_helper.o \ - test-drm_format.o + test-drm_format.o test-drm_framebuffer.o diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h b/drivers/gpu/drm/selftests/drm_modeset_selftests.h index 5f253d9e573c..66f6b31e1a7f 100644 --- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h +++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h @@ -10,7 +10,6 @@ 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) -selftest(check_drm_framebuffer_create, igt_check_drm_framebuffer_create) selftest(damage_iter_no_damage, igt_damage_iter_no_damage) selftest(damage_iter_no_damage_fractional_src, igt_damage_iter_no_damage_fractional_src) selftest(damage_iter_no_damage_src_moved, igt_damage_iter_no_damage_src_moved) diff --git a/drivers/gpu/drm/selftests/test-drm_framebuffer.c b/drivers/gpu/drm/selftests/test-drm_framebuffer.c index 61b44d3a6a61..faa01cefe4e5 100644 --- a/drivers/gpu/drm/selftests/test-drm_framebuffer.c +++ b/drivers/gpu/drm/selftests/test-drm_framebuffer.c @@ -3,6 +3,7 @@ * Test cases for the drm_framebuffer functions */ +#include #include #include @@ -12,20 +13,67 @@ #include "../drm_crtc_internal.h" -#include "test-drm_modeset_common.h" - #define MIN_WIDTH 4 #define MAX_WIDTH 4096 #define MIN_HEIGHT 4 #define MAX_HEIGHT 4096 -struct drm_framebuffer_test { +static struct drm_framebuffer *fb_create_mock(struct drm_device *dev, + struct drm_file *file_priv, + const struct drm_mode_fb_cmd2 *mode_cmd) +{ + int *buffer_created = dev->dev_private; + + *buffer_created = 1; + + return ERR_PTR(-EINVAL); +} + +static const struct drm_mode_config_funcs mock_config_funcs = { + .fb_create = fb_create_mock, +}; + +static int drm_framebuffer_test_init(struct kunit *test) +{ + struct drm_device *mock; + + mock = kunit_kzalloc(test, sizeof(*mock), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, mock); + + mock->mode_config = (struct drm_mode_config) { + .min_width = MIN_WIDTH, + .max_width = MAX_WIDTH, + .min_height = MIN_HEIGHT, + .max_height = MAX_HEIGHT, + .allow_fb_modifiers = true, + .funcs = &mock_config_funcs, + }; + + test->priv = mock; + + return 0; +} + +struct drm_framebuffer_create_test { int buffer_created; struct drm_mode_fb_cmd2 cmd; const char *name; }; -static struct drm_framebuffer_test createbuffer_tests[] = { +static void test_drm_framebuffer_create(struct kunit *test) +{ + const struct drm_framebuffer_create_test *params = test->param_value; + struct drm_device *mock = test->priv; + int buffer_created = 0; + + mock->dev_private = &buffer_created; + + drm_internal_framebuffer_create(mock, ¶ms->cmd, NULL); + + KUNIT_EXPECT_EQ(test, buffer_created, params->buffer_created); +} + +static const struct drm_framebuffer_create_test drm_framebuffer_create_tests[] = { { .buffer_created = 1, .name = "ABGR8888 normal sizes", .cmd = { .width = 600, .height = 600, .pixel_format = DRM_FORMAT_ABGR8888, .handles = { 1, 0, 0 }, .pitches = { 4 * 600, 0, 0 }, @@ -304,48 +352,25 @@ static struct drm_framebuffer_test createbuffer_tests[] = { }, }; -static struct drm_framebuffer *fb_create_mock(struct drm_device *dev, - struct drm_file *file_priv, - const struct drm_mode_fb_cmd2 *mode_cmd) +static void drm_framebuffer_create_desc(const struct drm_framebuffer_create_test *t, + char *desc) { - int *buffer_created = dev->dev_private; - *buffer_created = 1; - return ERR_PTR(-EINVAL); + sprintf(desc, "%s", t->name); } -static struct drm_mode_config_funcs mock_config_funcs = { - .fb_create = fb_create_mock, -}; +KUNIT_ARRAY_PARAM(drm_framebuffer_create, + drm_framebuffer_create_tests, + drm_framebuffer_create_desc); -static struct drm_device mock_drm_device = { - .mode_config = { - .min_width = MIN_WIDTH, - .max_width = MAX_WIDTH, - .min_height = MIN_HEIGHT, - .max_height = MAX_HEIGHT, - .allow_fb_modifiers = true, - .funcs = &mock_config_funcs, - }, +static struct kunit_case drm_framebuffer_tests[] = { + KUNIT_CASE_PARAM(test_drm_framebuffer_create, drm_framebuffer_create_gen_params), + {} }; -static int execute_drm_mode_fb_cmd2(struct drm_mode_fb_cmd2 *r) -{ - int buffer_created = 0; - - mock_drm_device.dev_private = &buffer_created; - drm_internal_framebuffer_create(&mock_drm_device, r, NULL); - return buffer_created; -} - -int igt_check_drm_framebuffer_create(void *ignored) -{ - int i = 0; - - for (i = 0; i < ARRAY_SIZE(createbuffer_tests); i++) { - FAIL(createbuffer_tests[i].buffer_created != - execute_drm_mode_fb_cmd2(&createbuffer_tests[i].cmd), - "Test %d: \"%s\" failed\n", i, createbuffer_tests[i].name); - } +static struct kunit_suite drm_framebuffer_test_suite = { + .name = "drm_framebuffer_tests", + .init = drm_framebuffer_test_init, + .test_cases = drm_framebuffer_tests, +}; - return 0; -} +kunit_test_suite(drm_framebuffer_test_suite); diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h index f6cfce2a5863..c09f38b791ad 100644 --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h @@ -20,7 +20,6 @@ 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); -int igt_check_drm_framebuffer_create(void *ignored); int igt_damage_iter_no_damage(void *ignored); int igt_damage_iter_no_damage_fractional_src(void *ignored); int igt_damage_iter_no_damage_src_moved(void *ignored); From patchwork Mon Jan 17 23:22:54 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: 12715721 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 6C9D0C4332F for ; Mon, 17 Jan 2022 23:24:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243795AbiAQXYe (ORCPT ); Mon, 17 Jan 2022 18:24:34 -0500 Received: from mga01.intel.com ([192.55.52.88]:50756 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243793AbiAQXYe (ORCPT ); Mon, 17 Jan 2022 18:24:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642461874; x=1673997874; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=oYnI6gON5CS6yEm312AIdaVVPuYUAG9qPC59+khH82E=; b=aPKN/YNmlPoJtojL4QQ1NThv2Ki66FlChpaqcfHU9UxjbXeMHJ19u10j kPlCdoRl1yVxHcSDpD7+IfialrCpzAJp6bYUUmR99CqFIkwNjjAw79zYg ie/M33QfmE+hewwxnV/W41BxfYpSGEF9X9fsVLSH6uIVyICspcD+VP35B TQsI47y4lUL9sZvp+xDlkUz+iHw/HS+Xz/GZJVQi49kb5TzAYFk2WwI7E wSWZ47efVouCtWpf+km0BhprIKb4EsdtWRCYAA2W0hW5jlFR1gXcYpry8 iiqL4+EPhXVbbAqbQ9W8GSNYY5jS4+yL3q7+7/J1wgS5iuZq7BfIRy6pl g==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="269082577" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="269082577" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2022 15:24:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="625325314" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga004.jf.intel.com with ESMTP; 17 Jan 2022 15:24:33 -0800 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) by fmsmsx601.amr.corp.intel.com (10.18.126.81) 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:32 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) 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 via Frontend Transport; Mon, 17 Jan 2022 15:24:32 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) 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:32 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WUBIr3Xd2I7jxkbDhGr2i4QXt0kTq/K07mTgnJVoy14MMIZrPTZpwvmqv0QovcRRu1xvt/6oYWk55AbCgnMsKMvO6ek3/u/SKyMlxyYxk9XF3bXk2J3r9RJjLWx1uJmcNt3t7WdcgCcKTFX1pdQIhKxNRFfJtzqMiIFlQ5POOTb82ltxkyBoRuUe2cSTqEfHNrqpn4noPRhPxqfKd0IxlkLvfVU35dDS24fM7LVHbuFqvMkSKYxlXKc9RLRii6bduIFEv5L7Zw26UuvYFNIIxG6My2Nq2F4n3ORFsXy5s+RbHwm3Ww4Br+zAlXDISyW8M5WHi/HjTt7BrAq0Gr08Mg== 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=N2PuRVqATPEecC6JGnykRvb2bjxi/0Gls7O7GDI7+2c=; b=YcMKscNRjlSHuinSp4pClvLcJqrQp4Y9FWYBCU8D7/L8VvabFPKDPqyh4GwybYxVi4rD3ByWJ+7V7iLnKhRVLAWDP4ZsRY58sF1mmexDy9ptRgJmWuFV02sCmMBNen8XMTGTunGZpi7GtHE6Q28AINOPn01cXVREb3M852M+dcUTuM6vL7WSlBCoawJhF/lzldUJVZC78sDKoGWB970vQY0ltRD6hptmYKLa5YbRJtXPO5R1PSehBhdL1n6c9LGyEL/SWKdu0Ryqb2XUz7KcKuT4i30eiVT7KOYkRb+YX0tEWD0y7TPsv65pYQhSRbJ9Z5hf8rlNkaEqXPGyYTEX+A== 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:28 +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:28 +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 05/10] drm: test-drm_damage_helper: Convert to KUnit Date: Tue, 18 Jan 2022 00:22:54 +0100 Message-ID: <20220117232259.180459-6-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: LNXP265CA0079.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:76::19) 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: 5bbc1bf1-fd8d-49b4-b16a-08d9da1081fd X-MS-TrafficTypeDiagnostic: DM4PR11MB5550:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Tk7wE5COz5pWTCvRV92fq7EGYYSAvOpglnauX8LIoR0egvUPUAvxR8GmryVvQblQN8BtU+72OgUlVSlsvbP5F7QxIlavc4em8ERhq6MRnb9Z/C2aUaAMijRBkzFHNOVz97fWYZ0h8grVcKnm9oUwv+BsjFgdRM63AQOv7TjgQLdNYlczSOZ+B6pvAsdN0o/5/cOAw1LofwEjtx4+3j4KlrqBzSOddEPa5VVbXYTEDW3m8i7HVypjTqvRQ8mbVG5mYVy8UGUwsGoDxHGNBe688Ejz/jQ0yfFY+x2twleRnl1kzVT/410ZXsbZLC1i59BhUZCam2AhG8EI3Y4LymBdHDkuIE+RVlmpiD5ln4nHccpLvYClg1yAf0A6mAh+YRG7u199Pb3C5x0y+InmwXhekj1IJgj2gX4vW3gc+oT2raUA+j55ahYP05GLcZuEh2KlTcG7gYfdN8guqlts9MT/WP3jDil9xC1pu6iJwHAsV+nDww16LoKSzSTTkMimWQKaNBtdG5zunh4Ya9SrMeo5D+XFSCuCXFQbIc5KBqRb9Dk8PS3PuTrh3Jnoo6tbijseoalljVE6gQfXs4MKfSMsvnplaGDvOxn9Sk/s9rl80/ZiVBXUVOUd9dMh9FByrtCjQHuJS9ncxXoHLwwqArWJeg== 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)(40140700001)(1076003)(54906003)(6512007)(83380400001)(26005)(66946007)(66476007)(66556008)(316002)(6486002)(38100700002)(8936002)(508600001)(2906002)(30864003)(6666004)(8676002)(2616005)(579004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?3X84AAZlbaFRCLMs8VzlyTW7YQJH?= =?utf-8?q?IskikKdJWHgkceo5GPtChPs//3roRRR8OSL3u3F/DKoJ3B4n38Kwos7HNtsX1qVeq?= =?utf-8?q?u8Zfdyj2KZBWyNQ5w3K2h7Avz8Zq7cQUE9VwAT3NqtNl/EJvIy/rLaXmdXxwPTlsR?= =?utf-8?q?7lMmmNDiMuRtSFwkHoKCHsZpQmgItmzKj6a+Cvl58da8nXxzzi3bt4GtvTnifNm/g?= =?utf-8?q?+gRHSjFCTSlck0/HgyTzswQeGbQK5tfSmaCbBo3wac+LIIt4RYbCB6TrAGqvBPoyc?= =?utf-8?q?onOWwtMJqNkBc0AAxDjpAXhg5ArzDHv7bhwlBLQiBXp3PSExtzKwv6lakWpCPfXDx?= =?utf-8?q?ur/fGdF41hUm7SGtza9BzbncLLUTQyFyJX9GILX37ez1kYJFddjvW8MVCprnT2zvG?= =?utf-8?q?I2/afqm7MDWyC/Ulm3eL3dASCamXBaglbne8gQWd3xk3DGofj2GHYPeJhf/ceLuZI?= =?utf-8?q?dssdb0Vqe8q1SJyVLIOw3b5ZtLa3tUsE4EFHT2lOAm3j6o4G3JKLHO/kw02AksuD7?= =?utf-8?q?Kx6v6+sbV1wPcertNSV5JnJWl5ZEp3tYhuqDIh16a192n6s07D3Q/uJGB6e/vqdoF?= =?utf-8?q?kUP8g0+DMPqj/QjmQVbtVi7irpSEvywtzQgSmCV3RXp3V4y059zU7HFMs/l6/yuih?= =?utf-8?q?of60YfM6rcz8ijiWSatN2b2VOKl44dI2niGPTpkQmqF1GNK/rslUXDFkBP/tQCt+3?= =?utf-8?q?f9qq6ILmSDFHunoONH3ml4qtnTVPnqJ0nSo9WyPp3uGeYs1TGHFn/IVajSk6ESnWS?= =?utf-8?q?ELwfIdGR5/8WvTM7zxcZuLiCg/veyY5UoYiUgr/mYGAO86h4wqt3Q4Y8cTj4xP3Cs?= =?utf-8?q?XxK98HKj7j+dQUYHVVoLJh9Y3Qdq5h6XTz/EA9so2DOJ53zvStZLVa+rdJEhFiiZY?= =?utf-8?q?wymie1Zhahhi7pmPDJVQqhQ8mcwCrbRhuqAK5/XCRqGo7gKHahh7fwHjN/ywTRj2m?= =?utf-8?q?ZgWjDCiiulQsH9BAIV9Zl/eWV1s2Y9e7zi7tBnYAU92unnf007gefH3T9pAe5hJue?= =?utf-8?q?DkJBK0+lXx630zAcrjFydaW4/HUruskrfkCOXYo993rO3hPn62c9OLYQMZVE4SQSU?= =?utf-8?q?bZFp+Jqg+RI7OdoxbZ3+4d++nabqIbVP45TDWD6n8yHVW6pEdqWZKDrhRhS4sowyp?= =?utf-8?q?14nph14UnSq7wxgJqbT3EUsfQCzlU1WE8uSp7xuhKg0wTrW/gi+tHAjQCLDCNldle?= =?utf-8?q?bseTeAw+rpu17nu5f7i7NbqNNbmb9XTjUucEWFiYchMYszA0qykIefGQtip5kjg6P?= =?utf-8?q?SONECU4IfNML0v1Mvw+xWP1yaHPz/sqLp4lygl0Q6xnkCnnp9uuKOeQZwxat6yi5w?= =?utf-8?q?4PQWfngyzUdrGXjYCPRM7LUcxDCrdc9YRCLcJp6eNJ5bJhxYPwiYBibBMdf7llqET?= =?utf-8?q?IbVdphFfqOVpMMFRGAHFNfZUKoruIfRmHBcTyUDVr2c9S63G2YnlJkNMWMh8buN4x?= =?utf-8?q?HnK0YNINWA44akXWWRpbbFQBNoWWfNM5eG3ssrIKgFZFfkO8hNKT1J7UxMKqpX6y2?= =?utf-8?q?yE8wJg1UduFiNr4CiE2g0SNbfI4xrx9QTWMD+D/qyvw/8NgMZSogcKQJMXS0VXFPn?= =?utf-8?q?Llwp1tdN83tUNSXxobB4RDVlesqOTDEcQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 5bbc1bf1-fd8d-49b4-b16a-08d9da1081fd 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:28.7197 (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: 3DbasW3cf+ht8s2e6G59HJqAOsDhAHkV1RsmHRHcmLOT0IoHNOj5Z34iIOTaWHn9GeLWIkQJ2qzI/HfbIfLpd98bGVdBuBCUvYyyNDIKWng= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5550 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Mocking was moved to .init() in order to separate it from test logic. No functional changes. Signed-off-by: Michał Winiarski --- drivers/gpu/drm/selftests/Makefile | 5 +- .../gpu/drm/selftests/drm_modeset_selftests.h | 21 - .../drm/selftests/test-drm_damage_helper.c | 570 +++++++++--------- .../drm/selftests/test-drm_modeset_common.h | 21 - 4 files changed, 288 insertions(+), 329 deletions(-) diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/selftests/Makefile index 1235eadca884..35f2f40dbaf3 100644 --- a/drivers/gpu/drm/selftests/Makefile +++ b/drivers/gpu/drm/selftests/Makefile @@ -1,11 +1,12 @@ # SPDX-License-Identifier: GPL-2.0-only test-drm_modeset-$(CONFIG_DRM_DEBUG_SELFTEST) := \ test-drm_modeset_common.o \ - test-drm_damage_helper.o test-drm_dp_mst_helper.o \ + test-drm_dp_mst_helper.o \ test-drm_rect.o obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.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_format.o test-drm_framebuffer.o \ + test-drm_damage_helper.o diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h b/drivers/gpu/drm/selftests/drm_modeset_selftests.h index 66f6b31e1a7f..b6a6dba66b64 100644 --- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h +++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h @@ -10,26 +10,5 @@ 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) -selftest(damage_iter_no_damage, igt_damage_iter_no_damage) -selftest(damage_iter_no_damage_fractional_src, igt_damage_iter_no_damage_fractional_src) -selftest(damage_iter_no_damage_src_moved, igt_damage_iter_no_damage_src_moved) -selftest(damage_iter_no_damage_fractional_src_moved, igt_damage_iter_no_damage_fractional_src_moved) -selftest(damage_iter_no_damage_not_visible, igt_damage_iter_no_damage_not_visible) -selftest(damage_iter_no_damage_no_crtc, igt_damage_iter_no_damage_no_crtc) -selftest(damage_iter_no_damage_no_fb, igt_damage_iter_no_damage_no_fb) -selftest(damage_iter_simple_damage, igt_damage_iter_simple_damage) -selftest(damage_iter_single_damage, igt_damage_iter_single_damage) -selftest(damage_iter_single_damage_intersect_src, igt_damage_iter_single_damage_intersect_src) -selftest(damage_iter_single_damage_outside_src, igt_damage_iter_single_damage_outside_src) -selftest(damage_iter_single_damage_fractional_src, igt_damage_iter_single_damage_fractional_src) -selftest(damage_iter_single_damage_intersect_fractional_src, igt_damage_iter_single_damage_intersect_fractional_src) -selftest(damage_iter_single_damage_outside_fractional_src, igt_damage_iter_single_damage_outside_fractional_src) -selftest(damage_iter_single_damage_src_moved, igt_damage_iter_single_damage_src_moved) -selftest(damage_iter_single_damage_fractional_src_moved, igt_damage_iter_single_damage_fractional_src_moved) -selftest(damage_iter_damage, igt_damage_iter_damage) -selftest(damage_iter_damage_one_intersect, igt_damage_iter_damage_one_intersect) -selftest(damage_iter_damage_one_outside, igt_damage_iter_damage_one_outside) -selftest(damage_iter_damage_src_moved, igt_damage_iter_damage_src_moved) -selftest(damage_iter_damage_not_visible, igt_damage_iter_damage_not_visible) 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_damage_helper.c b/drivers/gpu/drm/selftests/test-drm_damage_helper.c index 8d8d8e214c28..685d87575c3a 100644 --- a/drivers/gpu/drm/selftests/test-drm_damage_helper.c +++ b/drivers/gpu/drm/selftests/test-drm_damage_helper.c @@ -3,39 +3,55 @@ * Test case for drm_damage_helper functions */ -#define pr_fmt(fmt) "drm_damage_helper: " fmt +#include #include #include #include -#include "test-drm_modeset_common.h" - -struct drm_driver mock_driver; -static struct drm_device mock_device; -static struct drm_object_properties mock_obj_props; -static struct drm_plane mock_plane; -static struct drm_property mock_prop; +/* common mocked structs many tests need */ +struct drm_damage_mock { + struct drm_framebuffer fb; + struct drm_driver driver; + struct drm_device device; + struct drm_object_properties obj_props; + struct drm_plane plane; + struct drm_property prop; + struct drm_plane_state state; + struct drm_plane_state old_state; +}; -static void mock_setup(struct drm_plane_state *state) +static int drm_damage_test_init(struct kunit *test) { - static bool setup_done = false; + struct drm_damage_mock *mock; - state->plane = &mock_plane; + mock = kunit_kzalloc(test, sizeof(*mock), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, mock); - if (setup_done) - return; + mock->fb.width = 2048; + mock->fb.height = 2048; /* just enough so that drm_plane_enable_fb_damage_clips() works */ - mock_device.driver = &mock_driver; - mock_device.mode_config.prop_fb_damage_clips = &mock_prop; - mock_plane.dev = &mock_device; - mock_obj_props.count = 0; - mock_plane.base.properties = &mock_obj_props; - mock_prop.base.id = 1; /* 0 is an invalid id */ - mock_prop.dev = &mock_device; - - drm_plane_enable_fb_damage_clips(&mock_plane); + mock->device.driver = &mock->driver; + mock->device.mode_config.prop_fb_damage_clips = &mock->prop; + mock->plane.dev = &mock->device; + mock->obj_props.count = 0; + mock->plane.base.properties = &mock->obj_props; + mock->prop.base.id = 1; /* 0 is an invalid id */ + mock->prop.dev = &mock->device; + + drm_plane_enable_fb_damage_clips(&mock->plane); + + mock->state.crtc = ZERO_SIZE_PTR; + mock->state.fb = &mock->fb; + mock->state.visible = true; + mock->state.plane = &mock->plane; + + mock->old_state.plane = &mock->plane; + + test->priv = mock; + + return 0; } static void set_plane_src(struct drm_plane_state *state, int x1, int y1, int x2, @@ -69,8 +85,8 @@ static void set_plane_damage(struct drm_plane_state *state, state->fb_damage_clips = damage_blob; } -static bool check_damage_clip(struct drm_plane_state *state, struct drm_rect *r, - int x1, int y1, int x2, int y2) +static void check_damage_clip(struct kunit *test, struct drm_plane_state *state, + struct drm_rect *r, int x1, int y1, int x2, int y2) { /* * Round down x1/y1 and round up x2/y2. This is because damage is not in @@ -81,587 +97,571 @@ static bool check_damage_clip(struct drm_plane_state *state, struct drm_rect *r, int src_x2 = (state->src.x2 >> 16) + !!(state->src.x2 & 0xFFFF); int src_y2 = (state->src.y2 >> 16) + !!(state->src.y2 & 0xFFFF); - if (x1 >= x2 || y1 >= y2) { - pr_err("Cannot have damage clip with no dimension.\n"); - return false; - } - - if (x1 < src_x1 || y1 < src_y1 || x2 > src_x2 || y2 > src_y2) { - pr_err("Damage cannot be outside rounded plane src.\n"); - return false; - } - - if (r->x1 != x1 || r->y1 != y1 || r->x2 != x2 || r->y2 != y2) { - pr_err("Damage = %d %d %d %d\n", r->x1, r->y1, r->x2, r->y2); - return false; - } + KUNIT_EXPECT_FALSE_MSG(test, x1 >= x2 || y1 >= y2, + "Cannot have damage clip with no dimension."); + KUNIT_EXPECT_FALSE_MSG(test, x1 < src_x1 || y1 < src_y1 || x2 > src_x2 || y2 > src_y2, + "Damage cannot be outside rounded plane src."); - return true; + KUNIT_EXPECT_TRUE_MSG(test, r->x1 == x1 && r->y1 == y1 && r->x2 == x2 && r->y2 == y2, + "Damage = %d %d %d %d, expected = %d %d %d %d", + r->x1, r->y1, r->x2, r->y2, + x1, y1, x2, y2); } -const struct drm_framebuffer fb = { - .width = 2048, - .height = 2048 -}; - -/* common mocked structs many tests need */ -#define MOCK_VARIABLES() \ - struct drm_plane_state old_state; \ - struct drm_plane_state state = { \ - .crtc = ZERO_SIZE_PTR, \ - .fb = (struct drm_framebuffer *) &fb, \ - .visible = true, \ - }; \ - mock_setup(&old_state); \ - mock_setup(&state); - -int igt_damage_iter_no_damage(void *ignored) +static void drm_damage_iter_no_damage(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; + struct drm_framebuffer *fb = &mock->fb; struct drm_atomic_helper_damage_iter iter; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - /* Plane src same as fb size. */ - set_plane_src(&old_state, 0, 0, fb.width << 16, fb.height << 16); - set_plane_src(&state, 0, 0, fb.width << 16, fb.height << 16); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_src(old_state, 0, 0, fb->width << 16, fb->height << 16); + set_plane_src(state, 0, 0, fb->width << 16, fb->height << 16); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return plane src as damage."); - FAIL_ON(!check_damage_clip(&state, &clip, 0, 0, 2048, 2048)); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return plane src as damage."); + check_damage_clip(test, state, &clip, 0, 0, 2048, 2048); } -int igt_damage_iter_no_damage_fractional_src(void *ignored) +static void drm_damage_iter_no_damage_fractional_src(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - /* Plane src has fractional part. */ - set_plane_src(&old_state, 0x3fffe, 0x3fffe, + set_plane_src(old_state, 0x3fffe, 0x3fffe, 0x3fffe + (1024 << 16), 0x3fffe + (768 << 16)); - set_plane_src(&state, 0x3fffe, 0x3fffe, + set_plane_src(state, 0x3fffe, 0x3fffe, 0x3fffe + (1024 << 16), 0x3fffe + (768 << 16)); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return rounded off plane src as damage."); - FAIL_ON(!check_damage_clip(&state, &clip, 3, 3, 1028, 772)); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return rounded off plane src as damage."); + check_damage_clip(test, state, &clip, 3, 3, 1028, 772); } -int igt_damage_iter_no_damage_src_moved(void *ignored) +static void drm_damage_iter_no_damage_src_moved(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - /* Plane src moved since old plane state. */ - set_plane_src(&old_state, 0, 0, 1024 << 16, 768 << 16); - set_plane_src(&state, 10 << 16, 10 << 16, + set_plane_src(old_state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(state, 10 << 16, 10 << 16, (10 + 1024) << 16, (10 + 768) << 16); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return plane src as damage."); - FAIL_ON(!check_damage_clip(&state, &clip, 10, 10, 1034, 778)); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return plane src as damage."); + check_damage_clip(test, state, &clip, 10, 10, 1034, 778); } -int igt_damage_iter_no_damage_fractional_src_moved(void *ignored) +static void drm_damage_iter_no_damage_fractional_src_moved(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - /* Plane src has fractional part and it moved since old plane state. */ - set_plane_src(&old_state, 0x3fffe, 0x3fffe, + set_plane_src(old_state, 0x3fffe, 0x3fffe, 0x3fffe + (1024 << 16), 0x3fffe + (768 << 16)); - set_plane_src(&state, 0x40002, 0x40002, + set_plane_src(state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return plane src as damage."); - FAIL_ON(!check_damage_clip(&state, &clip, 4, 4, 1029, 773)); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return plane src as damage."); + check_damage_clip(test, state, &clip, 4, 4, 1029, 773); } -int igt_damage_iter_no_damage_not_visible(void *ignored) +static void drm_damage_iter_no_damage_not_visible(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - - state.visible = false; + state->visible = false; - mock_setup(&old_state); - - set_plane_src(&old_state, 0, 0, 1024 << 16, 768 << 16); - set_plane_src(&state, 0, 0, 1024 << 16, 768 << 16); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_src(old_state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(state, 0, 0, 1024 << 16, 768 << 16); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 0, "Should have no damage."); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 0, "Should have no damage."); } -int igt_damage_iter_no_damage_no_crtc(void *ignored) +static void drm_damage_iter_no_damage_no_crtc(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - - state.crtc = NULL; + state->crtc = NULL; - set_plane_src(&old_state, 0, 0, 1024 << 16, 768 << 16); - set_plane_src(&state, 0, 0, 1024 << 16, 768 << 16); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_src(old_state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(state, 0, 0, 1024 << 16, 768 << 16); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 0, "Should have no damage."); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 0, "Should have no damage."); } -int igt_damage_iter_no_damage_no_fb(void *ignored) +static void drm_damage_iter_no_damage_no_fb(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; - struct drm_plane_state old_state; struct drm_rect clip; uint32_t num_hits = 0; - struct drm_plane_state state = { - .crtc = ZERO_SIZE_PTR, - .fb = 0, - }; - - mock_setup(&old_state); + state->fb = NULL; - set_plane_src(&old_state, 0, 0, 1024 << 16, 768 << 16); - set_plane_src(&state, 0, 0, 1024 << 16, 768 << 16); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_src(old_state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(state, 0, 0, 1024 << 16, 768 << 16); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 0, "Should have no damage."); - - return 0; + KUNIT_EXPECT_EQ(test, num_hits, 0); } -int igt_damage_iter_simple_damage(void *ignored) +static void drm_damage_iter_simple_damage(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - - set_plane_src(&old_state, 0, 0, 1024 << 16, 768 << 16); - set_plane_src(&state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(old_state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(state, 0, 0, 1024 << 16, 768 << 16); /* Damage set to plane src */ set_damage_clip(&damage, 0, 0, 1024, 768); set_damage_blob(&damage_blob, &damage, sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return damage when set."); - FAIL_ON(!check_damage_clip(&state, &clip, 0, 0, 1024, 768)); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return damage when set."); + check_damage_clip(test, state, &clip, 0, 0, 1024, 768); } -int igt_damage_iter_single_damage(void *ignored) +static void drm_damage_iter_single_damage(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - - set_plane_src(&old_state, 0, 0, 1024 << 16, 768 << 16); - set_plane_src(&state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(old_state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(state, 0, 0, 1024 << 16, 768 << 16); set_damage_clip(&damage, 256, 192, 768, 576); set_damage_blob(&damage_blob, &damage, sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return damage when set."); - FAIL_ON(!check_damage_clip(&state, &clip, 256, 192, 768, 576)); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return damage when set."); + check_damage_clip(test, state, &clip, 256, 192, 768, 576); } -int igt_damage_iter_single_damage_intersect_src(void *ignored) +static void drm_damage_iter_single_damage_intersect_src(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - - set_plane_src(&old_state, 0, 0, 1024 << 16, 768 << 16); - set_plane_src(&state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(old_state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(state, 0, 0, 1024 << 16, 768 << 16); /* Damage intersect with plane src. */ set_damage_clip(&damage, 256, 192, 1360, 768); set_damage_blob(&damage_blob, &damage, sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return damage clipped to src."); - FAIL_ON(!check_damage_clip(&state, &clip, 256, 192, 1024, 768)); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return damage clipped to src."); + check_damage_clip(test, state, &clip, 256, 192, 1024, 768); } -int igt_damage_iter_single_damage_outside_src(void *ignored) +static void drm_damage_iter_single_damage_outside_src(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - - set_plane_src(&old_state, 0, 0, 1024 << 16, 768 << 16); - set_plane_src(&state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(old_state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(state, 0, 0, 1024 << 16, 768 << 16); /* Damage clip outside plane src */ set_damage_clip(&damage, 1360, 1360, 1380, 1380); set_damage_blob(&damage_blob, &damage, sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 0, "Should have no damage."); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 0, "Should have no damage."); } -int igt_damage_iter_single_damage_fractional_src(void *ignored) +static void drm_damage_iter_single_damage_fractional_src(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - /* Plane src has fractional part. */ - set_plane_src(&old_state, 0x40002, 0x40002, + set_plane_src(old_state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); - set_plane_src(&state, 0x40002, 0x40002, + set_plane_src(state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); set_damage_clip(&damage, 10, 10, 256, 330); set_damage_blob(&damage_blob, &damage, sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return damage when set."); - FAIL_ON(!check_damage_clip(&state, &clip, 10, 10, 256, 330)); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return damage when set."); + check_damage_clip(test, state, &clip, 10, 10, 256, 330); } -int igt_damage_iter_single_damage_intersect_fractional_src(void *ignored) +static void drm_damage_iter_single_damage_intersect_fractional_src(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - /* Plane src has fractional part. */ - set_plane_src(&old_state, 0x40002, 0x40002, + set_plane_src(old_state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); - set_plane_src(&state, 0x40002, 0x40002, + set_plane_src(state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); /* Damage intersect with plane src. */ set_damage_clip(&damage, 10, 1, 1360, 330); set_damage_blob(&damage_blob, &damage, sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return damage clipped to rounded off src."); - FAIL_ON(!check_damage_clip(&state, &clip, 10, 4, 1029, 330)); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return damage clipped to rounded off src."); + check_damage_clip(test, state, &clip, 10, 4, 1029, 330); } -int igt_damage_iter_single_damage_outside_fractional_src(void *ignored) +static void drm_damage_iter_single_damage_outside_fractional_src(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - /* Plane src has fractional part. */ - set_plane_src(&old_state, 0x40002, 0x40002, + set_plane_src(old_state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); - set_plane_src(&state, 0x40002, 0x40002, + set_plane_src(state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); /* Damage clip outside plane src */ set_damage_clip(&damage, 1360, 1360, 1380, 1380); set_damage_blob(&damage_blob, &damage, sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 0, "Should have no damage."); - - return 0; + KUNIT_EXPECT_EQ(test, num_hits, 0); } -int igt_damage_iter_single_damage_src_moved(void *ignored) +static void drm_damage_iter_single_damage_src_moved(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - /* Plane src moved since old plane state. */ - set_plane_src(&old_state, 0, 0, 1024 << 16, 768 << 16); - set_plane_src(&state, 10 << 16, 10 << 16, + set_plane_src(old_state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(state, 10 << 16, 10 << 16, (10 + 1024) << 16, (10 + 768) << 16); set_damage_clip(&damage, 20, 30, 256, 256); set_damage_blob(&damage_blob, &damage, sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return plane src as damage."); - FAIL_ON(!check_damage_clip(&state, &clip, 10, 10, 1034, 778)); - - return 0; + KUNIT_EXPECT_EQ(test, num_hits, 1); + check_damage_clip(test, state, &clip, 10, 10, 1034, 778); } -int igt_damage_iter_single_damage_fractional_src_moved(void *ignored) +static void drm_damage_iter_single_damage_fractional_src_moved(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - /* Plane src with fractional part moved since old plane state. */ - set_plane_src(&old_state, 0x3fffe, 0x3fffe, + set_plane_src(old_state, 0x3fffe, 0x3fffe, 0x3fffe + (1024 << 16), 0x3fffe + (768 << 16)); - set_plane_src(&state, 0x40002, 0x40002, + set_plane_src(state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); /* Damage intersect with plane src. */ set_damage_clip(&damage, 20, 30, 1360, 256); set_damage_blob(&damage_blob, &damage, sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return rounded off plane src as damage."); - FAIL_ON(!check_damage_clip(&state, &clip, 4, 4, 1029, 773)); - - return 0; + KUNIT_EXPECT_EQ(test, num_hits, 1); + check_damage_clip(test, state, &clip, 4, 4, 1029, 773); } -int igt_damage_iter_damage(void *ignored) +static void drm_damage_iter_damage(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage[2]; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - - set_plane_src(&old_state, 0, 0, 1024 << 16, 768 << 16); - set_plane_src(&state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(old_state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(state, 0, 0, 1024 << 16, 768 << 16); /* 2 damage clips. */ set_damage_clip(&damage[0], 20, 30, 200, 180); set_damage_clip(&damage[1], 240, 200, 280, 250); set_damage_blob(&damage_blob, &damage[0], sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) { if (num_hits == 0) - FAIL_ON(!check_damage_clip(&state, &clip, 20, 30, 200, 180)); + check_damage_clip(test, state, &clip, 20, 30, 200, 180); if (num_hits == 1) - FAIL_ON(!check_damage_clip(&state, &clip, 240, 200, 280, 250)); + check_damage_clip(test, state, &clip, 240, 200, 280, 250); num_hits++; } - FAIL(num_hits != 2, "Should return damage when set."); - - return 0; + KUNIT_EXPECT_EQ(test, num_hits, 2); } -int igt_damage_iter_damage_one_intersect(void *ignored) +static void drm_damage_iter_damage_one_intersect(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage[2]; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - - set_plane_src(&old_state, 0x40002, 0x40002, + set_plane_src(old_state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); - set_plane_src(&state, 0x40002, 0x40002, + set_plane_src(state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); /* 2 damage clips, one intersect plane src. */ set_damage_clip(&damage[0], 20, 30, 200, 180); set_damage_clip(&damage[1], 2, 2, 1360, 1360); set_damage_blob(&damage_blob, &damage[0], sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) { if (num_hits == 0) - FAIL_ON(!check_damage_clip(&state, &clip, 20, 30, 200, 180)); + check_damage_clip(test, state, &clip, 20, 30, 200, 180); if (num_hits == 1) - FAIL_ON(!check_damage_clip(&state, &clip, 4, 4, 1029, 773)); + check_damage_clip(test, state, &clip, 4, 4, 1029, 773); num_hits++; } - FAIL(num_hits != 2, "Should return damage when set."); - - return 0; + KUNIT_EXPECT_EQ(test, num_hits, 2); } -int igt_damage_iter_damage_one_outside(void *ignored) +static void drm_damage_iter_damage_one_outside(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage[2]; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - - set_plane_src(&old_state, 0, 0, 1024 << 16, 768 << 16); - set_plane_src(&state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(old_state, 0, 0, 1024 << 16, 768 << 16); + set_plane_src(state, 0, 0, 1024 << 16, 768 << 16); /* 2 damage clips, one outside plane src. */ set_damage_clip(&damage[0], 1360, 1360, 1380, 1380); set_damage_clip(&damage[1], 240, 200, 280, 250); set_damage_blob(&damage_blob, &damage[0], sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return damage when set."); - FAIL_ON(!check_damage_clip(&state, &clip, 240, 200, 280, 250)); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return damage when set."); + check_damage_clip(test, state, &clip, 240, 200, 280, 250); } -int igt_damage_iter_damage_src_moved(void *ignored) +static void drm_damage_iter_damage_src_moved(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage[2]; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); - - set_plane_src(&old_state, 0x40002, 0x40002, + set_plane_src(old_state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); - set_plane_src(&state, 0x3fffe, 0x3fffe, + set_plane_src(state, 0x3fffe, 0x3fffe, 0x3fffe + (1024 << 16), 0x3fffe + (768 << 16)); /* 2 damage clips, one outside plane src. */ set_damage_clip(&damage[0], 1360, 1360, 1380, 1380); set_damage_clip(&damage[1], 240, 200, 280, 250); set_damage_blob(&damage_blob, &damage[0], sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 1, "Should return round off plane src as damage."); - FAIL_ON(!check_damage_clip(&state, &clip, 3, 3, 1028, 772)); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 1, "Should return round off plane src as damage."); + check_damage_clip(test, state, &clip, 3, 3, 1028, 772); } -int igt_damage_iter_damage_not_visible(void *ignored) +static void drm_damage_iter_damage_not_visible(struct kunit *test) { + struct drm_damage_mock *mock = test->priv; + struct drm_plane_state *old_state = &mock->old_state; + struct drm_plane_state *state = &mock->state; struct drm_atomic_helper_damage_iter iter; struct drm_property_blob damage_blob; struct drm_mode_rect damage[2]; struct drm_rect clip; uint32_t num_hits = 0; - MOCK_VARIABLES(); + state->visible = false; - state.visible = false; - - set_plane_src(&old_state, 0x40002, 0x40002, + set_plane_src(old_state, 0x40002, 0x40002, 0x40002 + (1024 << 16), 0x40002 + (768 << 16)); - set_plane_src(&state, 0x3fffe, 0x3fffe, + set_plane_src(state, 0x3fffe, 0x3fffe, 0x3fffe + (1024 << 16), 0x3fffe + (768 << 16)); /* 2 damage clips, one outside plane src. */ set_damage_clip(&damage[0], 1360, 1360, 1380, 1380); set_damage_clip(&damage[1], 240, 200, 280, 250); set_damage_blob(&damage_blob, &damage[0], sizeof(damage)); - set_plane_damage(&state, &damage_blob); - drm_atomic_helper_damage_iter_init(&iter, &old_state, &state); + set_plane_damage(state, &damage_blob); + drm_atomic_helper_damage_iter_init(&iter, old_state, state); drm_atomic_for_each_plane_damage(&iter, &clip) num_hits++; - FAIL(num_hits != 0, "Should not return any damage."); - - return 0; + KUNIT_EXPECT_EQ_MSG(test, num_hits, 0, "Should not return any damage."); } + +static struct kunit_case drm_damage_helper_tests[] = { + KUNIT_CASE(drm_damage_iter_no_damage), + KUNIT_CASE(drm_damage_iter_no_damage_fractional_src), + KUNIT_CASE(drm_damage_iter_no_damage_src_moved), + KUNIT_CASE(drm_damage_iter_no_damage_fractional_src_moved), + KUNIT_CASE(drm_damage_iter_no_damage_not_visible), + KUNIT_CASE(drm_damage_iter_no_damage_no_crtc), + KUNIT_CASE(drm_damage_iter_no_damage_no_fb), + KUNIT_CASE(drm_damage_iter_simple_damage), + KUNIT_CASE(drm_damage_iter_single_damage), + KUNIT_CASE(drm_damage_iter_single_damage_intersect_src), + KUNIT_CASE(drm_damage_iter_single_damage_outside_src), + KUNIT_CASE(drm_damage_iter_single_damage_fractional_src), + KUNIT_CASE(drm_damage_iter_single_damage_intersect_fractional_src), + KUNIT_CASE(drm_damage_iter_single_damage_outside_fractional_src), + KUNIT_CASE(drm_damage_iter_single_damage_src_moved), + KUNIT_CASE(drm_damage_iter_single_damage_fractional_src_moved), + KUNIT_CASE(drm_damage_iter_damage), + KUNIT_CASE(drm_damage_iter_damage_one_intersect), + KUNIT_CASE(drm_damage_iter_damage_one_outside), + KUNIT_CASE(drm_damage_iter_damage_src_moved), + KUNIT_CASE(drm_damage_iter_damage_not_visible), + {} +}; + +static struct kunit_suite drm_damage_helper_test_suite = { + .name = "drm_damage_helper_tests", + .init = drm_damage_test_init, + .test_cases = drm_damage_helper_tests, +}; + +kunit_test_suite(drm_damage_helper_test_suite); diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h index c09f38b791ad..1501d99aee2f 100644 --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h @@ -20,27 +20,6 @@ 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); -int igt_damage_iter_no_damage(void *ignored); -int igt_damage_iter_no_damage_fractional_src(void *ignored); -int igt_damage_iter_no_damage_src_moved(void *ignored); -int igt_damage_iter_no_damage_fractional_src_moved(void *ignored); -int igt_damage_iter_no_damage_not_visible(void *ignored); -int igt_damage_iter_no_damage_no_crtc(void *ignored); -int igt_damage_iter_no_damage_no_fb(void *ignored); -int igt_damage_iter_simple_damage(void *ignored); -int igt_damage_iter_single_damage(void *ignored); -int igt_damage_iter_single_damage_intersect_src(void *ignored); -int igt_damage_iter_single_damage_outside_src(void *ignored); -int igt_damage_iter_single_damage_fractional_src(void *ignored); -int igt_damage_iter_single_damage_intersect_fractional_src(void *ignored); -int igt_damage_iter_single_damage_outside_fractional_src(void *ignored); -int igt_damage_iter_single_damage_src_moved(void *ignored); -int igt_damage_iter_single_damage_fractional_src_moved(void *ignored); -int igt_damage_iter_damage(void *ignored); -int igt_damage_iter_damage_one_intersect(void *ignored); -int igt_damage_iter_damage_one_outside(void *ignored); -int igt_damage_iter_damage_src_moved(void *ignored); -int igt_damage_iter_damage_not_visible(void *ignored); int igt_dp_mst_calc_pbn_mode(void *ignored); int igt_dp_mst_sideband_msg_req_decode(void *ignored); From patchwork Mon Jan 17 23:22:55 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: 12715722 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 1CFBAC433F5 for ; Mon, 17 Jan 2022 23:24:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243796AbiAQXYm (ORCPT ); Mon, 17 Jan 2022 18:24:42 -0500 Received: from mga11.intel.com ([192.55.52.93]:21981 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243793AbiAQXYl (ORCPT ); Mon, 17 Jan 2022 18:24:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642461881; x=1673997881; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=GcWP1LRMN7SxSYJ3pSTe8V2ey5lZyLVzDF6iV8Uf3kU=; b=Ogz/IjPEuxt3RsBqDtuAqAYl0wy0NLo+dPkCH6GPKR8Q7Ya9wSwhTJpG /AmqM95rBx9b13xm9QzgFRzshCb0zEIMHOzN4HcZXGeCnALZoTITGFJzS ByKGraOf2qbH4cw1urW37zWqXaN0oK7kAA2TyBwTVW7m4D78GfNyHQDCs HbrtaNGuISbA1vWWBKtn1G2Txe5psYY2YBQWbRiGJQoK0B/t14eGwDeao S2a44i8WYbRyJpI0Bqw6X/zgzjVjDOiskvxkaOug9XrAv/J1f198jHEyT 5F8wz2Ipd32asEYeGqTQ/hDvM+WzNg2iEu2dN7qOc+7CdaUdYaTDty8YU Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="242264065" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="242264065" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2022 15:24:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="517554411" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga007.jf.intel.com with ESMTP; 17 Jan 2022 15:24:41 -0800 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX603.amr.corp.intel.com (10.22.229.16) 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:40 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX609.amr.corp.intel.com (10.22.229.22) 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:40 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx611.amr.corp.intel.com (10.22.229.24) 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:40 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.171) by edgegateway.intel.com (134.134.137.103) 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:40 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V/ypTEqIjI5qLpdPy4LDBxwrPbLrip+xUz4uUm6gIVzDsGXK+GQTdhuMIeEptzOHstzA7d6rhOkJOieB0QMnFPGQt+UfOTAt42WUVXu5jZjgrJ525shE3uw0XT7qNUKQ6Wmh2zbDfSy5oVlifcWGhV5MPUPeIPaPvnS7c0HpOApmYehBEUq7bJ9lzCsbe8L6M1pInvH2wVdEUiWcx21q7vNHWoGwl2nQ2aoyH6Lm4JoJOd51+4RO4T8VaQw+yQyVHreX9aEKUFvhuFaGSBL+4hlKkqLuHbqlTUA1GhVe3E6V7JyZQHG5rgcf9kkx7R31KsBwVHaN/eubxkq+4MoTdw== 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=bhPMBEpU7fSd99CDkUXlfjakSYRMf0JwjL0TEAu1GOU=; b=h3FOo9bebJvnzqGJdzoQHMN8DMhc+5i4sg8rX0n1VUYx/h/kKOBpcYPRaXSg2UjsE2YO3YyKhhqNqSKmHa6wMN4aqvUTNAye429uJffCk8jb39j5tyR2yMDapOdUgrsnE0oP+xL7uKv6/dcHXAntp2OUjdFJtN9eIk7yAY8XzQm5nEUD/SuJ1U/zXyW0nDPgMYza23lVFgq01pU5utAN9/gEpg1xyt6T7ABGHvxTbw9PlbH+63l8iGKMFfnOH9YVYJWZXHxKoBniZyPcX7aULNc9hlZc5LZHvx15SAEl8gKMUiSBwPEzLJUYaOj5eFEPFYJFG6Bay60PVpUfWfGYRw== 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:36 +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:36 +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 06/10] drm: test-drm_dp_mst_helper: Convert to KUnit Date: Tue, 18 Jan 2022 00:22:55 +0100 Message-ID: <20220117232259.180459-7-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: LO2P265CA0056.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::20) 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: c6f0c31c-b6e4-4d26-4f1a-08d9da1086a8 X-MS-TrafficTypeDiagnostic: DM4PR11MB5550:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:773; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MMH3H+zODFnfLnkgrcVVhwPO8dhv0wVelBCByc4e3XMtvVKH5TZnlb5Vk/reg4GwsQ5tILrzdBPsyDIXXBUGqk91qyREbly6qfB56GkhhiFkdBiqR6ldue8pqO82zDaCmq4B3nmTBlYlpAvpJkD1tr0B6j2Dsjo8ThYXPiG9lTQDHkfBDzSrhJ08zPXciwFeculN0dAq9wDxMKKNNr3J+5KOOKjsBo4Iuq13sTl7btZDmLDD/hBFv56m+iw3e2krtvo274yK61QoDSvv58XJc6U1LxvamoYxUNAWtq32TWVHtK3erPlDIrWSz2AryuDZKyttl8dJJD2NGkS2KPBIh0Oai1y3DdmGD3qaRpJ7dDwKUPhASovOG+wtABANixyQY0X5HZ2N7/v8rKyK/6pvMslvuaVM9Ilm5cI9iroCPxtcrS1Rn1XrWKBvjcuwYrTRYyZXoAP1CN/4q/ljfkGPbRtNj3hrq1pFIKkcMZFTsAzTz3tOk9NlkbTVDGD7SqcaQ/A8tRVKkiFo7J4S25SvSdJg3L1Zzp+rR904KUsHWVIUiR1nCRVEyltM1uAHhP2pYDHoPvJ8+ahrsAEDM+GzyVGbPJYp1lyUN2/4OouF7Z1WKyOpt8Sj8CNSU9MgsdcmlyyBF2BQ7TKHB7gMJ5vUKw== 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?x0kLleus8I8qhBRTQKfbr74CjRCJ?= =?utf-8?q?xW2WCXHtftSMywoZ329/4kprWQzZrqT/vHGMYUW5pvk4/RUQfVhr7AP/Bh8AGbC3M?= =?utf-8?q?cJ5vTsjfn3gd6u/tUawt7ZYuUVAEThqJ+TKLA/B1+RfuWFGxIipsQVbO8N0Jyd0It?= =?utf-8?q?kdsEXutLofXRn5UrWl/eTAJxlHXy7LZX8mbSgHc84fUhI6HvY/z1BKrgOJr3N7cqV?= =?utf-8?q?+HmdpzEQlRUIKY5fZl1B4rt1aDtpXHQFM2AodtEGe93jf2+XK3SAnWqkE4sSefvw/?= =?utf-8?q?Dx1No3wxCeJtLkuAuhKBdj1lR2mlW0EaME/CJCDT4mUiIBr9gtwrjxLj3jrMg3Sm4?= =?utf-8?q?RqVMRxyfufX+TFmq3R7aI/NLnag74RXEpZXP+TDljxQWQKfBiQJf16TyI0viaNK7f?= =?utf-8?q?GyTee3JMUwto8i5ioSZ0l7i7cMdoZcy76tFo/1YMYAmrW2gq37dl/NR2BaJMu+3TW?= =?utf-8?q?ky/IZ9WqV2i5ywYjVTshQSqNFURahR4SliboRu4ogCHrMRyxWnmTfYuAUIgRhVGa7?= =?utf-8?q?rj5VxB9bkzCx2Gl/KvXQBmDh1ny9Y7ERfIkO7TQHq9GjxpmDakNMdz4OdECekRGOM?= =?utf-8?q?32l7H7u3YuWsvutWMyh71VwHNjLB9+KfZX1HkLzBtwLHljT3iewYpuP2TKdShRggw?= =?utf-8?q?jGBDQzkDGawcwJTEZubK7o7y31sTRTyTLE2hO4fD13VVfMJi9NGRx8cAW+YhuGLCV?= =?utf-8?q?ZJFUCxiPO5QCziNe+chSQEKt5rS9FEXwlQaJPlhwpjbxU8S2HC0IwjSOgWj9XYCdS?= =?utf-8?q?kdtrQc2UAw6xu/N+sahUbDCU0CEWaxx7CrPyY/kIzk7ZYLzSSkJpeSIU/eAXabcOV?= =?utf-8?q?utVKKqsj6cJbOYjxX5JpsA7TFoYhVviOosMN9KhSRQ9FVvQNPufEVYPQFedcqfjhZ?= =?utf-8?q?ZVA4OzL/cSWDi14Ne4n6Kriv3gnsLm+01pcpCnhYAKlPYXxFsB/jpo42SgrTJ9FqT?= =?utf-8?q?IYF7vO9NaNsXrEc7Sf1nBui47U4KyP9MOBDzkeAFIPwnxvCB45dYEKpWX9xRFUl0z?= =?utf-8?q?TLhkWxjw/VvDZr34BCViUO86X8yAED3Xs5IHwcu4XGvw6JTAo+wetBS3ywLoUS4IO?= =?utf-8?q?EiruXPlVkfZuHJBQM11RbH8YdVROxhCzvL/GCxzAICwbdKhaegdzQlFlggKPnbmL2?= =?utf-8?q?tNI8XVFbhVi41uDtiAwt+N7VaTDpg95nhrkXPPNfxyNAAzAz78yqRaS62fLehItK/?= =?utf-8?q?KeqebbmGcE21tEdLiwwUAdDW6h1L2RJ4IawY4CQC++XTjD+Y1QIqNUzH98Sl/0VlS?= =?utf-8?q?9Td4A5rwVbGqoKm29U4Pgb8ijH7Uy090T1m49kkeTK+5h0wkXKywbr27Ir3O7qtyR?= =?utf-8?q?8oc9bIVap1SbCQiAeElV3joJ4yEe2bZpa8D9f/I0QwWDUV+99RORngHnUJV7O+Zlx?= =?utf-8?q?SQBzOCBFXJ3z2A1/B8JPSek4gljQ9eHmSjv7id43xtMcpj6H1UVfCzUo/MjOqisHQ?= =?utf-8?q?bbvjrjP2wRtWFbRk2rH/MyUb0bg+ND30dwjGgMcMUS1Praf7DWMXOMVH+y+rEC13W?= =?utf-8?q?Zh4qYd4/J/KHJC1s2D7PjZd5XKz1d8PTN6jrFc8DJJqF8iRIme1Gx9FSGWdD8eOW6?= =?utf-8?q?N3ucaDs/w4ke11XBw1bLqMnRI2fUdFQdg=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: c6f0c31c-b6e4-4d26-4f1a-08d9da1086a8 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:36.5010 (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: BSwUeou16kHll76Z9u25crM6JAydeUjriX5t0N+BIJo+ErS8UxKcIUsVVQrIU3ILa2cGP1lPbv5nCG9YnTXPG7yv/j3+qp2Iwm/FA0dYNYc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5550 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org igt_dp_mst_calc_pbn_mode was converted one-to-one, igt_dp_mst_sideband_msg_req_decode was refactored to parameterized test. Signed-off-by: Michał Winiarski --- drivers/gpu/drm/selftests/Makefile | 3 +- .../gpu/drm/selftests/drm_modeset_selftests.h | 2 - .../drm/selftests/test-drm_dp_mst_helper.c | 502 ++++++++++++------ .../drm/selftests/test-drm_modeset_common.h | 2 - 4 files changed, 330 insertions(+), 179 deletions(-) diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/selftests/Makefile index 35f2f40dbaf3..77e37eebf099 100644 --- a/drivers/gpu/drm/selftests/Makefile +++ b/drivers/gpu/drm/selftests/Makefile @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only test-drm_modeset-$(CONFIG_DRM_DEBUG_SELFTEST) := \ test-drm_modeset_common.o \ - test-drm_dp_mst_helper.o \ test-drm_rect.o obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o @@ -9,4 +8,4 @@ obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.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_damage_helper.o test-drm_dp_mst_helper.o diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h b/drivers/gpu/drm/selftests/drm_modeset_selftests.h index b6a6dba66b64..630770d30aba 100644 --- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h +++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h @@ -10,5 +10,3 @@ 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) -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_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c index 6b4759ed6bfd..d0719f3c5a42 100644 --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c @@ -3,54 +3,97 @@ * Test cases for for the DRM DP MST helpers */ -#define PREFIX_STR "[drm_dp_mst_helper]" - +#include #include #include #include #include "../drm_dp_mst_topology_internal.h" -#include "test-drm_modeset_common.h" -int igt_dp_mst_calc_pbn_mode(void *ignored) +struct dp_mst_calc_pbn_mode_test { + int rate; + int bpp; + int expected; + bool dsc; +}; + +static void dp_mst_calc_pbn_mode(struct kunit *test) { - int pbn, i; - const struct { - int rate; - int bpp; - int expected; - bool dsc; - } test_params[] = { - { 154000, 30, 689, false }, - { 234000, 30, 1047, false }, - { 297000, 24, 1063, false }, - { 332880, 24, 50, true }, - { 324540, 24, 49, true }, - }; + const struct dp_mst_calc_pbn_mode_test *params = test->param_value; + int pbn; - for (i = 0; i < ARRAY_SIZE(test_params); i++) { - pbn = drm_dp_calc_pbn_mode(test_params[i].rate, - test_params[i].bpp, - test_params[i].dsc); - FAIL(pbn != test_params[i].expected, - "Expected PBN %d for clock %d bpp %d, got %d\n", - test_params[i].expected, test_params[i].rate, - test_params[i].bpp, pbn); - } + pbn = drm_dp_calc_pbn_mode(params->rate, + params->bpp, + params->dsc); + + KUNIT_EXPECT_EQ(test, pbn, params->expected); +} - return 0; +static const struct dp_mst_calc_pbn_mode_test dp_mst_calc_pbn_mode_tests[] = { + { + .rate = 154000, + .bpp = 30, + .expected = 689, + .dsc = false, + }, + { + .rate = 234000, + .bpp = 30, + .expected = 1047, + .dsc = false, + }, + { + .rate = 297000, + .bpp = 24, + .expected = 1063, + .dsc = false, + }, + { + .rate = 332880, + .bpp = 24, + .expected = 50, + .dsc = true, + }, + { + .rate = 324540, + .bpp = 24, + .expected = 49, + .dsc = true, + }, +}; + +static void dp_mst_calc_pbn_mode_desc(const struct dp_mst_calc_pbn_mode_test *t, + char *desc) +{ + sprintf(desc, "rate = %d, bpp = %d, dsc = %s", + t->rate, t->bpp, t->dsc ? "true" : "false"); } -static bool -sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in, - const struct drm_dp_sideband_msg_req_body *out) +KUNIT_ARRAY_PARAM(dp_mst_calc_pbn_mode, dp_mst_calc_pbn_mode_tests, dp_mst_calc_pbn_mode_desc); + +static void +drm_dp_mst_helper_printfn(struct drm_printer *p, struct va_format *vaf) +{ + struct kunit *test = p->arg; + + kunit_err(test, "%pV", vaf); +} + +static void +expect_sideband_msg_req_equal(struct kunit *test, + const struct drm_dp_sideband_msg_req_body *in, + const struct drm_dp_sideband_msg_req_body *out) { const struct drm_dp_remote_i2c_read_tx *txin, *txout; + struct drm_printer p = { + .printfn = drm_dp_mst_helper_printfn, + .arg = test + }; int i; if (in->req_type != out->req_type) - return false; + goto fail; switch (in->req_type) { /* @@ -65,7 +108,7 @@ sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in, IN.num_transactions != OUT.num_transactions || IN.port_number != OUT.port_number || IN.read_i2c_device_id != OUT.read_i2c_device_id) - return false; + goto fail; for (i = 0; i < IN.num_transactions; i++) { txin = &IN.transactions[i]; @@ -76,11 +119,11 @@ sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in, txin->num_bytes != txout->num_bytes || txin->i2c_transaction_delay != txout->i2c_transaction_delay) - return false; + goto fail; if (memcmp(txin->bytes, txout->bytes, txin->num_bytes) != 0) - return false; + goto fail; } break; #undef IN @@ -92,9 +135,12 @@ sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in, if (IN.dpcd_address != OUT.dpcd_address || IN.num_bytes != OUT.num_bytes || IN.port_number != OUT.port_number) - return false; + goto fail; - return memcmp(IN.bytes, OUT.bytes, IN.num_bytes) == 0; + if (memcmp(IN.bytes, OUT.bytes, IN.num_bytes) != 0) + goto fail; + + break; #undef IN #undef OUT @@ -104,55 +150,65 @@ sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in, if (IN.port_number != OUT.port_number || IN.write_i2c_device_id != OUT.write_i2c_device_id || IN.num_bytes != OUT.num_bytes) - return false; + goto fail; - return memcmp(IN.bytes, OUT.bytes, IN.num_bytes) == 0; + if (memcmp(IN.bytes, OUT.bytes, IN.num_bytes) != 0) + goto fail; + + break; #undef IN #undef OUT default: - return memcmp(in, out, sizeof(*in)) == 0; + if (memcmp(in, out, sizeof(*in)) != 0) + goto fail; } - return true; + return; + +fail: + drm_printf(&p, "Expected:\n"); + drm_dp_dump_sideband_msg_req_body(in, 1, &p); + drm_printf(&p, "Got:\n"); + drm_dp_dump_sideband_msg_req_body(out, 1, &p); + KUNIT_FAIL(test, "Encode/decode failed"); +} + +struct dp_mst_sideband_msg_req_decode_test { + const struct drm_dp_sideband_msg_req_body req; + const struct drm_dp_sideband_msg_req_body + (*f)(const struct drm_dp_sideband_msg_req_body *in); +}; + +const struct drm_dp_sideband_msg_req_body +param_to_dp_mst_sideband_msg_req_body(const struct dp_mst_sideband_msg_req_decode_test *t) +{ + if (t->f) + return t->f(&t->req); + + return t->req; } -static bool -sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in) +static void dp_mst_sideband_msg_req_decode(struct kunit *test) { + const struct drm_dp_sideband_msg_req_body in = + param_to_dp_mst_sideband_msg_req_body(test->param_value); struct drm_dp_sideband_msg_req_body *out; - struct drm_printer p = drm_err_printer(PREFIX_STR); struct drm_dp_sideband_msg_tx *txmsg; - int i, ret; - bool result = true; - - out = kzalloc(sizeof(*out), GFP_KERNEL); - if (!out) - return false; - - txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL); - if (!txmsg) - return false; - - drm_dp_encode_sideband_req(in, txmsg); - ret = drm_dp_decode_sideband_req(txmsg, out); - if (ret < 0) { - drm_printf(&p, "Failed to decode sideband request: %d\n", - ret); - result = false; - goto out; - } + int i; - if (!sideband_msg_req_equal(in, out)) { - drm_printf(&p, "Encode/decode failed, expected:\n"); - drm_dp_dump_sideband_msg_req_body(in, 1, &p); - drm_printf(&p, "Got:\n"); - drm_dp_dump_sideband_msg_req_body(out, 1, &p); - result = false; - goto out; - } + out = kunit_kzalloc(test, sizeof(*out), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, out); - switch (in->req_type) { + txmsg = kunit_kzalloc(test, sizeof(*txmsg), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, txmsg); + + drm_dp_encode_sideband_req(&in, txmsg); + KUNIT_ASSERT_EQ(test, drm_dp_decode_sideband_req(txmsg, out), 0); + + expect_sideband_msg_req_equal(test, &in, out); + + switch (in.req_type) { case DP_REMOTE_DPCD_WRITE: kfree(out->u.dpcd_write.bytes); break; @@ -164,110 +220,210 @@ sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in) kfree(out->u.i2c_write.bytes); break; } - - /* Clear everything but the req_type for the input */ - memset(&in->u, 0, sizeof(in->u)); - -out: - kfree(out); - kfree(txmsg); - return result; } -int igt_dp_mst_sideband_msg_req_decode(void *unused) +static u8 data[] = { 0xff, 0x0, 0xdd }; + +const struct drm_dp_sideband_msg_req_body +random_dp_query_enc_client_id(const struct drm_dp_sideband_msg_req_body *in) { - struct drm_dp_sideband_msg_req_body in = { 0 }; - u8 data[] = { 0xff, 0x0, 0xdd }; - int i; + struct drm_dp_query_stream_enc_status enc_status = { }; -#define DO_TEST() FAIL_ON(!sideband_msg_req_encode_decode(&in)) - - in.req_type = DP_ENUM_PATH_RESOURCES; - in.u.port_num.port_number = 5; - DO_TEST(); - - in.req_type = DP_POWER_UP_PHY; - in.u.port_num.port_number = 5; - DO_TEST(); - - in.req_type = DP_POWER_DOWN_PHY; - in.u.port_num.port_number = 5; - DO_TEST(); - - in.req_type = DP_ALLOCATE_PAYLOAD; - in.u.allocate_payload.number_sdp_streams = 3; - for (i = 0; i < in.u.allocate_payload.number_sdp_streams; i++) - in.u.allocate_payload.sdp_stream_sink[i] = i + 1; - DO_TEST(); - in.u.allocate_payload.port_number = 0xf; - DO_TEST(); - in.u.allocate_payload.vcpi = 0x7f; - DO_TEST(); - in.u.allocate_payload.pbn = U16_MAX; - DO_TEST(); - - in.req_type = DP_QUERY_PAYLOAD; - in.u.query_payload.port_number = 0xf; - DO_TEST(); - in.u.query_payload.vcpi = 0x7f; - DO_TEST(); - - in.req_type = DP_REMOTE_DPCD_READ; - in.u.dpcd_read.port_number = 0xf; - DO_TEST(); - in.u.dpcd_read.dpcd_address = 0xfedcb; - DO_TEST(); - in.u.dpcd_read.num_bytes = U8_MAX; - DO_TEST(); - - in.req_type = DP_REMOTE_DPCD_WRITE; - in.u.dpcd_write.port_number = 0xf; - DO_TEST(); - in.u.dpcd_write.dpcd_address = 0xfedcb; - DO_TEST(); - in.u.dpcd_write.num_bytes = ARRAY_SIZE(data); - in.u.dpcd_write.bytes = data; - DO_TEST(); - - in.req_type = DP_REMOTE_I2C_READ; - in.u.i2c_read.port_number = 0xf; - DO_TEST(); - in.u.i2c_read.read_i2c_device_id = 0x7f; - DO_TEST(); - in.u.i2c_read.num_transactions = 3; - in.u.i2c_read.num_bytes_read = ARRAY_SIZE(data) * 3; - for (i = 0; i < in.u.i2c_read.num_transactions; i++) { - in.u.i2c_read.transactions[i].bytes = data; - in.u.i2c_read.transactions[i].num_bytes = ARRAY_SIZE(data); - in.u.i2c_read.transactions[i].i2c_dev_id = 0x7f & ~i; - in.u.i2c_read.transactions[i].i2c_transaction_delay = 0xf & ~i; - } - DO_TEST(); - - in.req_type = DP_REMOTE_I2C_WRITE; - in.u.i2c_write.port_number = 0xf; - DO_TEST(); - in.u.i2c_write.write_i2c_device_id = 0x7f; - DO_TEST(); - in.u.i2c_write.num_bytes = ARRAY_SIZE(data); - in.u.i2c_write.bytes = data; - DO_TEST(); - - in.req_type = DP_QUERY_STREAM_ENC_STATUS; - in.u.enc_status.stream_id = 1; - DO_TEST(); - get_random_bytes(in.u.enc_status.client_id, - sizeof(in.u.enc_status.client_id)); - DO_TEST(); - in.u.enc_status.stream_event = 3; - DO_TEST(); - in.u.enc_status.valid_stream_event = 0; - DO_TEST(); - in.u.enc_status.stream_behavior = 3; - DO_TEST(); - in.u.enc_status.valid_stream_behavior = 1; - DO_TEST(); - -#undef DO_TEST - return 0; + get_random_bytes(enc_status.client_id, sizeof(enc_status.client_id)); + + return (const struct drm_dp_sideband_msg_req_body) { .req_type = in->req_type, + .u.enc_status = enc_status + }; } + +static const struct dp_mst_sideband_msg_req_decode_test dp_msg_sideband_msg_req_decode_tests[] = { + { + .req = { + .req_type = DP_ENUM_PATH_RESOURCES, + .u.port_num.port_number = 5, + }, + }, + { + .req = { + .req_type = DP_POWER_UP_PHY, + .u.port_num.port_number = 5, + }, + }, + { + .req = { + .req_type = DP_POWER_DOWN_PHY, + .u.port_num.port_number = 5, + }, + }, + { + .req = { + .req_type = DP_ALLOCATE_PAYLOAD, + .u.allocate_payload.number_sdp_streams = 3, + .u.allocate_payload.sdp_stream_sink = { 1, 2, 3 }, + }, + }, + { + .req = { + .req_type = DP_ALLOCATE_PAYLOAD, + .u.allocate_payload.port_number = 0xf, + }, + }, + { + .req = { + .req_type = DP_ALLOCATE_PAYLOAD, + .u.allocate_payload.vcpi = 0x7f, + }, + }, + { + .req = { + .req_type = DP_ALLOCATE_PAYLOAD, + .u.allocate_payload.pbn = U16_MAX, + }, + }, + { + .req = { + .req_type = DP_QUERY_PAYLOAD, + .u.query_payload.port_number = 0xf, + }, + }, + { + .req = { + .req_type = DP_QUERY_PAYLOAD, + .u.query_payload.vcpi = 0x7f, + }, + }, + { + .req = { + .req_type = DP_REMOTE_DPCD_READ, + .u.dpcd_read.port_number = 0xf, + }, + }, + { + .req = { + .req_type = DP_REMOTE_DPCD_READ, + .u.dpcd_read.dpcd_address = 0xfedcb, + }, + }, + { + .req = { + .req_type = DP_REMOTE_DPCD_READ, + .u.dpcd_read.num_bytes = U8_MAX, + }, + }, + { + .req = { + .req_type = DP_REMOTE_DPCD_WRITE, + .u.dpcd_write.port_number = 0xf, + }, + }, + { + .req = { + .req_type = DP_REMOTE_DPCD_WRITE, + .u.dpcd_write.dpcd_address = 0xfedcb, + }, + }, + { + .req = { + .req_type = DP_REMOTE_DPCD_WRITE, + .u.dpcd_write.num_bytes = ARRAY_SIZE(data), + .u.dpcd_write.bytes = data, + }, + }, + { + .req = { + .req_type = DP_REMOTE_I2C_READ, + .u.i2c_read.port_number = 0xf, + }, + }, + { + .req = { + .req_type = DP_REMOTE_I2C_READ, + .u.i2c_read.read_i2c_device_id = 0x7f, + }, + }, + { + .req = { + .req_type = DP_REMOTE_I2C_READ, + .u.i2c_read.num_transactions = 3, + .u.i2c_read.num_bytes_read = ARRAY_SIZE(data) * 3, + .u.i2c_read.transactions = { + { .bytes = data, .num_bytes = ARRAY_SIZE(data), + .i2c_dev_id = 0x7f, .i2c_transaction_delay = 0xf, }, + { .bytes = data, .num_bytes = ARRAY_SIZE(data), + .i2c_dev_id = 0x7e, .i2c_transaction_delay = 0xe, }, + { .bytes = data, .num_bytes = ARRAY_SIZE(data), + .i2c_dev_id = 0x7d, .i2c_transaction_delay = 0xd, }, + }, + }, + }, + { + .req = { + .req_type = DP_REMOTE_I2C_WRITE, + .u.i2c_write.port_number = 0xf, + }, + }, + { + .req = { + .req_type = DP_REMOTE_I2C_WRITE, + .u.i2c_write.write_i2c_device_id = 0x7f, + }, + }, + { + .req = { + .req_type = DP_REMOTE_I2C_WRITE, + .u.i2c_write.num_bytes = ARRAY_SIZE(data), + .u.i2c_write.bytes = data, + }, + }, + { + .req = { + .req_type = DP_QUERY_STREAM_ENC_STATUS, + .u.enc_status.stream_id = 1, + }, + }, + { + .req = { + .req_type = DP_QUERY_STREAM_ENC_STATUS, + }, + .f = random_dp_query_enc_client_id, + }, + { + .req = { + .req_type = DP_QUERY_STREAM_ENC_STATUS, + .u.enc_status.stream_event = 3, + }, + }, + { + .req = { + .req_type = DP_QUERY_STREAM_ENC_STATUS, + .u.enc_status.valid_stream_event = 0, + }, + }, + { + .req = { + .req_type = DP_QUERY_STREAM_ENC_STATUS, + .u.enc_status.stream_behavior = 3, + }, + }, + { + .req = { + .req_type = DP_QUERY_STREAM_ENC_STATUS, + .u.enc_status.valid_stream_behavior = 1, + }, + }, +}; + +KUNIT_ARRAY_PARAM(dp_mst_sideband_msg_req, dp_msg_sideband_msg_req_decode_tests, NULL); + +static struct kunit_case drm_dp_mst_helper_tests[] = { + KUNIT_CASE_PARAM(dp_mst_calc_pbn_mode, dp_mst_calc_pbn_mode_gen_params), + KUNIT_CASE_PARAM(dp_mst_sideband_msg_req_decode, dp_mst_sideband_msg_req_gen_params), + {} +}; + +static struct kunit_suite drm_dp_mst_helper_test_suite = { + .name = "drm_dp_mst_helper_tests", + .test_cases = drm_dp_mst_helper_tests, +}; + +kunit_test_suite(drm_dp_mst_helper_test_suite); diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h index 1501d99aee2f..c7cc5edc65f1 100644 --- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h +++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h @@ -20,7 +20,5 @@ 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); -int igt_dp_mst_calc_pbn_mode(void *ignored); -int igt_dp_mst_sideband_msg_req_decode(void *ignored); #endif 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); From patchwork Mon Jan 17 23:22:58 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: 12715724 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 956C9C433FE for ; Mon, 17 Jan 2022 23:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243798AbiAQXZD (ORCPT ); Mon, 17 Jan 2022 18:25:03 -0500 Received: from mga12.intel.com ([192.55.52.136]:55097 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243793AbiAQXZB (ORCPT ); Mon, 17 Jan 2022 18:25:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642461901; x=1673997901; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=7SZ5FkscuxR8Fu6Dmn9NNsNOTopG57Z6VqpuNtW5J8E=; b=R77yLJfNyp0l0U4uO602QR+xH8NBmAhccHtgZAkTH0PvmBoS89DivVMU Q6YE4p9dHLAUsY3zhmlcyOlQVATbPANwRQrecX83Q8RPiGQ9cdrCO99yK gqMoL4J2aiWyjwreQH9BdFwOaKvbUHk+dM0YzdwqNKTvP0unRUxqyHt2A Aqq7Emd3biSbYcNNPBMAgzWVAAPXC6evlyJoBKdU8FZzHOqHmMMOF49hz kO229CRCGkWPnF4aAdZXP/zkULiH+HOF6RidRfljJOo1bwhzRCPB5i/7R 1FQUCJWVh51E6GO/mVtRYv/Ql+5SjjCdFz+VfOPUCsEOBn0Z3+KxGKOXq w==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="224683797" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="224683797" 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:25:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="517554470" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga007.jf.intel.com with ESMTP; 17 Jan 2022 15:25:01 -0800 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX605.amr.corp.intel.com (10.22.229.18) 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:25:00 -0800 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX609.amr.corp.intel.com (10.22.229.22) 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:25:00 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx609.amr.corp.intel.com (10.22.229.22) 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:25:00 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.169) by edgegateway.intel.com (134.134.137.103) 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:25:00 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j0Ghs3ihrHzAChHBnIY0YYjHuaKG6n5NvPim9I7wbZ/v4fs2qdxmuJrn1J3x0Q0RC2uZZDsXwXrNcZ+lj2TIN5FmBl1saXdM5vLur2n2h5hTolHZROmkhIs0C1oN7yoAOPFzuyEC7tNSel9Y+tFL0VN1dMGQ/Dc30sBlyzab3gib64IOQCxV32u8B3j+E5whi3XHMkXPfx/fhXEngKVdc/tQzD4oDJnwGl89QXl81hMJxXqDmC5TJp+EmPxdaQeRGbnBGOl73TcPjx7NF9MOjjc1r+/wnPDpCm5DmrQ0TTZzB3Uvn/L9Q07YJP+6Zp4i1NbpTON3UVJ2ENezT96Niw== 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=lKlHknuBE7WK6xRv+9R+AldWiYg3irUWS2IbYi9xaQo=; b=P3gUgdf5GkRE2Dr8VEaSXbKoVD7/OYNP45OWKMO25sjthP2QoC9nocb/mdHG+ayrcfKLeCO0Qu+m3NNY0hF72L67h4563s9JEp85EPouFepjV4Ds6uu0BTRm5MklncLSXZLkGHLPCcGJ4ugYJlFdyK4rdRIcWrWNdpMHUM1HdUxTMiDsOFSvUjkqA9WDm1igyW/fJQnwK/XPDGcUPz5YLA8ZfADlqjKGMpwelX7JknrimK7wA932gycrJXj+fvQPwO54i7eZMFglDe/s8EhvwpWImQejznOeyyxJvhYYZnKNTBdZ712FFkNUnA3sJjxFWoEygNmBIM76QpTy2BIWKQ== 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:58 +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:58 +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 09/10] drm: selftests: Convert to KUnit Date: Tue, 18 Jan 2022 00:22:58 +0100 Message-ID: <20220117232259.180459-10-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: AS9PR06CA0409.eurprd06.prod.outlook.com (2603:10a6:20b:461::18) 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: 8064ead1-3a13-439f-570f-08d9da109389 X-MS-TrafficTypeDiagnostic: DM4PR11MB5550:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ktiPXdK1Yd1LWonUumMbng9XDIEiz9nVmFya20gGVrcPoEEUE98vKbmQfxpeSt/F4XOSzRaEySCmkBHd6LW2csWrHObh3vF/Su1AtRlVHYJcUBxOxuvpOBHM0LPmRw2Fq6ETYLvVP1UAQR/dFIfIcGe4tQM8phJ+dzJH3191DBjjqT3Z7n46Iv75FeNvXkpMGPVlZMHQFdlzxoN406k69K5cCxtODeBkecafL5Tsb8Fqsd+ScxhMX090UGzQc2SEwNc6sHnQNNmOOJGHTGHySz287bVQYub4lGJmyt1JSmZkmGo7Ag4eR5JEdHddOG3hTL6zaj6ErUnsn1hZ+ugxBQmMJJf9pS4VIRdCv05R+GxFiP+Vxpg6xVOT4q/99DSR+eHNAVNZ2QzOnSGs77wGrEc6jRPWt5+U9SH3n/r4lIcIzbWwq3wDrCpzADdAzJ7/mYHmdswXFKlvaZWrslz8frD0Cnke/1GCFCpBKrfbqRrMckqlkunZiURVVQbsj45WQrFENnMdY+1Owdpf22iHYVxEN4aeqlxiA1nj4qAhLMrcEt8/F+boFuBSE6tYZMKTXncbwPbMXx0ZbPLjM8K22BULnmuPzFjhcUvLpeyfPIKHE3Dyd5JZ8OwEtRUBsIuM9I0Lr9W6zk3CfKZo22Dddg== 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)(8676002)(2616005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?HXEReh4osXyfhzeWQ7zqZkGHwChE?= =?utf-8?q?b4PeIz0Z9ldjCYiut+2jFuQUt/wfUjH54mzX8aEz2Zc8pxXfC7diPVYPWeHIJ5X84?= =?utf-8?q?4vEoXjsQtleQk9zRnpuBw+VF2TNon0ergCg2/orNZrE6r+Wt9htJM8V5bL0RczTZP?= =?utf-8?q?HbcbQgtxwIn//PR4TZgNy/SiyAbXzvmG6XrL9wgt1Q0RQBrrlOBr+uJIWU6W6XcDl?= =?utf-8?q?PfJeEMlPgCf0Vt+LHqkRbAcRd4EWmHkXDkE7f4XaXuFboII8ke6HdL3uMFT5kpDwq?= =?utf-8?q?hFFhxR9xrpGHxsfHI6Ko+wMJAuEEIBq+iRHHBragri/SYZ314cQCjVwy/NzYIwG1z?= =?utf-8?q?yFqDRFUui1KAD3ZL31Q8L+5wwNZwuemYiKcXC8vqimKPEVzlH2OajC2tU5xWdYtKM?= =?utf-8?q?qH8oF0mfivmCMMXDq2A/e6HQCm7ljgNeibGE0CMGy/U8XY8b8Efl3RsL+rOdSgBZC?= =?utf-8?q?BeF6oWRJ6Cr/ImVE2HaEM/9u1/ouJFgK2B7Eh0J9M5maCvG1XAx697eMmfv2TCCrK?= =?utf-8?q?JJBbClU1YtaS6AxbF553NEnNtKrYnKUYQOmfcRUzkZxfrCZ5fkuof+IlHYk08vEq+?= =?utf-8?q?L7E+zgg1tDc4Pc1z67yHDlWP8gg5V3ScJJATNQ+EnSgj2A5NpXuPqfGbqFG+vWT8A?= =?utf-8?q?zuzaV2Gw/E41UpqgPJhKOfWXnryX8BeVX4NzuiFofQ/mQc+/J4ik7aoj89EbR5XKp?= =?utf-8?q?XYi189FiFjX2RCm8YhIxUJSGevEJap1ZXoONN0rPaoOiMWpzVd0nFx1sSiN9CqsRA?= =?utf-8?q?Ln25uNVwbi+BwSNm5/lSGt3wi08wPc4hJIg1w9Ff84sLHdC2hol9HZ9q5m9LY6PCS?= =?utf-8?q?WTReVciUbHba/laBRKIlSdNfqyzZ8UyhvGspS1Jgyw7kGd1cg5cTtoVuFok7+lYlw?= =?utf-8?q?GQuXXcnnUHhqfOZGjmC+9DSvVLQQggOCCl/gwthxt2U6/99rBIiw+AdeO65ubNN3/?= =?utf-8?q?D+LCFg+oQs4zp402mkq/V5IxVKpQa5QlKTHKjhCnsk6Y0gkjBcbtLFRtoQV9Ka1tG?= =?utf-8?q?6xiclDrjwKiyT21rQqlz+WK7LGz3jZQCkqYpRGKU65kp0Wt4fXeihbnCcSvYporZA?= =?utf-8?q?fTahpNm0iEmGjBC58/CJh4/sLLDFWkig9K4jMy+OoLkokBgYOy43OIPX+qrH+35Yb?= =?utf-8?q?fkrtuuVnCX5p+WZuIe3Lt84d84o5HaG6R15tdJkzUw03h75Q2CPxLtirgUDhwb+u3?= =?utf-8?q?e7nMIqi7uHQQuagwYz9yPzPeY+w/RhB5myELz60eoYbPf9HIG1mYscm1np7LQACJR?= =?utf-8?q?zmlscxwkV5If6U7Oyb9tqi3Iz9DkWH5ja+zygJ2eaw2DWSoL7YZFqH+a/EKbHi8qx?= =?utf-8?q?o2AQSLzT1VRPTE5OVs07zO/iJQ+W/YG/BwZNxPjz09E6MgFDBYX7N85LnjNsp85Dj?= =?utf-8?q?aKmBh1jkTmoPT2J2oFPKXXIVhg/DGniz1h7dUZu/9WQwVvdwf51s2TUEHIKEFNsi2?= =?utf-8?q?rW9OU8lSe2BGcTlXb+dcHMqSTdopQ2WOlzDeKWFct+oXjg/tWd1Lji6WtGCdc3bVH?= =?utf-8?q?gNWnB0m7SRUjDP0CC3+zU5urV/Ct7CLThyhiQdGR8CGWHFrU/IJ6vO7+G99VuDQH+?= =?utf-8?q?A+ZJdCZXCrnJdojODXI4QCBQ8QGOgFj8g=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 8064ead1-3a13-439f-570f-08d9da109389 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:58.0312 (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: XawDAc8gBKZyQBAIVbzg2W7e80Pi4Z4h/OMPtQf5cRaPbqTIPOO98iOctAZtM0LoYDDGlh5tYAbtOQoVtzX0axqWyGmwODyeovrzW3MfKD4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5550 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Now that all tests were converted, remove the content that's no longer used and rename the directory to "test". Signed-off-by: Michał Winiarski --- drivers/gpu/drm/Kconfig | 17 --- drivers/gpu/drm/Makefile | 2 +- drivers/gpu/drm/i915/Kconfig.debug | 1 - drivers/gpu/drm/selftests/drm_selftest.c | 109 ------------------ drivers/gpu/drm/selftests/drm_selftest.h | 41 ------- drivers/gpu/drm/{selftests => test}/Makefile | 0 .../test-drm_cmdline_parser.c | 0 .../test-drm_damage_helper.c | 0 .../test-drm_dp_mst_helper.c | 0 .../drm/{selftests => test}/test-drm_format.c | 0 .../test-drm_framebuffer.c | 0 .../gpu/drm/{selftests => test}/test-drm_mm.c | 0 .../test-drm_plane_helper.c | 0 .../drm/{selftests => test}/test-drm_rect.c | 0 14 files changed, 1 insertion(+), 169 deletions(-) delete mode 100644 drivers/gpu/drm/selftests/drm_selftest.c delete mode 100644 drivers/gpu/drm/selftests/drm_selftest.h rename drivers/gpu/drm/{selftests => test}/Makefile (100%) rename drivers/gpu/drm/{selftests => test}/test-drm_cmdline_parser.c (100%) rename drivers/gpu/drm/{selftests => test}/test-drm_damage_helper.c (100%) rename drivers/gpu/drm/{selftests => test}/test-drm_dp_mst_helper.c (100%) rename drivers/gpu/drm/{selftests => test}/test-drm_format.c (100%) rename drivers/gpu/drm/{selftests => test}/test-drm_framebuffer.c (100%) rename drivers/gpu/drm/{selftests => test}/test-drm_mm.c (100%) rename drivers/gpu/drm/{selftests => test}/test-drm_plane_helper.c (100%) rename drivers/gpu/drm/{selftests => test}/test-drm_rect.c (100%) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index c567324c96b9..7b18540a1b8a 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -63,23 +63,6 @@ config DRM_DEBUG_MM If in doubt, say "N". -config DRM_DEBUG_SELFTEST - tristate "kselftests for DRM" - depends on DRM - depends on DEBUG_KERNEL - select PRIME_NUMBERS - select DRM_LIB_RANDOM - select DRM_KMS_HELPER - select DRM_EXPORT_FOR_TESTS if m - default n - help - This option provides kernel modules that can be used to run - various selftests on parts of the DRM 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". - config DRM_KUNIT_TEST bool "DRM tests" if !KUNIT_ALL_TESTS depends on DRM=y && KUNIT=y diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 550800e81836..6fe8143c43e7 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -65,7 +65,7 @@ drm_kms_helper-$(CONFIG_DRM_DP_AUX_CHARDEV) += drm_dp_aux_dev.o drm_kms_helper-$(CONFIG_DRM_DP_CEC) += drm_dp_cec.o obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o -obj-y += selftests/ +obj-y += test/ obj-$(CONFIG_DRM) += drm.o obj-$(CONFIG_DRM_MIPI_DBI) += drm_mipi_dbi.o diff --git a/drivers/gpu/drm/i915/Kconfig.debug b/drivers/gpu/drm/i915/Kconfig.debug index e7fd3e76f8a2..425189f55d37 100644 --- a/drivers/gpu/drm/i915/Kconfig.debug +++ b/drivers/gpu/drm/i915/Kconfig.debug @@ -38,7 +38,6 @@ config DRM_I915_DEBUG select DRM_VGEM # used by igt/prime_vgem (dmabuf interop checks) select DRM_DEBUG_MM if DRM=y select DRM_EXPORT_FOR_TESTS if m - select DRM_DEBUG_SELFTEST select DMABUF_SELFTESTS select SW_SYNC # signaling validation framework (igt/syncobj*) select DRM_I915_WERROR diff --git a/drivers/gpu/drm/selftests/drm_selftest.c b/drivers/gpu/drm/selftests/drm_selftest.c deleted file mode 100644 index e29ed9faef5b..000000000000 --- a/drivers/gpu/drm/selftests/drm_selftest.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright © 2016 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include - -#define selftest(name, func) __idx_##name, -enum { -#include TESTS -}; -#undef selftest - -#define selftest(n, f) [__idx_##n] = { .name = #n, .func = f }, -static struct drm_selftest { - bool enabled; - const char *name; - int (*func)(void *); -} selftests[] = { -#include TESTS -}; -#undef selftest - -/* Embed the line number into the parameter name so that we can order tests */ -#define param(n) __PASTE(igt__, __PASTE(__PASTE(__LINE__, __), n)) -#define selftest_0(n, func, id) \ -module_param_named(id, selftests[__idx_##n].enabled, bool, 0400); -#define selftest(n, func) selftest_0(n, func, param(n)) -#include TESTS -#undef selftest - -static void set_default_test_all(struct drm_selftest *st, unsigned long count) -{ - unsigned long i; - - for (i = 0; i < count; i++) - if (st[i].enabled) - return; - - for (i = 0; i < count; i++) - st[i].enabled = true; -} - -static int run_selftests(struct drm_selftest *st, - unsigned long count, - void *data) -{ - int err = 0; - - set_default_test_all(st, count); - - /* Tests are listed in natural order in drm_*_selftests.h */ - for (; count--; st++) { - if (!st->enabled) - continue; - - pr_debug("drm: Running %s\n", st->name); - err = st->func(data); - if (err) - break; - } - - if (WARN(err > 0 || err == -ENOTTY, - "%s returned %d, conflicting with selftest's magic values!\n", - st->name, err)) - err = -1; - - rcu_barrier(); - return err; -} - -static int __maybe_unused -__drm_subtests(const char *caller, - const struct drm_subtest *st, - int count, - void *data) -{ - int err; - - for (; count--; st++) { - pr_debug("Running %s/%s\n", caller, st->name); - err = st->func(data); - if (err) { - pr_err("%s: %s failed with error %d\n", - caller, st->name, err); - return err; - } - } - - return 0; -} diff --git a/drivers/gpu/drm/selftests/drm_selftest.h b/drivers/gpu/drm/selftests/drm_selftest.h deleted file mode 100644 index c784ec02ff53..000000000000 --- a/drivers/gpu/drm/selftests/drm_selftest.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright © 2016 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#ifndef __DRM_SELFTEST_H__ -#define __DRM_SELFTEST_H__ - -struct drm_subtest { - int (*func)(void *data); - const char *name; -}; - -static int __drm_subtests(const char *caller, - const struct drm_subtest *st, - int count, - void *data); -#define drm_subtests(T, data) \ - __drm_subtests(__func__, T, ARRAY_SIZE(T), data) - -#define SUBTEST(x) { x, #x } - -#endif /* __DRM_SELFTEST_H__ */ diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/test/Makefile similarity index 100% rename from drivers/gpu/drm/selftests/Makefile rename to drivers/gpu/drm/test/Makefile diff --git a/drivers/gpu/drm/selftests/test-drm_cmdline_parser.c b/drivers/gpu/drm/test/test-drm_cmdline_parser.c similarity index 100% rename from drivers/gpu/drm/selftests/test-drm_cmdline_parser.c rename to drivers/gpu/drm/test/test-drm_cmdline_parser.c diff --git a/drivers/gpu/drm/selftests/test-drm_damage_helper.c b/drivers/gpu/drm/test/test-drm_damage_helper.c similarity index 100% rename from drivers/gpu/drm/selftests/test-drm_damage_helper.c rename to drivers/gpu/drm/test/test-drm_damage_helper.c diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/test/test-drm_dp_mst_helper.c similarity index 100% rename from drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c rename to drivers/gpu/drm/test/test-drm_dp_mst_helper.c diff --git a/drivers/gpu/drm/selftests/test-drm_format.c b/drivers/gpu/drm/test/test-drm_format.c similarity index 100% rename from drivers/gpu/drm/selftests/test-drm_format.c rename to drivers/gpu/drm/test/test-drm_format.c diff --git a/drivers/gpu/drm/selftests/test-drm_framebuffer.c b/drivers/gpu/drm/test/test-drm_framebuffer.c similarity index 100% rename from drivers/gpu/drm/selftests/test-drm_framebuffer.c rename to drivers/gpu/drm/test/test-drm_framebuffer.c diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/test/test-drm_mm.c similarity index 100% rename from drivers/gpu/drm/selftests/test-drm_mm.c rename to drivers/gpu/drm/test/test-drm_mm.c diff --git a/drivers/gpu/drm/selftests/test-drm_plane_helper.c b/drivers/gpu/drm/test/test-drm_plane_helper.c similarity index 100% rename from drivers/gpu/drm/selftests/test-drm_plane_helper.c rename to drivers/gpu/drm/test/test-drm_plane_helper.c diff --git a/drivers/gpu/drm/selftests/test-drm_rect.c b/drivers/gpu/drm/test/test-drm_rect.c similarity index 100% rename from drivers/gpu/drm/selftests/test-drm_rect.c rename to drivers/gpu/drm/test/test-drm_rect.c From patchwork Mon Jan 17 23:22:59 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: 12715725 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 1C719C433F5 for ; Mon, 17 Jan 2022 23:25:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243803AbiAQXZK (ORCPT ); Mon, 17 Jan 2022 18:25:10 -0500 Received: from mga07.intel.com ([134.134.136.100]:48918 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243793AbiAQXZJ (ORCPT ); Mon, 17 Jan 2022 18:25:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642461909; x=1673997909; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=Jt8teGclXTWX5oTZQ7V9oXxpvPlu8NnFH5sJhhX0uEs=; b=E5MrGPXLLqadzmVf00aefn/N4owF6MmZc3dv6S+u3m8PSrAifPkIb8Bc aGqXF4d+q8idU4j6k0ZlvT/wjqUn+oNT1K84vvvSVdx+SxcU4Hv4/5cjd P3/MoumUeCkvoKsvuD9r/l4WHzUbrjA8gVeggKHP6JmLcC6cb3aqdCxQH knpT14cR/qbFD9u4gWyfJnxWvzfNIftLVqyMcPX4P5GtP/hPAY5gp+Y2P cYaKuThtrPIEmT2Vu2/Luje3ZqAwKJ/grau1v2gZURxanaQACXSajGLaQ 4DnopcJQiHd5mEMJ4eIeuOBojfaR0OmGQMM1mhPqFALsMlDCbG8FBU5uv w==; X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="308043748" X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="308043748" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2022 15:25:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,296,1635231600"; d="scan'208";a="625325455" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga004.jf.intel.com with ESMTP; 17 Jan 2022 15:25:09 -0800 Received: from fmsmsx608.amr.corp.intel.com (10.18.126.88) by fmsmsx601.amr.corp.intel.com (10.18.126.81) 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:25:09 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) 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:25:09 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (192.55.55.70) 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:25:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rnvaxf/Doxy9L1u0W781iICAJEGt5eI8LuDUCNG06T2ku6EHyFnFQBEhzjLQlRxApG+95izfMAawyFPsrYQfmdC8M3QpujzL5ZfmSTxDwwKO88M8IJ0B668AFeDwNlUgCLbewG3NG1/qH7nsMFv9rYhBMS7eZjZ7kOVybp1+UxnqEzf1Jpty6JGe4Zq0LpUh3cFCWRV9qDDqrzOZ1cImuYQhrzV4kYmRDeuWVxvW/yepLySU+jMiDzOKtM25/b7Fi/xdb++Bo0cDHa9TIA7w9fDHgI+wdQ8NIGbfJ/yc2KatK6CCRX6HYXnf87ekVNn+dCooysV6UeX1w9c9hLtO8A== 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=9MX5FQiSWbnqIeMSJ7Sc8zY0Jc5rSneCC7mu/8gKVV4=; b=F56HfRTnoqxzTOE5fHtxwRLJ7szeiT/lCo/dFfXoqwM0CpTY6+PHaoH7RQ4SwsWriQQqAQbUSbNI0Yh1ph5umEs/zVJqzUYO4g3etwypwbNEbAMUmsmosAmfs5VD5RyQBCajIQ6AWx6pY2je/GBV6wii4CJrEm53LExpLTh/vDSUehJ45AUD8RJ8JJ3cb+2IK4wZVEMUXeWvDmoezM+cpen0T0/tzxhsHa3CtkA/tVGmMQ7aRfDgs+mELhoxs+Gbwgcj1M3OgtObTueZb6IRsVVsfJdCeyfskCwG2/lrMA3LXXc5ZKSjHiwujrqygGysw7oghgoMxerZJd4oJmqgWA== 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 DM6PR11MB4140.namprd11.prod.outlook.com (2603:10b6:5:19f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Mon, 17 Jan 2022 23:25:05 +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:25:05 +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 10/10] drm: test: Simplify testing on UML with kunit.py Date: Tue, 18 Jan 2022 00:22:59 +0100 Message-ID: <20220117232259.180459-11-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: LO4P123CA0377.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18e::22) 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: 72fc8e1a-5aaa-4d55-bef9-08d9da1097ad X-MS-TrafficTypeDiagnostic: DM6PR11MB4140:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LvmuZM26OvJZY3g4MScEkibXR/nzOYE36E+kGt3s21iS+Pp2bw8j2TIOB98ejmjVwyAgEtaXieMw3Mt4rqyuQhoLOCeFQkUX7ltzdMhbmz4bJX+XIymILFPqkT16TQeltnQJMlJMMmdCVSMTaCehnItUiwmFaolm9kHOm9njq4wlCFk29y8/cPDHkiYEAfcA46hh+wsEswZVx1G+0DPH3hcmn+122MgZDRqZXsaXIrYF050AdyW0TstcLEOV9zIW8aYFq0ZnLoiQGlgvLwH9q/ZUGPuK5upuq0CP8dM1W4KAg1r+A4XoIvlcjSst4aI0oOvkNzr63DKASWwxrDzG65vTRv5TC9MmWARXvF7CZo5zY85LGTg+83jV8kELd3qAdy9qFuvKHzjqzC/2CXPlnVc8xiwroZT0zaGA5HFNEsbiw0prfZ4/K+L3VVUN+T9Y4dh/uVxipyq/QaEyuH40cclGCnkxD1lm95zcB4vKDEXDsw3/mvT/YhfMZ2hg8fukmoLmvUJEVgX7PE24kGnU5fVnuEGziwujyO93DKJreklJI38oIWrpUzgWX2TfISuJaOFQbnsySub3shsUPTnhx7TXib4FLCDcYmMDwvyWWcYqBrnL156E0RuV3e0iUe5tLupQkgR6fQhBWS2vvU0BUQ== 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)(508600001)(7416002)(186003)(6506007)(82960400001)(86362001)(8676002)(6512007)(6666004)(38100700002)(8936002)(66556008)(54906003)(5660300002)(2906002)(6486002)(316002)(36756003)(2616005)(66946007)(26005)(1076003)(4326008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?kuHH2J5tg8G+AhhhK8LIQRv47310?= =?utf-8?q?5Hkr/4VgJtp4bYAiNMDZjLomZX2iRIPd1FEE12JFbi06WNU1jwbvv/6L6qvZcFbHF?= =?utf-8?q?UzofbRQlMw13lqVfcUyV1xKpaY9wthQeYS+bixLsrNt+zqT34/fJsM4fAwLfEsd8d?= =?utf-8?q?1mHG/HtWlQDZB+gB2K9twZPEM2LCE8iV2OVKJWh3MjS47b4HXRjYsXYFILF7lk6mw?= =?utf-8?q?946/dSCwZgbIW227Y7fk3Elc1UySHGZLgke/zyiUvXH1n7BoiHEszCzRbsveFCw37?= =?utf-8?q?tweYRkGO1IV/ULp8wK/rPD7r35euWZ4a/fu6Z2ZPY2CpoumojehISxKc0KQDMiu+F?= =?utf-8?q?gB3AdasRUtwXrMRaau5vr1ihkM2SGKB21BurCfJUAIWiXZI/2lJUqdB+p9slNNZYn?= =?utf-8?q?xk/swP16yKuYn58w9yGCx4IPsce9B7wKUthb1g38cj4dmsIGdZ3s7OYWE5JnzdKS7?= =?utf-8?q?WiFruHCyh1iipfDovRd52AzJxOa2GQpk0SZqLY2Wl+keqDH4Tl4Wx8+Xj6RwImSWD?= =?utf-8?q?BuQubmJgFEn6xAC0Ey3zADgNVTYByzsCkFirdQ8R8hwXegwVtkR56IzixMqMGDerO?= =?utf-8?q?z7amgiSKQc0OBZAuxwC1ECqYwPaJDjmPGCkE2QREKUeHWyU74Bw1v6caRqG6r1KpG?= =?utf-8?q?Y14PB0QhuhMDBICOx5c4ONTk2Dm1PeHarSsucwNqvIRA127tnhwbI+i0aIbj5gn3/?= =?utf-8?q?A8llqHvMRyrVwD3sWfEk2fjM2ZrIE+keNE/Kw+pWv4/2dz4X/WiMVyQ3RZIbdTw8c?= =?utf-8?q?5CUErmvdkRhRdaM0wVGUKN1OPJuqbUHaCW+NED+NXi6RyKw87O9SCXcNgDiXenFHb?= =?utf-8?q?aqY/bavFXthDdGW656Uecn70VVnNat4/DAQJYdo+rjEUEVMQ8zzHdThf6v98mSa8X?= =?utf-8?q?Vhm++Sld6p/QrKcKmb0CFDMBFtyH7SDed0fLKjVDm7nrdPjEgmX0xQY2/aroOSl+z?= =?utf-8?q?7+TmRABBbmvqSYTFZ7C2cudkBuiyOPp4CDAMHQ8AEzMv96UvnGGBdSXNKIsBTJ09n?= =?utf-8?q?P4MjucXF9ysgqSTpbeLYz8UX5ZboAnBwxEhqMzctURdt4m/HzujDX1Y/C93jSu2/N?= =?utf-8?q?fnpD93envVDJP2HC0sEv+ha7Ytz2746I/qqH9sFvZAqISZjcPG1KpE4auZa0LjBH1?= =?utf-8?q?KMnxPTy+GbXvZLfp+PatK9Zg+TIRZRvMCtSszRmzDNNws7qIC25R3oI4XcUw4bv1Z?= =?utf-8?q?YaAhS5TWmihAETiqFSFJW/2l26/oCswnd2MEJYnplvuOBblbbl91A0v6op9+m/GRz?= =?utf-8?q?y1SyR7sLyQ7YlRZW0HJAs2Y/abWja7IRcPwd34oKI3JWE0a2gcUekRVSL7LCxw/jV?= =?utf-8?q?zGFgX2LsDO9rveunexO7Culm7RXNbm54Tfxza5G09EppU18mZEBOCrUqqavo1Tbq/?= =?utf-8?q?r1Ne2+0Pjgesd+noDWgr3VdU9itbvxEFHjbBjVL0J3xO6elh4y+X0QTFhrMQ7CsKv?= =?utf-8?q?dDKqTbxoOW7IWBPb72TH0ImjjKWIPXWeIhlQLfEbFknKwnE0OnFuBuTDE3XLSjW/K?= =?utf-8?q?HyTOPWgod6LelF8RFTsv61R/KLuCFmHKQK0ECb5j7SPWxEV/sqkx6oYc3RKteG/F/?= =?utf-8?q?7GrJIpIeYU5rfJThWhJLXOdGvnZSxZ+spAEbFK3S1A54uC49pF58yQ=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 72fc8e1a-5aaa-4d55-bef9-08d9da1097ad 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:25:05.0431 (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: dP/dmuA+t0eUJZ723cqyePaB+n36W7J89FkvDgMpg6GrAMx+VNiqru2xA+wTmgWqdS0I1Fi02pXBvMCS2TZurtFIMthXGLYZTkJV3Zai0nU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4140 X-OriginatorOrg: intel.com Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org DRM depends on IOMEM and DMA, introduce an additional Kconfig to pull in IOMEM and DMA emulation on UML. Also, add .kunitconfig to simplify running DRM tests with: ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/gpu/drm Signed-off-by: Michał Winiarski --- drivers/gpu/drm/.kunitconfig | 3 +++ drivers/video/Kconfig | 4 ++++ 2 files changed, 7 insertions(+) create mode 100644 drivers/gpu/drm/.kunitconfig diff --git a/drivers/gpu/drm/.kunitconfig b/drivers/gpu/drm/.kunitconfig new file mode 100644 index 000000000000..6ec04b4c979d --- /dev/null +++ b/drivers/gpu/drm/.kunitconfig @@ -0,0 +1,3 @@ +CONFIG_KUNIT=y +CONFIG_DRM=y +CONFIG_DRM_KUNIT_TEST=y diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 427a993c7f57..0e6028f9b09e 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -46,5 +46,9 @@ if FB || SGI_NEWPORT_CONSOLE endif +config DRM_UML_IO_EMULATION + def_bool y if UML && KUNIT + select UML_DMA_EMULATION + select UML_IOMEM_EMULATION endmenu