blob: 3523860d2b312ad788209dfc290ef37e20bc2fea [file] [log] [blame]
Patrick Delaunayce891fca2020-01-13 11:34:56 +01001// SPDX-License-Identifier: GPL-2.0+
2
3#include <common.h>
4#include <dm.h>
5#include <dm/test.h>
6#include <test/ut.h>
7
Simon Glass92432242022-09-06 20:27:14 -06008static int dm_test_ofprop_get_property(struct unit_test_state *uts)
Patrick Delaunayce891fca2020-01-13 11:34:56 +01009{
10 ofnode node;
11 struct ofprop prop;
12 const void *value;
13 const char *propname;
14 int res, len, count = 0;
15
16 node = ofnode_path("/cros-ec/flash");
Simon Glass4b1f5712022-09-06 20:27:13 -060017 for (res = ofnode_first_property(node, &prop);
Patrick Delaunayce891fca2020-01-13 11:34:56 +010018 !res;
Simon Glass4b1f5712022-09-06 20:27:13 -060019 res = ofnode_next_property(&prop)) {
Simon Glass92432242022-09-06 20:27:14 -060020 value = ofprop_get_property(&prop, &propname, &len);
Patrick Delaunayce891fca2020-01-13 11:34:56 +010021 ut_assertnonnull(value);
22 switch (count) {
23 case 0:
24 ut_asserteq_str("image-pos", propname);
25 ut_asserteq(4, len);
26 break;
27 case 1:
28 ut_asserteq_str("size", propname);
29 ut_asserteq(4, len);
30 break;
31 case 2:
32 ut_asserteq_str("erase-value", propname);
33 ut_asserteq(4, len);
34 break;
35 case 3:
Simon Glasscaa4daa2020-12-03 16:55:18 -070036 /* only for plat */
Patrick Delaunayce891fca2020-01-13 11:34:56 +010037 ut_asserteq_str("name", propname);
38 ut_asserteq(6, len);
39 ut_asserteq_str("flash", value);
40 break;
41 default:
42 break;
43 }
44 count++;
45 }
46
47 return 0;
48}
Simon Glass92432242022-09-06 20:27:14 -060049DM_TEST(dm_test_ofprop_get_property, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);