From patchwork Thu Aug 4 13:17:03 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: 12936395 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8AF2DC19F2A for ; Thu, 4 Aug 2022 13:19:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A33A712A332; Thu, 4 Aug 2022 13:19:27 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by gabe.freedesktop.org (Postfix) with ESMTPS id 99A028B0FE for ; Thu, 4 Aug 2022 13:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659619155; x=1691155155; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=85vabZuhDZS56W5PwPnWvQ2q+QdNV+dF0TGfnLoqKuY=; b=Shj6P57ZhZxU1aXGE7RpYSD5y2XYsKSGPY144e9qQIPYJyUcuYx+69eh ICPRMPYuD8mCQP/N5gIjM/wos5mzAcOUa8qBcHju/6OINXij9nPKoxpW4 7WWTticylEm9uGNLu4lGLS7U5fjdU/+3885hVdslNaR9RRfVBIwl0M8oK +MZvRrOCmGpiUn5eekl+jmObubXFCe+IF7L93rjFAQTsgWWDNl9ycVEUN MKll0o2uqq+k0H2dmQr7NkrVZ1j/HNCpUYmaZEUkaASi4ExCNlBlqMFuP TzThAaC7UsQ9c66+QQD3IrUSUtEdSH4Xxj8X3LFSQvJc0pCSCwvRgNApn A==; X-IronPort-AV: E=McAfee;i="6400,9594,10429"; a="289940512" X-IronPort-AV: E=Sophos;i="5.93,215,1654585200"; d="scan'208";a="289940512" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2022 06:19:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,215,1654585200"; d="scan'208";a="671262068" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga004.fm.intel.com with ESMTP; 04 Aug 2022 06:19:14 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) 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.2375.28; Thu, 4 Aug 2022 06:19:14 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 4 Aug 2022 06:19:13 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Thu, 4 Aug 2022 06:19:13 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.45) 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.2375.28; Thu, 4 Aug 2022 06:19:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j2XRiaaWd16fm1dXzLxcev6TbehUDsc8UX9UgI+ywPAOJ7JSIhye3KI8P2g0VeThhpAhXDxoyw0jqcFgFH2iwouYQhD2t+cRjSlzW0j33/GCoSZMXK/ohTYpKRkX1UoF8dcOXpr0ki1Zru+w0e+g70AQhqjsEPL0VgkcNWj5zvoO5/kLK3qktkB5bQq/RkRvygGTvWGwUic1eh4Ld4wfW0E+OlLb72ke0KVp4IegRqYEduubmmE4bKz2n4WUdBceS0+xF9AyKjLNsa2oRTYNiCeDLTSNuHeC+TiGH5kjIVJ0MrxzxYxmvDAI46tuN30+MDc9+wNwKDd7UI9QejCofg== 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=K0MlK+QW6QsvmbLjV+H8vnJFP5dhAL+Z2Cdisjjt5V0=; b=jJNWqHt5WqD32MPsmh7T/cYGaUW08mZHBpKUdmFWYm8ztBd/gsxFa3xKwxwNPmqALQRQdV1+uCawuEfHH1GUz74Iyda+nvooXbaHEXl6469oukdSVmqB03S2N5Dh1Rlkyw1Ou5P427ZA5k9hmMEs64/TR3Y07fdDjXUMQbZZWfeNmIGB3pHyElZwFCXmiDqhpR8VpzD4iBX0CqyrL7eapP4wFWbDYxlWjtXZ8ZyRWxMQkwA+q8HGhbNNJ1ZTZbEvcoAZwGafA77KS0F8d0mG5NJVAlY857lgWW5PgjxEuRgXumUiYUQwMqCtD+DtcNqsInGXOC+w2WOPmMW5DVUgQg== 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 MW4PR11MB5934.namprd11.prod.outlook.com (2603:10b6:303:189::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.15; Thu, 4 Aug 2022 13:19:05 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e%7]) with mapi id 15.20.5504.015; Thu, 4 Aug 2022 13:19:05 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: Subject: [PATCH 1/2] drm/cmdline-parser: Merge negative tests Date: Thu, 4 Aug 2022 15:17:03 +0200 Message-ID: <20220804131704.97083-1-michal.winiarski@intel.com> X-Mailer: git-send-email 2.37.1 X-ClientProxiedBy: FR2P281CA0008.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::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: 4311f225-f147-4d5b-d4bd-08da761be807 X-MS-TrafficTypeDiagnostic: MW4PR11MB5934:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C6I3jzeVFezEaxCRWxeiPcUymBIIZPmB4kBgkVPDJfyUc/a/+yKoDHDqm+8HX5r3xhugKklx404cGiMCIQFhTfPimH80uck0RS1ueYy/Xkeu6YNrtGMMPG2xy0XoxbwOP0FFkOUGYcEYHqXdPfPO3jhSRUShrqiZVtDE7pgYh+HgKx4O3+or3HTAtrlskJ7KH3NHV9bEMdIzKKjePSQ1j7GJl4R1DMIr4O0ZFBj3IDrPrED50phpCPpgjApFjretqVK250SPbF7FPMan3XXHRr65IiJBIHJZab3jlQZSEMEAlopt72EBUhCqDfqzAmPlvr6kkdqyQEVjPRD21TvqD/ypK0r77/B387qSgRibVKX0NwNF74y/REvWJC765TPEmNbG/9Wpd0U4b/l2fvhN3U2x0xJwvp9SbxU653Qm7ZEbkeUMmWRCD9QRYVyAtu7+9N68CXJ/lnHqcrHjtdTFvc//LZY3/iFTTTOFduUNBQGyEFVXqeSzPVCf6qYU+Juvy6gyiio0/Zj+v3b8edFIZAowp1k1EXgwXfrTDhgRlVCaHXWEmUr5cYocJj3DMX3I1j2Tfz3GXSLpPZ+jPBXm7yqkjo1oEPP+/YuXzyZZZl3e2q3m/9RJ/e2reG5NFrDp9m200ZbaphxgsCxAn5FhVYTBH0RUTJSmOlj7bXlcw4ezJUjV0lZsDcRD4//pxZVzEsVWEKEM19WI4yhiUB9IdICZxlGbZFX2kC0vLv3b8mGCp+6e7t4lerTwDlZ4CfT5 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:(13230016)(366004)(346002)(376002)(136003)(39860400002)(396003)(6506007)(2906002)(82960400001)(107886003)(1076003)(316002)(54906003)(26005)(6512007)(38100700002)(36756003)(6916009)(2616005)(8936002)(86362001)(5660300002)(30864003)(66556008)(66946007)(41300700001)(66476007)(4326008)(8676002)(186003)(83380400001)(478600001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?3ACkJM9gYXb+B0/Q7C2to55DXn2L?= =?utf-8?q?AnlX10m3TiaDzrQO4fWzZCRCgBZI1yg9j1HakXtq1Y0JMRBK7k1GvD6qOkqHG3Q7k?= =?utf-8?q?CWoO4MPSh+X0EGv9w1iTflKdpV0V+FQ8lf6zT65S7WUgp7FexDm2S3zzAF9UMREm3?= =?utf-8?q?i4HGdbDgUVYo86pYt0/I0wSZbOA15+U51fiJv/qpzxCG3yIHHw32FAT7WagR6OAJh?= =?utf-8?q?ZdhOdZ4OkHeySZtI8QW36d2m84d4s7q517ztIqZjxF+Zm01+/3/yrh4eBlYqO/Y1J?= =?utf-8?q?FEU7vmOfdvDpqXbIrXx1l35C6i5JLkrLCEnCsN/4BlvS/ybUQKr86+cHUj2EcjlyL?= =?utf-8?q?xuKzGvUVo/SDVY8ajhBEcnS9nRuQ247igHeUpecau8+I71r0u4lqL2Byc0r54ULoW?= =?utf-8?q?GBtfrBzEyZRjKcscgjEgQPAsPWxptgTgM/fC83Ul6AFBppy2cyV6wAR/AegHaHmXV?= =?utf-8?q?0xk5E90Jev7PrZO389ido3bihY6dJnWAu9o/d8/7SpSyPEuFlk7BCcjtnzQUyMTmS?= =?utf-8?q?DnWtdPLYEf4BbLIIB4yWndp3xWexiTt7VWoolVANsi81tnCACPcs1HIahc9xOdCEK?= =?utf-8?q?m4u3wvGuRV/PRCHhjW+fbnTTnkQt+wLv1DHdQCFJqkLgIBVoN3ixhKdLLhCfZUH53?= =?utf-8?q?z8B7+SKdFt5D+ZO7CkX6G8AHF/Txw+C/lyITFVu3TZGi075L4bu41aGpdHouJdkeL?= =?utf-8?q?/Gl4rwuN07qlmW4KcCxSax6WqvF/zRyLJYeXc0oTMtJi8m8cimbJ4Xh3VUw9dscYL?= =?utf-8?q?IVkm6CruLtfYsdJYm+2BQ67bmL4J9OG+w1e8B3CR6MY+4upYeqvouVyCmukXoM2M4?= =?utf-8?q?xo/+Nf/noHmpSDjROnYNJ++0EceA/GX7ifDLKrE8A8QXJS2IRbyBw4JqivJ8MuRli?= =?utf-8?q?vKlefarTtWBWG++VH1TrjrvTsacM3vyT3JOqFyqIlHooO7hduZVTwqTfzDBS6y34k?= =?utf-8?q?yhb0gF0/L6NUTN3jQrEdHI7xPlmZ0eDmPngeV3P6qchEDqg0DRiNsC37LBuV9S2lw?= =?utf-8?q?0c72AGFtlHiiK34I47ksM+fK2Cf1+dv00mALUIgNwklymMbg4ZGg894gP0l/lMVNP?= =?utf-8?q?A0xhR95sKrmkIhEPVwzzQBaE5H83p+eDWz0Ox3EvFGrEj8hC+t3pnrZCAg+EtxPpX?= =?utf-8?q?CVrR6FJ6ixn/yjYYaW/asCzKptSA1caav0YCKxPCxqgYNjXIrKXCPbRH0Wrhg1qfx?= =?utf-8?q?VoM8/pcWiZPR4BwjJpqY6pbkdjQjqUfAfgutjlH84pXPs5yOvf8MLEYIutJcTKKuU?= =?utf-8?q?ugXNJ4erV/wrLdoLmNwClhEiBH5IOdtSdbJ8hmuxrwi1rh813AsKmthWeMeDurSw0?= =?utf-8?q?Vre4NOqLBKpk8/Hf23H+RVbA6isZzLfLDXY+I1q2sxhIXyX9qocTZbn8eZ06qYUyE?= =?utf-8?q?v/71zBGTNYtRzwCgFib8baVNxMAssBo8b5NzqllglmstA0AREAdEGeEsk1mKEIIB/?= =?utf-8?q?MYNzkX9kmQbxSoeqq/4siccpkvx2++YbBW7204Mqfg7EHUTF/jvkMDW+Bv3lRul3g?= =?utf-8?q?wquYKg2VMEqCgSIjsyU5pg9mFUnK4L0vmw=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4311f225-f147-4d5b-d4bd-08da761be807 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2022 13:19:05.7555 (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: 46BZPUPuFaA5BTey8Fk440qYoz9rsg6qkmgUPvyX4bYagzZlQcWZl4jYiFrIAq+KxNJrSQHq/n5HnNVXLGw/RwSazYYz6WepeYHmaUnj5HE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB5934 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , Arthur Grillo , David Airlie , =?utf-8?q?Ma=C3=ADra_Canal?= , Daniel Latypov , Javier Martinez Canillas Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Negative tests can be expressed as a single parameterized test case, which highlights that we're following the same test logic (passing negative cmdline and expecting drm_mode_parse_command_line_for_connector to fail), which improves readability. Signed-off-by: Michał Winiarski Tested-by: Maíra Canal --- .../gpu/drm/tests/drm_cmdline_parser_test.c | 293 ++++++------------ 1 file changed, 103 insertions(+), 190 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_cmdline_parser_test.c b/drivers/gpu/drm/tests/drm_cmdline_parser_test.c index 59b29cdfdd35..058808faaf4a 100644 --- a/drivers/gpu/drm/tests/drm_cmdline_parser_test.c +++ b/drivers/gpu/drm/tests/drm_cmdline_parser_test.c @@ -109,24 +109,6 @@ static void drm_cmdline_test_force_d_only(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_OFF); } -static void drm_cmdline_test_margin_only(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "m"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - -static void drm_cmdline_test_interlace_only(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "i"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - static void drm_cmdline_test_res(struct kunit *test) { struct drm_cmdline_mode mode = { }; @@ -149,42 +131,6 @@ static void drm_cmdline_test_res(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static void drm_cmdline_test_res_missing_x(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "x480"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - -static void drm_cmdline_test_res_missing_y(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "1024x"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - -static void drm_cmdline_test_res_bad_y(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "1024xtest"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - -static void drm_cmdline_test_res_missing_y_bpp(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "1024x-24"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - static void drm_cmdline_test_res_vesa(struct kunit *test) { struct drm_cmdline_mode mode = { }; @@ -274,15 +220,6 @@ static void drm_cmdline_test_res_bpp(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static void drm_cmdline_test_res_bad_bpp(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480-test"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - static void drm_cmdline_test_res_refresh(struct kunit *test) { struct drm_cmdline_mode mode = { }; @@ -306,15 +243,6 @@ static void drm_cmdline_test_res_refresh(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static void drm_cmdline_test_res_bad_refresh(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480@refresh"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - static void drm_cmdline_test_res_bpp_refresh(struct kunit *test) { struct drm_cmdline_mode mode = { }; @@ -411,15 +339,6 @@ static void drm_cmdline_test_res_bpp_refresh_force_off(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_OFF); } -static void drm_cmdline_test_res_bpp_refresh_force_on_off(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480-24@60de"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - static void drm_cmdline_test_res_bpp_refresh_force_on(struct kunit *test) { struct drm_cmdline_mode mode = { }; @@ -563,24 +482,6 @@ static void drm_cmdline_test_res_vesa_margins(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static void drm_cmdline_test_res_invalid_mode(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480f"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - -static void drm_cmdline_test_res_bpp_wrong_place_mode(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480e-24"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - static void drm_cmdline_test_name(struct kunit *test) { struct drm_cmdline_mode mode = { }; @@ -608,42 +509,6 @@ static void drm_cmdline_test_name_bpp(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.bpp, 24); } -static void drm_cmdline_test_name_bpp_refresh(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "NTSC-24@60"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - -static void drm_cmdline_test_name_refresh(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "NTSC@60"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - -static void drm_cmdline_test_name_refresh_wrong_mode(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "NTSC@60m"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - -static void drm_cmdline_test_name_refresh_invalid_mode(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "NTSC@60f"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - static void drm_cmdline_test_name_option(struct kunit *test) { struct drm_cmdline_mode mode = { }; @@ -762,33 +627,6 @@ static void drm_cmdline_test_rotate_270(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static void drm_cmdline_test_rotate_multiple(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480,rotate=0,rotate=90"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - -static void drm_cmdline_test_rotate_invalid_val(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480,rotate=42"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - -static void drm_cmdline_test_rotate_truncated(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480,rotate="; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - static void drm_cmdline_test_hmirror(struct kunit *test) { struct drm_cmdline_mode mode = { }; @@ -885,15 +723,6 @@ static void drm_cmdline_test_multiple_options(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } -static void drm_cmdline_test_invalid_option(struct kunit *test) -{ - struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480,test=42"; - - KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(cmdline, - &no_connector, &mode)); -} - static void drm_cmdline_test_bpp_extra_and_option(struct kunit *test) { struct drm_cmdline_mode mode = { }; @@ -1006,64 +835,148 @@ static void drm_cmdline_test_panel_orientation(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); } +struct drm_cmdline_negative_test { + const char *name; + const char *cmdline; +}; + +static void drm_cmdline_test_negative(struct kunit *test) +{ + const struct drm_cmdline_negative_test *params = test->param_value; + struct drm_cmdline_mode mode = { }; + + KUNIT_EXPECT_FALSE(test, drm_mode_parse_command_line_for_connector(params->cmdline, + &no_connector, + &mode)); +} + +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 void drm_cmdline_negative_desc(const struct drm_cmdline_negative_test *t, + char *desc) +{ + sprintf(desc, "%s", t->name); +} + +KUNIT_ARRAY_PARAM(drm_cmdline_negative, drm_cmdline_negative_tests, drm_cmdline_negative_desc); + static struct kunit_case drm_cmdline_parser_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_margin_only), - KUNIT_CASE(drm_cmdline_test_interlace_only), KUNIT_CASE(drm_cmdline_test_res), - KUNIT_CASE(drm_cmdline_test_res_missing_x), - KUNIT_CASE(drm_cmdline_test_res_missing_y), - KUNIT_CASE(drm_cmdline_test_res_bad_y), - KUNIT_CASE(drm_cmdline_test_res_missing_y_bpp), 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_bad_bpp), KUNIT_CASE(drm_cmdline_test_res_refresh), - KUNIT_CASE(drm_cmdline_test_res_bad_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_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_res_invalid_mode), - KUNIT_CASE(drm_cmdline_test_res_bpp_wrong_place_mode), KUNIT_CASE(drm_cmdline_test_name), KUNIT_CASE(drm_cmdline_test_name_bpp), - KUNIT_CASE(drm_cmdline_test_name_refresh), - KUNIT_CASE(drm_cmdline_test_name_bpp_refresh), - KUNIT_CASE(drm_cmdline_test_name_refresh_wrong_mode), - KUNIT_CASE(drm_cmdline_test_name_refresh_invalid_mode), 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_rotate_multiple), - KUNIT_CASE(drm_cmdline_test_rotate_invalid_val), - KUNIT_CASE(drm_cmdline_test_rotate_truncated), 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_invalid_option), 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), {} }; From patchwork Thu Aug 4 13:17:04 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: 12936396 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 06707C19F2A for ; Thu, 4 Aug 2022 13:19:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 108CD11350A; Thu, 4 Aug 2022 13:19:44 +0000 (UTC) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id A941C8B0FE for ; Thu, 4 Aug 2022 13:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659619158; x=1691155158; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=G4zBhaspLwnvat6HbHMbFfOKH4qEqDMrMP/pPVIGqZ8=; b=Mh1+mSXGyxT7i2onn9Ilxcnk9vj70Y1XpTWUHLycN4A6UJOMUSDZJ6Zj viDxcemHBY4VulMdQhd+Tdua/HYdCQI755l6Hmmg0J3BTR3vtE+Qtasyv fIo3DLq7j8ZK6StFLPCFlUmMQv+0w9q19rkuf6PYJH/730YyhWpOGfWJQ cmBwcrgzFS6EJSDzulqcyd6QP+FIH35A2VLRfaaQ9bEtZ4PWhahW6uScA 70Ztn1qa/M7oP72BxRcqcLf1QVI822oDt1OiwnyWhiTzo8XOfA3qZHEFE mRT2XGsyyRWAMLqyjZcmdcB8UZkLLX7I/QmY08vntZPhuqRjiEC1ZCnVu Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10429"; a="290703632" X-IronPort-AV: E=Sophos;i="5.93,215,1654585200"; d="scan'208";a="290703632" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2022 06:19:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,215,1654585200"; d="scan'208";a="692623814" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by FMSMGA003.fm.intel.com with ESMTP; 04 Aug 2022 06:19:15 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) 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.2375.28; Thu, 4 Aug 2022 06:19:14 -0700 Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 4 Aug 2022 06:19:14 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) 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.2375.28 via Frontend Transport; Thu, 4 Aug 2022 06:19:14 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.45) 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.2375.28; Thu, 4 Aug 2022 06:19:14 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bYz1/E1nDyiQM5E33jVkAkXYF+s6/3GcK5JCJ28RT6As+4B2yBFL97VPlESpVY1ktD2bVbbA88aMprTalgzeOCseaRmh013cAixhM8maT3bPRPLmFtBYGX7crlDmQSnmKaPYl+yU5VcNofKn4rbLxtxiZsfXs4PUpjv698fbEz5Y8cvJ83i95lgpb9zTZsKSQBvJxjr30qfejlBxrl/lMkwXrmzcxBlYadbpeFRfmAFl41BExRafL3HbgfBXjvoSnnJReMUpn5YbHU0lw+TF8VMiybgwBBqwaxG1NzUTxiXvoot9Pp4VbFGm/hjgmPbMyu2A3khc59CQ3utszMggYA== 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=QexP5zAG2G7JtBhLtu0Tr7+IciNvmL1TvmMX7HJo+7M=; b=l3wMRBrPGFZ/6ZSmB1IyDakNeSBUtOkHagt2FGvhhG2SnJQYWcq1kvu0QJpZtkaYW2D7BMc11yAPtkIEANSWk+38ggIY1mtZErC9kCiinA2wmk3zznMrHJo+DBsAilhdc9fQlixrlIjMZpUoWM9pvm8GEL+SIFr40i3dV1RCmWL5r/v5VkiDYc8XgJ4qyKEdYgjv/G1P1zWceuIonPpII6/aCP2hNk/BBmdq4lj/O4Pop4JlTAjk6fNnesCSaXs2sUTpYb/0HrWVM4LVdXTTC+OhGHURoaWEo4fR65zVAsvminWKzkZNQNx1bFL5b0uRzHbRMY/8uaBrMN6KThLuzw== 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 MW4PR11MB5934.namprd11.prod.outlook.com (2603:10b6:303:189::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.15; Thu, 4 Aug 2022 13:19:12 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e%7]) with mapi id 15.20.5504.015; Thu, 4 Aug 2022 13:19:12 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: Subject: [PATCH 2/2] drm/cmdline-parser: Use assert when needed Date: Thu, 4 Aug 2022 15:17:04 +0200 Message-ID: <20220804131704.97083-2-michal.winiarski@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220804131704.97083-1-michal.winiarski@intel.com> References: <20220804131704.97083-1-michal.winiarski@intel.com> X-ClientProxiedBy: AM6PR01CA0041.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::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: a5975092-7500-4321-5227-08da761bec2d X-MS-TrafficTypeDiagnostic: MW4PR11MB5934:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c8bzIpfJJGNuXAWfp9ynmas7JklQjhJbDXxPVSuyJlDysRPQK5faLjDwsi+GfyICROZFaXSSxHeB0CLqeCdKFrE9bxRwOgVeaKPVp7ZZTDDfNSWOEZcYj4QITSp+B27IGcTIj9UePQ8n87EkZPNgNPqAkVfNtpIvowaWQacv9c4/eZ0SG124UA/PwG1coD5P9reu6T46ovV3H88Q8VvtfF8AaXefvYfhekMnBPIIe/6rwYLaLvnJm9zrx64w9UQINOp7iQaP5EW2haPhBgBAkjGu6NAae25CoNVCz0Bpr1ew0FN2gpUmKjLZIxPr+q35JVFCoIotwhtEPvo9mZiPo9w+U0UkR2DGhs2C5KeOkF89yjLGHtdFyLssHlqxrUPVp4c+AGPwPiiSpT6lQi0PMkjHzb17QV2U2g4uOPGl7+o52B3+6UMExOnFVAwLA4nlhcB1eUt3E8KEYTH3UeeC8EYMcsxPyEmWFoVwOvmd7yITnc/4xoOM6/X2jw6yztbx2xCUoRIheW4uFMNh8arEkkrhEHwjIU1LcI6eEPFwrFaqEypI0z+ptz8eWjqIBLMAUHgHoyW5Advclud+rmmSwhnvtGhIjfJCGYfo+5naDriLato57XpXpvtmrj+ydyf0cWK6isbtgWzmmrMaDa7MCULgl8jJvmZqCTYrXUtB/r+MACbC8pA7FRJj7iwjp8lgCVsTauaCTmmqgQmowTZNIMD7LhVwBACVuSbpuxiH8xgrPgESmQDRstSfIdeNxi+f 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:(13230016)(366004)(346002)(376002)(136003)(39860400002)(396003)(6506007)(6666004)(2906002)(82960400001)(107886003)(1076003)(316002)(54906003)(26005)(6512007)(38100700002)(36756003)(6916009)(2616005)(8936002)(86362001)(5660300002)(30864003)(66556008)(66946007)(41300700001)(66476007)(4326008)(8676002)(186003)(83380400001)(478600001)(6486002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Zw1vTImEupoYLblvaHuJOuYqy9CQ?= =?utf-8?q?o1dx428ueA1x9OfO26YbrTtOPeYfZ5PcmgC5+w75AiJ42RfXxBcEKzxjPF1+qoU6z?= =?utf-8?q?bTZLy6NutcwC1JriCkHcUbWcLmtc2/p8MmVOvBPWqE4gNyYFrhqciC4XtAzUuCF0U?= =?utf-8?q?ED0o7M8V0RPaBzuo3Ume9vRvDMpzQWEPET9CuKVRgOdirHKJAx4tApSyNVU+z/Izq?= =?utf-8?q?jylSR7APUnTi49hghRtba4taPPZipNCpoPl51DejB4LsA/oEmAGz2ESyMzVsOv2PH?= =?utf-8?q?713jJPhrfB1nu7qq0A3LTmVaZozgyzJG7nmRP7yeK7E08y4uEnExube6pu3PF3m5/?= =?utf-8?q?OIVOhB3OExSGV/mcgtNqyCXmknbhoUgZNab7aYspzMaWPjosq7apPtivDuXHnPPoo?= =?utf-8?q?WTGt9HL4eDBTnCW/IksyUdvIJO1NwEXpA6P6fj8sxkebDHyBJ1jRwovV0x+Rdupvb?= =?utf-8?q?RBwbEFQLjZ4mI/Fw8RYLtm2UkUrxgeoCBz9eWWW2eceuDGJegJg4uofVpXPfvaE3T?= =?utf-8?q?psN1rCybXqNTyt7MOJCslBVobKQkyfOXjylWH+2yyrNeYL0CXlB26S/Je7MK28ABQ?= =?utf-8?q?hrhwsSyhKGSnkjVkYAZrV5ckMRQJvUJuzILYZcEJcWDJNc0NLIQimaJZ1r/Z3m4NW?= =?utf-8?q?s6JLigMV2OVXcl7x0hW9Ck9P9T+WG00UFCGOOslHJATLsIi0s2Q4MG2wzvtqs0O78?= =?utf-8?q?gmCy25CPtkkwd2RH1/k/Xr2wIgOOjqa6Qi6wD3NB50zeB6nf+rNk5QmfbiCEAH9cU?= =?utf-8?q?/lscjzHSGIROSl1XzOxE4bo1+/CY4W6hYPpewExG0gCWnwumeKEgKVuMbXT2YaCKi?= =?utf-8?q?WNMjeYuPbBHg61z9r5HD5gWOyO11ioODEdEt1wYtTy0yYNPGlMzxaZRBJjfeGImvz?= =?utf-8?q?CtAfPEWRZKm/hk0cD1rHMzauo0DJBubrH9+oP7RSPcRixuJQnsaHJIgDJKXkMQxal?= =?utf-8?q?rMQ5HqTj4AnyrqCBoiYpWYUDtMRVR0y494MbnHldf7Ql7Lq3vLdyUySKcrZi0JQvS?= =?utf-8?q?Yncdc260X/RKvPw+jKIXrStPZ3t3URnChZdm1dif5oMQnlpy4vpEaaBkhn7C1Ub7A?= =?utf-8?q?mfUo6m0abigQeaX/HM+kYwKtAI9s5ndy556ApA7XbV4XW4+jZcZsDum6hho+Evy4c?= =?utf-8?q?NTEs3zwhLFm4/PMk4UDE9HKSFpX+d/VUTDtXRLOm0ZCmXQFzHRHWc0Ue3ibV4x/7+?= =?utf-8?q?2toFTOgHS0EQBAAjMRS1QkTugUyNgSs4oenecHrJuzo3DeoZpdNlBCPcivWLsieH+?= =?utf-8?q?TXXzXrmVyPNlpERSv2EXXJ28QDQ288MuSarvorkehHwElqhG1UitwCiriiNy5eTzA?= =?utf-8?q?mIALJObvfKXhsFGdEG53yeHQrBUBh/0Jo8y0Bmk+bkIg+1/IWzNqytP3apbd3Tvof?= =?utf-8?q?HVW73eQkXQDbVYHtG3nOn2gggT7DKYFYvwoS1rqSylGJJPvsAmNEv6sCQ1vfryfTv?= =?utf-8?q?2sQwjIF9RHnRV1/HOSunPDP9LWH+dkTSmb7xs1ShiMajGcpYyrJoFhQudO/kMa2lE?= =?utf-8?q?cG+BmOCE5DD1Qb3h3AyOd/KZ6k5EI32JKQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: a5975092-7500-4321-5227-08da761bec2d X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2022 13:19:12.6965 (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: YwbW/pTmoWhS/4CH4qz/8FyJ+4BX8WDsvLZgN/rGXSYADtWqVzeMk8DSEe6nzo4Y7s3dnZVw0TmFcHIH0mtuKFI8cM+BiLhvap4ypbxvWDY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR11MB5934 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Micha=C5=82_Winiarski?= , Arthur Grillo , David Airlie , =?utf-8?q?Ma=C3=ADra_Canal?= , Daniel Latypov , Javier Martinez Canillas Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Expecting to observe a specific value, when the function responsible for setting the value has failed will lead to extra noise in test output. Use assert when the situation calls for it. Also - very small tidying up around the changed areas (whitespace / variable locality). Signed-off-by: Michał Winiarski Reported-by: kernel test robot Reported-by: kernel test robot --- .../gpu/drm/tests/drm_cmdline_parser_test.c | 93 +++++++++---------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_cmdline_parser_test.c b/drivers/gpu/drm/tests/drm_cmdline_parser_test.c index 058808faaf4a..7a313e2fd52a 100644 --- a/drivers/gpu/drm/tests/drm_cmdline_parser_test.c +++ b/drivers/gpu/drm/tests/drm_cmdline_parser_test.c @@ -16,7 +16,7 @@ static void drm_cmdline_test_force_e_only(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "e"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -34,7 +34,7 @@ static void drm_cmdline_test_force_D_only_not_digital(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "D"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -47,16 +47,16 @@ static void drm_cmdline_test_force_D_only_not_digital(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON); } -static const struct drm_connector connector_hdmi = { - .connector_type = DRM_MODE_CONNECTOR_HDMIB, -}; static void drm_cmdline_test_force_D_only_hdmi(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const struct drm_connector connector_hdmi = { + .connector_type = DRM_MODE_CONNECTOR_HDMIB, + }; const char *cmdline = "D"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -69,16 +69,15 @@ static void drm_cmdline_test_force_D_only_hdmi(struct kunit *test) KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_ON_DIGITAL); } -static const struct drm_connector connector_dvi = { - .connector_type = DRM_MODE_CONNECTOR_DVII, -}; - static void drm_cmdline_test_force_D_only_dvi(struct kunit *test) { struct drm_cmdline_mode mode = { }; + const struct drm_connector connector_dvi = { + .connector_type = DRM_MODE_CONNECTOR_DVII, + }; const char *cmdline = "D"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -96,7 +95,7 @@ static void drm_cmdline_test_force_d_only(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "d"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -114,7 +113,7 @@ static void drm_cmdline_test_res(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -136,7 +135,7 @@ static void drm_cmdline_test_res_vesa(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480M"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -158,7 +157,7 @@ static void drm_cmdline_test_res_vesa_rblank(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480MR"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -180,7 +179,7 @@ static void drm_cmdline_test_res_rblank(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480R"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -202,7 +201,7 @@ static void drm_cmdline_test_res_bpp(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480-24"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -225,7 +224,7 @@ static void drm_cmdline_test_res_refresh(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480@60"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -248,7 +247,7 @@ static void drm_cmdline_test_res_bpp_refresh(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480-24@60"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -272,7 +271,7 @@ static void drm_cmdline_test_res_bpp_refresh_interlaced(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480-24@60i"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -294,9 +293,9 @@ static void drm_cmdline_test_res_bpp_refresh_interlaced(struct kunit *test) static void drm_cmdline_test_res_bpp_refresh_margins(struct kunit *test) { struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480-24@60m"; + const char *cmdline = "720x480-24@60m"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -318,9 +317,9 @@ static void drm_cmdline_test_res_bpp_refresh_margins(struct kunit *test) static void drm_cmdline_test_res_bpp_refresh_force_off(struct kunit *test) { struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480-24@60d"; + const char *cmdline = "720x480-24@60d"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -342,9 +341,9 @@ static void drm_cmdline_test_res_bpp_refresh_force_off(struct kunit *test) static void drm_cmdline_test_res_bpp_refresh_force_on(struct kunit *test) { struct drm_cmdline_mode mode = { }; - const char *cmdline = "720x480-24@60e"; + const char *cmdline = "720x480-24@60e"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -368,7 +367,7 @@ static void drm_cmdline_test_res_bpp_refresh_force_on_analog(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480-24@60D"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -390,12 +389,12 @@ static void drm_cmdline_test_res_bpp_refresh_force_on_analog(struct kunit *test) 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, }; const char *cmdline = "720x480-24@60D"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -443,7 +442,7 @@ static void drm_cmdline_test_res_margins_force_on(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480me"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -465,7 +464,7 @@ static void drm_cmdline_test_res_vesa_margins(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480Mm"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -487,7 +486,7 @@ static void drm_cmdline_test_name(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "NTSC"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -499,7 +498,7 @@ static void drm_cmdline_test_name_bpp(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "NTSC-24"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + KUNIT_ASSERT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, &no_connector, &mode)); KUNIT_EXPECT_STREQ(test, mode.name, "NTSC"); @@ -514,7 +513,7 @@ static void drm_cmdline_test_name_option(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "NTSC,rotate=180"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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"); @@ -526,7 +525,7 @@ static void drm_cmdline_test_name_bpp_option(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "NTSC-24,rotate=180"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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"); @@ -540,7 +539,7 @@ static void drm_cmdline_test_rotate_0(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480,rotate=0"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -563,7 +562,7 @@ static void drm_cmdline_test_rotate_90(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480,rotate=90"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -586,7 +585,7 @@ static void drm_cmdline_test_rotate_180(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480,rotate=180"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -609,7 +608,7 @@ static void drm_cmdline_test_rotate_270(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480,rotate=270"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -632,7 +631,7 @@ static void drm_cmdline_test_hmirror(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480,reflect_x"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -655,7 +654,7 @@ static void drm_cmdline_test_vmirror(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480,reflect_y"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -679,7 +678,7 @@ static void drm_cmdline_test_margin_options(struct kunit *test) const char *cmdline = "720x480,margin_right=14,margin_left=24,margin_bottom=36,margin_top=42"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -705,7 +704,7 @@ static void drm_cmdline_test_multiple_options(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480,rotate=270,reflect_x"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -728,7 +727,7 @@ static void drm_cmdline_test_bpp_extra_and_option(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480-24e,rotate=180"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -752,7 +751,7 @@ static void drm_cmdline_test_extra_and_option(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "720x480e,rotate=180"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -774,7 +773,7 @@ static void drm_cmdline_test_freestanding_options(struct kunit *test) struct drm_cmdline_mode mode = { }; const char *cmdline = "margin_right=14,margin_left=24,margin_bottom=36,margin_top=42"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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); @@ -797,7 +796,7 @@ static void drm_cmdline_test_freestanding_force_e_and_options(struct kunit *test struct drm_cmdline_mode mode = { }; const char *cmdline = "e,margin_right=14,margin_left=24,margin_bottom=36,margin_top=42"; - KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(cmdline, + 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);