diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2007-09-28 15:51:04 +1000 |
---|---|---|
committer | Jon Loeliger <jdl@freescale.com> | 2007-10-15 08:27:24 -0500 |
commit | d2a9da045897c37071597d9aa473964717b14735 (patch) | |
tree | 0c80c6a8906795c4a86721b44940bfd5eb6e253c | |
parent | 02a5556850bbb64a73cd45b2dbca6579880bb424 (diff) | |
download | dtc-d2a9da045897c37071597d9aa473964717b14735.zip dtc-d2a9da045897c37071597d9aa473964717b14735.tar.gz dtc-d2a9da045897c37071597d9aa473964717b14735.tar.bz2 |
libfdt: Make unit address optional for finding nodes
At present, the fdt_subnode_offset() and fdt_path_offset() functions
in libfdt require the exact name of the nodes in question be passed,
including unit address.
This is contrary to traditional OF-like finddevice() behaviour, which
allows the unit address to be omitted (which is useful when the device
name is unambiguous without the address).
This patch introduces similar behaviour to
fdt_subnode_offset_namelen(), and hence to fdt_subnode_offset() and
fdt_path_offset() which are implemented in terms of the former. The
unit address can be omitted from the given node name. If this is
ambiguous, the first such node in the flattened tree will be selected
(this behaviour is consistent with IEEE1275 which specifies only that
an arbitrary node matching the given information be selected).
This very small change is then followed by many more diffs which
change the test examples and testcases to exercise this behaviour.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r-- | libfdt/fdt_ro.c | 14 | ||||
-rw-r--r-- | tests/del_node.c | 26 | ||||
-rw-r--r-- | tests/get_name.c | 8 | ||||
-rw-r--r-- | tests/get_path.c | 8 | ||||
-rw-r--r-- | tests/node_offset_by_prop_value.c | 8 | ||||
-rw-r--r-- | tests/nop_node.c | 22 | ||||
-rw-r--r-- | tests/notfound.c | 2 | ||||
-rw-r--r-- | tests/parent_offset.c | 8 | ||||
-rw-r--r-- | tests/path_offset.c | 22 | ||||
-rw-r--r-- | tests/rw_tree1.c | 6 | ||||
-rw-r--r-- | tests/subnode_offset.c | 15 | ||||
-rw-r--r-- | tests/supernode_atdepth_offset.c | 8 | ||||
-rw-r--r-- | tests/sw_tree1.c | 6 | ||||
-rw-r--r-- | tests/test_tree1.dts | 6 | ||||
-rw-r--r-- | tests/tests.h | 1 | ||||
-rw-r--r-- | tests/testutils.c | 15 | ||||
-rw-r--r-- | tests/trees.S | 6 |
17 files changed, 103 insertions, 78 deletions
diff --git a/libfdt/fdt_ro.c b/libfdt/fdt_ro.c index f358a20..8dab7a8 100644 --- a/libfdt/fdt_ro.c +++ b/libfdt/fdt_ro.c @@ -62,8 +62,8 @@ return err; \ } -static int offset_streq(const void *fdt, int offset, - const char *s, int len) +static int nodename_eq(const void *fdt, int offset, + const char *s, int len) { const char *p = fdt_offset_ptr(fdt, offset, len+1); @@ -74,10 +74,12 @@ static int offset_streq(const void *fdt, int offset, if (memcmp(p, s, len) != 0) return 0; - if (p[len] != '\0') + if (p[len] == '\0') + return 1; + else if (!memchr(s, '@', len) && (p[len] == '@')) + return 1; + else return 0; - - return 1; } char *fdt_string(const void *fdt, int stroffset) @@ -110,7 +112,7 @@ int fdt_subnode_offset_namelen(const void *fdt, int parentoffset, level++; if (level != 1) continue; - if (offset_streq(fdt, offset+FDT_TAGSIZE, name, namelen)) + if (nodename_eq(fdt, offset+FDT_TAGSIZE, name, namelen)) /* Found it! */ return offset; break; diff --git a/tests/del_node.c b/tests/del_node.c index 26bb061..51b12b2 100644 --- a/tests/del_node.c +++ b/tests/del_node.c @@ -42,21 +42,21 @@ int main(int argc, char *argv[]) oldsize = fdt_totalsize(fdt); - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); + subnode1_offset = fdt_path_offset(fdt, "/subnode@1"); if (subnode1_offset < 0) - FAIL("Couldn't find \"/subnode1\": %s", + FAIL("Couldn't find \"/subnode@1\": %s", fdt_strerror(subnode1_offset)); check_getprop_typed(fdt, subnode1_offset, "prop-int", TEST_VALUE_1); - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); + subnode2_offset = fdt_path_offset(fdt, "/subnode@2"); if (subnode2_offset < 0) - FAIL("Couldn't find \"/subnode2\": %s", + FAIL("Couldn't find \"/subnode@2\": %s", fdt_strerror(subnode2_offset)); check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2); - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); + subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode"); if (subsubnode2_offset < 0) - FAIL("Couldn't find \"/subnode2/subsubnode\": %s", + FAIL("Couldn't find \"/subnode@2/subsubnode\": %s", fdt_strerror(subsubnode2_offset)); check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2); @@ -64,21 +64,21 @@ int main(int argc, char *argv[]) if (err) FAIL("fdt_del_node(subnode1): %s", fdt_strerror(err)); - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); + subnode1_offset = fdt_path_offset(fdt, "/subnode@1"); if (subnode1_offset != -FDT_ERR_NOTFOUND) FAIL("fdt_path_offset(subnode1) returned \"%s\" instead of \"%s\"", fdt_strerror(subnode1_offset), fdt_strerror(-FDT_ERR_NOTFOUND)); - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); + subnode2_offset = fdt_path_offset(fdt, "/subnode@2"); if (subnode2_offset < 0) FAIL("Couldn't find \"/subnode2\": %s", fdt_strerror(subnode2_offset)); check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2); - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); + subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode"); if (subsubnode2_offset < 0) - FAIL("Couldn't find \"/subnode2/subsubnode\": %s", + FAIL("Couldn't find \"/subnode@2/subsubnode\": %s", fdt_strerror(subsubnode2_offset)); check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2); @@ -86,19 +86,19 @@ int main(int argc, char *argv[]) if (err) FAIL("fdt_del_node(subnode2): %s", fdt_strerror(err)); - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); + subnode1_offset = fdt_path_offset(fdt, "/subnode@1"); if (subnode1_offset != -FDT_ERR_NOTFOUND) FAIL("fdt_path_offset(subnode1) returned \"%s\" instead of \"%s\"", fdt_strerror(subnode1_offset), fdt_strerror(-FDT_ERR_NOTFOUND)); - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); + subnode2_offset = fdt_path_offset(fdt, "/subnode@2"); if (subnode2_offset != -FDT_ERR_NOTFOUND) FAIL("fdt_path_offset(subnode2) returned \"%s\" instead of \"%s\"", fdt_strerror(subnode2_offset), fdt_strerror(-FDT_ERR_NOTFOUND)); - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); + subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode"); if (subsubnode2_offset != -FDT_ERR_NOTFOUND) FAIL("fdt_path_offset(subsubnode2) returned \"%s\" instead of \"%s\"", fdt_strerror(subsubnode2_offset), diff --git a/tests/get_name.c b/tests/get_name.c index aef4d9c..2481741 100644 --- a/tests/get_name.c +++ b/tests/get_name.c @@ -74,10 +74,10 @@ int main(int argc, char *argv[]) fdt = load_blob_arg(argc, argv); check_name(fdt, "/"); - check_name(fdt, "/subnode1"); - check_name(fdt, "/subnode2"); - check_name(fdt, "/subnode1/subsubnode"); - check_name(fdt, "/subnode2/subsubnode"); + check_name(fdt, "/subnode@1"); + check_name(fdt, "/subnode@2"); + check_name(fdt, "/subnode@1/subsubnode"); + check_name(fdt, "/subnode@2/subsubnode@0"); PASS(); } diff --git a/tests/get_path.c b/tests/get_path.c index 1f09479..eb217bd 100644 --- a/tests/get_path.c +++ b/tests/get_path.c @@ -82,10 +82,10 @@ int main(int argc, char *argv[]) fdt = load_blob_arg(argc, argv); check_path(fdt, "/"); - check_path(fdt, "/subnode1"); - check_path(fdt, "/subnode2"); - check_path(fdt, "/subnode1/subsubnode"); - check_path(fdt, "/subnode2/subsubnode"); + check_path(fdt, "/subnode@1"); + check_path(fdt, "/subnode@2"); + check_path(fdt, "/subnode@1/subsubnode"); + check_path(fdt, "/subnode@2/subsubnode@0"); PASS(); } diff --git a/tests/node_offset_by_prop_value.c b/tests/node_offset_by_prop_value.c index b56cdf5..651bc05 100644 --- a/tests/node_offset_by_prop_value.c +++ b/tests/node_offset_by_prop_value.c @@ -83,10 +83,10 @@ int main(int argc, char *argv[]) test_init(argc, argv); fdt = load_blob_arg(argc, argv); - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); - subsubnode1_offset = fdt_path_offset(fdt, "/subnode1/subsubnode"); - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); + subnode1_offset = fdt_path_offset(fdt, "/subnode@1"); + subnode2_offset = fdt_path_offset(fdt, "/subnode@2"); + subsubnode1_offset = fdt_path_offset(fdt, "/subnode@1/subsubnode"); + subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode@0"); if ((subnode1_offset < 0) || (subnode2_offset < 0) || (subsubnode1_offset < 0) || (subsubnode2_offset < 0)) diff --git a/tests/nop_node.c b/tests/nop_node.c index 80cf4d0..ab487a4 100644 --- a/tests/nop_node.c +++ b/tests/nop_node.c @@ -39,21 +39,21 @@ int main(int argc, char *argv[]) test_init(argc, argv); fdt = load_blob_arg(argc, argv); - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); + subnode1_offset = fdt_path_offset(fdt, "/subnode@1"); if (subnode1_offset < 0) FAIL("Couldn't find \"/subnode1\": %s", fdt_strerror(subnode1_offset)); check_getprop_typed(fdt, subnode1_offset, "prop-int", TEST_VALUE_1); - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); + subnode2_offset = fdt_path_offset(fdt, "/subnode@2"); if (subnode2_offset < 0) FAIL("Couldn't find \"/subnode2\": %s", fdt_strerror(subnode2_offset)); check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2); - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); + subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode"); if (subsubnode2_offset < 0) - FAIL("Couldn't find \"/subnode2/subsubnode\": %s", + FAIL("Couldn't find \"/subnode@2/subsubnode\": %s", fdt_strerror(subsubnode2_offset)); check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2); @@ -61,21 +61,21 @@ int main(int argc, char *argv[]) if (err) FAIL("fdt_nop_node(subnode1): %s", fdt_strerror(err)); - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); + subnode1_offset = fdt_path_offset(fdt, "/subnode@1"); if (subnode1_offset != -FDT_ERR_NOTFOUND) FAIL("fdt_path_offset(subnode1) returned \"%s\" instead of \"%s\"", fdt_strerror(subnode1_offset), fdt_strerror(-FDT_ERR_NOTFOUND)); - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); + subnode2_offset = fdt_path_offset(fdt, "/subnode@2"); if (subnode2_offset < 0) FAIL("Couldn't find \"/subnode2\": %s", fdt_strerror(subnode2_offset)); check_getprop_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2); - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); + subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode"); if (subsubnode2_offset < 0) - FAIL("Couldn't find \"/subnode2/subsubnode\": %s", + FAIL("Couldn't find \"/subnode@2/subsubnode\": %s", fdt_strerror(subsubnode2_offset)); check_getprop_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2); @@ -83,19 +83,19 @@ int main(int argc, char *argv[]) if (err) FAIL("fdt_nop_node(subnode2): %s", fdt_strerror(err)); - subnode1_offset = fdt_path_offset(fdt, "/subnode1"); + subnode1_offset = fdt_path_offset(fdt, "/subnode@1"); if (subnode1_offset != -FDT_ERR_NOTFOUND) FAIL("fdt_path_offset(subnode1) returned \"%s\" instead of \"%s\"", fdt_strerror(subnode1_offset), fdt_strerror(-FDT_ERR_NOTFOUND)); - subnode2_offset = fdt_path_offset(fdt, "/subnode2"); + subnode2_offset = fdt_path_offset(fdt, "/subnode@2"); if (subnode2_offset != -FDT_ERR_NOTFOUND) FAIL("fdt_path_offset(subnode2) returned \"%s\" instead of \"%s\"", fdt_strerror(subnode2_offset), fdt_strerror(-FDT_ERR_NOTFOUND)); - subsubnode2_offset = fdt_path_offset(fdt, "/subnode2/subsubnode"); + subsubnode2_offset = fdt_path_offset(fdt, "/subnode@2/subsubnode"); if (subsubnode2_offset != -FDT_ERR_NOTFOUND) FAIL("fdt_path_offset(subsubnode2) returned \"%s\" instead of \"%s\"", fdt_strerror(subsubnode2_offset), diff --git a/tests/notfound.c b/tests/notfound.c index e8d0582..ae28c44 100644 --- a/tests/notfound.c +++ b/tests/notfound.c @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) val = fdt_getprop(fdt, 0, "nonexistant-property", &lenerr); check_error("fdt_getprop(\"nonexistant-property\"", lenerr); - subnode1_offset = fdt_subnode_offset(fdt, 0, "subnode1"); + subnode1_offset = fdt_subnode_offset(fdt, 0, "subnode@1"); if (subnode1_offset < 0) FAIL("Couldn't find subnode1: %s", fdt_strerror(subnode1_offset)); diff --git a/tests/parent_offset.c b/tests/parent_offset.c index f3d2c32..309ef6c 100644 --- a/tests/parent_offset.c +++ b/tests/parent_offset.c @@ -77,10 +77,10 @@ int main(int argc, char *argv[]) test_init(argc, argv); fdt = load_blob_arg(argc, argv); - check_path(fdt, "/subnode1"); - check_path(fdt, "/subnode2"); - check_path(fdt, "/subnode1/subsubnode"); - check_path(fdt, "/subnode2/subsubnode"); + check_path(fdt, "/subnode@1"); + check_path(fdt, "/subnode@2"); + check_path(fdt, "/subnode@1/subsubnode"); + check_path(fdt, "/subnode@2/subsubnode@0"); err = fdt_parent_offset(fdt, 0); if (err != -FDT_ERR_NOTFOUND) FAIL("fdt_parent_offset(/) returns %d instead of " diff --git a/tests/path_offset.c b/tests/path_offset.c index c962000..834bc93 100644 --- a/tests/path_offset.c +++ b/tests/path_offset.c @@ -48,7 +48,7 @@ int check_subnode(void *fdt, int parent, const char *name) if (tag != FDT_BEGIN_NODE) FAIL("Incorrect tag 0x%08x on property \"%s\"", tag, name); - if (!streq(nh->name, name)) + if (!nodename_eq(nh->name, name)) FAIL("Subnode name mismatch \"%s\" instead of \"%s\"", nh->name, name); @@ -61,8 +61,8 @@ int main(int argc, char *argv[]) int root_offset; int subnode1_offset, subnode2_offset; int subnode1_offset_p, subnode2_offset_p; - int subsubnode1_offset, subsubnode2_offset; - int subsubnode1_offset_p, subsubnode2_offset_p; + int subsubnode1_offset, subsubnode2_offset, subsubnode2_offset2; + int subsubnode1_offset_p, subsubnode2_offset_p, subsubnode2_offset2_p; test_init(argc, argv); fdt = load_blob_arg(argc, argv); @@ -74,11 +74,11 @@ int main(int argc, char *argv[]) else if (root_offset != 0) FAIL("fdt_path_offset(\"/\") returns incorrect offset %d", root_offset); - subnode1_offset = check_subnode(fdt, 0, "subnode1"); - subnode2_offset = check_subnode(fdt, 0, "subnode2"); + subnode1_offset = check_subnode(fdt, 0, "subnode@1"); + subnode2_offset = check_subnode(fdt, 0, "subnode@2"); - subnode1_offset_p = fdt_path_offset(fdt, "/subnode1"); - subnode2_offset_p = fdt_path_offset(fdt, "/subnode2"); + subnode1_offset_p = fdt_path_offset(fdt, "/subnode@1"); + subnode2_offset_p = fdt_path_offset(fdt, "/subnode@2"); if (subnode1_offset != subnode1_offset_p) FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)", @@ -89,10 +89,12 @@ int main(int argc, char *argv[]) subnode2_offset, subnode2_offset_p); subsubnode1_offset = check_subnode(fdt, subnode1_offset, "subsubnode"); - subsubnode2_offset = check_subnode(fdt, subnode2_offset, "subsubnode"); + subsubnode2_offset = check_subnode(fdt, subnode2_offset, "subsubnode@0"); + subsubnode2_offset2 = check_subnode(fdt, subnode2_offset, "subsubnode"); - subsubnode1_offset_p = fdt_path_offset(fdt, "/subnode1/subsubnode"); - subsubnode2_offset_p = fdt_path_offset(fdt, "/subnode2/subsubnode"); + subsubnode1_offset_p = fdt_path_offset(fdt, "/subnode@1/subsubnode"); + subsubnode2_offset_p = fdt_path_offset(fdt, "/subnode@2/subsubnode@0"); + subsubnode2_offset2_p = fdt_path_offset(fdt, "/subnode@2/subsubnode"); if (subsubnode1_offset != subsubnode1_offset_p) FAIL("Mismatch between subnode_offset (%d) and path_offset (%d)", diff --git a/tests/rw_tree1.c b/tests/rw_tree1.c index 3fb9307..099b3f4 100644 --- a/tests/rw_tree1.c +++ b/tests/rw_tree1.c @@ -72,14 +72,14 @@ int main(int argc, char *argv[]) CHECK(fdt_setprop_typed(fdt, 0, "prop-int", TEST_VALUE_1)); CHECK(fdt_setprop_string(fdt, 0, "prop-str", TEST_STRING_1)); - OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode1")); + OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@1")); CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_1)); OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode")); CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_1)); - OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode2")); + OFF_CHECK(offset, fdt_add_subnode(fdt, 0, "subnode@2")); CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_2)); - OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode")); + OFF_CHECK(offset, fdt_add_subnode(fdt, offset, "subsubnode@0")); CHECK(fdt_setprop_typed(fdt, offset, "prop-int", TEST_VALUE_2)); diff --git a/tests/subnode_offset.c b/tests/subnode_offset.c index d4edfe4..eafce2c 100644 --- a/tests/subnode_offset.c +++ b/tests/subnode_offset.c @@ -48,7 +48,7 @@ int check_subnode(struct fdt_header *fdt, int parent, const char *name) if (tag != FDT_BEGIN_NODE) FAIL("Incorrect tag 0x%08x on property \"%s\"", tag, name); - if (!streq(nh->name, name)) + if (!nodename_eq(nh->name, name)) FAIL("Subnode name mismatch \"%s\" instead of \"%s\"", nh->name, name); @@ -59,13 +59,13 @@ int main(int argc, char *argv[]) { void *fdt; int subnode1_offset, subnode2_offset; - int subsubnode1_offset, subsubnode2_offset; + int subsubnode1_offset, subsubnode2_offset, subsubnode2_offset2; test_init(argc, argv); fdt = load_blob_arg(argc, argv); - subnode1_offset = check_subnode(fdt, 0, "subnode1"); - subnode2_offset = check_subnode(fdt, 0, "subnode2"); + subnode1_offset = check_subnode(fdt, 0, "subnode@1"); + subnode2_offset = check_subnode(fdt, 0, "subnode@2"); if (subnode1_offset == subnode2_offset) FAIL("Different subnodes have same offset"); @@ -74,10 +74,15 @@ int main(int argc, char *argv[]) check_property_typed(fdt, subnode2_offset, "prop-int", TEST_VALUE_2); subsubnode1_offset = check_subnode(fdt, subnode1_offset, "subsubnode"); - subsubnode2_offset = check_subnode(fdt, subnode2_offset, "subsubnode"); + subsubnode2_offset = check_subnode(fdt, subnode2_offset, "subsubnode@0"); + subsubnode2_offset2 = check_subnode(fdt, subnode2_offset, "subsubnode"); check_property_typed(fdt, subsubnode1_offset, "prop-int", TEST_VALUE_1); check_property_typed(fdt, subsubnode2_offset, "prop-int", TEST_VALUE_2); + check_property_typed(fdt, subsubnode2_offset2, "prop-int", TEST_VALUE_2); + + if (subsubnode2_offset != subsubnode2_offset2) + FAIL("Different offsets with and without unit address"); PASS(); } diff --git a/tests/supernode_atdepth_offset.c b/tests/supernode_atdepth_offset.c index 6736aca..39cade6 100644 --- a/tests/supernode_atdepth_offset.c +++ b/tests/supernode_atdepth_offset.c @@ -135,10 +135,10 @@ int main(int argc, char *argv[]) fdt = load_blob_arg(argc, argv); check_path(fdt, "/"); - check_path(fdt, "/subnode1"); - check_path(fdt, "/subnode2"); - check_path(fdt, "/subnode1/subsubnode"); - check_path(fdt, "/subnode2/subsubnode"); + check_path(fdt, "/subnode@1"); + check_path(fdt, "/subnode@2"); + check_path(fdt, "/subnode@1/subsubnode"); + check_path(fdt, "/subnode@2/subsubnode@0"); PASS(); } diff --git a/tests/sw_tree1.c b/tests/sw_tree1.c index 7b54359..34bee4f 100644 --- a/tests/sw_tree1.c +++ b/tests/sw_tree1.c @@ -54,16 +54,16 @@ int main(int argc, char *argv[]) CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1)); CHECK(fdt_property_string(fdt, "prop-str", TEST_STRING_1)); - CHECK(fdt_begin_node(fdt, "subnode1")); + CHECK(fdt_begin_node(fdt, "subnode@1")); CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1)); CHECK(fdt_begin_node(fdt, "subsubnode")); CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_1)); CHECK(fdt_end_node(fdt)); CHECK(fdt_end_node(fdt)); - CHECK(fdt_begin_node(fdt, "subnode2")); + CHECK(fdt_begin_node(fdt, "subnode@2")); CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_2)); - CHECK(fdt_begin_node(fdt, "subsubnode")); + CHECK(fdt_begin_node(fdt, "subsubnode@0")); CHECK(fdt_property_typed(fdt, "prop-int", TEST_VALUE_2)); CHECK(fdt_end_node(fdt)); CHECK(fdt_end_node(fdt)); diff --git a/tests/test_tree1.dts b/tests/test_tree1.dts index 5ddc208..30091f1 100644 --- a/tests/test_tree1.dts +++ b/tests/test_tree1.dts @@ -2,7 +2,7 @@ prop-int = <deadbeef>; prop-str = "hello world"; - subnode1 { + subnode@1 { prop-int = <deadbeef>; subsubnode { @@ -10,10 +10,10 @@ }; }; - subnode2 { + subnode@2 { prop-int = <abcd1234>; - subsubnode { + subsubnode@0 { prop-int = <abcd1234>; }; }; diff --git a/tests/tests.h b/tests/tests.h index ace7ba3..62716ce 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -126,6 +126,7 @@ const void *check_getprop(void *fdt, int nodeoffset, const char *name, }) #define check_getprop_string(fdt, nodeoffset, name, s) \ check_getprop((fdt), (nodeoffset), (name), strlen(s)+1, (s)) +int nodename_eq(const char *s1, const char *s2); //void *load_blob(const char *filename); void *load_blob_arg(int argc, char *argv[]); void save_blob(const char *filename, void *blob); diff --git a/tests/testutils.c b/tests/testutils.c index 82aebc5..68cc88a 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -125,6 +125,21 @@ const void *check_getprop(void *fdt, int nodeoffset, const char *name, return propval; } +int nodename_eq(const char *s1, const char *s2) +{ + int len = strlen(s2); + + len = strlen(s2); + if (strncmp(s1, s2, len) != 0) + return 0; + if (s1[len] == '\0') + return 1; + else if (!memchr(s2, '@', len) && (s1[len] == '@')) + return 1; + else + return 0; +} + #define CHUNKSIZE 128 void *load_blob(const char *filename) diff --git a/tests/trees.S b/tests/trees.S index 60e1b55..78c92d7 100644 --- a/tests/trees.S +++ b/tests/trees.S @@ -78,7 +78,7 @@ test_tree1_struct: PROP_INT(test_tree1, prop_int, TEST_VALUE_1) PROP_STR(test_tree1, prop_str, TEST_STRING_1) - BEGIN_NODE("subnode1") + BEGIN_NODE("subnode@1") PROP_INT(test_tree1, prop_int, TEST_VALUE_1) BEGIN_NODE("subsubnode") @@ -86,10 +86,10 @@ test_tree1_struct: END_NODE END_NODE - BEGIN_NODE("subnode2") + BEGIN_NODE("subnode@2") PROP_INT(test_tree1, prop_int, TEST_VALUE_2) - BEGIN_NODE("subsubnode") + BEGIN_NODE("subsubnode@0") PROP_INT(test_tree1, prop_int, TEST_VALUE_2) END_NODE END_NODE |