From patchwork Wed Jul 20 12:29:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 591867 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5817:0:0:0:0 with SMTP id j23csp4893959max; Wed, 20 Jul 2022 05:31:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vfdNeq6FJACCrRammFUErMkhz0xN3eMxlI/uVhncBqNZypfa6rzs7RGKb88LMDRXi7Uz+9 X-Received: by 2002:a05:6638:339b:b0:33f:5a4c:4d8e with SMTP id h27-20020a056638339b00b0033f5a4c4d8emr19252723jav.93.1658320298058; Wed, 20 Jul 2022 05:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658320298; cv=none; d=google.com; s=arc-20160816; b=KHHw4UIzDi9QmzJ/LewK+s6AC8EXp/Su7JJoO9yWlAnvdmibIoJ7eiCi95Mpdz/gEQ SrWASyyB9U83xM8kwNobQ9Fu0cc7bGdxRqagniZCbJ08JYSxMwdAe1sdyCyEipgtY/YO 5Yochn7LDURwWTgkhclJlLcNNZ0b/xeVZOPJcgh2ekYIsQfK78O5eSVcOweQRQTB0Zu0 Y8Jh4gOYinaXos1fUmiAL9O7bOmemskPxMLSI5fyboXaD4KTgsiVnbQ88jQ1XxfhYt6I iXk0zVlkL/uZke55WuFia6L6ViNwlD6dk8+eRkEIsXoRF66qUvYPMccsin3A/OTxNZ8E oFqw== 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=lRLTn+taxP3AkyBpe1JM5LEZL1H8yvQNvOGKsOrTLEE=; b=Ps+B/tjPwi2AYcVgoG2sqD7xr83Hn9K4HrHR3bbfXjVGEgfsQHe+ophEYeIrw4rxqm 7Y9ebfsaBV7g4cu8HAVxzpKp8nIkrfIVGphnOeMs5eQZrqvSR/A1Vsj4A6gKHv7gj97u qCj+uRqu6xhh90LDfX47CKqZrUu9CxbekmFmr6guSlUD4kd1IQbWrt9pKm+z0T+Fw0My mWPm2dL0d2cwBo2ijHtuT50KVsQXehR9J81VZsCpZHEZ4suuQvOBKAenXEJFmiq4lDP0 unPOGIznr8xn0lbSJaHaOJXKe6uH8IterFNijLrfbEb4145EEcJdB2ww3TIPbCgge1RK UJWA== 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 l9-20020a056638220900b0033ebec78473si17698062jas.58.2022.07.20.05.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jul 2022 05:31:38 -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 0E31284103; Wed, 20 Jul 2022 14:30:39 +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 DB12F840B3; Wed, 20 Jul 2022 14:30:24 +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 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 4BDAC840A8 for ; Wed, 20 Jul 2022 14:30:20 +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 0B3391576; Wed, 20 Jul 2022 05:30:20 -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 8C6083F73D; Wed, 20 Jul 2022 05:30:17 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Tom Rini , Sughosh Ganu Subject: [PATCH v7 7/7] test: rng: Add a UT testcase for the rng command Date: Wed, 20 Jul 2022 17:59:26 +0530 Message-Id: <20220720122926.415659-8-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220720122926.415659-1-sughosh.ganu@linaro.org> References: <20220720122926.415659-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. Signed-off-by: Sughosh Ganu Reviewed-by: Simon Glass Acked-by: Ilias Apalodimas --- Changes since V6: None cmd/Kconfig | 1 + test/dm/rng.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index d5f842136c..76878ce307 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1961,6 +1961,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);