Hi Juuso,
On 2026-07-10T04:51:17, Juuso Rinta <[email protected]> wrote:
> test: wdt: add a test for wdt_get_timeout
>
> Add a DM test for wdt_get_timeout on the sandbox driver.
>
> Signed-off-by: Juuso Rinta <[email protected]>
>
> test/dm/wdt.c | 4 ++++
> 1 file changed, 4 insertions(+)
> diff --git a/test/dm/wdt.c b/test/dm/wdt.c
> @@ -38,6 +38,10 @@ static int dm_test_wdt_base(struct unit_test_state *uts)
> + u64 get_timeout_val = 21;
> + ut_assertok(wdt_get_timeout(dev, &get_timeout_val));
> + ut_asserteq(get_timeout_val, state->wdt.counter);
Please can you move the declaration to the top of the function with
the others? The initialiser of 21 serves no purpose once ut_assertok()
has passed, so it can be dropped.
The ut_asserteq() convention is (expected, actual), so the arguments
are swapped. Since the test has already checked that
state->wdt.counter equals 'timeout' a few lines above, it would be
clearer to check the expected value directly:
ut_asserteq(timeout, get_timeout_val);
> diff --git a/test/dm/wdt.c b/test/dm/wdt.c
> @@ -38,6 +38,10 @@ static int dm_test_wdt_base(struct unit_test_state *uts)
> + ut_assertok(wdt_get_timeout(dev, &get_timeout_val));
This only covers the success path - the -ENOSYS branch in
wdt_get_timeout() from patch 1 is untested. The gpio-wdt device in
dm_test_wdt_gpio_toggle() has no get_timeout operation, so you could
add a check there, e.g.
ut_asserteq(-ENOSYS, wdt_get_timeout(wdt, &val));
along with a check that the value is left unchanged on error, since
patch 1 documents that behaviour.
Regards,
Simon