From 33bb3b60d95b78149b14b7b09753c355f41fffd9 Mon Sep 17 00:00:00 2001 From: Christophe Dufaza Date: Tue, 5 Dec 2023 08:48:10 +0100 Subject: [PATCH] edtlib: test filters set by including bindings Make sure filters set by property-allowlist and property-blocklist in an including binding are recursively applied to included bindings. Signed-off-by: Christophe Dufaza --- .../tests/test-bindings-include/inc-base.yaml | 3 +++ .../tests/test-bindings-include/top-allows.yaml | 10 ++++++++++ .../tests/test-bindings-include/top-blocks.yaml | 10 ++++++++++ .../dts/python-devicetree/tests/test_edtlib.py | 17 +++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 scripts/dts/python-devicetree/tests/test-bindings-include/inc-base.yaml create mode 100644 scripts/dts/python-devicetree/tests/test-bindings-include/top-allows.yaml create mode 100644 scripts/dts/python-devicetree/tests/test-bindings-include/top-blocks.yaml 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 00000000000..59dc45eab0d --- /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 00000000000..a4938eb0d67 --- /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 00000000000..787db223a93 --- /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 151e61b16aa..a81aa929370 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():