summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPatrick Delaunay <[email protected]>2020-09-24 17:26:20 +0200
committerSimon Glass <[email protected]>2020-10-06 09:07:54 -0600
commit6d9949fe866751c527c5dafab5350af89b7b8332 (patch)
tree51b073975092d29df11ff9b60bf2bf9b5c244fc0 /test
parent45dbe75da6fbc3de280021bf4b5c9dfc94c70f8f (diff)
dm: update test on of_offset in ofnode_valid
Update the test for node.of_offset because an invalid offset is not always set to -1 because the return value of the libfdt functions are: + an error with a value < 0 + a valid offset with value >=0 For example, in ofnode_get_by_phandle() function, we have: node.of_offset = fdt_node_offset_by_phandle(gd->fdt_blob, phandle); and this function can return -FDT_ERR_BADPHANDLE (-6). Without this patch, the added test dm_test_ofnode_get_by_phandle failed. Signed-off-by: Patrick Delaunay <[email protected]> Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/dm/ofnode.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 8bfb7066026..4ae8d281a70 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -19,6 +19,22 @@ static int dm_test_ofnode_compatible(struct unit_test_state *uts)
}
DM_TEST(dm_test_ofnode_compatible, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+static int dm_test_ofnode_get_by_phandle(struct unit_test_state *uts)
+{
+ /* test invalid phandle */
+ ut_assert(!ofnode_valid(ofnode_get_by_phandle(0)));
+ ut_assert(!ofnode_valid(ofnode_get_by_phandle(-1)));
+
+ /* test first valid phandle */
+ ut_assert(ofnode_valid(ofnode_get_by_phandle(1)));
+
+ /* test unknown phandle */
+ ut_assert(!ofnode_valid(ofnode_get_by_phandle(0x1000000)));
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_get_by_phandle, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
static int dm_test_ofnode_by_prop_value(struct unit_test_state *uts)
{
const char propname[] = "compatible";