diff options
Diffstat (limited to 'test/dm/ofnode.c')
-rw-r--r-- | test/dm/ofnode.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c index 845cded..ceeb8e5 100644 --- a/test/dm/ofnode.c +++ b/test/dm/ofnode.c @@ -17,6 +17,7 @@ */ #include <common.h> +#include <abuf.h> #include <dm.h> #include <log.h> #include <of_live.h> @@ -26,6 +27,7 @@ #include <dm/root.h> #include <dm/test.h> #include <dm/uclass-internal.h> +#include <linux/sizes.h> #include <test/test.h> #include <test/ut.h> @@ -1456,3 +1458,25 @@ static int dm_test_ofnode_delete(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_ofnode_delete, UT_TESTF_SCAN_FDT); + +static int dm_test_oftree_to_fdt(struct unit_test_state *uts) +{ + oftree tree, check; + struct abuf buf, buf2; + + tree = oftree_default(); + ut_assertok(oftree_to_fdt(tree, &buf)); + ut_assert(abuf_size(&buf) > SZ_16K); + + /* convert it back to a tree and see if it looks OK */ + check = oftree_from_fdt(abuf_data(&buf)); + ut_assert(oftree_valid(check)); + + ut_assertok(oftree_to_fdt(check, &buf2)); + ut_assert(abuf_size(&buf2) > SZ_16K); + ut_asserteq(abuf_size(&buf), abuf_size(&buf2)); + ut_asserteq_mem(abuf_data(&buf), abuf_data(&buf2), abuf_size(&buf)); + + return 0; +} +DM_TEST(dm_test_oftree_to_fdt, UT_TESTF_SCAN_FDT); |