diff --git a/scripts/dts/python-devicetree/tests/test-bindings-include/inc-base.yaml b/scripts/dts/python-devicetree/tests/test-bindings-include/inc-base.yaml new file mode 100644 index 00000000000000..59dc45eab0dbbe --- /dev/null +++ b/scripts/dts/python-devicetree/tests/test-bindings-include/inc-base.yaml @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: BSD-3-Clause + +include: base.yaml diff --git a/scripts/dts/python-devicetree/tests/test-bindings-include/top-allows.yaml b/scripts/dts/python-devicetree/tests/test-bindings-include/top-allows.yaml new file mode 100644 index 00000000000000..a4938eb0d67680 --- /dev/null +++ b/scripts/dts/python-devicetree/tests/test-bindings-include/top-allows.yaml @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause + +description: Test property-allowlist filters set by including bindings + +compatible: "top-allowlist" + +include: + - name: inc-base.yaml + property-allowlist: + - x diff --git a/scripts/dts/python-devicetree/tests/test-bindings-include/top-blocks.yaml b/scripts/dts/python-devicetree/tests/test-bindings-include/top-blocks.yaml new file mode 100644 index 00000000000000..787db223a939ee --- /dev/null +++ b/scripts/dts/python-devicetree/tests/test-bindings-include/top-blocks.yaml @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: BSD-3-Clause + +description: Test property-blocklist filters set by including bindings. + +compatible: "top-blocklist" + +include: + - name: inc-base.yaml + property-blocklist: + - x diff --git a/scripts/dts/python-devicetree/tests/test_edtlib.py b/scripts/dts/python-devicetree/tests/test_edtlib.py index 151e61b16aa4fd..a81aa929370a07 100644 --- a/scripts/dts/python-devicetree/tests/test_edtlib.py +++ b/scripts/dts/python-devicetree/tests/test_edtlib.py @@ -378,6 +378,23 @@ def test_include_paths(): assert 'base.yaml' == os.path.basename(top.prop2specs["y"].path) assert 'top.yaml' == os.path.basename(top.prop2specs["p"].path) +def test_include_filters_included_bindings(): + '''Test filters set by including bindings.''' + fname2path = {'base.yaml': 'test-bindings-include/base.yaml', + 'inc-base.yaml': 'test-bindings-include/inc-base.yaml'} + + with from_here(): + top_allows = edtlib.Binding('test-bindings-include/top-allows.yaml', fname2path) + assert top_allows.prop2specs.get("x") + assert not top_allows.prop2specs.get("y") + + with from_here(): + top_blocks = edtlib.Binding('test-bindings-include/top-blocks.yaml', fname2path) + assert not top_blocks.prop2specs.get("x") + assert top_blocks.prop2specs.get("y") + + + def test_bus(): '''Test 'bus:' and 'on-bus:' in bindings''' with from_here():