From patchwork Fri Mar 4 13:34:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 548118 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6713:0:0:0:0 with SMTP id u19csp22519mag; Fri, 4 Mar 2022 05:36:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZYv7DAWgjbEnNTRnlJ7+VwTRHI0prmI0qkcDo5kMtmVOaqeq7iGC+iIjREW3nqo9bXy+8 X-Received: by 2002:a05:6402:90b:b0:412:e7f8:6de6 with SMTP id g11-20020a056402090b00b00412e7f86de6mr39340961edz.182.1646401000140; Fri, 04 Mar 2022 05:36:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646401000; cv=none; d=google.com; s=arc-20160816; b=qh9/UYF0OsNFcJpwcwqKitS4SPLY7DEbugs91u72WeD4xtktAP6nNcZYwO1ms8Wywv I/+SSrbXJOF4w+dwKead6N0MUr1oDaxZuOGdIyEJfCOyyY6zSHB12e00abQ97glxWRoa yXggx4KD80d2XOsM3lDwIyvqFsj7ykYEviXppL1m5DQSVm4b1VNCAx0c8YO0tuC+vkZS MOJg9k2LjREPNxmcbL4sUKhA7RjN+9eLgdoTKhQ0m/jBijbB2r76DLph697RSCgBAQ1x SpxaDez8kpA/zl4HvR1N23QbY4c2hwDeTItR2yW9LxoYho1Jxw7f3Yy22FS8FiLyJrIr 8P+g== 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=4q6dTFZS0V0wA/W73sHv/mFBZc4hYhVjXKWp7px/oH4=; b=pUmf+hfndXvKYbWuZCLkqTmVAJGKw0Uq6Iftt238Xmmqu5pdxP0wp4u32lII8XUt+z qs9HYGIOzEOQkJ5Kq7hIAxCfKsSmoe7rayyUSGJv0zCrcvdU1WaejlwJzvJRfwYHWucj bl/x/ACfPkwpQ/KjtRzhw1baS8/AwZtOhyIVA405iGmdSsefjgmBo70yOkoZrlXbpGJ4 NOuEc3RPOt5JKczPqiSzFHYXsktju+lbnaAb6iyLa2zD61xsAW5powDoj4Yv6eyGUTsi mu+hLJrldpAG6phboEhAlqufYCMivCKbIL6w6jUjnh5Xb71wASDVurjXwRAccH371Pzu I/yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id kz2-20020a17090777c200b006d0adc95b44si3021947ejc.525.2022.03.04.05.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 05:36:39 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 C2CEA83D4D; Fri, 4 Mar 2022 14:35:52 +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 4300283B6C; Fri, 4 Mar 2022 14:35:26 +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.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 DCD7183D32 for ; Fri, 4 Mar 2022 14:35:17 +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 33A021396; Fri, 4 Mar 2022 05:35:17 -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 882093F70D; Fri, 4 Mar 2022 05:35:15 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Simon Glass , Heinrich Schuchardt , Sughosh Ganu Subject: [PATCH v3 8/8] test: rng: Add a UT testcase for the rng command Date: Fri, 4 Mar 2022 19:04:29 +0530 Message-Id: <20220304133429.1047752-9-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220304133429.1047752-1-sughosh.ganu@linaro.org> References: <20220304133429.1047752-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 V2: 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);