From patchwork Fri Jul 22 16:02:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 592475 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp636406mab; Fri, 22 Jul 2022 09:04:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uMGUyudmeR6tT5ZLW1AvsJllyz/0eBcR76QbSPfWMSGc6FShT03vHOBP/ZNJSkPBHllUEc X-Received: by 2002:a92:cbc5:0:b0:2da:d35b:c06b with SMTP id s5-20020a92cbc5000000b002dad35bc06bmr282757ilq.37.1658505860518; Fri, 22 Jul 2022 09:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658505860; cv=none; d=google.com; s=arc-20160816; b=OAg2V/cK16QotN6Zrv6+gvo+sEeA8kGBFHbSniXo8dT3Jg/lmRBf99iKJ2RfJLFw4W RbIq+e0bMr+nPUcdHTgmA7mUWKEVEVoC3o4dqiy2fOq6wXyw4XdoZEXVK5Ok8ISQQl56 Y7SfyhaXgjrYt07v5mdsLGmCTA3iUxqHVWu9XYDolg9sCI0IDrOxJXmvdQJH4AV5tpSV 8zdRlatZuV9mAnda8qC9bHnULpHBEIEzheHGSsCPK+aOR0kGLshOBcSppM1B7YplmgF5 5JHyqAmK+d1URZ6XD/JKRh4Rkryhxs7L2sxGhV/KBfFzlgOZn4HRJiu5fQ7F4iXAYrdz IimQ== 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=c16b5L0KHWThO0l29lQy91niMcdecLKCg3Fy5IUEN4k=; b=m2MGixRJyxDhWE+37sKj4On6CtyqHZukIq6kcjqh/9r0bvYV7cIgGP2KGp4gAfIbA5 VTEy7Og2JsgPOxjcHMUIalqWUDncyFbNQYan028kaGDXnnhEF8/nQURsdnXksKtKvjBD zzrJggNpi+RlFlUOF/DWBZd48O4sVyM5gc1fpZxKZXYGsSJXjGN4r0woz9z+neaC2JJD +XQQ+wmT3Y9sa5mcioYTQyzpwAthvF3d1sBc4d8RU67FeiTDe/gfhpcq+gM9zIzhFQ4i gKtkl4iOSdyPkzg/RK3Z2s6eG7epjODuK5uELMjs+KXG5VLY8xxS3HdDuIRa7Z2HIJMv U0jA== 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 a8-20020a92d588000000b002dcebc7608fsi3617307iln.47.2022.07.22.09.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 09:04:20 -0700 (PDT) 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 07F39840E6; Fri, 22 Jul 2022 18:03:09 +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 5352B83FC0; Fri, 22 Jul 2022 18:02:52 +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 773E68406A for ; Fri, 22 Jul 2022 18:02:47 +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 3496D106F; Fri, 22 Jul 2022 09:02:47 -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 B13DE3F73D; Fri, 22 Jul 2022 09:02:44 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Tom Rini , Sughosh Ganu Subject: [PATCH v8 8/8] test: rng: Add a UT testcase for the rng command Date: Fri, 22 Jul 2022 21:32:09 +0530 Message-Id: <20220722160209.863840-9-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220722160209.863840-1-sughosh.ganu@linaro.org> References: <20220722160209.863840-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 V7: None cmd/Kconfig | 1 + test/dm/rng.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index b3820f1e04..b4bf207a2d 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1963,6 +1963,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);