blob: 8c7dd825136eed87a4d9e21a3331e98e04771b02 [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:
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}
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);