Skip to content

Commit

Permalink
edtlib: test "last modified" semantic for included property specs
Browse files Browse the repository at this point in the history
Make sure the property specs answered by the Binding.prop2specs API
do not all claim (PropertySpec.path) they were last modified
by the top-level binding.

Signed-off-by: Christophe Dufaza <[email protected]>
  • Loading branch information
dottspina committed Dec 2, 2023
1 parent b1532ce commit 6649266
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause

properties:
x:
type: int
y:
type: int
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause

include: base.yaml

properties:
x:
required: true
21 changes: 21 additions & 0 deletions scripts/dts/python-devicetree/tests/test-bindings-include/top.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-License-Identifier: BSD-3-Clause

description: |
Top-level binding file for testing included property spec paths.
base.yaml: specifies properties "x" and "y"
modified.yaml: includes base.yaml, modifies property "x"
top.yaml (this file): includes modified.yaml, specifies property "p"
From the top-level binding, we expect:
- "x" was last modified in modified.yaml
- "y" was last modified in base.yaml
- "p" was last modified in top.yaml
compatible: top-level

include: modified.yaml

properties:
p:
type: int
12 changes: 12 additions & 0 deletions scripts/dts/python-devicetree/tests/test_edtlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,18 @@ def test_include_filters():
assert set(child.prop2specs.keys()) == {'child-prop-1', 'child-prop-2',
'x', 'z'} # root level 'y' is blocked

def test_include_paths():
'''Test "last modified" semantic for included bindings paths.'''

fname2path = {'base.yaml': 'test-bindings-include/base.yaml',
'modified.yaml': 'test-bindings-include/modified.yaml'}

with from_here():
top = edtlib.Binding('test-bindings-include/top.yaml', fname2path)

assert 'modified.yaml' == os.path.basename(top.prop2specs["x"].path)
assert 'base.yaml' == os.path.basename(top.prop2specs["y"].path)
assert 'top.yaml' == os.path.basename(top.prop2specs["p"].path)

def test_bus():
'''Test 'bus:' and 'on-bus:' in bindings'''
Expand Down

0 comments on commit 6649266

Please sign in to comment.