1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2017 Google, Inc
14 /* Test that watchdog driver functions are called */
15 static int dm_test_wdt_base(struct unit_test_state *uts)
17 struct sandbox_state *state = state_get_current();
19 const u64 timeout = 42;
21 ut_assertok(uclass_get_device(UCLASS_WDT, 0, &dev));
22 ut_assertnonnull(dev);
23 ut_asserteq(0, state->wdt.counter);
24 ut_asserteq(false, state->wdt.running);
26 ut_assertok(wdt_start(dev, timeout, 0));
27 ut_asserteq(timeout, state->wdt.counter);
28 ut_asserteq(true, state->wdt.running);
30 uint reset_count = state->wdt.reset_count;
31 ut_assertok(wdt_reset(dev));
32 ut_asserteq(reset_count + 1, state->wdt.reset_count);
33 ut_asserteq(true, state->wdt.running);
35 ut_assertok(wdt_stop(dev));
36 ut_asserteq(false, state->wdt.running);
40 DM_TEST(dm_test_wdt_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);