aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSughosh Ganu2022-07-22 21:32:09 +0530
committerIlias Apalodimas2022-08-02 23:50:02 +0300
commitde70619dd3db08e4a1ac881801d3fab979408fd3 (patch)
treefb86bd0d7fa19403cc5a2b9ffbca2f854e099edf /test
parent4bdbb54ee5f2abd6ee3d0ec6bcfc627ed7a6cd41 (diff)
test: rng: Add a UT testcase for the rng command
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 <sughosh.ganu@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/rng.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/dm/rng.c b/test/dm/rng.c
index 5b34c93ed67..6d1f68848d5 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);