mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-15 19:51:37 +00:00
test: rng: Add basic test for random number generator(rng) uclass
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> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
23b3f3c0fc
commit
4ee08eb115
2 changed files with 27 additions and 0 deletions
|
@ -68,4 +68,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
|
||||
|
|
26
test/dm/rng.c
Normal file
26
test/dm/rng.c
Normal file
|
@ -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_assertok(dm_rng_read(dev, &rand1, sizeof(rand1)));
|
||||
ut_assertok(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);
|
Loading…
Add table
Reference in a new issue