wdt.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2017 Google, Inc
  4. */
  5. #include <common.h>
  6. #include <dm.h>
  7. #include <wdt.h>
  8. #include <asm/state.h>
  9. #include <asm/test.h>
  10. #include <dm/test.h>
  11. #include <test/ut.h>
  12. /* Test that watchdog driver functions are called */
  13. static int dm_test_wdt_base(struct unit_test_state *uts)
  14. {
  15. struct sandbox_state *state = state_get_current();
  16. struct udevice *dev;
  17. const u64 timeout = 42;
  18. ut_assertok(uclass_get_device(UCLASS_WDT, 0, &dev));
  19. ut_assertnonnull(dev);
  20. ut_asserteq(0, state->wdt.counter);
  21. ut_asserteq(false, state->wdt.running);
  22. ut_assertok(wdt_start(dev, timeout, 0));
  23. ut_asserteq(timeout, state->wdt.counter);
  24. ut_asserteq(true, state->wdt.running);
  25. uint reset_count = state->wdt.reset_count;
  26. ut_assertok(wdt_reset(dev));
  27. ut_asserteq(reset_count + 1, state->wdt.reset_count);
  28. ut_asserteq(true, state->wdt.running);
  29. ut_assertok(wdt_stop(dev));
  30. ut_asserteq(false, state->wdt.running);
  31. return 0;
  32. }
  33. DM_TEST(dm_test_wdt_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);