[PATCH 2/2] drm/tests: Split drm_test_dp_mst_sideband_msg_req_decode into parameterized tests
Michał Winiarski
michal.winiarski at intel.com
Mon Sep 26 02:35:20 UTC 2022
On Sun, Sep 25, 2022 at 07:27:19PM -0300, Maíra Canal wrote:
> The drm_test_dp_mst_sideband_msg_req_decode repeats the same test
> structure with different parameters. This could be better represented
> by parameterized tests, provided by KUnit.
>
> So, convert drm_test_dp_mst_sideband_msg_req_decode into parameterized
> tests and make the test's allocations and prints completly managed by KUnit.
There's a small functional change not mentioned in the commit message.
>
> Signed-off-by: Maíra Canal <mcanal at igalia.com>
> ---
> .../gpu/drm/tests/drm_dp_mst_helper_test.c | 370 ++++++++++++------
> 1 file changed, 243 insertions(+), 127 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 12f41881db6b..545beea33e8c 100644
> --- a/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
> +++ b/drivers/gpu/drm/tests/drm_dp_mst_helper_test.c
> @@ -5,12 +5,8 @@
> * Copyright (c) 2022 Maíra Canal <mairacanal at riseup.net>
> */
>
> -#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>
>
> @@ -72,6 +68,217 @@ static void dp_mst_calc_pbn_mode_desc(const struct drm_dp_mst_calc_pbn_mode_test
> KUNIT_ARRAY_PARAM(drm_dp_mst_calc_pbn_mode, drm_dp_mst_calc_pbn_mode_cases,
> dp_mst_calc_pbn_mode_desc);
>
> +static u8 data[] = { 0xff, 0x00, 0xdd };
> +
> +struct drm_dp_mst_sideband_msg_req_test {
> + const char *desc;
> + const struct drm_dp_sideband_msg_req_body in;
> +};
> +
> +static const struct drm_dp_mst_sideband_msg_req_test drm_dp_mst_sideband_msg_req_cases[] = {
> + {
> + .desc = "DP_ENUM_PATH_RESOURCES with port number",
> + .in = {
> + .req_type = DP_ENUM_PATH_RESOURCES,
> + .u.port_num.port_number = 5,
> + },
> + },
> + {
> + .desc = "DP_POWER_UP_PHY with port number",
> + .in = {
> + .req_type = DP_POWER_UP_PHY,
> + .u.port_num.port_number = 5,
> + },
> + },
> + {
> + .desc = "DP_POWER_DOWN_PHY with port number",
> + .in = {
> + .req_type = DP_POWER_DOWN_PHY,
> + .u.port_num.port_number = 5,
> + },
> + },
> + {
> + .desc = "DP_ALLOCATE_PAYLOAD with SDP stream sinks",
> + .in = {
> + .req_type = DP_ALLOCATE_PAYLOAD,
> + .u.allocate_payload.number_sdp_streams = 3,
> + .u.allocate_payload.sdp_stream_sink = { 1, 2, 3 },
> + },
> + },
> + {
> + .desc = "DP_ALLOCATE_PAYLOAD with port number",
> + .in = {
> + .req_type = DP_ALLOCATE_PAYLOAD,
> + .u.allocate_payload.port_number = 0xf,
> + },
> + },
> + {
> + .desc = "DP_ALLOCATE_PAYLOAD with VCPI",
> + .in = {
> + .req_type = DP_ALLOCATE_PAYLOAD,
> + .u.allocate_payload.vcpi = 0x7f,
> + },
> + },
> + {
> + .desc = "DP_ALLOCATE_PAYLOAD with PBN",
> + .in = {
> + .req_type = DP_ALLOCATE_PAYLOAD,
> + .u.allocate_payload.pbn = U16_MAX,
> + },
> + },
> + {
> + .desc = "DP_QUERY_PAYLOAD with port number",
> + .in = {
> + .req_type = DP_QUERY_PAYLOAD,
> + .u.query_payload.port_number = 0xf,
> + },
> + },
> + {
> + .desc = "DP_QUERY_PAYLOAD with VCPI",
> + .in = {
> + .req_type = DP_QUERY_PAYLOAD,
> + .u.query_payload.vcpi = 0x7f,
> + },
> + },
> + {
> + .desc = "DP_REMOTE_DPCD_READ with port number",
> + .in = {
> + .req_type = DP_REMOTE_DPCD_READ,
> + .u.dpcd_read.port_number = 0xf,
> + },
> + },
> + {
> + .desc = "DP_REMOTE_DPCD_READ with DPCD address",
> + .in = {
> + .req_type = DP_REMOTE_DPCD_READ,
> + .u.dpcd_read.dpcd_address = 0xfedcb,
> + },
> + },
> + {
> + .desc = "DP_REMOTE_DPCD_READ with max number of bytes",
> + .in = {
> + .req_type = DP_REMOTE_DPCD_READ,
> + .u.dpcd_read.num_bytes = U8_MAX,
> + },
> + },
> + {
> + .desc = "DP_REMOTE_DPCD_WRITE with port number",
> + .in = {
> + .req_type = DP_REMOTE_DPCD_WRITE,
> + .u.dpcd_write.port_number = 0xf,
> + },
> + },
> + {
> + .desc = "DP_REMOTE_DPCD_WRITE with DPCD address",
> + .in = {
> + .req_type = DP_REMOTE_DPCD_WRITE,
> + .u.dpcd_write.dpcd_address = 0xfedcb,
> + },
> + },
> + {
> + .desc = "DP_REMOTE_DPCD_WRITE with data array",
> + .in = {
> + .req_type = DP_REMOTE_DPCD_WRITE,
> + .u.dpcd_write.num_bytes = ARRAY_SIZE(data),
> + .u.dpcd_write.bytes = data,
> + },
> + },
> + {
> + .desc = "DP_REMOTE_I2C_READ with port number",
> + .in = {
> + .req_type = DP_REMOTE_I2C_READ,
> + .u.i2c_read.port_number = 0xf,
> + },
> + },
> + {
> + .desc = "DP_REMOTE_I2C_READ with I2C device ID",
> + .in = {
> + .req_type = DP_REMOTE_I2C_READ,
> + .u.i2c_read.read_i2c_device_id = 0x7f,
> + },
> + },
> + {
> + .desc = "DP_REMOTE_I2C_READ with transactions array",
> + .in = {
> + .req_type = DP_REMOTE_I2C_READ,
> + .u.i2c_read.num_transactions = 3,
> + .u.i2c_read.num_bytes_read = ARRAY_SIZE(data) * 3,
> + .u.i2c_read.transactions = {
> + { .bytes = data, .num_bytes = ARRAY_SIZE(data), .i2c_dev_id = 0x7f,
> + .i2c_transaction_delay = 0xf, },
> + { .bytes = data, .num_bytes = ARRAY_SIZE(data), .i2c_dev_id = 0x7e,
> + .i2c_transaction_delay = 0xe, },
> + { .bytes = data, .num_bytes = ARRAY_SIZE(data), .i2c_dev_id = 0x7d,
> + .i2c_transaction_delay = 0xd, },
> + },
> + },
> + },
> + {
> + .desc = "DP_REMOTE_I2C_WRITE with port number",
> + .in = {
> + .req_type = DP_REMOTE_I2C_WRITE,
> + .u.i2c_write.port_number = 0xf,
> + },
> + },
> + {
> + .desc = "DP_REMOTE_I2C_WRITE with I2C device ID",
> + .in = {
> + .req_type = DP_REMOTE_I2C_WRITE,
> + .u.i2c_write.write_i2c_device_id = 0x7f,
> + },
> + },
> + {
> + .desc = "DP_REMOTE_I2C_WRITE with data array",
> + .in = {
> + .req_type = DP_REMOTE_I2C_WRITE,
> + .u.i2c_write.num_bytes = ARRAY_SIZE(data),
> + .u.i2c_write.bytes = data,
> + },
> + },
> + {
> + .desc = "DP_QUERY_STREAM_ENC_STATUS with stream ID",
> + .in = {
> + .req_type = DP_QUERY_STREAM_ENC_STATUS,
> + .u.enc_status.stream_id = 1,
> + },
> + },
> + {
> + .desc = "DP_QUERY_STREAM_ENC_STATUS with client ID",
> + .in = {
> + .req_type = DP_QUERY_STREAM_ENC_STATUS,
> + .u.enc_status.client_id = { 0x4f, 0x7f, 0xb4, 0x00, 0x8c, 0x0d, 0x67 },
Before the conversion - client_id used to be random (different for every run of
the test).
Even if it doesn't matter from test perspective, please mention that in the
commit message.
-Michał
More information about the dri-devel
mailing list