From: "Maíra Canal" <maira.canal@usp.br>
To: "Isabella Basso" <isabbasso@riseup.net>,
magalilemes00@gmail.com, tales.aparecida@gmail.com,
mwen@igalia.com, andrealmeid@riseup.net,
"Trevor Woerner" <twoerner@gmail.com>,
leandro.ribeiro@collabora.com, n@nfraprado.net,
"Daniel Vetter" <daniel@ffwll.ch>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"David Airlie" <airlied@linux.ie>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
michal.winiarski@intel.com,
"Javier Martinez Canillas" <javierm@redhat.com>,
"José Expósito" <jose.exposito89@gmail.com>,
"David Gow" <davidgow@google.com>,
"Daniel Latypov" <dlatypov@google.com>,
brendanhiggins@google.com
Cc: "Maíra Canal" <maira.canal@usp.br>,
"Rubens Gomes Neto" <rubens.gomes.neto@usp.br>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com
Subject: [PATCH 07/10] drm: selftest: convert drm_dp_mst_helper selftest to KUnit
Date: Wed, 15 Jun 2022 10:58:21 -0300 [thread overview]
Message-ID: <20220615135824.15522-8-maira.canal@usp.br> (raw)
In-Reply-To: <20220615135824.15522-1-maira.canal@usp.br>
Considering the current adoption of the KUnit framework, convert the
DRM DP MST helper selftest to the KUnit API.
Co-developed-by: Rubens Gomes Neto <rubens.gomes.neto@usp.br>
Signed-off-by: Rubens Gomes Neto <rubens.gomes.neto@usp.br>
Signed-off-by: Maíra Canal <maira.canal@usp.br>
---
drivers/gpu/drm/selftests/Makefile | 3 +-
.../gpu/drm/selftests/drm_modeset_selftests.h | 2 -
.../drm/selftests/test-drm_modeset_common.h | 2 -
drivers/gpu/drm/tests/Kconfig | 13 +++
drivers/gpu/drm/tests/Makefile | 1 +
.../test-drm_dp_mst_helper.c | 82 ++++++++++---------
6 files changed, 59 insertions(+), 44 deletions(-)
rename drivers/gpu/drm/{selftests => tests}/test-drm_dp_mst_helper.c (73%)
diff --git a/drivers/gpu/drm/selftests/Makefile b/drivers/gpu/drm/selftests/Makefile
index 9e0ccb482841..1539f55db9a7 100644
--- a/drivers/gpu/drm/selftests/Makefile
+++ b/drivers/gpu/drm/selftests/Makefile
@@ -1,6 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-only
-test-drm_modeset-y := test-drm_modeset_common.o test-drm_framebuffer.o \
- test-drm_dp_mst_helper.o
+test-drm_modeset-y := test-drm_modeset_common.o test-drm_framebuffer.o
obj-$(CONFIG_DRM_DEBUG_SELFTEST) += test-drm_mm.o test-drm_modeset.o \
test-drm_buddy.o
diff --git a/drivers/gpu/drm/selftests/drm_modeset_selftests.h b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
index 22e467f6465a..40a29b8cf386 100644
--- a/drivers/gpu/drm/selftests/drm_modeset_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_modeset_selftests.h
@@ -7,5 +7,3 @@
* Tests are executed in order by igt/drm_selftests_helper
*/
selftest(check_drm_framebuffer_create, igt_check_drm_framebuffer_create)
-selftest(dp_mst_calc_pbn_mode, igt_dp_mst_calc_pbn_mode)
-selftest(dp_mst_sideband_msg_req_decode, igt_dp_mst_sideband_msg_req_decode)
diff --git a/drivers/gpu/drm/selftests/test-drm_modeset_common.h b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
index 790f3cf31f0d..3feb2fea1a6b 100644
--- a/drivers/gpu/drm/selftests/test-drm_modeset_common.h
+++ b/drivers/gpu/drm/selftests/test-drm_modeset_common.h
@@ -17,7 +17,5 @@
#define FAIL_ON(x) FAIL((x), "%s", "FAIL_ON(" __stringify(x) ")\n")
int igt_check_drm_framebuffer_create(void *ignored);
-int igt_dp_mst_calc_pbn_mode(void *ignored);
-int igt_dp_mst_sideband_msg_req_decode(void *ignored);
#endif
diff --git a/drivers/gpu/drm/tests/Kconfig b/drivers/gpu/drm/tests/Kconfig
index 5aa8ac2dd28e..eea0783f981d 100644
--- a/drivers/gpu/drm/tests/Kconfig
+++ b/drivers/gpu/drm/tests/Kconfig
@@ -73,4 +73,17 @@ config DRM_PLANE_HELPER_KUNIT_TEST
If in doubt, say "N".
+config DRM_DP_MST_HELPER_KUNIT_TEST
+ tristate "KUnit tests for DRM DP MST helper" if !DRM_KUNIT_TEST
+ select DRM_DISPLAY_HELPER
+ select DRM_DISPLAY_DP_HELPER
+ default y if DRM_KUNIT_TEST
+ help
+ This option provides a kunit module that can be used to run
+ an unit test on the DRM DP MST helper API. This option is not
+ useful for distributions or general kernels, but only for kernel
+ developers working on DRM and associated drivers.
+
+ If in doubt, say "N".
+
endmenu
diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile
index 6e3a10806cd8..735ca8e4c446 100644
--- a/drivers/gpu/drm/tests/Makefile
+++ b/drivers/gpu/drm/tests/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_DRM_CMDLINE_PARSER_KUNIT_TEST) += test-drm_cmdline_parser.o
obj-$(CONFIG_DRM_RECT_KUNIT_TEST) += test-drm_rect.o
obj-$(CONFIG_DRM_FORMAT_KUNIT_TEST) += test-drm_format.o
obj-$(CONFIG_DRM_PLANE_HELPER_KUNIT_TEST) += test-drm_plane_helper.o
+obj-$(CONFIG_DRM_DP_MST_HELPER_KUNIT_TEST) += test-drm_dp_mst_helper.o
diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/tests/test-drm_dp_mst_helper.c
similarity index 73%
rename from drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
rename to drivers/gpu/drm/tests/test-drm_dp_mst_helper.c
index 967c52150b67..88120e878a15 100644
--- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
+++ b/drivers/gpu/drm/tests/test-drm_dp_mst_helper.c
@@ -5,15 +5,15 @@
#define PREFIX_STR "[drm_dp_mst_helper]"
+#include <kunit/test.h>
#include <linux/random.h>
#include <drm/display/drm_dp_mst_helper.h>
#include <drm/drm_print.h>
#include "../display/drm_dp_mst_topology_internal.h"
-#include "test-drm_modeset_common.h"
-int igt_dp_mst_calc_pbn_mode(void *ignored)
+static void igt_dp_mst_calc_pbn_mode(struct kunit *test)
{
int pbn, i;
const struct {
@@ -33,13 +33,11 @@ int igt_dp_mst_calc_pbn_mode(void *ignored)
pbn = drm_dp_calc_pbn_mode(test_params[i].rate,
test_params[i].bpp,
test_params[i].dsc);
- FAIL(pbn != test_params[i].expected,
+ 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);
}
-
- return 0;
}
static bool
@@ -176,66 +174,64 @@ sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
return result;
}
-int igt_dp_mst_sideband_msg_req_decode(void *unused)
+static void igt_dp_mst_sideband_msg_req_decode(struct kunit *test)
{
struct drm_dp_sideband_msg_req_body in = { 0 };
u8 data[] = { 0xff, 0x0, 0xdd };
int i;
-#define DO_TEST() FAIL_ON(!sideband_msg_req_encode_decode(&in))
-
in.req_type = DP_ENUM_PATH_RESOURCES;
in.u.port_num.port_number = 5;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.req_type = DP_POWER_UP_PHY;
in.u.port_num.port_number = 5;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.req_type = DP_POWER_DOWN_PHY;
in.u.port_num.port_number = 5;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.req_type = DP_ALLOCATE_PAYLOAD;
in.u.allocate_payload.number_sdp_streams = 3;
for (i = 0; i < in.u.allocate_payload.number_sdp_streams; i++)
in.u.allocate_payload.sdp_stream_sink[i] = i + 1;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.allocate_payload.port_number = 0xf;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.allocate_payload.vcpi = 0x7f;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.allocate_payload.pbn = U16_MAX;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.req_type = DP_QUERY_PAYLOAD;
in.u.query_payload.port_number = 0xf;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.query_payload.vcpi = 0x7f;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.req_type = DP_REMOTE_DPCD_READ;
in.u.dpcd_read.port_number = 0xf;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.dpcd_read.dpcd_address = 0xfedcb;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.dpcd_read.num_bytes = U8_MAX;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.req_type = DP_REMOTE_DPCD_WRITE;
in.u.dpcd_write.port_number = 0xf;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.dpcd_write.dpcd_address = 0xfedcb;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.dpcd_write.num_bytes = ARRAY_SIZE(data);
in.u.dpcd_write.bytes = data;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.req_type = DP_REMOTE_I2C_READ;
in.u.i2c_read.port_number = 0xf;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.i2c_read.read_i2c_device_id = 0x7f;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.i2c_read.num_transactions = 3;
in.u.i2c_read.num_bytes_read = ARRAY_SIZE(data) * 3;
for (i = 0; i < in.u.i2c_read.num_transactions; i++) {
@@ -244,32 +240,42 @@ int igt_dp_mst_sideband_msg_req_decode(void *unused)
in.u.i2c_read.transactions[i].i2c_dev_id = 0x7f & ~i;
in.u.i2c_read.transactions[i].i2c_transaction_delay = 0xf & ~i;
}
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.req_type = DP_REMOTE_I2C_WRITE;
in.u.i2c_write.port_number = 0xf;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.i2c_write.write_i2c_device_id = 0x7f;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.i2c_write.num_bytes = ARRAY_SIZE(data);
in.u.i2c_write.bytes = data;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.req_type = DP_QUERY_STREAM_ENC_STATUS;
in.u.enc_status.stream_id = 1;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
get_random_bytes(in.u.enc_status.client_id,
sizeof(in.u.enc_status.client_id));
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.enc_status.stream_event = 3;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.enc_status.valid_stream_event = 0;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.enc_status.stream_behavior = 3;
- DO_TEST();
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
in.u.enc_status.valid_stream_behavior = 1;
- DO_TEST();
-
-#undef DO_TEST
- return 0;
+ KUNIT_EXPECT_TRUE(test, sideband_msg_req_encode_decode(&in));
}
+
+static struct kunit_case drm_dp_mst_helper_tests[] = {
+ KUNIT_CASE(igt_dp_mst_calc_pbn_mode),
+ KUNIT_CASE(igt_dp_mst_sideband_msg_req_decode),
+ { }
+};
+
+static struct kunit_suite drm_dp_mst_helper_test_suite = {
+ .name = "drm_dp_mst_helper_tests",
+ .test_cases = drm_dp_mst_helper_tests,
+};
+
+kunit_test_suite(drm_dp_mst_helper_test_suite);
--
2.36.1
next prev parent reply other threads:[~2022-06-15 13:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 13:58 [PATCH 00/10] drm: selftest: Convert to KUnit Maíra Canal
2022-06-15 13:58 ` [PATCH 01/10] drm: selftest: convert drm_damage_helper selftest " Maíra Canal
2022-06-15 14:16 ` [PATCH 02/10] drm: selftest: refactor drm_cmdline_parser Maíra Canal
2022-06-15 13:58 ` Maíra Canal
2022-06-17 22:58 ` Shuah Khan
2022-06-15 13:58 ` [PATCH 03/10] drm: selftest: convert drm_cmdline_parser selftest to KUnit Maíra Canal
2022-06-15 13:58 ` [PATCH 04/10] drm: selftest: convert drm_rect " Maíra Canal
2022-06-15 13:58 ` [PATCH 05/10] drm: selftest: convert drm_format " Maíra Canal
2022-06-15 18:03 ` kernel test robot
2022-06-15 13:58 ` [PATCH 06/10] drm: selftest: convert drm_plane_helper " Maíra Canal
2022-06-15 13:58 ` Maíra Canal [this message]
2022-06-18 13:38 ` [PATCH 07/10] drm: selftest: convert drm_dp_mst_helper " kernel test robot
2022-06-15 13:58 ` [PATCH 08/10] drm: selftest: convert drm_framebuffer " Maíra Canal
2022-06-19 15:40 ` kernel test robot
2022-06-15 13:58 ` [PATCH 09/10] drm: selftest: convert drm_buddy " Maíra Canal
2022-06-15 14:27 ` [PATCH 10/10] drm: selftest: convert drm_mm " Maíra Canal
2022-06-16 14:55 ` [PATCH 00/10] drm: selftest: Convert " David Gow
2022-06-16 16:43 ` Javier Martinez Canillas
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=20220615135824.15522-8-maira.canal@usp.br \
--to=maira.canal@usp.br \
--cc=airlied@linux.ie \
--cc=andrealmeid@riseup.net \
--cc=brendanhiggins@google.com \
--cc=daniel@ffwll.ch \
--cc=davidgow@google.com \
--cc=dlatypov@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=isabbasso@riseup.net \
--cc=javierm@redhat.com \
--cc=jose.exposito89@gmail.com \
--cc=kunit-dev@googlegroups.com \
--cc=leandro.ribeiro@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=magalilemes00@gmail.com \
--cc=michal.winiarski@intel.com \
--cc=mripard@kernel.org \
--cc=mwen@igalia.com \
--cc=n@nfraprado.net \
--cc=rubens.gomes.neto@usp.br \
--cc=skhan@linuxfoundation.org \
--cc=tales.aparecida@gmail.com \
--cc=twoerner@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).