blob: 9fd3751ef7e15e47c63158fc762e2408c3285642 [file] [log] [blame]
Philipp Tomsich1fc53302018-12-14 21:14:29 +01001// 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 Glass0f2af882020-05-10 11:40:05 -06009#include <log.h>
Philipp Tomsich1fc53302018-12-14 21:14:29 +010010#include <asm/test.h>
11#include <dm/test.h>
Simon Glass75c4d412020-07-19 10:15:37 -060012#include <test/test.h>
Philipp Tomsich1fc53302018-12-14 21:14:29 +010013#include <test/ut.h>
14
15static int dm_test_bootcount(struct unit_test_state *uts)
16{
17 struct udevice *dev;
18 u32 val;
19
20 ut_assertok(uclass_get_device(UCLASS_BOOTCOUNT, 0, &dev));
21 ut_assertok(dm_bootcount_set(dev, 0));
22 ut_assertok(dm_bootcount_get(dev, &val));
23 ut_assert(val == 0);
24 ut_assertok(dm_bootcount_set(dev, 0xab));
25 ut_assertok(dm_bootcount_get(dev, &val));
26 ut_assert(val == 0xab);
27
28 return 0;
29}
30
31DM_TEST(dm_test_bootcount, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
32