mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
dm: core: Add a way to delete a node
Add a function to delete a node in an existing tree. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -1425,3 +1425,34 @@ static int dm_test_ofnode_copy_node_ot(struct unit_test_state *uts)
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_ofnode_copy_node_ot, UT_TESTF_SCAN_FDT | UT_TESTF_OTHER_FDT);
|
||||
|
||||
static int dm_test_ofnode_delete(struct unit_test_state *uts)
|
||||
{
|
||||
ofnode node;
|
||||
|
||||
/*
|
||||
* At present the livetree is not restored after changes made in tests.
|
||||
* See test_pre_run() for how this is done with the other FDT and
|
||||
* dm_test_pre_run() where it sets up the root-tree pointer. So use
|
||||
* nodes which don't matter to other tests.
|
||||
*
|
||||
* We could fix this by detecting livetree changes and regenerating it
|
||||
* before the next test if needed.
|
||||
*/
|
||||
node = ofnode_path("/leds/iracibble");
|
||||
ut_assert(ofnode_valid(node));
|
||||
ut_assertok(ofnode_delete(&node));
|
||||
ut_assert(!ofnode_valid(node));
|
||||
ut_assert(!ofnode_valid(ofnode_path("/leds/iracibble")));
|
||||
|
||||
node = ofnode_path("/leds/default_on");
|
||||
ut_assert(ofnode_valid(node));
|
||||
ut_assertok(ofnode_delete(&node));
|
||||
ut_assert(!ofnode_valid(node));
|
||||
ut_assert(!ofnode_valid(ofnode_path("/leds/default_on")));
|
||||
|
||||
ut_asserteq(2, ofnode_get_child_count(ofnode_path("/leds")));
|
||||
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_ofnode_delete, UT_TESTF_SCAN_FDT);
|
||||
|
||||
Reference in New Issue
Block a user