Sughosh Ganu | 912893d | 2019-12-28 23:58:33 +0530 | [diff] [blame] | 1 | // 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> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 8 | #include <log.h> |
Sughosh Ganu | 912893d | 2019-12-28 23:58:33 +0530 | [diff] [blame] | 9 | #include <rng.h> |
| 10 | #include <dm/test.h> |
| 11 | #include <test/ut.h> |
| 12 | |
| 13 | /* Basic test of the rng uclass */ |
| 14 | static int dm_test_rng_read(struct unit_test_state *uts) |
| 15 | { |
| 16 | unsigned long rand1 = 0, rand2 = 0; |
| 17 | struct udevice *dev; |
| 18 | |
| 19 | ut_assertok(uclass_get_device(UCLASS_RNG, 0, &dev)); |
| 20 | ut_assertnonnull(dev); |
| 21 | ut_assertok(dm_rng_read(dev, &rand1, sizeof(rand1))); |
| 22 | ut_assertok(dm_rng_read(dev, &rand2, sizeof(rand2))); |
| 23 | ut_assert(rand1 != rand2); |
| 24 | |
| 25 | return 0; |
| 26 | } |
| 27 | DM_TEST(dm_test_rng_read, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |