diff options
author | Sughosh Ganu <sughosh.ganu@linaro.org> | 2019-12-28 23:58:33 +0530 |
---|---|---|
committer | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2020-01-07 18:08:21 +0100 |
commit | 4ee08eb115c3d22cfda415a8f6bc9e975595d204 (patch) | |
tree | d8974ce2687f1e7c44a8e48839954e3653f10774 /test/dm/rng.c | |
parent | 23b3f3c0fc6f881cf9381642196ca11dcc0eb61b (diff) |
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>
Diffstat (limited to 'test/dm/rng.c')
-rw-r--r-- | test/dm/rng.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/dm/rng.c b/test/dm/rng.c new file mode 100644 index 0000000000..ce20e2d7c2 --- /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_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); |