[PATCH 3/8] cyclic: Test return code from cyclic_register() in test

Marek Vasut marek.vasut+renesas at mailbox.org
Sat Jan 18 05:00:57 CET 2025


Update the cyclic test code to verify return code from cyclic_register() works.

Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: Aaron Williams <awilliams at marvell.com>
Cc: Anatolij Gustschin <agust at denx.de>
Cc: Angelo Dureghello <angelo at kernel-space.org>
Cc: Christian Marangi <ansuelsmth at gmail.com>
Cc: Devarsh Thakkar <devarsht at ti.com>
Cc: Heinrich Schuchardt <xypron.glpk at gmx.de>
Cc: Jaehoon Chung <jh80.chung at samsung.com>
Cc: Michael Polyntsov <michael.polyntsov at iopsys.eu>
Cc: Michael Trimarchi <michael at amarulasolutions.com>
Cc: Nikhil M Jain <n-jain1 at ti.com>
Cc: Peng Fan <peng.fan at nxp.com>
Cc: Peter Robinson <pbrobinson at gmail.com>
Cc: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
Cc: Ronald Wahl <ronald.wahl at legrand.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Stefan Roese <sr at denx.de>
Cc: Tim Harvey <tharvey at gateworks.com>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at lists.denx.de
---
 test/common/cyclic.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/test/common/cyclic.c b/test/common/cyclic.c
index 51a07c576b6..714dec60b7f 100644
--- a/test/common/cyclic.c
+++ b/test/common/cyclic.c
@@ -25,8 +25,11 @@ static void test_cb(struct cyclic_info *c)
 
 static int dm_test_cyclic_running(struct unit_test_state *uts)
 {
+	int ret;
+
 	cyclic_test.called = false;
-	cyclic_register(&cyclic_test.cyclic, test_cb, 10 * 1000, "cyclic_test");
+	ret = cyclic_register(&cyclic_test.cyclic, test_cb, 10 * 1000, "cyclic_test");
+	ut_asserteq(ret, 0);
 
 	/* Execute all registered cyclic functions */
 	schedule();
@@ -37,3 +40,19 @@ static int dm_test_cyclic_running(struct unit_test_state *uts)
 	return 0;
 }
 COMMON_TEST(dm_test_cyclic_running, 0);
+
+static int dm_test_cyclic_reregister(struct unit_test_state *uts)
+{
+	int ret;
+
+	cyclic_test.called = false;
+	ret = cyclic_register(&cyclic_test.cyclic, test_cb, 10 * 1000, "cyclic_test1");
+	ut_asserteq(ret, 0);
+	ret = cyclic_register(&cyclic_test.cyclic, test_cb, 10 * 1000, "cyclic_test2");
+	ut_asserteq(ret, -EALREADY);
+
+	cyclic_unregister(&cyclic_test.cyclic);
+
+	return 0;
+}
+COMMON_TEST(dm_test_cyclic_reregister, 0);
-- 
2.45.2



More information about the U-Boot mailing list