diff --git a/dts/bindings/test/vnd,great-grandchild-bindings.yaml b/dts/bindings/test/vnd,great-grandchild-bindings.yaml new file mode 100644 index 00000000000..c2a89b550ce --- /dev/null +++ b/dts/bindings/test/vnd,great-grandchild-bindings.yaml @@ -0,0 +1,27 @@ +# Copyright (c) 2020 Nordic Semiconductor ASA +# SPDX-License-Identifier: Apache-2.0 + +description: | + Test binding for 3 levels of "child-binding". + + Previous versions of Zephyr only allowed up to two levels of + "child-binding:" in a YAML file. This file is used to test that the + restriction no longer holds. + +compatible: "vnd,great-grandchild-bindings" + +include: [base.yaml] + +child-binding: + description: child node, no properties + + child-binding: + description: grandchild node, no properties + + child-binding: + description: great-grandchild node, ggc-prop property + + properties: + ggc-prop: + type: int + required: true diff --git a/tests/lib/devicetree/app.overlay b/tests/lib/devicetree/app.overlay index 5ad052821bb..913fc72d2a3 100644 --- a/tests/lib/devicetree/app.overlay +++ b/tests/lib/devicetree/app.overlay @@ -332,5 +332,17 @@ val = <2>; }; }; + + test-great-grandchildren { + compatible = "vnd,great-grandchild-bindings"; + + child { + grandchild { + test_ggc: great-grandchild { + ggc-prop = <42>; + }; + }; + }; + }; }; }; diff --git a/tests/lib/devicetree/src/main.c b/tests/lib/devicetree/src/main.c index cdf1d5fdd14..c83475e513f 100644 --- a/tests/lib/devicetree/src/main.c +++ b/tests/lib/devicetree/src/main.c @@ -1442,6 +1442,12 @@ static void test_child_nodes_list(void) #undef TEST_FUNC } +static void test_great_grandchild(void) +{ + zassert_equal(DT_PROP(DT_NODELABEL(test_ggc), ggc_prop), + 42, "great-grandchild bindings returned wrong value"); +} + void test_main(void) { ztest_test_suite(devicetree_api, @@ -1471,7 +1477,8 @@ void test_main(void) ztest_unit_test(test_enums), ztest_unit_test(test_clocks), ztest_unit_test(test_parent), - ztest_unit_test(test_child_nodes_list) + ztest_unit_test(test_child_nodes_list), + ztest_unit_test(test_great_grandchild) ); ztest_run_test_suite(devicetree_api); }