blob: 1d31ec55c64d5b701383ba18fa7b0ac077b6a029 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
maxims@google.comdaea6d42017-04-17 12:00:21 -07002/*
3 * Copyright 2017 Google, Inc
maxims@google.comdaea6d42017-04-17 12:00:21 -07004 */
5
6#include <common.h>
7#include <dm.h>
8#include <wdt.h>
9#include <asm/state.h>
10#include <asm/test.h>
11#include <dm/test.h>
12#include <test/ut.h>
13
14/* Test that watchdog driver functions are called */
15static int dm_test_wdt_base(struct unit_test_state *uts)
16{
17 struct sandbox_state *state = state_get_current();
18 struct udevice *dev;
19 const u64 timeout = 42;
20
21 ut_assertok(uclass_get_device(UCLASS_WDT, 0, &dev));
Simon Glass2e8faa22017-06-07 10:28:43 -060022 ut_assertnonnull(dev);
maxims@google.comdaea6d42017-04-17 12:00:21 -070023 ut_asserteq(0, state->wdt.counter);
24 ut_asserteq(false, state->wdt.running);
25
26 ut_assertok(wdt_start(dev, timeout, 0));
27 ut_asserteq(timeout, state->wdt.counter);
28 ut_asserteq(true, state->wdt.running);
29
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);
34
35 ut_assertok(wdt_stop(dev));
36 ut_asserteq(false, state->wdt.running);
37
38 return 0;
39}
40DM_TEST(dm_test_wdt_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);