]>
Commit | Line | Data |
---|---|---|
ce891fca PD |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | ||
ce891fca PD |
3 | #include <dm.h> |
4 | #include <dm/test.h> | |
5 | #include <test/ut.h> | |
6 | ||
92432246 | 7 | static int dm_test_ofprop_get_property(struct unit_test_state *uts) |
ce891fca PD |
8 | { |
9 | ofnode node; | |
10 | struct ofprop prop; | |
11 | const void *value; | |
12 | const char *propname; | |
13 | int res, len, count = 0; | |
14 | ||
15 | node = ofnode_path("/cros-ec/flash"); | |
4b1f5714 | 16 | for (res = ofnode_first_property(node, &prop); |
ce891fca | 17 | !res; |
4b1f5714 | 18 | res = ofnode_next_property(&prop)) { |
92432246 | 19 | value = ofprop_get_property(&prop, &propname, &len); |
ce891fca PD |
20 | ut_assertnonnull(value); |
21 | switch (count) { | |
22 | case 0: | |
23 | ut_asserteq_str("image-pos", propname); | |
24 | ut_asserteq(4, len); | |
25 | break; | |
26 | case 1: | |
27 | ut_asserteq_str("size", propname); | |
28 | ut_asserteq(4, len); | |
29 | break; | |
30 | case 2: | |
31 | ut_asserteq_str("erase-value", propname); | |
32 | ut_asserteq(4, len); | |
33 | break; | |
34 | case 3: | |
caa4daa2 | 35 | /* only for plat */ |
ce891fca PD |
36 | ut_asserteq_str("name", propname); |
37 | ut_asserteq(6, len); | |
38 | ut_asserteq_str("flash", value); | |
39 | break; | |
40 | default: | |
41 | break; | |
42 | } | |
43 | count++; | |
44 | } | |
45 | ||
46 | return 0; | |
47 | } | |
92432246 | 48 | DM_TEST(dm_test_ofprop_get_property, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |