Patrick Delaunay | caee155 | 2020-01-13 11:34:56 +0100 | [diff] [blame] | 1 | // 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 | |
| 8 | static 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 Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame^] | 36 | /* only for plat */ |
Patrick Delaunay | caee155 | 2020-01-13 11:34:56 +0100 | [diff] [blame] | 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 | } |
| 49 | DM_TEST(dm_test_ofnode_get_property_by_prop, |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 50 | UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |