From patchwork Wed Mar 9 12:28:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 549710 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp3515468mag; Wed, 9 Mar 2022 04:30:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJzI90q0MqOzKbBx1qXemKAOtWgsV1dgpkYXz3daC9EuIlspDuH1LHXEwauB3Q1M4wrigTl3 X-Received: by 2002:a17:906:4711:b0:6d0:67bb:59e1 with SMTP id y17-20020a170906471100b006d067bb59e1mr16484202ejq.211.1646829044078; Wed, 09 Mar 2022 04:30:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646829044; cv=none; d=google.com; s=arc-20160816; b=ItEmNAI2DPajJkWvTEks1lYxwf1HgdABfVIidl5i1XCEXzZgDNmckqKkkiHOxhN2Yb Sg5s8rrC9Sl04YIGthsVXdJCm3Huwf4JHBrYa4VnO0gmh3qEYB6hFqcpWAZ6PawqK+R/ sgQUtCgbZs6goJPzAlAzzsLTiu1Deqjd57gmNh+2yMNkx89eAFJXzA5Q/F28m8mr1yHs KbzQ7DpIpfHJiIa0SSfaAuahZsmKwNB66x+XKydzUk+W3MXJS83inpclM5TMbRbbYk5M Ttr9kLiuxGY5k+8kdKsg2QgzBEXaJOkNc6MwFpcVet9708MulhI1vAfxTgxGveUP8Ji5 GkuQ== 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=DGuAx4ZJcQ4+L3NirU9PPA35FaK19TcSpExVBj/jmNI=; b=TQNzfbAl2VTQQBOBtg/wPaD6THwDgCB1HM5lOiPPDkuj/M569+/BDXSnupnzT+BmVU eeYq6zUBI28AEaLjwgK0QsEM3TRj6N2+Bb/wcUjjZqFqYBgsWWCu7v9h7DeOrYxmbQpl WUVPosQxBMachSQb6vozz4ld4uV7mTUOZ6YyJA+clW7jX7ASuVGJcBKSGWVi0hDtJn3l rdrdvUnxqqcoa1MFertlVZIU8O15afRQFx/rcZvsr41AqrzOnz+7vxw/RC2RGLhEMXqZ tDMddd5DdpEATPBGiBV+DsK87yHB9s6SQi9kASl3B0xaeTfCdqZK2IZJL17PJy8XuU1O eXMg== 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 sh34-20020a1709076ea200b006dabf0b7ca8si961855ejc.306.2022.03.09.04.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 04:30:44 -0800 (PST) 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 D1FC6839B3; Wed, 9 Mar 2022 13:30:38 +0100 (CET) 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 1FB4C83937; Wed, 9 Mar 2022 13:29:23 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE,T_SPF_TEMPERROR autolearn=ham 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 AAAB883995 for ; Wed, 9 Mar 2022 13:28:51 +0100 (CET) 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 2313A1688; Wed, 9 Mar 2022 04:28:51 -0800 (PST) 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 56F203FA4D; Wed, 9 Mar 2022 04:28:49 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Heinrich Schuchardt , Sughosh Ganu Subject: [PATCH v4 8/8] test: rng: Add a UT testcase for the rng command Date: Wed, 9 Mar 2022 17:58:00 +0530 Message-Id: <20220309122800.3940001-9-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220309122800.3940001-1-sughosh.ganu@linaro.org> References: <20220309122800.3940001-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.5 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. Signed-off-by: Sughosh Ganu Reviewed-by: Simon Glass --- Changes since V3: None cmd/Kconfig | 1 + test/dm/rng.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index 5e25e45fd2..47f1e23ef0 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1810,6 +1810,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);