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), {} };