Commit 930c5807 authored by Martí Bolívar's avatar Martí Bolívar Committed by Carles Cufi
Browse files

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: default avatarMartí Bolívar <marti.bolivar@nordicsemi.no>
parent 71686dde
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
# 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
+12 −0
Original line number Diff line number Diff line
@@ -332,5 +332,17 @@
				val = <2>;
			};
		};

		test-great-grandchildren {
			compatible = "vnd,great-grandchild-bindings";

			child {
				grandchild {
					test_ggc: great-grandchild {
						ggc-prop = <42>;
					};
				};
			};
		};
	};
};
+8 −1
Original line number Diff line number Diff line
@@ -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);
}