Stefan Roese | af042c2 | 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 | |
| 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 */ |
| 16 | static bool cyclic_active = false; |
| 17 | |
| 18 | static void cyclic_test(void *ctx) |
| 19 | { |
| 20 | cyclic_active = true; |
| 21 | } |
| 22 | |
| 23 | static 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 Roese | 29caf93 | 2022-09-02 14:10:46 +0200 | [diff] [blame^] | 30 | schedule(); |
Stefan Roese | af042c2 | 2022-09-02 13:57:54 +0200 | [diff] [blame] | 31 | ut_asserteq(true, cyclic_active); |
| 32 | |
| 33 | return 0; |
| 34 | } |
| 35 | COMMON_TEST(dm_test_cyclic_running, 0); |