drm/i915/kunit: Setup DP link test context

Initialize a reusable test context for DP link KUnit tests. Sets up
minimal device, connector, encoder, and DP structures, and seeds the
pseudo-random generator for deterministic test runs.

Reviewed-by: Michał Grzelak <michal.grzelak@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patch.msgid.link/20260701153204.4124150-31-imre.deak@intel.com
This commit is contained in:
Imre Deak
2026-07-01 18:31:59 +03:00
parent d5a48b4817
commit df152476d0

View File

@@ -5,7 +5,32 @@
#include <kunit/test.h>
#include <linux/compiler.h>
#include <linux/device.h>
#include <linux/prandom.h>
#include <linux/random.h>
#include <drm/display/drm_dp_helper.h>
#include <drm/intel/display_member.h>
#include "intel_connector.h"
#include "intel_display_core.h"
#include "intel_display_types.h"
struct test_ctx {
struct {
struct intel_display display;
struct device device;
struct __intel_generic_device generic_device;
struct intel_connector connector;
struct intel_digital_port dig_port;
struct intel_crtc_state crtc_state;
} dev;
struct rnd_state rnd;
};
static struct kunit_case intel_dp_link_test_cases[] = {
@@ -16,6 +41,29 @@ static struct test_ctx test_ctx;
static int intel_dp_link_test_init(struct kunit *test)
{
struct intel_digital_port *dig_port;
struct intel_encoder *encoder;
struct intel_dp *intel_dp;
/* Reset the dev state for each test. */
memset(&test_ctx.dev, 0, sizeof(test_ctx.dev));
test_ctx.dev.generic_device.drm.dev = &test_ctx.dev.device;
test_ctx.dev.display.drm = &test_ctx.dev.generic_device.drm;
test_ctx.dev.generic_device.display = &test_ctx.dev.display;
encoder = &test_ctx.dev.dig_port.base;
encoder->base.dev = &test_ctx.dev.generic_device.drm;
dig_port = &test_ctx.dev.dig_port;
dig_port->base.type = INTEL_OUTPUT_DP;
test_ctx.dev.connector.encoder = encoder;
intel_dp = &dig_port->dp;
intel_dp->attached_connector = &test_ctx.dev.connector;
test->priv = &test_ctx;
return 0;
@@ -27,6 +75,8 @@ static void intel_dp_link_test_exit(struct kunit *test)
static int intel_dp_link_test_suite_init(struct kunit_suite *test_suite)
{
prandom_seed_state(&test_ctx.rnd, 0);
return 0;
}