blob: ce20e2d7c2ce16d8a43e43d260bc88bec7cda9f3 [file] [log] [blame]
Sughosh Ganu4ee08eb2019-12-28 23:58:33 +05301// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (c) 2019, Linaro Limited
4 */
5
6#include <common.h>
7#include <dm.h>
8#include <rng.h>
9#include <dm/test.h>
10#include <test/ut.h>
11
12/* Basic test of the rng uclass */
13static int dm_test_rng_read(struct unit_test_state *uts)
14{
15 unsigned long rand1 = 0, rand2 = 0;
16 struct udevice *dev;
17
18 ut_assertok(uclass_get_device(UCLASS_RNG, 0, &dev));
19 ut_assertnonnull(dev);
20 ut_assertok(dm_rng_read(dev, &rand1, sizeof(rand1)));
21 ut_assertok(dm_rng_read(dev, &rand2, sizeof(rand2)));
22 ut_assert(rand1 != rand2);
23
24 return 0;
25}
26DM_TEST(dm_test_rng_read, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);