tests: devicetree: test great-grandchild bindings

At some point, "child-binding:" apparently only worked up to 2 levels
deep. That's not the case anymore, but add a regression test to make
sure that doesn't break. 3 levels deep ought to be enough for anyone.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2020-05-26 13:01:10 -07:00 committed by Carles Cufí
commit 930c5807d5
3 changed files with 47 additions and 1 deletions

View file

@ -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

View file

@ -332,5 +332,17 @@
val = <2>;
};
};
test-great-grandchildren {
compatible = "vnd,great-grandchild-bindings";
child {
grandchild {
test_ggc: great-grandchild {
ggc-prop = <42>;
};
};
};
};
};
};

View file

@ -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);
}