blob: 069551a31af521eebed6940763f17d821a39a84a [file] [log] [blame]
Patrick Delaunaycaee1552020-01-13 11:34:56 +01001// SPDX-License-Identifier: GPL-2.0+
2
Patrick Delaunaycaee1552020-01-13 11:34:56 +01003#include <dm.h>
4#include <dm/test.h>
5#include <test/ut.h>
6
Simon Glassd0aff8b2022-09-06 20:27:14 -06007static int dm_test_ofprop_get_property(struct unit_test_state *uts)
Patrick Delaunaycaee1552020-01-13 11:34:56 +01008{
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");
Simon Glassfec058d2022-09-06 20:27:13 -060016 for (res = ofnode_first_property(node, &prop);
Patrick Delaunaycaee1552020-01-13 11:34:56 +010017 !res;
Simon Glassfec058d2022-09-06 20:27:13 -060018 res = ofnode_next_property(&prop)) {
Simon Glassd0aff8b2022-09-06 20:27:14 -060019 value = ofprop_get_property(&prop, &propname, &len);
Patrick Delaunaycaee1552020-01-13 11:34:56 +010020 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:
Simon Glass71fa5b42020-12-03 16:55:18 -070035 /* only for plat */
Patrick Delaunaycaee1552020-01-13 11:34:56 +010036 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}
Simon Glass1a92f832024-08-22 07:57:48 -060048DM_TEST(dm_test_ofprop_get_property, UTF_SCAN_PDATA | UTF_SCAN_FDT);