All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sughosh Ganu <sughosh.ganu@linaro.org>
To: u-boot@lists.denx.de
Subject: [PATCH v5 7/8] test: rng: Add basic test for random number generator(rng) uclass
Date: Thu, 26 Dec 2019 22:55:07 +0530	[thread overview]
Message-ID: <1577381108-6320-8-git-send-email-sughosh.ganu@linaro.org> (raw)
In-Reply-To: <1577381108-6320-1-git-send-email-sughosh.ganu@linaro.org>

Add a unit test for testing the rng uclass functionality using the
sandbox rng driver.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
---
Changes since V4:
* Change the test checking logic based on changes made in the sandbox
  rng driver, which now returns number of bytes read.

 test/dm/Makefile |  1 +
 test/dm/rng.c    | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 test/dm/rng.c

diff --git a/test/dm/Makefile b/test/dm/Makefile
index 0c2fd5c..f61bf65 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -65,4 +65,5 @@ obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o
 obj-$(CONFIG_DMA) += dma.o
 obj-$(CONFIG_DM_MDIO) += mdio.o
 obj-$(CONFIG_DM_MDIO_MUX) += mdio_mux.o
+obj-$(CONFIG_DM_RNG) += rng.o
 endif
diff --git a/test/dm/rng.c b/test/dm/rng.c
new file mode 100644
index 0000000..02c6c44
--- /dev/null
+++ b/test/dm/rng.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019, Linaro Limited
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <rng.h>
+#include <dm/test.h>
+#include <test/ut.h>
+
+/* Basic test of the rng uclass */
+static int dm_test_rng_read(struct unit_test_state *uts)
+{
+	unsigned long rand1 = 0, rand2 = 0;
+	struct udevice *dev;
+
+	ut_assertok(uclass_get_device(UCLASS_RNG, 0, &dev));
+	ut_assertnonnull(dev);
+	ut_asserteq(sizeof(rand1), dm_rng_read(dev, &rand1, sizeof(rand1)));
+	ut_asserteq(sizeof(rand2), dm_rng_read(dev, &rand2, sizeof(rand2)));
+	ut_assert(rand1 != rand2);
+
+	return 0;
+}
+DM_TEST(dm_test_rng_read, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
-- 
2.7.4

  parent reply	other threads:[~2019-12-26 17:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-26 17:25 [PATCH v5 0/8] Add a random number generator uclass Sughosh Ganu
2019-12-26 17:25 ` [PATCH v5 1/8] dm: rng: Add random number generator(rng) uclass Sughosh Ganu
2019-12-27  7:04   ` Heinrich Schuchardt
2019-12-27 11:38     ` Sughosh Ganu
2019-12-26 17:25 ` [PATCH v5 2/8] clk: stm32mp1: Add a clock entry for RNG1 device Sughosh Ganu
2019-12-26 17:25 ` [PATCH v5 3/8] stm32mp1: rng: Add a driver for random number generator(rng) device Sughosh Ganu
2019-12-27  7:51   ` Heinrich Schuchardt
2019-12-27 11:19     ` Sughosh Ganu
2019-12-27 12:42       ` Heinrich Schuchardt
2019-12-27 12:50         ` Heinrich Schuchardt
2019-12-27 12:58           ` Sughosh Ganu
2019-12-27 12:52         ` Sughosh Ganu
2019-12-26 17:25 ` [PATCH v5 4/8] configs: stm32mp15: Enable " Sughosh Ganu
2019-12-26 17:25 ` [PATCH v5 5/8] sandbox: rng: Add a random number generator(rng) driver Sughosh Ganu
2019-12-27  6:54   ` Heinrich Schuchardt
2019-12-27 11:40     ` Sughosh Ganu
2019-12-26 17:25 ` [PATCH v5 6/8] configs: sandbox: Enable random number generator(rng) device Sughosh Ganu
2019-12-26 17:25 ` Sughosh Ganu [this message]
2019-12-26 17:25 ` [PATCH v5 8/8] virtio: rng: Add a random number generator(rng) driver Sughosh Ganu
2019-12-27  7:12   ` Heinrich Schuchardt
2019-12-27 11:29     ` Sughosh Ganu
2019-12-27 12:27       ` Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1577381108-6320-8-git-send-email-sughosh.ganu@linaro.org \
    --to=sughosh.ganu@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.