From mboxrd@z Thu Jan 1 00:00:00 1970 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 7859CC38145 for ; Fri, 2 Sep 2022 11:59:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 20F4F84ABE; Fri, 2 Sep 2022 13:58:24 +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=1662119904; bh=3rdetDDsztE5pS1vFssk6u5GMF5iV5cxJiDyFJeLMjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=f+dv0gQmir5FmViXiQvfIiHnu+Ea5m/Kb94TKNQZql25YpMKyuyJXekzn0+Qwjh9/ 0ZE1fu3y0asYeSpEs+ZXIrpA3yMw+X6+EBo79yQr20g2UbdsC1jr/MzozIEqek5abp 2HHEW/CIYktBRTgZ54HkHogYwB5HL0Mq5Mfm8FH/cAB5kY/1NJbgVCkkBqCLDlEd/6 5wAGL+tFod8+6BMZ6thLNt8DDUKdNMeH8Ti+TJ6m5CF5qi+qgHwMX7Ax95GcHc/gGj +/d0RLg8Cucttccqqh1KoRi6HZMaNvLBkRYCHxauxJChjH9QgOMLuZz+rSFbc0r4IP sgdGFU/R8peZw== Received: by phobos.denx.de (Postfix, from userid 109) id 7CD9083E13; Fri, 2 Sep 2022 13:58:07 +0200 (CEST) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [IPv6:2001:67c:2050:101:465::204]) (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 9837784A91 for ; Fri, 2 Sep 2022 13:58:00 +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 [10.196.197.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-204.mailbox.org (Postfix) with ESMTPS id 4MJxHp4Q9tz9sSp; Fri, 2 Sep 2022 13:57:58 +0200 (CEST) From: Stefan Roese To: u-boot@lists.denx.de Cc: trini@konsulko.com, sjg@chromium.org, awilliams@marvell.com, cchavva@marvell.com Subject: [PATCH v6 8/8] cyclic: Add a simple test Date: Fri, 2 Sep 2022 13:57:54 +0200 Message-Id: <20220902115754.1280789-9-sr@denx.de> In-Reply-To: <20220902115754.1280789-1-sr@denx.de> References: <20220902115754.1280789-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 --- v6: - No change 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 | 35 +++++++++++++++++++++++++++++++++++ test/test-main.c | 3 +++ 3 files changed, 39 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..a5c4e78989b9 --- /dev/null +++ b/test/common/cyclic.c @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2022 Stefan Roese + */ + +#include +#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.3