From patchwork Wed Aug 31 21:56:07 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: 12961480 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 524E7ECAAD1 for ; Wed, 31 Aug 2022 21:57:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 197D610E425; Wed, 31 Aug 2022 21:57:46 +0000 (UTC) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7497E10E425 for ; Wed, 31 Aug 2022 21:57:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661983061; x=1693519061; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=zsPioFM5wYFWCkLRbTTswgDX0SQJrC8qqAHd8F95EWQ=; b=AHwta+XyjscMMqHgAD9FUgwOnJdYBFE72lJzzyh18JbyKOQC/78Lxr7w 3i0rZ7UrZULf24bzwuKEAd/Gm3Eg1Z5Q9wW3oKaLvDRQEB+40oqRNLUfK w9yCSHD6RkGCsyhthphvA6FMV4Ya0jL5864wQ+1PTPESw9rS4Wp/YSis1 nmStadySGbDUZhd7t2lP2ADwkTo/m14HHX6NtM21LNQZJggN78h+QULie UNXlP4WsbWLeI7BJHieoWxWDk8z9rc69zDyA94DX9hh9AeOhOzSRxGpYw 1oUrqwA438SV8Bw7v1ySmffGtUasykUXhFbZSc65HW8mIZpEAZf+F4L0H Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10456"; a="278571281" X-IronPort-AV: E=Sophos;i="5.93,279,1654585200"; d="scan'208";a="278571281" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2022 14:57:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,279,1654585200"; d="scan'208";a="612244855" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2022 14:57:40 -0700 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.2375.31; Wed, 31 Aug 2022 14:57:39 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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.2375.31 via Frontend Transport; Wed, 31 Aug 2022 14:57:39 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.109) 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.2375.31; Wed, 31 Aug 2022 14:57:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nnQyhre8Q9a8pHJt5J/16o11fU9u2UAv32SUw7+m04DAOBzSVnJbGZVyGOpINpBQhpYOTmWzrsxOkfp4KgmNjjFpdhrUgaVeW68ecK/x2qXCYcUQZjZdQQCVaB2YxwBCA7M5WhAVNskhA1i8T2FQmXa8CSycpzHBHzPCpxS/UU9sh59TUEhzk5YOj98Nq+S6PE+5C761GGU8EiJu+/VcCboIMSxPnntufuSx+EMQfWMxLQmvaVKm9k64wbae6y792n7jSAmtBR7OGxDX6HcUVuh3he7rymA6lkRQIUY/VCR/6t7JfdZWUpw4TQUTr4mFQCy5LeyCrpJASzf6y26z4w== 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=k4GO6Oz0Pe/6p3WVWPjE6Ojfakw1hOwb2/mjOK32//0=; b=CXmfF4Hq/i+Xv7zvMq9Mixm4gqwZa1JYL3EnZQrCTLjxnyRTKoBoNyo+wKB9siGdEawzzDNcOPERF3IJCeNxq+us3H3UVuT7QrHcxX3ul55kcyAlfgoDSgDGBq/nVXZyKQ04B89M5JXhH3MIjpNnSOCx+W9uySDSx5PEAuXRKPE3a/e0HprCBcrHv3lATIxlxW/MNz4vf5bdH6F5KetyHk8hLhhWixTOFDCsuQR1HhImtF6Ghvw1cbx3qkOVkWcRmrl7o+IIoFQAN2cKD0cWjxbzCOlKciMf3Tin0bqbr2kABGhk08vaF6PanahGPzigF8LuXqIkH2ICUjmuIHeSEg== 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 MWHPR1101MB2144.namprd11.prod.outlook.com (2603:10b6:301:51::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10; Wed, 31 Aug 2022 21:57:32 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e%9]) with mapi id 15.20.5566.021; Wed, 31 Aug 2022 21:57:32 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: Subject: [PATCH 1/2] drm/format: Use appropriate types in expect/assert Date: Wed, 31 Aug 2022 23:56:07 +0200 Message-ID: <20220831215608.349269-1-michal.winiarski@intel.com> X-Mailer: git-send-email 2.37.1 X-ClientProxiedBy: FR3P281CA0022.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::10) 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: 7a430f68-8f1a-4ec4-50ff-08da8b9bcdea X-MS-TrafficTypeDiagnostic: MWHPR1101MB2144:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iaqFdFAN/jh06FhIaB4iXqEcwh+KQS8/8xQ0rdsRGdJ5RfB8ngPRzNrWOMyMi1BYDQz/6tfFTQbfP4xnGt3vJkkPqfLUssSqC7E1C/dtT3GR7FtEmA64o5xTbgAxfK64BEnAnIAvJpX4HpRaiQ7GLRioGLZSZ4eIaHnn//WMfVUteuvrVL0mNHrOuwjTxOz8o12lSwq0NMEyAYP1aQ16J6mRxnEyleGxQ63w3w7g4lKeyKPaZ8xoIE2MoooQ875jkDc9lJOjbl+bez249/PszuOQSQwEQluarRXZSBYOJq6JfrFdnObE6vxGaAUWvH+Fe9gkeElZYGOao/knDeou2Kq9UpYm6ZdEaOTqRzp8BuVY2YaSrICl8UIdw7iW8vS9U4dVZdFv32SpNteIbyyqzeuTIKetKaT+GSd3cYExxeAWQvnvLDPZLgo9XYpPhR+cn4dHrA5eb7/+zUnX9mr36BQHRLRo5KXIrIdP7igjLWiUN8NOgF+eBeOSDlp04oS5H2bc2anleU9bDr0BoDXjzBnT52GOHnwN+r24GH7LSYbkiSv3QK88X4ClH/2NsMjF/GzgXT7iLKD940w8JWViV5aJfT5yoZZkR+5YwK0rrGJlnhEJoGJJGBoVPk+ZkbiDLw8bKOs899Mw9u/AC6+iyuicoHiZNX7wS0b2i/Dt39YDPi43npYND+5l2VeloPlGE8S20aMn7P6GA0SNMrJ5AA== 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)(376002)(396003)(366004)(136003)(346002)(39860400002)(6486002)(4326008)(66556008)(478600001)(66476007)(8676002)(66946007)(316002)(54906003)(5660300002)(6916009)(8936002)(2906002)(30864003)(82960400001)(38100700002)(83380400001)(86362001)(36756003)(26005)(186003)(6506007)(107886003)(1076003)(2616005)(6512007)(6666004)(41300700001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?8FUecm/JQxq9S4EYdblnkaP55qsD?= =?utf-8?q?GbYkZwr7b4ltJHWW+jTpUSjJN0Z7aD3AOrmSK4OfTl3FPy/7fx5qjW3NrnGNhnllJ?= =?utf-8?q?hZyeXXUAZTz1MXukgR9ZaeSPokJpOh6znuyLHnPEeEtmZetV9pgNAsUQnee4lNfeK?= =?utf-8?q?xmecj6sTyyRqm2WBcvGsR4MV3nrdofOihFeDmOlH1TDSeYjwEJVA8HuFHWlQDFJ4P?= =?utf-8?q?8ZiPeszi2gJGxK5CbNmUgO3tbpLotIj7t3kp7B6CgPHobXbrAkr+deRWRb+MVVD0a?= =?utf-8?q?AW/cFTg5YNgDoEFyINsroTjig//IQtCpIex9xDUWk/kn3p+yYhqkY7KHUshMfizlx?= =?utf-8?q?JUkpIrI6FRNwsQrKHNltE27t+QAhBfm+FAkYW1ZdD6xS1n40bPMwCzCky3zMuQFAC?= =?utf-8?q?g/kHxpteihVTkqMqw7+GyomB6o4RgTumJJBW9OcA6zGvKzpnNqPIuerp2qQPjc72r?= =?utf-8?q?/ti2ASWLQZDzMM9mMXA/2eKq0AZhRZLQEeA0BVzXKXw8rrBVOeNr1F1GA2teLCN4Y?= =?utf-8?q?W0K8seylOKQDtC9yCrnyV+fW1sGBsb3rZmMlxocx0fgc2krNAeZDKvd1vBC8Rn9/N?= =?utf-8?q?Y8e68SkuTGshjuKcWpHlfhK/2MLclnI9xIvze1EVSvrZJ4znJU/e6A07809KCfO0P?= =?utf-8?q?Efp2hZy0d9CTriw08J35S6Lsb81uLP027SNy9LlUQD0LmMYjlmgo8INDUz0dJb1k6?= =?utf-8?q?JbKKHfCnQOizUMZF8aEuAaHyX+3AH7NqBqg+pYGc947FwWDvTwVfNiA+WdZaUrPrk?= =?utf-8?q?7DUBaDpZroHsolcKzyr59WEsmJk0ZXikkY0rhVzprFiORRyEkVxUEJ9fQ9TDZcMLF?= =?utf-8?q?hIe7oCdmze+QGC0iNo7HPz1ufo5F2pCg/5u098nh/77DEP1sTB/pnAGPYWKcgBRa8?= =?utf-8?q?vk2GDHFK1M/xwktNbN11NLcDMpydGGUWsZBBPMpJ9mB6fcIVf6N/BXU68XRaTb0OR?= =?utf-8?q?re0V5VBUtKNs54Zv2WPhzjWVEOl8DZ07LteumVuDhwlFHanA7aTrRlh0M8epPek+k?= =?utf-8?q?SGkIGZnxiM6Mvqd0uem548nsUracbj0Yq9goguJNMdo4Wv40oIp2mQOldStTmavEt?= =?utf-8?q?9H01Ulg6zBrKk/bOe7X+DiVgqO6OzcBLbPUJkXNH1lb+jxKoxHpJDwNdVd9DU7q6O?= =?utf-8?q?tLZ/jR/bkZeTNZYTLD7JFVndCPYXxIsg3ewq5ICxV7bNdzSRKFy2Zb5Agpgq11dnw?= =?utf-8?q?ytsvcBYzBG9ttmvF6ldrsgHVxQkgD1rSz8ieRWyZXfpDTUbsOU487O/RpG107cX+A?= =?utf-8?q?t1yrEiHR7oQLF5p3fj5doXHqIQ9RiHivVlaF1qsfnbL0LrdDKx9aSvrEABZznXK2j?= =?utf-8?q?x0b+vUHIH0PYciwr0lM7bnH9BzVtck6/jOdn6Sm8/flPWqI1H82pbyYrNq+Q1+9dk?= =?utf-8?q?vFafSbmAplRBnaiWPRJCQRjt3MCsmLJqfJvtusypMB3Uohxj3ar1JrUX87RVRa51q?= =?utf-8?q?dO6NgAeqiWmllvyGXxsRVC1mWudZGT1QOmSOKEwk3TtXR1RnHAyGsP2iyvfGr/1se?= =?utf-8?q?iyCI2uvDd3S2MARnryRbqqnFGx6S0Suq/Q=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 7a430f68-8f1a-4ec4-50ff-08da8b9bcdea X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 21:57:31.9567 (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: 9Xw1bVDdcwDINdJGAyTsHcwrWlvl6dKXcXM1OXm6DbQzeuhdnzjWyVxHoGJHyUOeQ1dcOdI7E6tl9qV/fLVoNtsHDI2j+D9pyfQXrhwVovs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1101MB2144 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?Andr=C3=A9_Almeida?= , David Airlie , Daniel Latypov , Javier Martinez Canillas , =?utf-8?q?Ma=C3=ADra_Canal?= , =?utf-8?q?Micha=C5=82?= =?utf-8?q?_Winiarski?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm_format_info_* functions don't return bool, and the info variable is a pointer. Expecting non-NULL info will cause the test to crash if it is NULL in checks that follow (which dereference it). Use appropriate KUNIT_EXPECT/KUNIT_ASSERT variants. Signed-off-by: Michał Winiarski --- drivers/gpu/drm/tests/drm_format_test.c | 152 ++++++++++++------------ 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_format_test.c b/drivers/gpu/drm/tests/drm_format_test.c index afb4bca72187..0efa88bf56a9 100644 --- a/drivers/gpu/drm/tests/drm_format_test.c +++ b/drivers/gpu/drm/tests/drm_format_test.c @@ -14,40 +14,40 @@ static void igt_check_drm_format_block_width(struct kunit *test) const struct drm_format_info *info = NULL; /* Test invalid arguments */ - KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, -1)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, 1)); + 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); /* Test 1 plane format */ info = drm_format_info(DRM_FORMAT_XRGB4444); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_width(info, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, 1)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, -1)); + KUNIT_ASSERT_NOT_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); /* Test 2 planes format */ info = drm_format_info(DRM_FORMAT_NV12); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_width(info, 0)); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_width(info, 1)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, 2)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, -1)); + KUNIT_ASSERT_NOT_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); /* Test 3 planes format */ info = drm_format_info(DRM_FORMAT_YUV422); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_width(info, 0)); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_width(info, 1)); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_width(info, 2)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, 3)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, -1)); + KUNIT_ASSERT_NOT_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); /* Test a tiled format */ info = drm_format_info(DRM_FORMAT_X0L0); - KUNIT_EXPECT_TRUE(test, info); + KUNIT_ASSERT_NOT_NULL(test, info); KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 2); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, 1)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_width(info, -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 igt_check_drm_format_block_height(struct kunit *test) @@ -55,40 +55,40 @@ static void igt_check_drm_format_block_height(struct kunit *test) const struct drm_format_info *info = NULL; /* Test invalid arguments */ - KUNIT_EXPECT_FALSE(test, drm_format_info_block_height(info, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_height(info, -1)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_height(info, 1)); + 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); /* Test 1 plane format */ info = drm_format_info(DRM_FORMAT_XRGB4444); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_height(info, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_height(info, -1)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_height(info, 1)); + KUNIT_ASSERT_NOT_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); /* Test 2 planes format */ info = drm_format_info(DRM_FORMAT_NV12); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_height(info, 0)); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_height(info, 1)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_height(info, 2)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_height(info, -1)); + KUNIT_ASSERT_NOT_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); /* Test 3 planes format */ info = drm_format_info(DRM_FORMAT_YUV422); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_height(info, 0)); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_height(info, 1)); - KUNIT_EXPECT_TRUE(test, drm_format_info_block_height(info, 2)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_height(info, 3)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_height(info, -1)); + KUNIT_ASSERT_NOT_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); /* Test a tiled format */ info = drm_format_info(DRM_FORMAT_X0L0); - KUNIT_EXPECT_TRUE(test, info); + KUNIT_ASSERT_NOT_NULL(test, info); KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 2); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_height(info, 1)); - KUNIT_EXPECT_FALSE(test, drm_format_info_block_height(info, -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 igt_check_drm_format_min_pitch_for_single_plane(struct kunit *test) @@ -96,16 +96,16 @@ static void igt_check_drm_format_min_pitch_for_single_plane(struct kunit *test) const struct drm_format_info *info = NULL; /* Test invalid arguments */ - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 0, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, -1, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 1, 0)); + 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); /* Test 1 plane 8 bits per pixel format */ info = drm_format_info(DRM_FORMAT_RGB332); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 0, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, -1, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 1, 0)); + KUNIT_ASSERT_NOT_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); @@ -121,10 +121,10 @@ static void igt_check_drm_format_min_pitch_for_single_plane(struct kunit *test) /* Test 1 plane 16 bits per pixel format */ info = drm_format_info(DRM_FORMAT_XRGB4444); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 0, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, -1, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 1, 0)); + KUNIT_ASSERT_NOT_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); @@ -140,10 +140,10 @@ static void igt_check_drm_format_min_pitch_for_single_plane(struct kunit *test) /* Test 1 plane 24 bits per pixel format */ info = drm_format_info(DRM_FORMAT_RGB888); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 0, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, -1, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 1, 0)); + KUNIT_ASSERT_NOT_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); @@ -159,10 +159,10 @@ static void igt_check_drm_format_min_pitch_for_single_plane(struct kunit *test) /* Test 1 plane 32 bits per pixel format */ info = drm_format_info(DRM_FORMAT_ABGR8888); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 0, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, -1, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 1, 0)); + KUNIT_ASSERT_NOT_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); @@ -183,11 +183,11 @@ static void igt_check_drm_format_min_pitch_for_multi_planar(struct kunit *test) /* Test 2 planes format */ info = drm_format_info(DRM_FORMAT_NV12); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 0, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 1, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, -1, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 2, 0)); + KUNIT_ASSERT_NOT_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); @@ -214,12 +214,12 @@ static void igt_check_drm_format_min_pitch_for_multi_planar(struct kunit *test) /* Test 3 planes 8 bits per pixel format */ info = drm_format_info(DRM_FORMAT_YUV422); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 0, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 1, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 2, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, -1, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 3, 0)); + KUNIT_ASSERT_NOT_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); @@ -262,10 +262,10 @@ static void igt_check_drm_format_min_pitch_for_tiled_format(struct kunit *test) /* Test tiled format */ info = drm_format_info(DRM_FORMAT_X0L2); - KUNIT_EXPECT_TRUE(test, info); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 0, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, -1, 0)); - KUNIT_EXPECT_FALSE(test, drm_format_info_min_pitch(info, 1, 0)); + KUNIT_ASSERT_NOT_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); From patchwork Wed Aug 31 21:56:08 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: 12961481 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 C97D9ECAAD1 for ; Wed, 31 Aug 2022 21:57:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 633BE10E4F0; Wed, 31 Aug 2022 21:57:55 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9505210E3EB for ; Wed, 31 Aug 2022 21:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661983071; x=1693519071; h=from:to:cc:subject:date:message-id:in-reply-to: references:content-transfer-encoding:mime-version; bh=E+dBs7Os0eBUZmFKrzgVpGNf3I+JCdvOgT9quBKcN/4=; b=a8XIyNn0dVhd54+izLRrLuqCup4G2ATbRkX6iSFQQZbOhdj/SZzKHtCS 0kjU49jQ5y0S9/cnLQI9RM1X1hWJ6SyfwwhYKdSzMLb9Lz0SZuY3YIZIB mk98zDVuAeRZFoipWirfc6gcdEsTx9UAJ0HCTjOJSnPA5N2pvu+OwE9lW 99nSsci22TDCOba3UzguqAyZLiiOiOv1nrfIUgrAZg8wCCwVli71JSTKx SIjFTQ2CRrkCjNgTmPbN2xGEfYSptST8ORIFgeR8VhdDS6DQbKzEy0P39 zbnyHcXDfSr7FVVodcCH6BaGHJNBlRhpvLbmriYqwesA2j5a7zPi0ucL3 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10456"; a="296834424" X-IronPort-AV: E=Sophos;i="5.93,279,1654585200"; d="scan'208";a="296834424" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Aug 2022 14:57:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,279,1654585200"; d="scan'208";a="612244974" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga002.jf.intel.com with ESMTP; 31 Aug 2022 14:57:50 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 31 Aug 2022 14:57:50 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31 via Frontend Transport; Wed, 31 Aug 2022 14:57:50 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.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.2375.31; Wed, 31 Aug 2022 14:57:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xf/zDZeS/UEW6KTxD7KTzAUJ6bqoLfp388wLu7qPChgb/dqsLKuNZWJsAHxQL8Nyup1Zu0B1+0FcbFIQDpRDj6ifAYuo9tmN8aUEJ0k0tEelbd8D458kOa3TY1H3u50Yb8Yy2rwyC/Vqvw79D4OUIg4YQ5woCfQnp4zMmwM0S98rduBhJmE01aN2D4bHtCDj8UQB7R6wBmi49q4qxAaL9+ANp/SpRw3eeUikhb4bNWxKiDYSe+WlMS0tOsRQRSAy6HD1n6X+C8SlvK4/mE0/IaXP5gZf0c67iOg6X6JPzdYtUaD6JlZHu0A+rrZzO7X1Ewga8oMOIar/pPdOMcn6rg== 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=ZbPZ1DblDnR4lKACAMonxasiGtyPm8q4iwR//nqOhBQ=; b=ZNB+L94XhfQ1SaeEPKO2MuHuXfg+8zacHTmpsv39eAyoiJgv+7lmzMioWSIVzcDAMhIlqAxL0i9FBEnfMe5hMJ7d5ey39UpBYs1eaFo3xydLlklB2gYmD5F0G8gvv5lDEJRfh6m3fTAq8uLv8YOTUhc8jo2JDIl3Hx1Y9GyQJbWZUcEbyZL/ECJVhfLHIsx4QK1grScPJH7d2UU6hG47h7NBkDcSKGoFfHTnqan8xqbMTZvfXKk2g2cdnWgHyVvowSvR2+k+nKd41ulY0VsINNpTQJIEV0gMxwRiDGn6/RutZPXqFdrfMuZxVClWnOCAorGnZEs3nDlAW0CYpmabMg== 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 DS0PR11MB6349.namprd11.prod.outlook.com (2603:10b6:8:ce::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.21; Wed, 31 Aug 2022 21:57:42 +0000 Received: from DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e]) by DM4PR11MB5373.namprd11.prod.outlook.com ([fe80::b04c:807c:4ea0:c62e%9]) with mapi id 15.20.5566.021; Wed, 31 Aug 2022 21:57:42 +0000 From: =?utf-8?q?Micha=C5=82_Winiarski?= To: Subject: [PATCH 2/2] drm/format: Split into more granular test cases Date: Wed, 31 Aug 2022 23:56:08 +0200 Message-ID: <20220831215608.349269-2-michal.winiarski@intel.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220831215608.349269-1-michal.winiarski@intel.com> References: <20220831215608.349269-1-michal.winiarski@intel.com> X-ClientProxiedBy: FR3P281CA0165.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::10) 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: e0ccc402-b0cf-4f1b-fc38-08da8b9bd43d X-MS-TrafficTypeDiagnostic: DS0PR11MB6349:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d1mbGGMthCr2bcghvImSr1PSgtFouxsYDExzzKcLsf2PVnk2Rk6L2DDL65WbpNZx5nmrNpBPNrUh7U3lfWpP3vqP9KfgYHZwX0C1k+Mi2YrFdXjYs3dizRNyKeYRmOQjeTyEV32mQpWhshdTR+6xAF0ZcQTycfCwL0Y1ymggRqxfr4tHw7dG/nohZuoYzrrbFU3Ve9HLzKLelQcN0hgXmMa/m+4gQlglQt5DSMTffuvgQk0VZRgDYBRRQBfOHqar6WgkBBCI95vD537NaZazQkfs8zf3sT6m73JnC+RfgLpsI/KwlRweyalnKKmo2BcOFKCq2VvFoznbff0cbn/XMEFCMwjaDZAfHP8qaW4hqEG1WvrqselZracO3GbX5BdrehqrBz38vV3g5zMkEUYU5H5p/7Cs65BaPzk9Md0pLLZIuPD1txlRHcEDjO0XqvF+2hLjQcimHVjRr9XdAS/V7cVVFB2VDWXpf4PSf+JTgkvSOcvzgxhTiLaT0fkIcnZ5mMQJ8NBeRsRFxSySFok/VGooRbrAQagXuLhGf2FP5hmxhoC6drcyc0TC0MJQvA1BFFr3N0qVOnA0QWSAIUkECRMXgpeW6tiu2uZtmPoHbzL/wrM4JWb8sbfYatQ71RWxpUW8q/bh/wG6Q+N0rYvQldlgA7SxfAqRI6oardi/EXyFlMkzoizJ+kfOtaS44Fuw4I2F5pjQsrrJA+M9ISEYKQ== 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)(376002)(396003)(346002)(366004)(39860400002)(136003)(5660300002)(66476007)(66556008)(66946007)(107886003)(478600001)(30864003)(8676002)(4326008)(6506007)(8936002)(6666004)(41300700001)(83380400001)(6486002)(86362001)(1076003)(82960400001)(186003)(6512007)(2616005)(26005)(38100700002)(316002)(6916009)(36756003)(2906002)(54906003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?OEcA88rpsy59dFMqEpX5DpB1oIAt?= =?utf-8?q?NsmGtv1dKLK6tnOixrNNG0tFknJYWCTr65q5334D6htKUT/xvZPT/GcK/7s2HXHHR?= =?utf-8?q?8J4+7G2o7ePrID3iRHI7lSr10Z3TIWQKNtDFansYlZonwgnBhBybb9hCGfjlHW6r9?= =?utf-8?q?ny9nPHuJeLD5mFC6wYky/f+3YQIHFm+4B+PWB9NQpaGvU9Fyums90O5PtRcgUDkLR?= =?utf-8?q?0M33OqqfKfpD2YEvnx1EZSNrq9yBckSa6q+8Es0HLcnH6tHWZOSkmnufat3qXCbBo?= =?utf-8?q?OBi/sUixnfsd+IuFtb83b7yWm8VsO7S5NadIvIFnFxKbJDQu6+cgk8ynyYWp9yWa+?= =?utf-8?q?pRH7scmrzTH6aACHXG+qnsYvA8L3VbxCXrcfP4vHYxhVmAJgL9qPqzG6NnW2ZBqFF?= =?utf-8?q?KnVM3w3OCV/TrT5cGkKsJBq19nuCph6zs6pAhVrc3MBfvTu6O70Kmp3lRwOSh6iLd?= =?utf-8?q?uoAq0Cf/3ObWv9dvu96ktfAuRjrrBEokqk2Pz5eOBEtZCDmUyp8iFaCaHXgfsaKbP?= =?utf-8?q?QrIwQAF6RNVwxzgIysC+R0GlRiX9NhYIUHI/QP17GXpLIvSvaQM3QjMtiAm9/OOIB?= =?utf-8?q?umIX7gI21NYf2H4X0Qksub75eE4IQylxvDpEmMI40cdS/JBC9S2IsLLx3asxiT+R4?= =?utf-8?q?UjsC6mVKuedLkYgepNk7n0pA1UJM20sc7TmWxvEuBer6NSl3LRs0EHOxqii4NtWm9?= =?utf-8?q?S2rEaf6Gp30GPWoOutv+xt027roev/mPooCxQ9vLVrHx/ZkvI1uoInzpWB+Z94PWh?= =?utf-8?q?NwUQg0EOm9rCA5aGMWnnE1C5WGyZvNQJwSuvOAZKKrRGhqhPRqwhZia9X0Sljmkac?= =?utf-8?q?ZXguFYztERYXIIWKVVShE8GU7dDr8WIKovqNKpha4/IPYAItj2uWyz2cE51ZdhSVa?= =?utf-8?q?BnLc7GOfl9/VIhLOpmXu7kVrSW7rqUrZX8I2gBVS/NIULFfUZ0HG9oEX1gA7CpW7Z?= =?utf-8?q?iYIjF6C6jNxG3tK8JBasxxjdMxdWgyWSB3MU1cU+n9dRwEFHfHfTnm36nQ9M0HHTj?= =?utf-8?q?LgGVSv62VJUB7dNwu15/dKEmx5eqM6lOqAvDbdl8gMauuCCzCCTVJS9oDDOeDMO6v?= =?utf-8?q?vGvjjWQeXgO0AicGhJ1sWKIHlWWQVYmVNASxy/0g2ynTv9d4dLcgNvJvh7Wu1r44b?= =?utf-8?q?4wd3uQH4PSq0NPyWnl7+cJm4upS+rj8xfkavnRu5tZnTHSerX0BXURjYvX32JFhaX?= =?utf-8?q?E3a6jpFuH1vo4hM0eJzjF6pD7s+SfEq/3/7tt3YGRUXVnxfTpycza6x0b7XMqs05z?= =?utf-8?q?f8acWmw+m9MWyhCfy1/7gP2KKJRfinaNuyCypINXkjHrqqzvbfyN3WBboH/Zep5nK?= =?utf-8?q?yqBuX2rS/6CDRZxY+o5SBbxJUy1NvgcvD/PrOK/F4Rl5FyJrtVtqahz9cKalvX5ob?= =?utf-8?q?pgclXCOhoa0BdK6fRBUqkaDwnv/OczmWyxtJJDsc6zhwakDvDhO+/xzsS7vKv45UQ?= =?utf-8?q?6MFMet1irAsJIaQhmxSIL3fj55OowNs6FmniVtMANp4z0V1qSxdOdGrLghxj36BL8?= =?utf-8?q?0suGZuXtErXDRDV8pro9r9LYSoBYqwVZHQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: e0ccc402-b0cf-4f1b-fc38-08da8b9bd43d X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB5373.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2022 21:57:42.5414 (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: N8I0XkUrTuOqVOeEe4GNY7Ec/h9IjpqhnH+SUOttaZOOKHJULYwdV2Rf2jEmyV3Ek4q1L5K0xoEHWJtHgifF0olj0aY7lBfVeFQXxj0pL7E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB6349 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?Andr=C3=A9_Almeida?= , David Airlie , Daniel Latypov , Javier Martinez Canillas , =?utf-8?q?Ma=C3=ADra_Canal?= , =?utf-8?q?Micha=C5=82?= =?utf-8?q?_Winiarski?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" While we have multiple test cases, most of them check multiple conditions, calling the function that is tested multiple times with different arguments (with comments that indicate test case boundary). This usually means that it can be easily converted into multiple test cases. Passing output: ============================================================ ================= drm_format (18 subtests) ================= [PASSED] drm_format_block_width_invalid [PASSED] drm_format_block_width_one_plane [PASSED] drm_format_block_width_two_plane [PASSED] drm_format_block_width_three_plane [PASSED] drm_format_block_width_tiled [PASSED] drm_format_block_height_invalid [PASSED] drm_format_block_height_one_plane [PASSED] drm_format_block_height_two_plane [PASSED] drm_format_block_height_three_plane [PASSED] drm_format_block_height_tiled [PASSED] drm_format_min_pitch_invalid [PASSED] drm_format_min_pitch_one_plane_8bpp [PASSED] drm_format_min_pitch_one_plane_16bpp [PASSED] drm_format_min_pitch_one_plane_24bpp [PASSED] drm_format_min_pitch_one_plane_32bpp [PASSED] drm_format_min_pitch_two_plane [PASSED] drm_format_min_pitch_three_plane_8bpp [PASSED] drm_format_min_pitch_tiled =================== [PASSED] drm_format ==================== ============================================================ Testing complete. Ran 18 tests: passed: 18 Signed-off-by: Michał Winiarski Reviewed-by: Maíra Canal --- drivers/gpu/drm/tests/drm_format_test.c | 156 ++++++++++++++++-------- 1 file changed, 108 insertions(+), 48 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_format_test.c b/drivers/gpu/drm/tests/drm_format_test.c index 0efa88bf56a9..1936d2d59908 100644 --- a/drivers/gpu/drm/tests/drm_format_test.c +++ b/drivers/gpu/drm/tests/drm_format_test.c @@ -9,100 +9,133 @@ #include -static void igt_check_drm_format_block_width(struct kunit *test) +static void drm_format_block_width_invalid(struct kunit *test) { const struct drm_format_info *info = NULL; - /* Test invalid arguments */ 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); - /* Test 1 plane format */ - info = drm_format_info(DRM_FORMAT_XRGB4444); KUNIT_ASSERT_NOT_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); - /* Test 2 planes format */ - info = drm_format_info(DRM_FORMAT_NV12); KUNIT_ASSERT_NOT_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); +} + +static void drm_format_block_width_three_plane(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422); - /* Test 3 planes format */ - info = drm_format_info(DRM_FORMAT_YUV422); KUNIT_ASSERT_NOT_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); - /* Test a tiled format */ - info = drm_format_info(DRM_FORMAT_X0L0); KUNIT_ASSERT_NOT_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 igt_check_drm_format_block_height(struct kunit *test) +static void drm_format_block_height_invalid(struct kunit *test) { const struct drm_format_info *info = NULL; - /* Test invalid arguments */ 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); +} + +static void drm_format_block_height_one_plane(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444); - /* Test 1 plane format */ - info = drm_format_info(DRM_FORMAT_XRGB4444); KUNIT_ASSERT_NOT_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); - /* Test 2 planes format */ - info = drm_format_info(DRM_FORMAT_NV12); KUNIT_ASSERT_NOT_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); - /* Test 3 planes format */ - info = drm_format_info(DRM_FORMAT_YUV422); KUNIT_ASSERT_NOT_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); - /* Test a tiled format */ - info = drm_format_info(DRM_FORMAT_X0L0); KUNIT_ASSERT_NOT_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 igt_check_drm_format_min_pitch_for_single_plane(struct kunit *test) +static void drm_format_min_pitch_invalid(struct kunit *test) { const struct drm_format_info *info = NULL; - /* Test invalid arguments */ 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); - /* Test 1 plane 8 bits per pixel format */ - info = drm_format_info(DRM_FORMAT_RGB332); KUNIT_ASSERT_NOT_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); @@ -118,10 +151,14 @@ static void igt_check_drm_format_min_pitch_for_single_plane(struct kunit *test) (uint64_t)UINT_MAX); KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)), (uint64_t)(UINT_MAX - 1)); +} + +static void drm_format_min_pitch_one_plane_16bpp(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444); - /* Test 1 plane 16 bits per pixel format */ - info = drm_format_info(DRM_FORMAT_XRGB4444); KUNIT_ASSERT_NOT_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); @@ -137,10 +174,14 @@ static void igt_check_drm_format_min_pitch_for_single_plane(struct kunit *test) (uint64_t)UINT_MAX * 2); KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)), (uint64_t)(UINT_MAX - 1) * 2); +} + +static void drm_format_min_pitch_one_plane_24bpp(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_RGB888); - /* Test 1 plane 24 bits per pixel format */ - info = drm_format_info(DRM_FORMAT_RGB888); KUNIT_ASSERT_NOT_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); @@ -154,12 +195,16 @@ static void igt_check_drm_format_min_pitch_for_single_plane(struct kunit *test) 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); - KUNIT_EXPECT_EQ(test, 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); +} + +static void drm_format_min_pitch_one_plane_32bpp(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_ABGR8888); - /* Test 1 plane 32 bits per pixel format */ - info = drm_format_info(DRM_FORMAT_ABGR8888); KUNIT_ASSERT_NOT_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); @@ -173,17 +218,16 @@ static void igt_check_drm_format_min_pitch_for_single_plane(struct kunit *test) 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); - KUNIT_EXPECT_EQ(test, 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); } -static void igt_check_drm_format_min_pitch_for_multi_planar(struct kunit *test) +static void drm_format_min_pitch_two_plane(struct kunit *test) { - const struct drm_format_info *info = NULL; + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12); - /* Test 2 planes format */ - info = drm_format_info(DRM_FORMAT_NV12); KUNIT_ASSERT_NOT_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); @@ -211,10 +255,14 @@ static void igt_check_drm_format_min_pitch_for_multi_planar(struct kunit *test) (uint64_t)(UINT_MAX - 1)); KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, (UINT_MAX - 1) / 2), (uint64_t)(UINT_MAX - 1)); +} + +static void drm_format_min_pitch_three_plane_8bpp(struct kunit *test) +{ + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422); - /* Test 3 planes 8 bits per pixel format */ - info = drm_format_info(DRM_FORMAT_YUV422); KUNIT_ASSERT_NOT_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); @@ -256,13 +304,12 @@ static void igt_check_drm_format_min_pitch_for_multi_planar(struct kunit *test) (uint64_t)(UINT_MAX - 1) / 2); } -static void igt_check_drm_format_min_pitch_for_tiled_format(struct kunit *test) +static void drm_format_min_pitch_tiled(struct kunit *test) { - const struct drm_format_info *info = NULL; + const struct drm_format_info *info = drm_format_info(DRM_FORMAT_X0L2); - /* Test tiled format */ - info = drm_format_info(DRM_FORMAT_X0L2); KUNIT_ASSERT_NOT_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); @@ -281,12 +328,25 @@ static void igt_check_drm_format_min_pitch_for_tiled_format(struct kunit *test) } static struct kunit_case drm_format_tests[] = { - KUNIT_CASE(igt_check_drm_format_block_width), - KUNIT_CASE(igt_check_drm_format_block_height), - KUNIT_CASE(igt_check_drm_format_min_pitch_for_single_plane), - KUNIT_CASE(igt_check_drm_format_min_pitch_for_multi_planar), - KUNIT_CASE(igt_check_drm_format_min_pitch_for_tiled_format), - { } + 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 = {