xref: /openbmc/u-boot/test/dm/smem.c (revision 5c8fd32b)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2018 Ramon Fried <ramon.fried@gmail.com>
4  */
5 
6 #include <common.h>
7 #include <dm.h>
8 #include <smem.h>
9 #include <dm/test.h>
10 #include <test/ut.h>
11 
12 /* Basic test of the smem uclass */
13 static int dm_test_smem_base(struct unit_test_state *uts)
14 {
15 	struct udevice *dev;
16 	size_t size;
17 
18 	ut_assertok(uclass_get_device(UCLASS_SMEM, 0, &dev));
19 	ut_assertnonnull(dev);
20 	ut_assertok(smem_alloc(dev, -1, 0, 16));
21 	ut_asserteq(0, smem_get_free_space(dev, -1));
22 	ut_assertnull(smem_get(dev, -1, 0, &size));
23 
24 	return 0;
25 }
26 DM_TEST(dm_test_smem_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
27 
28