From patchwork Mon Jul 4 13:34:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 587145 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:1ec:0:0:0:0 with SMTP id 12csp840240map; Mon, 4 Jul 2022 06:36:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tQo+6dlSQ39jlaVHv0zRjwFQVX35PbS9LVpP7EHCXxkBlY15GsiwIZuQrfzw/zTuJqFpgR X-Received: by 2002:ac2:4c2d:0:b0:47f:6b84:35a3 with SMTP id u13-20020ac24c2d000000b0047f6b8435a3mr18360388lfq.652.1656941794520; Mon, 04 Jul 2022 06:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656941794; cv=none; d=google.com; s=arc-20160816; b=QG71y3mqwaNI1MnJbbfGtJDSpI+HvA93jYnzYcF9wIZJkBxMavyXhUOMm16JMwQ5K7 qo0muv3gRkb8x2+qSsa4ua8Ty39asC/alKfdyRDKNWrCoMnS8ChYQdD2kahkgM4GpYIt Ak7pKoHKMfQT7i2dH4KP2ISgbFMjCZ4KQmqtZZCW9i9F3QUY05jh352PDPrO6z9gisKn CSqX6ptWB7qFy07Vbd0xydTXhKuMaSgrnBGFeqn7nnhfhOStfztE8m7LcZWCzK+uW+E9 po2BPhi+59pXT0tRQ0jP9Z2EPOlEahPA36CrFh9fFcbwBM5ncy4NbJkYU51RxVmFLE3w ZpnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=s4BBGGAR++tOj4fZ8Ny5ruDP+dyD5CLB9mftvKC4Hz8=; b=SjFoejaKO8CWoLrgHwZda9sq6E3c36f7tNMNWDm00nXuIpRytgDzmQ4TiM/5OPSIjT Nj7ZkqzCVnSqPTNexUOOPbcXwftHxo7L553LYnqmrF6dboufnLnJr8QW05MFGcAyY3i0 TbzlJwrkK/gkGVu0dvX4bonk64c8cMN0MYU1kSKduc6NMNYMgdnIRvsV9wNV7dwOHiH+ oEQbEeaJqIAhw6D8t5IhPToZsS+jALOmM6t88NqviegUYhUM/UFQ+56U3v78M9jyX1eS xRJ4bQHVdZ+vqyqNCq9YdHDRpT0D8RYrNGxd7zZzIqP232xSErwNiCPtB3ha02IYc0Ty PHsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id a15-20020a2e860f000000b0025bec7c2780si17917267lji.586.2022.07.04.06.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Jul 2022 06:36:34 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CE293844E1; Mon, 4 Jul 2022 15:35:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id F0802844DB; Mon, 4 Jul 2022 15:35:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id E78F1844EC for ; Mon, 4 Jul 2022 15:35:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B3A6523A; Mon, 4 Jul 2022 06:35:28 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 85E903F66F; Mon, 4 Jul 2022 06:35:26 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Tom Rini , Sughosh Ganu Subject: [PATCH v6 7/7] test: rng: Add a UT testcase for the rng command Date: Mon, 4 Jul 2022 19:04:44 +0530 Message-Id: <20220704133444.1110715-8-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220704133444.1110715-1-sughosh.ganu@linaro.org> References: <20220704133444.1110715-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 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 The 'rng' command dumps a number of random bytes on the console. Add a set of tests for the 'rng' command. The test function performs basic sanity testing of the command. Since a unit test is being added for the command, enable it by default in the sandbox platforms. Reviewed-by: Simon Glass Signed-off-by: Sughosh Ganu Acked-by: Ilias Apalodimas --- cmd/Kconfig | 1 + test/dm/rng.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index 09193b61b9..eee5d44348 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1916,6 +1916,7 @@ config CMD_GETTIME config CMD_RNG bool "rng command" depends on DM_RNG + default y if SANDBOX select HEXDUMP help Print bytes from the hardware random number generator. diff --git a/test/dm/rng.c b/test/dm/rng.c index 5b34c93ed6..6d1f68848d 100644 --- a/test/dm/rng.c +++ b/test/dm/rng.c @@ -25,3 +25,32 @@ static int dm_test_rng_read(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_rng_read, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +/* Test the rng command */ +static int dm_test_rng_cmd(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_get_device(UCLASS_RNG, 0, &dev)); + ut_assertnonnull(dev); + + ut_assertok(console_record_reset_enable()); + + run_command("rng", 0); + ut_assert_nextlinen("00000000:"); + ut_assert_nextlinen("00000010:"); + ut_assert_nextlinen("00000020:"); + ut_assert_nextlinen("00000030:"); + ut_assert_console_end(); + + run_command("rng 0 10", 0); + ut_assert_nextlinen("00000000:"); + ut_assert_console_end(); + + run_command("rng 20", 0); + ut_assert_nextlinen("No RNG device"); + ut_assert_console_end(); + + return 0; +} +DM_TEST(dm_test_rng_cmd, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_CONSOLE_REC);