Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4658178rwe; Tue, 30 Aug 2022 14:30:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR4C4AfD/XrGkHuyQkBWYKU0TXoG7VyJjx7p06B+5iYx8lEBVuBmTl/KGycBPFdNNQ44yuIi X-Received: by 2002:a17:902:ce92:b0:16d:d2a9:43af with SMTP id f18-20020a170902ce9200b0016dd2a943afmr22573591plg.23.1661895016807; Tue, 30 Aug 2022 14:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661895016; cv=none; d=google.com; s=arc-20160816; b=twlp63WuznbGU4FCE5pypg4dIPztB0W6nGTmCL8UIE+cBob9UtLSWNDA3Um0XLOGCY I0cDO5baXycOdXSC0RuAjW65rSkJhpV4WLUSqvVmV3/N4ueN4eyAjXZdrLbnP1kTKb9P l9cuXE8jhjVlvJ0srRGa0/pM43H53S0/cCvaYm3jw/u/TcyCTAJysWjP4gTJnf8CGxwZ hdmUz/QGvm74b45UvquAOSq7APY1Ew1gh3zdliRXeIbrP9PVQU8+3bvWZyxGPQwnvjy3 5yLFiBG912lW+NPwp0XiqPaww1tw52pyB+aPiSNhOmgY541X+LcZ/v0KHUwaguE7ot5l y9kA== 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=1i7K6FXPhCj7ZwuwHbJLmYymVMLui4SpNPSmnqIP7Cc=; b=x1QWpmM3tFqyLWSVlBMyNaRhrqvIZxRoBvqceK02hJVYSLEBAkR8mj1sAvBuScCdaG GppEYeMT2d5IN9JuaaKmGNStuPAiIy0cE3UWt0b2ctE+tVJjJgg+k6oO5mEZDh7WNosY g2K2jzxGx0EcsJ/awxXLkxrVq2x1MubSFx17FYtd4/JgUeKxUEQRUCpr+ySfX7F74MHc a+sBt92XD1tZqCPpXeEtJxQbCf6qWtCj9ncOaNY1CqdrxxkP6fOfryDmRrwXcLPQ0a1p d4vLlHVyZKUXOtWXdhkNxHlwATRE00yK9QEVXMhI4D6hgYQ56cj0AlQZhuncPD2a79CK kgjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b=BM5wux5W; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020a170902d40200b0016da4dcae60si11487415ple.64.2022.08.30.14.30.05; Tue, 30 Aug 2022 14:30:16 -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=pass header.i=@riseup.net header.s=squak header.b=BM5wux5W; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231334AbiH3VQZ (ORCPT + 99 others); Tue, 30 Aug 2022 17:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbiH3VQW (ORCPT ); Tue, 30 Aug 2022 17:16:22 -0400 Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1B598606B; Tue, 30 Aug 2022 14:16:20 -0700 (PDT) Received: from fews2.riseup.net (fews2-pn.riseup.net [10.0.1.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4MHKqR65VtzDrsL; Tue, 30 Aug 2022 21:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1661894180; bh=2LJd07g7yK6u2XwvnyVnORNPFxUFZJkyUqJFurUTMrQ=; h=From:To:Cc:Subject:Date:From; b=BM5wux5WKOM8D76JkVaGsBkoeV/gdAdQ45z7BGR0hoE7EYDZsf+g7/KWHArdeF/Sw 6p0XCto3DIMm3TqP60WgKlNrQKgar338etQ2CMKwg2QleloSLBsKfQq1vrAs2Y4c3+ d4HFd37cqKDCR+yx3JzTPOSrihI/AQgSthLqrPAk= X-Riseup-User-ID: DB8C30363A75DDC5AAAB0D7668C8A89B53A1C6DDDE5383F9E75BDEF30F6F0259 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4MHKqK55TRz1ySR; Tue, 30 Aug 2022 21:16:13 +0000 (UTC) From: =?UTF-8?q?Ma=C3=ADra=20Canal?= To: Isabella Basso , magalilemes00@gmail.com, tales.aparecida@gmail.com, mwen@igalia.com, andrealmeid@riseup.net, siqueirajordao@riseup.net, Trevor Woerner , Daniel Vetter , David Airlie , Javier Martinez Canillas , David Gow , brendanhiggins@google.com, Arthur Grillo , michal.winiarski@intel.com, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Cc: kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Ma=C3=ADra=20Canal?= Subject: [PATCH 1/2] drm/tests: Split drm_framebuffer_create_test into parameterized tests Date: Tue, 30 Aug 2022 18:16:02 -0300 Message-Id: <20220830211603.191734-1-mairacanal@riseup.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 igt_check_drm_framebuffer_create is based on a loop that executes tests for all createbuffer_tests test cases. This could be better represented by parameterized tests, provided by KUnit. So, convert the igt_check_drm_framebuffer_create test into parameterized tests. Signed-off-by: MaĆ­ra Canal --- drivers/gpu/drm/tests/drm_framebuffer_test.c | 23 +++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_framebuffer_test.c b/drivers/gpu/drm/tests/drm_framebuffer_test.c index ec7a08ba4056..3e46fd9f6615 100644 --- a/drivers/gpu/drm/tests/drm_framebuffer_test.c +++ b/drivers/gpu/drm/tests/drm_framebuffer_test.c @@ -25,7 +25,7 @@ struct drm_framebuffer_test { const char *name; }; -static struct drm_framebuffer_test createbuffer_tests[] = { +static const struct drm_framebuffer_test drm_framebuffer_create_cases[] = { { .buffer_created = 1, .name = "ABGR8888 normal sizes", .cmd = { .width = 600, .height = 600, .pixel_format = DRM_FORMAT_ABGR8888, .handles = { 1, 0, 0 }, .pitches = { 4 * 600, 0, 0 }, @@ -340,28 +340,25 @@ static struct drm_device mock_drm_device = { }, }; -static int execute_drm_mode_fb_cmd2(struct drm_mode_fb_cmd2 *r) +static void drm_framebuffer_create_test(struct kunit *test) { + const struct drm_framebuffer_test *params = test->param_value; int buffer_created = 0; mock_drm_device.dev_private = &buffer_created; - drm_internal_framebuffer_create(&mock_drm_device, r, NULL); - return buffer_created; + drm_internal_framebuffer_create(&mock_drm_device, ¶ms->cmd, NULL); + KUNIT_EXPECT_EQ(test, params->buffer_created, buffer_created); } -static void igt_check_drm_framebuffer_create(struct kunit *test) +static void drm_framebuffer_to_desc(const struct drm_framebuffer_test *t, char *desc) { - int i = 0; - - for (i = 0; i < ARRAY_SIZE(createbuffer_tests); i++) { - KUNIT_EXPECT_EQ_MSG(test, createbuffer_tests[i].buffer_created, - execute_drm_mode_fb_cmd2(&createbuffer_tests[i].cmd), - "Test %d: \"%s\" failed\n", i, createbuffer_tests[i].name); - } + strcpy(desc, t->name); } +KUNIT_ARRAY_PARAM(drm_framebuffer_create, drm_framebuffer_create_cases, drm_framebuffer_to_desc); + static struct kunit_case drm_framebuffer_tests[] = { - KUNIT_CASE(igt_check_drm_framebuffer_create), + KUNIT_CASE_PARAM(drm_framebuffer_create_test, drm_framebuffer_create_gen_params), { } }; -- 2.37.2