Stefan Roese | 5be8f37 | 2022-09-02 13:57:54 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2022 Stefan Roese <sr@denx.de> |
| 4 | */ |
| 5 | |
Stefan Roese | 5be8f37 | 2022-09-02 13:57:54 +0200 | [diff] [blame] | 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 | |
| 14 | /* Test that cyclic function is called */ |
| 15 | static bool cyclic_active = false; |
| 16 | |
| 17 | static void cyclic_test(void *ctx) |
| 18 | { |
| 19 | cyclic_active = true; |
| 20 | } |
| 21 | |
| 22 | static 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 Roese | 80877fa | 2022-09-02 14:10:46 +0200 | [diff] [blame] | 29 | schedule(); |
Stefan Roese | 5be8f37 | 2022-09-02 13:57:54 +0200 | [diff] [blame] | 30 | ut_asserteq(true, cyclic_active); |
| 31 | |
| 32 | return 0; |
| 33 | } |
| 34 | COMMON_TEST(dm_test_cyclic_running, 0); |