blob: 9064426e2137612311cc0400a83f2e57c311c685 [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
8static int dm_test_ofnode_get_property_by_prop(struct unit_test_state *uts)
9{
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");
17 for (res = ofnode_get_first_property(node, &prop);
18 !res;
19 res = ofnode_get_next_property(&prop)) {
20 value = ofnode_get_property_by_prop(&prop, &propname, &len);
21 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:
36 /* only for platdata */
37 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}
49DM_TEST(dm_test_ofnode_get_property_by_prop,
Simon Glasse180c2b2020-07-28 19:41:12 -060050 UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);