Re: [PATCH] drm/sched/tests: Make timedout_job callback a better role model

From: Maíra Canal
Date: Mon Jun 16 2025 - 08:50:51 EST


Hi Danilo,

On 16/06/25 08:14, Danilo Krummrich wrote:
On Mon, Jun 16, 2025 at 11:57:47AM +0100, Tvrtko Ursulin wrote:
Code looks fine, but currently nothing is broken and I disagree with the
goal that the _mock_^1 components should be role models. The idea is to
implement as little in the mock components as it is required to exercise the
tested functionality.

No, please consider the following.

1) When we write tests for common infrastructure we should be testing things
as close as possible to how we intend real code to use this infrastructure.
Relying on internals in creative ways is likely to underrun this testing.

Regarding unit testing (and KUnit is a unit testing framework), the core
principle is that individual components of the code should be tested in
isolation to validate that they perform as expected.

The "units" should be tested independently and we use those mocks to
simulate dependencies, ensuring that the test focuses solely on the unit
under scrutiny.

If we introduce more things into the mock, we end up losing the
isolation. The mock scheduler, from what I understand, is not suppose to
be a reference design or even something close to a driver. It should
remain just a mock, a minimal interface to test the scheduler's
internals.

Best Regards,
- Maíra


2) Being close to a reference design is a good thing, why wouldn't we want
that? The reality is that people *will* look at this code for reference.

Also, there are various ways drivers use the scheduler API. Trying to make
the mock scheduler a reference driver implementation would only be able to
make it a reference for one possible use.

Why? Nothing prevents us from covering all of them eventually.

If for now, we just implement one of them, that's better than none, so why not?