Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1574886rwb; Tue, 27 Sep 2022 15:26:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7lOffSuWdp7alF2sf/Kj+WQapo1ZcbYS093HZXjmS+1b8wfqnc6u1hRxLrCik5OGZjFoCy X-Received: by 2002:a17:902:8214:b0:178:95c9:bd5d with SMTP id x20-20020a170902821400b0017895c9bd5dmr29973831pln.106.1664317611435; Tue, 27 Sep 2022 15:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664317611; cv=none; d=google.com; s=arc-20160816; b=WHp+Z/iFKbvd7t4Kd9YDvYEuAkXouRBmOlJpirVgHywlFBkTcVhOxCaipMHAC/OCy9 PTzFOtMFoLsJvSv+yNKNO6w9WcVrp/cZC4Y/e+WfvoVIEBunb/+XQEh6gWCIJ1NdCbNv HC4qecVmNAWzyjkr44tb9dD2x54PQ8bDyargefoJcGklhWO+55PGfqYNtHxBjlXAotoG 5KOvvoXwD93whBz0oQK4RqMPUSwi3dfYWi1Y8EA3iPb5q3FTn0hMgPIyGHmuXHCB08G8 H1UldfCzrGGYFbGotjdPQT1JUwB3YLXNYDFjmvRiCTRtVqngiRoNozcrLc1DlllNKN0O /hCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=OQqrYheo/UyRR+1g1GEetPZjkt3ZHK1BPRuh8I0zE84=; b=WgWKSPoEbNBlRop5c55lOSokJhk7ZHSBIJZ63h2S7vepeuc3wc/SCmM1w71gX5IJfJ xsswwUbi9z0SYK3qcQBEQpdhBC+qnECXiRm253amFcAZaM+6GquB72f0LCvFf9jXXThR so56NUWlotd2dZVKjQ9n7gyi8xyEyCaE0s+6YsaJayrRhdGhChbbQahlEKU13S1L5D1h /RGEygE4IfhHIAlzOxHNl5zEwneCRwQdTlwyce5rH+X8WhdVsNsJnr4RHUDbNOTwnJdh Dpbnlrjaw1fHHuHSXJKUnCrpRe4qrd7QWyyHBDEV2HkWSbvJZYOaHwOAI3SVsNFjRQZj SvgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=lklDJPjW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j191-20020a6380c8000000b0043dc6ccef5csi3254269pgd.547.2022.09.27.15.26.40; Tue, 27 Sep 2022 15:26:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=lklDJPjW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229630AbiI0WNL (ORCPT + 99 others); Tue, 27 Sep 2022 18:13:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbiI0WNJ (ORCPT ); Tue, 27 Sep 2022 18:13:09 -0400 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 111D410963B for ; Tue, 27 Sep 2022 15:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=OQqrYheo/UyRR+1g1GEetPZjkt3ZHK1BPRuh8I0zE84=; b=lklDJPjWTcQu09wGTjZ2PHsQGj sBmn4fVwC4uh/mtiMmx0afSo7wKHHhJW0a2V6UP+/+FQi+H4Cn29plPyT4kVUxMj1YWosDwYAp0lf /0l1eQEe0l8dNLIZRbtdp0v3YHtPeHVgYdnh3FEg+d913ULJvkuUycQa0lu1pLf6W9J21gHzgA1VS sKf3am6xz1LnVah0TXXLv8hrTpRXPwo0o5sBfGfCAEKECU15XarYdwgXvKeugIxegn+KxY9N+Yd9t cKZJxasXVODlTkcaSwmTqM85j9Cw+2u+iut8YCBeF9JPTA/PL+OLkkpB/HKbDnpPv0R0yQbF9/bTq UIcKBZGw==; Received: from [177.34.169.227] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1odIom-00E9Og-4k; Wed, 28 Sep 2022 00:12:44 +0200 From: =?UTF-8?q?Ma=C3=ADra=20Canal?= To: David Airlie , Daniel Vetter , Melissa Wen , =?UTF-8?q?Andr=C3=A9=20Almeida?= , Javier Martinez Canillas , =?UTF-8?q?Micha=C5=82=20Winiarski?= , Daniel Latypov , David Gow Cc: Arthur Grillo , Isabella Basso , magalilemes00@gmail.com, tales.aparecida@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Ma=C3=ADra=20Canal?= Subject: [PATCH v2 1/2] drm/tests: Split drm_test_dp_mst_calc_pbn_mode into parameterized tests Date: Tue, 27 Sep 2022 19:12:05 -0300 Message-Id: <20220927221206.55930-1-mcanal@igalia.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The drm_test_dp_mst_calc_pbn_mode is based on a loop that executes tests for a couple of test cases. This could be better represented by parameterized tests, provided by KUnit. So, convert the drm_test_dp_mst_calc_pbn_mode into parameterized tests. Signed-off-by: Maíra Canal Reviewed-by: Michał Winiarski --- v1 -> v2: https://lore.kernel.org/dri-devel/20220925222719.345424-1-mcanal@igalia.com/T/#m056610a23a63109484afeafefb5846178c4d36b2 - Add Michał's Reviewed-by tag. --- .../gpu/drm/tests/drm_dp_mst_helper_test.c | 77 +++++++++++++------ 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c b/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c index 65c9d225b558..12f41881db6b 100644 --- a/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c +++ b/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c @@ -16,33 +16,62 @@ #include "../display/drm_dp_mst_topology_internal.h" +struct drm_dp_mst_calc_pbn_mode_test { + const int clock; + const int bpp; + const bool dsc; + const int expected; +}; + +static const struct drm_dp_mst_calc_pbn_mode_test drm_dp_mst_calc_pbn_mode_cases[] = { + { + .clock = 154000, + .bpp = 30, + .dsc = false, + .expected = 689 + }, + { + .clock = 234000, + .bpp = 30, + .dsc = false, + .expected = 1047 + }, + { + .clock = 297000, + .bpp = 24, + .dsc = false, + .expected = 1063 + }, + { + .clock = 332880, + .bpp = 24, + .dsc = true, + .expected = 50 + }, + { + .clock = 324540, + .bpp = 24, + .dsc = true, + .expected = 49 + }, +}; + static void drm_test_dp_mst_calc_pbn_mode(struct kunit *test) { - int pbn, i; - const struct { - int rate; - int bpp; - int expected; - bool dsc; - } test_params[] = { - { 154000, 30, 689, false }, - { 234000, 30, 1047, false }, - { 297000, 24, 1063, false }, - { 332880, 24, 50, true }, - { 324540, 24, 49, true }, - }; - - for (i = 0; i < ARRAY_SIZE(test_params); i++) { - pbn = drm_dp_calc_pbn_mode(test_params[i].rate, - test_params[i].bpp, - test_params[i].dsc); - KUNIT_EXPECT_EQ_MSG(test, pbn, test_params[i].expected, - "Expected PBN %d for clock %d bpp %d, got %d\n", - test_params[i].expected, test_params[i].rate, - test_params[i].bpp, pbn); - } + const struct drm_dp_mst_calc_pbn_mode_test *params = test->param_value; + + KUNIT_EXPECT_EQ(test, drm_dp_calc_pbn_mode(params->clock, params->bpp, params->dsc), + params->expected); } +static void dp_mst_calc_pbn_mode_desc(const struct drm_dp_mst_calc_pbn_mode_test *t, char *desc) +{ + sprintf(desc, "Clock %d BPP %d DSC %s", t->clock, t->bpp, t->dsc ? "enabled" : "disabled"); +} + +KUNIT_ARRAY_PARAM(drm_dp_mst_calc_pbn_mode, drm_dp_mst_calc_pbn_mode_cases, + dp_mst_calc_pbn_mode_desc); + static bool sideband_msg_req_equal(const struct drm_dp_sideband_msg_req_body *in, const struct drm_dp_sideband_msg_req_body *out) @@ -271,7 +300,7 @@ static void drm_test_dp_mst_sideband_msg_req_decode(struct kunit *test) } static struct kunit_case drm_dp_mst_helper_tests[] = { - KUNIT_CASE(drm_test_dp_mst_calc_pbn_mode), + KUNIT_CASE_PARAM(drm_test_dp_mst_calc_pbn_mode, drm_dp_mst_calc_pbn_mode_gen_params), KUNIT_CASE(drm_test_dp_mst_sideband_msg_req_decode), { } }; -- 2.37.3