Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp511616lqh; Tue, 7 May 2024 06:19:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXTao7kUSn1I1dwj7/d01YrSWe+Br+Cefviv0xP8bdkjoUSZnaafcBtxsdpphPtKEcYKBHXtEQlYbIwhVVJ48OZdOEbjQUmywCZ8iZXgQ== X-Google-Smtp-Source: AGHT+IFHtPIQ+fQXhHGHg1ksml+hc8MQTMkxo7NSkr9HlErkyinEH1R/nu8DPD2LLl4MhDsxG8g7 X-Received: by 2002:a17:906:7153:b0:a59:d0be:dba4 with SMTP id z19-20020a170906715300b00a59d0bedba4mr4678051ejj.13.1715087940585; Tue, 07 May 2024 06:19:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715087940; cv=pass; d=google.com; s=arc-20160816; b=P8KUG0sRVtxJ4XT2Psd440sAadACNoXTNTf3Q2VXbU/pzpkOdVSnJzJnDutUxDKt7+ cJZ3c3IKLP6lR8OB3ZGDF9yEipjtWXCN6JlCcrCdch4IRuGlLvtp00Wy/VCQipRD8N1/ RQZG/aoRELz4voB3KGQHvEii7veDcvmLpi3WnhKRIFmSAg6PWTqMmFos5vU7c9TSZB8T 87+trrG+Vw8Vk38+LB/wunvM8RtELpVMv+YTTd/YwSHzeCsjl9KH/ez+IC3upjoz4vUI n/k2WmTydziaij6iJuYLi4bGql76Zn+9BYN5H24H83/LotXeZtSeAaoOYArCETFYBpnc hl6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=B4js7nLIIhDTsDgigNIOp0WBy0JYgGrQaAV7jrpj1dc=; fh=ufmwd8Wo0DI+kdMOJWC7ZXqsyLxoMBbO0En/E/GApYU=; b=n8dSshx/PLsNrtIiIjQ6p5XDTJ0mor6So7G/TsYaJCJ+R8LmVjbTkbNknCygejqHwx x5aKVKrbAt3xW60413mcOAmYVkLxsIWcyyAHq7hbGaGFichoidCf4wJKdAyt/KUDn5pP F/htp3AjhG2+IYzdOMEGdft44VZe2gXECipG/+C2GLQOMeaC8VKJz31a86hNH9A2+3Wi hOsh4WkKTp+dJRSmCcKUy5Y3yP8OyNTMsKMwJcHBH5MvebPgnKnSJF6XvLSjpLR/n1Wd A2zP4gUtk48ya4A2bMMO7YZa4aAIGVRlXZCshzOBr6F4Mjwv2pYcbH6CuqHUQQ5A4u/s DhlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZE4WXMdI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-171373-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171373-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s21-20020a170906a19500b00a555ddde855si5681810ejy.369.2024.05.07.06.19.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 06:19:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171373-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZE4WXMdI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-171373-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171373-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B67F91F239AF for ; Tue, 7 May 2024 13:18:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F2A015ECEA; Tue, 7 May 2024 13:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZE4WXMdI" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9810E15ECD9; Tue, 7 May 2024 13:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715087872; cv=none; b=FgSnw/xIv4Gz3Yw0KJgPYRoDcFWJ1eYXNM7wRFqZssK/aW9spF2CN5vklChpURinRTpd55UEmobFg0MxLMVfhxGZSHaHFxCw+zIW/YqrWQXZoBesmtbQ/phSDa0MuRJalsV7tAqGV0Vg+ltq6/VJ2ZTLxcNDDY0pXgM2zCvP0S4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715087872; c=relaxed/simple; bh=kpugqRRTtI2zqYUkrRQOUtStRse4zcye8LofRM1/4QM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SkqS8I82hUixCJG8vIl4+kTejMJwj34xcN1juiyraHHp8G6JS7VVPJelvvRtBtI02G6+4qCAbUVNJa8YNlYOl1nm04100STbOw+NoakLlPG78rsldbMQQ2sGRqfRU2g+BMlXISasdaf1Ds67rEnoAEcijMS2Zk/f4EgwKvyV2l4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZE4WXMdI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA772C4DDE0; Tue, 7 May 2024 13:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715087872; bh=kpugqRRTtI2zqYUkrRQOUtStRse4zcye8LofRM1/4QM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZE4WXMdImKJGnK/i0VosUpvwHfw44ldd7Ml7S0Xp24JFoqB7vODRbUwVLV7ajRQEM U2Bq7t+/GNUaMxbtcszu0jOxdf1Jwsh2UYNlqCx7UCKn0Efqpi++lvb1/vhfHvWjlV M+Y9C6uRKK1DXZ6Pj6OCK7sTz0Jt3WqCmPZFPwkBGHBFnFVG+7My74ssh83Zt8YSe3 C7nkAus3T02QzekE/35VNdoNHudfIWnRO50oneKKRycvyh4QnZ2yB+3GzohdG7V5bb ZMUDdNrZ5ISM/uZH5OOcm9tJEsvZIe9itTSKF9EvbsY2eF5MVcr8j37YcfpHx4o6uC HkDocdz5y/S4g== From: Maxime Ripard Date: Tue, 07 May 2024 15:17:21 +0200 Subject: [PATCH v13 03/28] drm/tests: connector: Add tests for drmm_connector_hdmi_init Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240507-kms-hdmi-connector-state-v13-3-8fafc5efe8be@kernel.org> References: <20240507-kms-hdmi-connector-state-v13-0-8fafc5efe8be@kernel.org> In-Reply-To: <20240507-kms-hdmi-connector-state-v13-0-8fafc5efe8be@kernel.org> To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Jonathan Corbet , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Andy Yan Cc: Hans Verkuil , Sebastian Wick , =?utf-8?q?Ville_Syrj=C3=A4l=C3=A4?= , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Maxime Ripard , Dave Stevenson X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5120; i=mripard@kernel.org; h=from:subject:message-id; bh=kpugqRRTtI2zqYUkrRQOUtStRse4zcye8LofRM1/4QM=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGlWmi8+V+xLPLxdYkna22kmFZM3zJpR8aP/300vrcYgw c7115OmdkxlYRDmZJAVU2R5IhN2enn74ioH+5U/YOawMoEMYeDiFICJTO1hrDP4eELMfW2m87zL W0KmT9UwtePdXbjZ4b3WSsW9648lTNhzt1/dY/sKtfBm6RPxtde79Bgbjl9lOnV2NS+f5a1HPKu W3AkJm62/1r6qpVU55NWh6UfD7HL/9bbl9+1bFbL46OzrpkqRAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D We just introduced a new initialization function for our connectors, so let's build a kunit test suite for it as well. Reviewed-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/tests/drm_connector_test.c | 123 +++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c index 44f82ed2a958..261d4109946d 100644 --- a/drivers/gpu/drm/tests/drm_connector_test.c +++ b/drivers/gpu/drm/tests/drm_connector_test.c @@ -170,10 +170,132 @@ static struct kunit_suite drmm_connector_init_test_suite = { .name = "drmm_connector_init", .init = drm_test_connector_init, .test_cases = drmm_connector_init_tests, }; +/* + * Test that the registration of a bog standard connector works as + * expected and doesn't report any error. + */ +static void drm_test_connector_hdmi_init_valid(struct kunit *test) +{ + struct drm_connector_init_priv *priv = test->priv; + int ret; + + ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, + &dummy_funcs, + DRM_MODE_CONNECTOR_HDMIA, + &priv->ddc); + KUNIT_EXPECT_EQ(test, ret, 0); +} + +/* + * Test that the registration of a connector without a DDC adapter + * doesn't report any error. + */ +static void drm_test_connector_hdmi_init_null_ddc(struct kunit *test) +{ + struct drm_connector_init_priv *priv = test->priv; + int ret; + + ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, + &dummy_funcs, + DRM_MODE_CONNECTOR_HDMIA, + NULL); + KUNIT_EXPECT_EQ(test, ret, 0); +} + +/* + * Test that the registration of an HDMI connector with an HDMI + * connector type succeeds. + */ +static void drm_test_connector_hdmi_init_type_valid(struct kunit *test) +{ + struct drm_connector_init_priv *priv = test->priv; + unsigned int connector_type = *(unsigned int *)test->param_value; + int ret; + + ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, + &dummy_funcs, + connector_type, + &priv->ddc); + KUNIT_EXPECT_EQ(test, ret, 0); +} + +static const unsigned int drm_connector_hdmi_init_type_valid_tests[] = { + DRM_MODE_CONNECTOR_HDMIA, + DRM_MODE_CONNECTOR_HDMIB, +}; + +static void drm_connector_hdmi_init_type_desc(const unsigned int *type, char *desc) +{ + sprintf(desc, "%s", drm_get_connector_type_name(*type)); +} + +KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_type_valid, + drm_connector_hdmi_init_type_valid_tests, + drm_connector_hdmi_init_type_desc); + +/* + * Test that the registration of an HDMI connector with an !HDMI + * connector type fails. + */ +static void drm_test_connector_hdmi_init_type_invalid(struct kunit *test) +{ + struct drm_connector_init_priv *priv = test->priv; + unsigned int connector_type = *(unsigned int *)test->param_value; + int ret; + + ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, + &dummy_funcs, + connector_type, + &priv->ddc); + KUNIT_EXPECT_LT(test, ret, 0); +} + +static const unsigned int drm_connector_hdmi_init_type_invalid_tests[] = { + DRM_MODE_CONNECTOR_Unknown, + DRM_MODE_CONNECTOR_VGA, + DRM_MODE_CONNECTOR_DVII, + DRM_MODE_CONNECTOR_DVID, + DRM_MODE_CONNECTOR_DVIA, + DRM_MODE_CONNECTOR_Composite, + DRM_MODE_CONNECTOR_SVIDEO, + DRM_MODE_CONNECTOR_LVDS, + DRM_MODE_CONNECTOR_Component, + DRM_MODE_CONNECTOR_9PinDIN, + DRM_MODE_CONNECTOR_DisplayPort, + DRM_MODE_CONNECTOR_TV, + DRM_MODE_CONNECTOR_eDP, + DRM_MODE_CONNECTOR_VIRTUAL, + DRM_MODE_CONNECTOR_DSI, + DRM_MODE_CONNECTOR_DPI, + DRM_MODE_CONNECTOR_WRITEBACK, + DRM_MODE_CONNECTOR_SPI, + DRM_MODE_CONNECTOR_USB, +}; + +KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_type_invalid, + drm_connector_hdmi_init_type_invalid_tests, + drm_connector_hdmi_init_type_desc); + +static struct kunit_case drmm_connector_hdmi_init_tests[] = { + KUNIT_CASE(drm_test_connector_hdmi_init_valid), + KUNIT_CASE(drm_test_connector_hdmi_init_null_ddc), + KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_type_valid, + drm_connector_hdmi_init_type_valid_gen_params), + KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_type_invalid, + drm_connector_hdmi_init_type_invalid_gen_params), + { } +}; + +static struct kunit_suite drmm_connector_hdmi_init_test_suite = { + .name = "drmm_connector_hdmi_init", + .init = drm_test_connector_init, + .test_cases = drmm_connector_hdmi_init_tests, +}; + struct drm_get_tv_mode_from_name_test { const char *name; enum drm_connector_tv_mode expected_mode; }; @@ -234,10 +356,11 @@ static struct kunit_suite drm_get_tv_mode_from_name_test_suite = { .name = "drm_get_tv_mode_from_name", .test_cases = drm_get_tv_mode_from_name_tests, }; kunit_test_suites( + &drmm_connector_hdmi_init_test_suite, &drmm_connector_init_test_suite, &drm_get_tv_mode_from_name_test_suite ); MODULE_AUTHOR("Maxime Ripard "); -- 2.45.0