cyclic.c 733 B

1234567891011121314151617181920212223242526272829303132333435
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2022 Stefan Roese <sr@denx.de>
  4. */
  5. #include <common.h>
  6. #include <cyclic.h>
  7. #include <dm.h>
  8. #include <test/common.h>
  9. #include <test/test.h>
  10. #include <test/ut.h>
  11. #include <watchdog.h>
  12. #include <linux/delay.h>
  13. /* Test that cyclic function is called */
  14. static bool cyclic_active = false;
  15. static void cyclic_test(void *ctx)
  16. {
  17. cyclic_active = true;
  18. }
  19. static int dm_test_cyclic_running(struct unit_test_state *uts)
  20. {
  21. cyclic_active = false;
  22. ut_assertnonnull(cyclic_register(cyclic_test, 10 * 1000, "cyclic_demo",
  23. NULL));
  24. /* Execute all registered cyclic functions */
  25. schedule();
  26. ut_asserteq(true, cyclic_active);
  27. return 0;
  28. }
  29. COMMON_TEST(dm_test_cyclic_running, 0);