From: Dipam Turkar <dipamt1729@gmail.com>
To: maarten.lankhorst@linux.intel.com
Cc: mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com,
daniel@ffwll.ch, mairacanal@riseup.net, javierm@redhat.com,
arthurgrillo@riseup.net, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, Dipam Turkar <dipamt1729@gmail.com>
Subject: [PATCH v2] drm/tests: Add KUnit tests for drm_mode_create_dvi_i_properties()
Date: Sat, 11 Nov 2023 00:54:53 +0530 [thread overview]
Message-ID: <20231110192452.734925-1-dipamt1729@gmail.com> (raw)
Introduce unit tests for the drm_mode_create_dvi_i_properties() function to ensure
the proper creation of DVI-I specific connector properties.
Signed-off-by: Dipam Turkar <dipamt1729@gmail.com>
---
drivers/gpu/drm/tests/drm_connector_test.c | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c
index c66aa2dc8d9d..9ac1fd32c579 100644
--- a/drivers/gpu/drm/tests/drm_connector_test.c
+++ b/drivers/gpu/drm/tests/drm_connector_test.c
@@ -4,6 +4,9 @@
*/
#include <drm/drm_connector.h>
+#include <drm/drm_device.h>
+#include <drm/drm_drv.h>
+#include <drm/drm_kunit_helpers.h>
#include <kunit/test.h>
@@ -58,6 +61,30 @@ static void drm_test_get_tv_mode_from_name_truncated(struct kunit *test)
KUNIT_EXPECT_LT(test, ret, 0);
};
+/*
+ * Test that drm_mode_create_dvi_i_properties() succeeds and
+ * DVI-I subconnector and select subconectors properties have
+ * been created.
+ */
+static void drm_test_mode_create_dvi_i_properties(struct kunit *test)
+{
+ struct drm_device *drm;
+ struct device *dev;
+
+ dev = drm_kunit_helper_alloc_device(test);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
+
+ drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0, DRIVER_MODESET);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm);
+
+ KUNIT_EXPECT_EQ(test, drm_mode_create_dvi_i_properties(drm), 0);
+ KUNIT_EXPECT_NOT_ERR_OR_NULL(test, drm->mode_config.dvi_i_select_subconnector_property);
+ KUNIT_EXPECT_NOT_ERR_OR_NULL(test, drm->mode_config.dvi_i_subconnector_property);
+
+ // Expect the function to return 0 if called twice.
+ KUNIT_EXPECT_EQ(test, drm_mode_create_dvi_i_properties(drm), 0);
+}
+
static struct kunit_case drm_get_tv_mode_from_name_tests[] = {
KUNIT_CASE_PARAM(drm_test_get_tv_mode_from_name_valid,
drm_get_tv_mode_from_name_valid_gen_params),
@@ -70,7 +97,18 @@ static struct kunit_suite drm_get_tv_mode_from_name_test_suite = {
.test_cases = drm_get_tv_mode_from_name_tests,
};
+static struct kunit_case drm_connector_tests[] = {
+ KUNIT_CASE(drm_test_mode_create_dvi_i_properties),
+ { }
+};
+
+static struct kunit_suite drm_connector_test_suite = {
+ .name = "drm_connector",
+ .test_cases = drm_connector_tests,
+};
+
kunit_test_suite(drm_get_tv_mode_from_name_test_suite);
+kunit_test_suite(drm_connector_test_suite);
MODULE_AUTHOR("Maxime Ripard <maxime@cerno.tech>");
MODULE_LICENSE("GPL");
--
2.34.1
next reply other threads:[~2023-11-10 19:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-10 19:24 Dipam Turkar [this message]
2023-11-28 12:05 ` Javier Martinez Canillas
2023-11-28 15:09 ` Maxime Ripard
[not found] ` <CALHmwspWRT=pj+mPDhf8YTwSpTz6LiNjq18wbUk7wCW3ijKU4A@mail.gmail.com>
2024-01-06 14:01 ` [PATCH v3 1/1] " Dipam Turkar
2024-01-08 10:50 ` Maxime Ripard
2024-01-08 10:49 ` [PATCH v2] " Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231110192452.734925-1-dipamt1729@gmail.com \
--to=dipamt1729@gmail.com \
--cc=airlied@gmail.com \
--cc=arthurgrillo@riseup.net \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=javierm@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mairacanal@riseup.net \
--cc=mripard@kernel.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®