blob: 6a252f3f504fcba553a43c0cd0b568ee38db6f2f [file] [log] [blame]
Masahiro Yamadab4f2dda2018-04-27 01:02:02 +09001// SPDX-License-Identifier: GPL-2.0+
2
3#include <common.h>
4#include <dm.h>
Simon Glass0f2af882020-05-10 11:40:05 -06005#include <log.h>
Simon Glassef75c592022-07-30 15:52:08 -06006#include <of_live.h>
Simon Glass699c9ca2018-10-01 12:22:08 -06007#include <dm/of_extra.h>
Masahiro Yamadab4f2dda2018-04-27 01:02:02 +09008#include <dm/test.h>
Simon Glass75c4d412020-07-19 10:15:37 -06009#include <test/test.h>
Masahiro Yamadab4f2dda2018-04-27 01:02:02 +090010#include <test/ut.h>
11
12static int dm_test_ofnode_compatible(struct unit_test_state *uts)
13{
14 ofnode root_node = ofnode_path("/");
15
16 ut_assert(ofnode_valid(root_node));
17 ut_assert(ofnode_device_is_compatible(root_node, "sandbox"));
18
19 return 0;
20}
Simon Glass974dccd2020-07-28 19:41:12 -060021DM_TEST(dm_test_ofnode_compatible, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
Jens Wiklanderd9fd0ac2018-08-20 11:10:00 +020022
Patrick Delaunay04fcfe72020-09-24 17:26:20 +020023static int dm_test_ofnode_get_by_phandle(struct unit_test_state *uts)
24{
25 /* test invalid phandle */
26 ut_assert(!ofnode_valid(ofnode_get_by_phandle(0)));
27 ut_assert(!ofnode_valid(ofnode_get_by_phandle(-1)));
28
29 /* test first valid phandle */
30 ut_assert(ofnode_valid(ofnode_get_by_phandle(1)));
31
32 /* test unknown phandle */
33 ut_assert(!ofnode_valid(ofnode_get_by_phandle(0x1000000)));
34
35 return 0;
36}
37DM_TEST(dm_test_ofnode_get_by_phandle, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
38
Jens Wiklanderd9fd0ac2018-08-20 11:10:00 +020039static int dm_test_ofnode_by_prop_value(struct unit_test_state *uts)
40{
41 const char propname[] = "compatible";
42 const char propval[] = "denx,u-boot-fdt-test";
43 const char *str;
44 ofnode node = ofnode_null();
45
46 /* Find first matching node, there should be at least one */
47 node = ofnode_by_prop_value(node, propname, propval, sizeof(propval));
48 ut_assert(ofnode_valid(node));
49 str = ofnode_read_string(node, propname);
50 ut_assert(str && !strcmp(str, propval));
51
52 /* Find the rest of the matching nodes */
53 while (true) {
54 node = ofnode_by_prop_value(node, propname, propval,
55 sizeof(propval));
56 if (!ofnode_valid(node))
57 break;
58 str = ofnode_read_string(node, propname);
59 ut_assert(str && !strcmp(str, propval));
60 }
61
62 return 0;
63}
Simon Glass974dccd2020-07-28 19:41:12 -060064DM_TEST(dm_test_ofnode_by_prop_value, UT_TESTF_SCAN_FDT);
Simon Glass699c9ca2018-10-01 12:22:08 -060065
66static int dm_test_ofnode_fmap(struct unit_test_state *uts)
67{
68 struct fmap_entry entry;
69 ofnode node;
70
71 node = ofnode_path("/cros-ec/flash");
72 ut_assert(ofnode_valid(node));
73 ut_assertok(ofnode_read_fmap_entry(node, &entry));
74 ut_asserteq(0x08000000, entry.offset);
75 ut_asserteq(0x20000, entry.length);
76
77 return 0;
78}
Simon Glass974dccd2020-07-28 19:41:12 -060079DM_TEST(dm_test_ofnode_fmap, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
Simon Glassf3455962020-01-27 08:49:43 -070080
Simon Glass0c2e9802020-01-27 08:49:44 -070081static int dm_test_ofnode_read(struct unit_test_state *uts)
82{
83 const u32 *val;
84 ofnode node;
85 int size;
86
87 node = ofnode_path("/a-test");
88 ut_assert(ofnode_valid(node));
89
90 val = ofnode_read_prop(node, "int-value", &size);
91 ut_assertnonnull(val);
92 ut_asserteq(4, size);
93 ut_asserteq(1234, fdt32_to_cpu(val[0]));
94
95 val = ofnode_read_prop(node, "missing", &size);
96 ut_assertnull(val);
97 ut_asserteq(-FDT_ERR_NOTFOUND, size);
98
99 /* Check it works without a size parameter */
100 val = ofnode_read_prop(node, "missing", NULL);
101 ut_assertnull(val);
102
103 return 0;
104}
Simon Glass974dccd2020-07-28 19:41:12 -0600105DM_TEST(dm_test_ofnode_read, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
Simon Glass0c2e9802020-01-27 08:49:44 -0700106
Patrick Delaunay8cd28012020-09-25 09:41:16 +0200107static int dm_test_ofnode_phandle(struct unit_test_state *uts)
108{
109 struct ofnode_phandle_args args;
110 ofnode node;
111 int ret;
112 const char prop[] = "test-gpios";
113 const char cell[] = "#gpio-cells";
114 const char prop2[] = "phandle-value";
115
116 node = ofnode_path("/a-test");
117 ut_assert(ofnode_valid(node));
118
119 /* Test ofnode_count_phandle_with_args with cell name */
120 ret = ofnode_count_phandle_with_args(node, "missing", cell, 0);
121 ut_asserteq(-ENOENT, ret);
122 ret = ofnode_count_phandle_with_args(node, prop, "#invalid", 0);
123 ut_asserteq(-EINVAL, ret);
124 ret = ofnode_count_phandle_with_args(node, prop, cell, 0);
125 ut_asserteq(5, ret);
126
127 /* Test ofnode_parse_phandle_with_args with cell name */
128 ret = ofnode_parse_phandle_with_args(node, "missing", cell, 0, 0,
129 &args);
130 ut_asserteq(-ENOENT, ret);
131 ret = ofnode_parse_phandle_with_args(node, prop, "#invalid", 0, 0,
132 &args);
133 ut_asserteq(-EINVAL, ret);
134 ret = ofnode_parse_phandle_with_args(node, prop, cell, 0, 0, &args);
135 ut_assertok(ret);
136 ut_asserteq(1, args.args_count);
137 ut_asserteq(1, args.args[0]);
138 ret = ofnode_parse_phandle_with_args(node, prop, cell, 0, 1, &args);
139 ut_assertok(ret);
140 ut_asserteq(1, args.args_count);
141 ut_asserteq(4, args.args[0]);
142 ret = ofnode_parse_phandle_with_args(node, prop, cell, 0, 2, &args);
143 ut_assertok(ret);
144 ut_asserteq(5, args.args_count);
145 ut_asserteq(5, args.args[0]);
146 ut_asserteq(1, args.args[4]);
147 ret = ofnode_parse_phandle_with_args(node, prop, cell, 0, 3, &args);
148 ut_asserteq(-ENOENT, ret);
149 ret = ofnode_parse_phandle_with_args(node, prop, cell, 0, 4, &args);
150 ut_assertok(ret);
151 ut_asserteq(1, args.args_count);
152 ut_asserteq(12, args.args[0]);
153 ret = ofnode_parse_phandle_with_args(node, prop, cell, 0, 5, &args);
154 ut_asserteq(-ENOENT, ret);
155
156 /* Test ofnode_count_phandle_with_args with cell count */
157 ret = ofnode_count_phandle_with_args(node, "missing", NULL, 2);
158 ut_asserteq(-ENOENT, ret);
159 ret = ofnode_count_phandle_with_args(node, prop2, NULL, 1);
160 ut_asserteq(3, ret);
161
162 /* Test ofnode_parse_phandle_with_args with cell count */
163 ret = ofnode_parse_phandle_with_args(node, prop2, NULL, 1, 0, &args);
164 ut_assertok(ret);
165 ut_asserteq(1, ofnode_valid(args.node));
166 ut_asserteq(1, args.args_count);
167 ut_asserteq(10, args.args[0]);
168 ret = ofnode_parse_phandle_with_args(node, prop2, NULL, 1, 1, &args);
169 ut_asserteq(-EINVAL, ret);
170 ret = ofnode_parse_phandle_with_args(node, prop2, NULL, 1, 2, &args);
171 ut_assertok(ret);
172 ut_asserteq(1, ofnode_valid(args.node));
173 ut_asserteq(1, args.args_count);
174 ut_asserteq(30, args.args[0]);
175 ret = ofnode_parse_phandle_with_args(node, prop2, NULL, 1, 3, &args);
176 ut_asserteq(-ENOENT, ret);
177
178 return 0;
179}
180DM_TEST(dm_test_ofnode_phandle, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
181
Simon Glassf3455962020-01-27 08:49:43 -0700182static int dm_test_ofnode_read_chosen(struct unit_test_state *uts)
183{
184 const char *str;
Simon Glasse09223c2020-01-27 08:49:46 -0700185 const u32 *val;
Simon Glassf3455962020-01-27 08:49:43 -0700186 ofnode node;
Simon Glasse09223c2020-01-27 08:49:46 -0700187 int size;
Simon Glassf3455962020-01-27 08:49:43 -0700188
189 str = ofnode_read_chosen_string("setting");
190 ut_assertnonnull(str);
191 ut_asserteq_str("sunrise ohoka", str);
192 ut_asserteq_ptr(NULL, ofnode_read_chosen_string("no-setting"));
193
194 node = ofnode_get_chosen_node("other-node");
195 ut_assert(ofnode_valid(node));
196 ut_asserteq_str("c-test@5", ofnode_get_name(node));
197
198 node = ofnode_get_chosen_node("setting");
199 ut_assert(!ofnode_valid(node));
200
Simon Glasse09223c2020-01-27 08:49:46 -0700201 val = ofnode_read_chosen_prop("int-values", &size);
202 ut_assertnonnull(val);
203 ut_asserteq(8, size);
204 ut_asserteq(0x1937, fdt32_to_cpu(val[0]));
205 ut_asserteq(72993, fdt32_to_cpu(val[1]));
206
Simon Glassf3455962020-01-27 08:49:43 -0700207 return 0;
208}
Simon Glass974dccd2020-07-28 19:41:12 -0600209DM_TEST(dm_test_ofnode_read_chosen, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
developercf8bc132020-05-02 11:35:10 +0200210
Michal Simek92a88622020-07-28 12:51:08 +0200211static int dm_test_ofnode_read_aliases(struct unit_test_state *uts)
212{
213 const void *val;
214 ofnode node;
215 int size;
216
Michael Walle7efcdfd2021-02-25 16:51:11 +0100217 node = ofnode_get_aliases_node("ethernet3");
Michal Simek92a88622020-07-28 12:51:08 +0200218 ut_assert(ofnode_valid(node));
219 ut_asserteq_str("sbe5", ofnode_get_name(node));
220
221 node = ofnode_get_aliases_node("unknown");
222 ut_assert(!ofnode_valid(node));
223
224 val = ofnode_read_aliases_prop("spi0", &size);
225 ut_assertnonnull(val);
226 ut_asserteq(7, size);
227 ut_asserteq_str("/spi@0", (const char *)val);
228
229 return 0;
230}
231DM_TEST(dm_test_ofnode_read_aliases, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
232
developercf8bc132020-05-02 11:35:10 +0200233static int dm_test_ofnode_get_child_count(struct unit_test_state *uts)
234{
235 ofnode node, child_node;
236 u32 val;
237
238 node = ofnode_path("/i-test");
239 ut_assert(ofnode_valid(node));
240
241 val = ofnode_get_child_count(node);
242 ut_asserteq(3, val);
243
244 child_node = ofnode_first_subnode(node);
245 ut_assert(ofnode_valid(child_node));
246 val = ofnode_get_child_count(child_node);
247 ut_asserteq(0, val);
248
249 return 0;
250}
251DM_TEST(dm_test_ofnode_get_child_count,
Simon Glass974dccd2020-07-28 19:41:12 -0600252 UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
Simon Glass5de5b3b2020-11-28 17:50:02 -0700253
254static int dm_test_ofnode_is_enabled(struct unit_test_state *uts)
255{
256 ofnode root_node = ofnode_path("/");
257 ofnode node = ofnode_path("/usb@0");
258
259 ut_assert(ofnode_is_enabled(root_node));
260 ut_assert(!ofnode_is_enabled(node));
261
262 return 0;
263}
264DM_TEST(dm_test_ofnode_is_enabled, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
Chen Guanqiaobe0512f2021-04-12 14:51:12 +0800265
266static int dm_test_ofnode_get_reg(struct unit_test_state *uts)
267{
268 ofnode node;
269 fdt_addr_t addr;
270 fdt_size_t size;
271
272 node = ofnode_path("/translation-test@8000");
273 ut_assert(ofnode_valid(node));
274 addr = ofnode_get_addr(node);
275 size = ofnode_get_size(node);
276 ut_asserteq(0x8000, addr);
277 ut_asserteq(0x4000, size);
278
279 node = ofnode_path("/translation-test@8000/dev@1,100");
280 ut_assert(ofnode_valid(node));
281 addr = ofnode_get_addr(node);
282 size = ofnode_get_size(node);
283 ut_asserteq(0x9000, addr);
284 ut_asserteq(0x1000, size);
285
286 node = ofnode_path("/emul-mux-controller");
287 ut_assert(ofnode_valid(node));
288 addr = ofnode_get_addr(node);
289 size = ofnode_get_size(node);
Patrice Chotardb4c52112022-01-04 08:42:48 +0100290 ut_asserteq_64(FDT_ADDR_T_NONE, addr);
Chen Guanqiaobe0512f2021-04-12 14:51:12 +0800291 ut_asserteq(FDT_SIZE_T_NONE, size);
292
Marek Behún177ab7f2021-05-26 14:08:17 +0200293 node = ofnode_path("/translation-test@8000/noxlatebus@3,300/dev@42");
294 ut_assert(ofnode_valid(node));
295 addr = ofnode_get_addr_size_index_notrans(node, 0, &size);
296 ut_asserteq_64(0x42, addr);
297
Chen Guanqiaobe0512f2021-04-12 14:51:12 +0800298 return 0;
299}
300DM_TEST(dm_test_ofnode_get_reg, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
Marek Behúne897e3c2021-05-26 14:08:18 +0200301
302static int dm_test_ofnode_get_path(struct unit_test_state *uts)
303{
304 const char *path = "/translation-test@8000/noxlatebus@3,300/dev@42";
305 char buf[64];
306 ofnode node;
307 int res;
308
309 node = ofnode_path(path);
310 ut_assert(ofnode_valid(node));
311
312 res = ofnode_get_path(node, buf, 64);
313 ut_asserteq(0, res);
314 ut_asserteq_str(path, buf);
315
316 res = ofnode_get_path(node, buf, 32);
317 ut_asserteq(-ENOSPC, res);
318
319 return 0;
320}
321DM_TEST(dm_test_ofnode_get_path, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
Simon Glass0034d962021-08-07 07:24:01 -0600322
323static int dm_test_ofnode_conf(struct unit_test_state *uts)
324{
325 ut_assert(!ofnode_conf_read_bool("missing"));
326 ut_assert(ofnode_conf_read_bool("testing-bool"));
327
328 ut_asserteq(123, ofnode_conf_read_int("testing-int", 0));
329 ut_asserteq(6, ofnode_conf_read_int("missing", 6));
330
331 ut_assertnull(ofnode_conf_read_str("missing"));
332 ut_asserteq_str("testing", ofnode_conf_read_str("testing-str"));
333
334 return 0;
335}
336DM_TEST(dm_test_ofnode_conf, 0);
Michael Wallef1f87402021-10-15 15:15:18 +0200337
338static int dm_test_ofnode_for_each_compatible_node(struct unit_test_state *uts)
339{
340 const char compatible[] = "denx,u-boot-fdt-test";
341 bool found = false;
342 ofnode node;
343
344 ofnode_for_each_compatible_node(node, compatible) {
345 ut_assert(ofnode_device_is_compatible(node, compatible));
346 found = true;
347 }
348
349 /* There should be at least one matching node */
350 ut_assert(found);
351
352 return 0;
353}
354DM_TEST(dm_test_ofnode_for_each_compatible_node, UT_TESTF_SCAN_FDT);
Simon Glass73025392021-10-23 17:26:04 -0600355
356static int dm_test_ofnode_string(struct unit_test_state *uts)
357{
Simon Glass9580bfc2021-10-23 17:26:07 -0600358 const char **val;
Simon Glass73025392021-10-23 17:26:04 -0600359 const char *out;
360 ofnode node;
361
362 node = ofnode_path("/a-test");
363 ut_assert(ofnode_valid(node));
364
365 /* single string */
366 ut_asserteq(1, ofnode_read_string_count(node, "str-value"));
367 ut_assertok(ofnode_read_string_index(node, "str-value", 0, &out));
368 ut_asserteq_str("test string", out);
369 ut_asserteq(0, ofnode_stringlist_search(node, "str-value",
370 "test string"));
Simon Glass9580bfc2021-10-23 17:26:07 -0600371 ut_asserteq(1, ofnode_read_string_list(node, "str-value", &val));
372 ut_asserteq_str("test string", val[0]);
373 ut_assertnull(val[1]);
374 free(val);
Simon Glass73025392021-10-23 17:26:04 -0600375
376 /* list of strings */
377 ut_asserteq(5, ofnode_read_string_count(node, "mux-control-names"));
378 ut_assertok(ofnode_read_string_index(node, "mux-control-names", 0,
379 &out));
380 ut_asserteq_str("mux0", out);
381 ut_asserteq(0, ofnode_stringlist_search(node, "mux-control-names",
382 "mux0"));
Simon Glass9580bfc2021-10-23 17:26:07 -0600383 ut_asserteq(5, ofnode_read_string_list(node, "mux-control-names",
384 &val));
385 ut_asserteq_str("mux0", val[0]);
386 ut_asserteq_str("mux1", val[1]);
387 ut_asserteq_str("mux2", val[2]);
388 ut_asserteq_str("mux3", val[3]);
389 ut_asserteq_str("mux4", val[4]);
390 ut_assertnull(val[5]);
391 free(val);
Simon Glass73025392021-10-23 17:26:04 -0600392
393 ut_assertok(ofnode_read_string_index(node, "mux-control-names", 4,
394 &out));
395 ut_asserteq_str("mux4", out);
396 ut_asserteq(4, ofnode_stringlist_search(node, "mux-control-names",
397 "mux4"));
398
399 return 0;
400}
401DM_TEST(dm_test_ofnode_string, 0);
402
403static int dm_test_ofnode_string_err(struct unit_test_state *uts)
404{
Simon Glass9580bfc2021-10-23 17:26:07 -0600405 const char **val;
Simon Glass73025392021-10-23 17:26:04 -0600406 const char *out;
407 ofnode node;
408
409 /*
410 * Test error codes only on livetree, as they are different with
411 * flattree
412 */
413 node = ofnode_path("/a-test");
414 ut_assert(ofnode_valid(node));
415
416 /* non-existent property */
417 ut_asserteq(-EINVAL, ofnode_read_string_count(node, "missing"));
418 ut_asserteq(-EINVAL, ofnode_read_string_index(node, "missing", 0,
419 &out));
Simon Glass9580bfc2021-10-23 17:26:07 -0600420 ut_asserteq(-EINVAL, ofnode_read_string_list(node, "missing", &val));
Simon Glass73025392021-10-23 17:26:04 -0600421
422 /* empty property */
423 ut_asserteq(-ENODATA, ofnode_read_string_count(node, "bool-value"));
424 ut_asserteq(-ENODATA, ofnode_read_string_index(node, "bool-value", 0,
425 &out));
Simon Glass9580bfc2021-10-23 17:26:07 -0600426 ut_asserteq(-ENODATA, ofnode_read_string_list(node, "bool-value",
427 &val));
Simon Glass73025392021-10-23 17:26:04 -0600428
429 /* badly formatted string list */
430 ut_asserteq(-EILSEQ, ofnode_read_string_count(node, "int64-value"));
431 ut_asserteq(-EILSEQ, ofnode_read_string_index(node, "int64-value", 0,
432 &out));
Simon Glass9580bfc2021-10-23 17:26:07 -0600433 ut_asserteq(-EILSEQ, ofnode_read_string_list(node, "int64-value",
434 &val));
Simon Glass73025392021-10-23 17:26:04 -0600435
436 /* out of range / not found */
437 ut_asserteq(-ENODATA, ofnode_read_string_index(node, "str-value", 1,
438 &out));
439 ut_asserteq(-ENODATA, ofnode_stringlist_search(node, "str-value",
440 "other"));
441
442 /* negative value for index is not allowed, so don't test for that */
443
444 ut_asserteq(-ENODATA, ofnode_read_string_index(node,
445 "mux-control-names", 5,
446 &out));
447
448 return 0;
449}
450DM_TEST(dm_test_ofnode_string_err, UT_TESTF_LIVE_TREE);
Marek Behúnf4f1ddc2022-04-07 00:32:57 +0200451
452static int dm_test_ofnode_get_phy(struct unit_test_state *uts)
453{
454 ofnode eth_node, phy_node;
Marek Behúnbc194772022-04-07 00:33:01 +0200455 phy_interface_t mode;
Marek Behúnf4f1ddc2022-04-07 00:32:57 +0200456 u32 reg;
457
458 eth_node = ofnode_path("/phy-test-eth");
459 ut_assert(ofnode_valid(eth_node));
460
Marek Behúnbc194772022-04-07 00:33:01 +0200461 mode = ofnode_read_phy_mode(eth_node);
462 ut_assert(mode == PHY_INTERFACE_MODE_2500BASEX);
463
Marek Behúnf4f1ddc2022-04-07 00:32:57 +0200464 phy_node = ofnode_get_phy_node(eth_node);
465 ut_assert(ofnode_valid(phy_node));
466
467 reg = ofnode_read_u32_default(phy_node, "reg", -1U);
468 ut_asserteq_64(0x1, reg);
469
470 return 0;
471}
472DM_TEST(dm_test_ofnode_get_phy, 0);
Simon Glassef75c592022-07-30 15:52:08 -0600473
474/**
475 * make_ofnode_fdt() - Create an FDT for testing with ofnode
476 *
477 * The size is set to the minimum needed
478 *
479 * @uts: Test state
480 * @fdt: Place to write FDT
481 * @size: Maximum size of space for fdt
482 */
483static int make_ofnode_fdt(struct unit_test_state *uts, void *fdt, int size)
484{
485 ut_assertok(fdt_create(fdt, size));
486 ut_assertok(fdt_finish_reservemap(fdt));
487 ut_assert(fdt_begin_node(fdt, "") >= 0);
488
489 ut_assert(fdt_begin_node(fdt, "aliases") >= 0);
490 ut_assertok(fdt_property_string(fdt, "mmc0", "/new-mmc"));
491 ut_assertok(fdt_end_node(fdt));
492
493 ut_assert(fdt_begin_node(fdt, "new-mmc") >= 0);
494 ut_assertok(fdt_end_node(fdt));
495
496 ut_assertok(fdt_end_node(fdt));
497 ut_assertok(fdt_finish(fdt));
498
499 return 0;
500}
501
502static int dm_test_ofnode_root(struct unit_test_state *uts)
503{
504 struct device_node *root = NULL;
505 char fdt[256];
506 oftree tree;
507 ofnode node;
508
509 /* Check that aliases work on the control FDT */
510 node = ofnode_get_aliases_node("ethernet3");
511 ut_assert(ofnode_valid(node));
512 ut_asserteq_str("sbe5", ofnode_get_name(node));
513
514 ut_assertok(make_ofnode_fdt(uts, fdt, sizeof(fdt)));
515 if (of_live_active()) {
516 ut_assertok(unflatten_device_tree(fdt, &root));
517 tree.np = root;
518 } else {
519 tree.fdt = fdt;
520 }
521
522 /* Make sure they don't work on this new tree */
523 node = ofnode_path_root(tree, "mmc0");
524 ut_assert(!ofnode_valid(node));
525
526 /* It should appear in the new tree */
527 node = ofnode_path_root(tree, "/new-mmc");
528 ut_assert(ofnode_valid(node));
529
530 /* ...and not in the control FDT */
531 node = ofnode_path_root(oftree_default(), "/new-mmc");
532 ut_assert(!ofnode_valid(node));
533
534 free(root);
535
536 return 0;
537}
538DM_TEST(dm_test_ofnode_root, UT_TESTF_SCAN_FDT);