Philipp Tomsich | 6f2d59c | 2018-12-14 21:14:29 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * (C) 2018 Theobroma Systems Design und Consulting GmbH |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
| 8 | #include <bootcount.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Philipp Tomsich | 6f2d59c | 2018-12-14 21:14:29 +0100 | [diff] [blame] | 10 | #include <asm/test.h> |
| 11 | #include <dm/test.h> |
| 12 | #include <test/ut.h> |
| 13 | |
| 14 | static int dm_test_bootcount(struct unit_test_state *uts) |
| 15 | { |
| 16 | struct udevice *dev; |
| 17 | u32 val; |
| 18 | |
| 19 | ut_assertok(uclass_get_device(UCLASS_BOOTCOUNT, 0, &dev)); |
| 20 | ut_assertok(dm_bootcount_set(dev, 0)); |
| 21 | ut_assertok(dm_bootcount_get(dev, &val)); |
| 22 | ut_assert(val == 0); |
| 23 | ut_assertok(dm_bootcount_set(dev, 0xab)); |
| 24 | ut_assertok(dm_bootcount_get(dev, &val)); |
| 25 | ut_assert(val == 0xab); |
| 26 | |
| 27 | return 0; |
| 28 | } |
| 29 | |
| 30 | DM_TEST(dm_test_bootcount, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); |
| 31 | |