diff options
author | Daniel Axtens <dja@axtens.net> | 2015-02-27 16:06:35 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-03-05 11:27:54 +1100 |
commit | d718afa570473277a47db7e562cafde4cc5e327e (patch) | |
tree | dc4cce7dc5d04ab6d09d922d60f1f95ba8e3e51d /core | |
parent | 8030a32728190414d85974a9b9192f43e9e7325d (diff) | |
download | skiboot-d718afa570473277a47db7e562cafde4cc5e327e.zip skiboot-d718afa570473277a47db7e562cafde4cc5e327e.tar.gz skiboot-d718afa570473277a47db7e562cafde4cc5e327e.tar.bz2 |
core/test: Test compatible, chip id and phandle related DT functions
Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/test/run-device.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/core/test/run-device.c b/core/test/run-device.c index 101b56f..cd6ec8d 100644 --- a/core/test/run-device.c +++ b/core/test/run-device.c @@ -54,6 +54,7 @@ int main(void) unsigned int n; char *s; size_t sz; + u32 phandle; root = dt_new_root(""); assert(!list_top(&root->properties, struct dt_property, list)); @@ -241,5 +242,60 @@ int main(void) /* No leaks for valgrind! */ dt_free(root); + + /* Test compatible and chip id. */ + root = dt_new_root(""); + + c1 = dt_new(root, "chip1"); + dt_add_property_cells(c1, "ibm,chip-id", 0xcafe); + assert(dt_get_chip_id(c1) == 0xcafe); + dt_add_property_strings(c1, "compatible", + "specific-fake-chip", + "generic-fake-chip"); + assert(dt_node_is_compatible(c1, "specific-fake-chip")); + assert(dt_node_is_compatible(c1, "generic-fake-chip")); + + c2 = dt_new(root, "chip2"); + dt_add_property_cells(c2, "ibm,chip-id", 0xbeef); + assert(dt_get_chip_id(c2) == 0xbeef); + dt_add_property_strings(c2, "compatible", + "specific-fake-bus", + "generic-fake-bus"); + + gc1 = dt_new(c1, "coprocessor1"); + dt_add_property_strings(gc1, "compatible", + "specific-fake-coprocessor"); + + gc2 = dt_new(c1, "node-without-compatible"); + assert(__dt_find_property(gc2, "compatible") == NULL); + assert(!dt_node_is_compatible(gc2, "any-property")); + + assert(dt_find_compatible_node(root, NULL, "generic-fake-bus") == c2); + assert(dt_find_compatible_node(root, c2, "generic-fake-bus") == NULL); + + /* we can find the coprocessor once on the cpu */ + assert(dt_find_compatible_node_on_chip(root, + NULL, + "specific-fake-coprocessor", + 0xcafe) == gc1); + assert(dt_find_compatible_node_on_chip(root, + gc1, + "specific-fake-coprocessor", + 0xcafe) == NULL); + + /* we can't find the coprocessor on the bus */ + assert(dt_find_compatible_node_on_chip(root, + NULL, + "specific-fake-coprocessor", + 0xbeef) == NULL); + + /* Test phandles. We override the automatically generated one. */ + phandle = 0xf00; + dt_add_property(gc2, "phandle", (const void *)&phandle, 4); + assert(last_phandle == 0xf00); + assert(dt_find_by_phandle(root, 0xf00) == gc2); + assert(dt_find_by_phandle(root, 0xf0f) == NULL); + + dt_free(root); return 0; } |