blob: 6e758e89dbdb456b366385d581d51d52f6731067 [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
6#include <common.h>
7#include <cyclic.h>
8#include <dm.h>
9#include <test/common.h>
10#include <test/test.h>
11#include <test/ut.h>
12#include <watchdog.h>
13#include <linux/delay.h>
14
15/* Test that cyclic function is called */
16static bool cyclic_active = false;
17
18static void cyclic_test(void *ctx)
19{
20 cyclic_active = true;
21}
22
23static int dm_test_cyclic_running(struct unit_test_state *uts)
24{
25 cyclic_active = false;
26 ut_assertnonnull(cyclic_register(cyclic_test, 10 * 1000, "cyclic_demo",
27 NULL));
28
29 /* Execute all registered cyclic functions */
Stefan Roese80877fa2022-09-02 14:10:46 +020030 schedule();
Stefan Roese5be8f372022-09-02 13:57:54 +020031 ut_asserteq(true, cyclic_active);
32
33 return 0;
34}
35COMMON_TEST(dm_test_cyclic_running, 0);