-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
edtlib: tests: refine coverage of Binding objects initialization #79900
edtlib: tests: refine coverage of Binding objects initialization #79900
Conversation
The build failure seems to be unrelated to this change.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this commit from #78095 then? I assume it is verbatim the same that I reviewed there?
I think so too: if this PR were to fail by itself, it would do so in some "Devicetree script tests", since it only adds unit tests to python-devicetree (which are not supposed to fail). |
No, it's not. This PR adds only the unit tests that the current implementation of The other tests will be added as we address the issues raised incidentally while working on #78095:
The rationale is to merge (and run) unit tests as soon as we can to avoid regressions as we triage/fix the above issues. [Edit: then we may rebase #78095 onto all this, and rethink the |
Ok, good. IIRC you wanted to add separate issues for those, right? If you like you could reference PRs with the corresponding failing tests to those issues. I'll try to address those issues as quickly as possible then once we agreed in arch WG what the general direction will be for configuration. |
I think commit eb45da5 has since fixed the unrelated error reported by the CI.
@fgrandel , I pushed a PR reverting #65221, which seems to address all known issues with property filters (#79948): could you please take a look at #80030 ? The only remaining concerns that I'm aware of are (with failing unit tests at hand):
Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confusing, at least for me with my limited brain capacity. But I'm referring with this to the include and inheritance system itself. The tests themselves are as clear as possible, considering the complexity of the tested system.
True. Includes is fine but the filters are not. IMO another instance of how convoluted design generates more convoluted design. Had we made it easier to influence the schema below the parent node in more flexible and obvious ways, we'd probably never had the idea to first design an inappropriate schema just to make it appropriate down the inheritance line by filtering it. :-D I don't think anyone will want to use filters once we have a proper child definition language in place. I'm quite positive that we'll be able to deprecate filtering down the line. |
@dottspina Have you seen that there are failing tests? Guess you'll have to fix them (even though they seem be unrelated) before you get more reviews. ;-) Maybe a rebase helps? |
9d85da0
to
17a0e39
Compare
I was thinking of perhaps waiting until #80030 is merged, to be able to add the unit tests for inheritance here (which would otherwise fail).
Thanks. |
Just my two cents: yes, the include and inheritance system is, in a way, confusing by-design, I've felt it more than once too, but I'm not so sure the issue is specifically the use of property filters to describe child bindings. AFAICT, the Let me give an example, based on compatible: "st,stm32-temp-cal"
include:
- name: st,stm32-temp-cal-common.yaml
property-blocklist:
- avgslope
- ntc Here, Same when this happens at the (grand) child binding level, e.g. in child-binding:
description: LPC IOCON pin controller pin group
child-binding:
description: |
LPC IOCON pin controller pin configuration node
include:
- name: pincfg-node.yaml
property-allowlist:
- drive-open-drain
- bias-pull-up
- bias-pull-down
- drive-push-pull
- input-schmitt-enable What troubles me is rather reading bindings like bellow ( compatible: "renesas,smartbond-lp-osc"
include:
- name: fixed-clock.yaml
property-allowlist:
- status
- compatible
- clock-frequency Here I find confusing that we recursively pull all properties specified in
If we were able to describe the binding as bellow, everything would be crystal clear:
The above example is a bit simplistic, just to sketch out my thinking. Now take a look at this ( compatible: "nordic,owned-partitions"
include:
- name: nordic,owned-memory.yaml
property-blocklist:
- reg
child-binding:
include:
- name: base.yaml
property-blocklist:
- compatible
properties:
reg:
required: true Try to guess what this binding (compatible) is for without the human readable Compared to, e.g.: compatible: "nordic,owned-partitions"
include: nordic,partition-table.yaml
child-binding:
include: memory-partition.yaml To me, these examples don't show that property filters (at any level) are broken per se, but perhaps we're missing the finer-grained basic bindings that would allow us to write more consistent (and readable) device bindings. Another aspect of the
As previously mentioned, IMO property filters were introduced to be able to quickly add supported devices without having to first multiply base bindings with stricter separation of concerns, not as something specifically needed (or useful) to describe child bindings (child nodes). This is not to say that approaches like #79751 are not interesting (or even desirable), just that it does not seem to address the same use cases |
17a0e39
to
0cc4fb8
Compare
Updated PR content:
Inheritance of bindings' descriptions and compatible stringsConsider the binding file bellow: description: Binding's description.
compatible: vnd,device
include:
- name: base_first.yaml
- name: base_last.yaml Where both The rules deduced from the
With the same inheritance diagram, the included first wins rule also applies to property descriptions inheritance. I previously assumed that in these later situations the included last would instead win, as long as overwriting descriptions and compatible strings is permitted, and corresponding unit tests were put aside because they were known to fail. Indirect property filtersThis PR now also includes the unit tests which cover all issues documented in #79948. These six unit tests are expected to fail until the issues are fixed (see #80030), and disabled by default, e.g.: # Disable testing a known issue:
# - edtlib: indirect "include:"s break property filters
# - https://github.com/zephyrproject-rtos/zephyr/issues/79948
#
# See also:
# - https://github.com/zephyrproject-rtos/zephyr/pull/80030
TEST_ISSUE_79948: bool = os.environ.get("EDTLIB_TEST_ISSUE_79948") is not None
@pytest.mark.skipif(not TEST_ISSUE_79948, reason="Expected to fail (#79948).")
def test_filter_inherited_propspecs_basics() -> None:
... Rationale:
Last modified semanticIn #65221 we tried to get more valuable answers from the This patch:
We decided to forget all this until we find a proper approach: nothing here tests this last modified thing, and #80030 will also revert the related unit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Very thorough. I checked about 70% of these in detail and skimmed the rest, LGTM. From your comment in #79948, this needs to be rebased now since the tests that are expected to fail should be fixed, right?
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# Top level binding file (device binding) for testing | ||
# descirptions and compatible strings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: 'descriptions'
|
||
Args: | ||
propsec: The property specification to verify. | ||
expect_type: The exepected property type definition. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'expected' typo
# | ||
# See also: | ||
# - https://github.com/zephyrproject-rtos/zephyr/pull/80030 | ||
TEST_ISSUE_79948: bool = os.environ.get("EDTLIB_TEST_ISSUE_79948") is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#79948 is closed now -- I guess it's time to rebase and remove this? Or did I misunderstand that issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 18 out of 33 changed files in this pull request and generated no suggestions.
Files not reviewed (15)
- scripts/dts/python-devicetree/tests/test-bindings-init/invalid_child_proptype.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/invalid_grandchild_propdefault.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/base_inherit.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/base_multi.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/compat_desc.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/compat_desc_base.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/compat_desc_multi.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/filter_allows_notblocked.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/invalid_grandchild_propreq.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/base_amend.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/diamond.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/invalid_child_propconst.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/invalid_child_propdefault.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/invalid_grandchild_propenum.yaml: Evaluated as low risk
- scripts/dts/python-devicetree/tests/test-bindings-init/filter_among_allowed.yaml: Evaluated as low risk
0cc4fb8
to
d161aca
Compare
d161aca
to
e7c7b21
Compare
Add a series of unit tests which try to cover somewhat systematically the possible inputs and what we finally get at the exit of the Binding constructor. Running the assumption that any (valid) YAML binding file is something we can make a Binding instance with: - check which properties are defined at which level (binding, child-binding, grandchild-binding, etc) and their specifications once the binding is initialized - check how including bindings are permitted to specialize the specifications of inherited properties - check the rules applied when overwriting a binding's description or compatible string (at the binding, child-binding, etc, levels) Some tests covering known issues are disabled by default: - this permits to document these issues - while not causing CI errors (when running the python-devicetree unit tests) - enabling these tests without causing errors should allow us to consider the related issues are fixed Signed-off-by: Christophe Dufaza <[email protected]>
e7c7b21
to
07c5d89
Compare
@mbolivar , thank you for your careful review.
Right, I removed all Note that to comply with the new ruff linter a few other changes were required:
So it seems there are a lot of changes, but it's actually only fixing the typo you reported, and removing the Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Bindings initialization supports a rich include mechanism:
include:
ed at any level: binding, child-binding, grandchild-binding, etc, the specified properties being injected (in cascade) at the level of inclusioninclude:
appears, the including binding may filter the properties it chooses to inherit at the binding, child-binding, etc, levels; these filters apply across included filesrequired: true
or changing aconst:
value)All this happens (recursively) in the
Binding
constructor, independently of any actual devicetree model (EDT
instance).This commit is the first in a series which will try to cover somewhat systematically the possible inputs and what we finally get at the exit of the constructor once the object is completely initialized.
Thanks.
See also: #78095