Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 549A7C32772 for ; Wed, 17 Aug 2022 07:54:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7B159849DB; Wed, 17 Aug 2022 09:53:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1660722799; bh=rjXs2DMFZEtRoV6DKsbsH17NOyenG6bSqqpmQhJBzV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=v5BqRayV+bBsZOGM4JQEFByYYITzZErikpW2Za4XX6/dNseanlPpRJgBJPjyhMNaK di/6NP0tAPhM/E25f0tiexPiAx4QyOrvFE1lh8Cy6sS7y+DQzhp2vCeZPXYgQlIlbn DWAio6aDoHI9rbgQ6wBc95Zrn0q5YiND0r0YZwuoLRRSMNsIXRAX+S85HE9NPGHDxQ xb+N69WTqedmLozOsoRIfoKjHe/YylJH05zKF0bc9ISjiDZnosy0XHfJKzwsoUlHqz CvbAsXFNE+0ar+KRkRzsEOLsMUBeKsf8X+79GFisAZmo+RH4eWeTdzZCrxSZs2fbw+ R9FezUm65hc8g== Received: by phobos.denx.de (Postfix, from userid 109) id 5D808849C2; Wed, 17 Aug 2022 09:53:06 +0200 (CEST) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [80.241.59.207]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D817A849B0 for ; Wed, 17 Aug 2022 09:53:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4M70cH5Gh1z9sjp; Wed, 17 Aug 2022 09:52:47 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, cchavva@marvell.com, awilliams@marvell.com Subject: [PATCH v5 8/8] cyclic: Add a simple test Date: Wed, 17 Aug 2022 09:52:43 +0200 Message-Id: <20220817075243.3242445-9-sr@denx.de> In-Reply-To: <20220817075243.3242445-1-sr@denx.de> References: <20220817075243.3242445-1-sr@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add a test for cyclic function registration and activation. Signed-off-by: Stefan Roese Reviewed-by: Simon Glass --- v5: - Set 'cyclic_active' to false before registering the test - Use WATCHDOG_RESET() instead of mdelay() - Use COMMON_TEST() - Added Simon's RB tag v4: - New patch test/common/Makefile | 1 + test/common/cyclic.c | 34 ++++++++++++++++++++++++++++++++++ test/test-main.c | 3 +++ 3 files changed, 38 insertions(+) create mode 100644 test/common/cyclic.c diff --git a/test/common/Makefile b/test/common/Makefile index 9087788ba6a8..cc918f64e544 100644 --- a/test/common/Makefile +++ b/test/common/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0+ obj-y += cmd_ut_common.o obj-$(CONFIG_AUTOBOOT) += test_autoboot.o +obj-$(CONFIG_CYCLIC) += cyclic.o obj-$(CONFIG_EVENT) += event.o diff --git a/test/common/cyclic.c b/test/common/cyclic.c new file mode 100644 index 000000000000..ded54892d76e --- /dev/null +++ b/test/common/cyclic.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2022 Stefan Roese + */ + +#include +#include +#include +#include +#include +#include +#include + +/* Test that cyclic function is called */ +static bool cyclic_active = false; + +static void cyclic_test(void *ctx) +{ + cyclic_active = true; +} + +static int dm_test_cyclic_running(struct unit_test_state *uts) +{ + cyclic_active = false; + ut_assertnonnull(cyclic_register(cyclic_test, 10 * 1000, "cyclic_demo", + NULL)); + + /* Execute all registered cyclic functions */ + WATCHDOG_RESET(); + ut_asserteq(true, cyclic_active); + + return 0; +} +COMMON_TEST(dm_test_cyclic_running, 0); diff --git a/test/test-main.c b/test/test-main.c index 31837e57a8fb..8a609a8a2fce 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -220,6 +221,7 @@ static int dm_test_restore(struct device_node *of_root) static int test_pre_run(struct unit_test_state *uts, struct unit_test *test) { ut_assertok(event_init()); + ut_assertok(cyclic_init()); if (test->flags & UT_TESTF_DM) ut_assertok(dm_test_pre_run(uts)); @@ -265,6 +267,7 @@ static int test_post_run(struct unit_test_state *uts, struct unit_test *test) ut_unsilence_console(uts); if (test->flags & UT_TESTF_DM) ut_assertok(dm_test_post_run(uts)); + ut_assertok(cyclic_uninit()); ut_assertok(event_uninit()); return 0; -- 2.37.2