blob: 461f8cf91f45ed0e530e8648f91fc946b663bca0 [file] [log] [blame]
Stefan Roese5be8f372022-09-02 13:57:54 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2022 Stefan Roese <sr@denx.de>
4 */
5
Stefan Roese5be8f372022-09-02 13:57:54 +02006#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
14/* Test that cyclic function is called */
15static bool cyclic_active = false;
16
17static void cyclic_test(void *ctx)
18{
19 cyclic_active = true;
20}
21
22static int dm_test_cyclic_running(struct unit_test_state *uts)
23{
24 cyclic_active = false;
25 ut_assertnonnull(cyclic_register(cyclic_test, 10 * 1000, "cyclic_demo",
26 NULL));
27
28 /* Execute all registered cyclic functions */
Stefan Roese80877fa2022-09-02 14:10:46 +020029 schedule();
Stefan Roese5be8f372022-09-02 13:57:54 +020030 ut_asserteq(true, cyclic_active);
31
32 return 0;
33}
34COMMON_TEST(dm_test_cyclic_running, 0);