Skip to content

Commit ee5c520

Browse files
dottspinakartben
authored andcommitted
edtlib: tests: refine coverage of Binding objects initialization
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]>
1 parent 4ad83e7 commit ee5c520

33 files changed

+1992
-0
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
#
3+
# Base include file for testing bindings initialization.
4+
#
5+
# Involves base property definitions ("type:", "description:", "const:",
6+
# "required:", "enum:" and "default:") up to the grandchild-binding level.
7+
#
8+
# Binding:
9+
# + prop-1
10+
# + prop-2
11+
# + prop-enum
12+
# + prop-req
13+
# + prop-const
14+
# + prop-default
15+
#
16+
# Child-binding:
17+
# + child-prop-1
18+
# + child-prop-2
19+
# + child-prop-enum
20+
# + child-prop-req
21+
# + child-prop-const
22+
# + child-prop-default
23+
#
24+
# Grandchild-binding:
25+
# + grandchild-prop-1
26+
# + grandchild-prop-2
27+
# + grandchild-prop-enum
28+
# + grandchild-prop-req
29+
# + grandchild-prop-const
30+
# + grandchild-prop-default
31+
32+
description: Base property specifications.
33+
34+
properties:
35+
prop-1:
36+
description: Base property 1.
37+
type: int
38+
prop-2:
39+
type: string
40+
prop-enum:
41+
type: string
42+
required: false
43+
enum:
44+
- FOO
45+
- BAR
46+
prop-const:
47+
type: int
48+
const: 8
49+
prop-req:
50+
type: int
51+
required: true
52+
prop-default:
53+
type: int
54+
default: 1
55+
56+
child-binding:
57+
description: Base child-binding description.
58+
59+
properties:
60+
child-prop-1:
61+
description: Base child-prop 1.
62+
type: int
63+
child-prop-2:
64+
type: string
65+
child-prop-enum:
66+
type: string
67+
required: false
68+
enum:
69+
- CHILD_FOO
70+
- CHILD_BAR
71+
child-prop-const:
72+
type: int
73+
const: 16
74+
child-prop-req:
75+
type: int
76+
required: true
77+
child-prop-default:
78+
type: int
79+
default: 2
80+
81+
child-binding:
82+
description: Base grandchild-binding description.
83+
84+
properties:
85+
grandchild-prop-1:
86+
description: Base grandchild-prop 1.
87+
type: int
88+
grandchild-prop-2:
89+
type: string
90+
grandchild-prop-enum:
91+
type: string
92+
required: false
93+
enum:
94+
- GRANDCHILD_FOO
95+
- GRANDCHILD_BAR
96+
grandchild-prop-const:
97+
type: int
98+
const: 32
99+
grandchild-prop-req:
100+
type: int
101+
required: true
102+
grandchild-prop-default:
103+
type: int
104+
default: 3
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
#
3+
# Amends base properties specifications:
4+
# - extends property specifications by adding definitions,
5+
# e.g. setting a "default:" value
6+
# - overwrites existing definitions of a property,
7+
# e.g. change its "description:"
8+
# - specify new properties
9+
#
10+
# The same kind of amendments are applied to the same properties
11+
# at each level (binding, child-binding, grandchild-binding).
12+
#
13+
# | Definition | Extended for | Overwritten for |
14+
# |----------------|--------------|-----------------|
15+
# | description: | prop-2 | prop-1 |
16+
# | required: | | prop-enum |
17+
# | enum: | prop-2 | |
18+
# | const: | prop-1 | |
19+
# | default: | prop-2 | |
20+
#
21+
# Non authorized amendments, e.g. changing a "const:" value
22+
# or downgrading a "required: true" definition are tested separately.
23+
24+
description: Amended description.
25+
26+
include: base.yaml
27+
28+
properties:
29+
prop-1:
30+
# The including binding is permitted to overwrite a property description.
31+
description: Overwritten description.
32+
# The including binding is permitted to set a "const:" value.
33+
const: 0xf0
34+
35+
prop-2:
36+
# The including binding is permitted to add a property description.
37+
description: New description.
38+
# The including binding is permitted to limit property values
39+
# to an enumeration.
40+
enum:
41+
- EXT_FOO
42+
- EXT_BAR
43+
# The including binding is permitted to set a default value.
44+
default: EXT_FOO
45+
46+
# The including binding is permitted to promote a property
47+
# to requirement.
48+
prop-enum:
49+
required: true
50+
51+
# The including binding is permitted to define a new property.
52+
prop-new:
53+
type: int
54+
55+
# Same amendments at the child-binding level.
56+
child-binding:
57+
properties:
58+
child-prop-1:
59+
description: Overwritten description (child).
60+
const: 0xf1
61+
62+
child-prop-2:
63+
description: New description (child).
64+
enum:
65+
- CHILD_EXT_FOO
66+
- CHILD_EXT_BAR
67+
default: CHILD_EXT_FOO
68+
69+
child-prop-enum:
70+
required: true
71+
72+
child-prop-new:
73+
type: int
74+
75+
# Same amendments at the grandchild-binding level.
76+
child-binding:
77+
# Plus amended grandchild-binding description.
78+
description: Amended grandchild-binding description.
79+
80+
properties:
81+
grandchild-prop-1:
82+
description: Overwritten description (grandchild).
83+
const: 0xf2
84+
85+
grandchild-prop-2:
86+
description: New description (grandchild).
87+
enum:
88+
- GRANDCHILD_EXT_FOO
89+
- GRANDCHILD_EXT_BAR
90+
default: GRANDCHILD_EXT_FOO
91+
92+
grandchild-prop-enum:
93+
required: true
94+
95+
grandchild-prop-new:
96+
type: int
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
#
3+
# Inherit base specifications without modification.
4+
5+
include: base.yaml
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
#
3+
# Includes base bindings at multiple levels (binding,
4+
# child-binding, grandchild-binding):
5+
#
6+
# include: base.yaml
7+
# child-binding:
8+
# include: base.yaml
9+
# child-binding:
10+
# include: base.yaml
11+
#
12+
# Which properties are specified at which levels is summarized bellow
13+
# for convenience.
14+
#
15+
# Child-binding level:
16+
# From top-level "include:" element.
17+
# - child-prop-1 (amended)
18+
# - child-prop-2
19+
# - child-prop-enum
20+
# From "child-binding: include:" element.
21+
# - prop-1 (amended)
22+
# - prop-2 (amended)
23+
# - prop-enum (amended)
24+
#
25+
# Grandchild-binding level:
26+
# From top-level "include:" element.
27+
# - grandchild-prop-1 (amended)
28+
# - grandchild-prop-2
29+
# - grandchild-prop-enum
30+
# From "child-binding: include:" element.
31+
# - child-prop-1 (amended)
32+
# - child-prop-2
33+
# - child-prop-enum
34+
# From "child-binding: child-binding: include:" element.
35+
# - prop-1 (amended)
36+
# - prop-2 (amended)
37+
# - prop-enum (amended)
38+
#
39+
# Grand-grandchild-binding level:
40+
# From "child-binding: include:" element.
41+
# - child-prop-1
42+
# - child-prop-2
43+
# - child-prop-enum
44+
# From "child-binding: child-binding: include:" element.
45+
# - grandchild-prop-1
46+
# - grandchild-prop-2
47+
# - grandchild-prop-enum
48+
49+
description: Description of 'base_multi.yaml'.
50+
51+
include:
52+
- name: base.yaml
53+
child-binding:
54+
property-allowlist: [child-prop-1, child-prop-2, child-prop-enum]
55+
child-binding:
56+
property-allowlist: [grandchild-prop-1, grandchild-prop-2, grandchild-prop-enum]
57+
58+
child-binding:
59+
include:
60+
- name: base.yaml
61+
property-allowlist: [prop-1, prop-2, prop-enum]
62+
child-binding:
63+
property-allowlist: [child-prop-1, child-prop-2, child-prop-enum]
64+
child-binding:
65+
property-allowlist: [grandchild-prop-1, grandchild-prop-2, grandchild-prop-enum]
66+
67+
properties:
68+
# Amend top-level "include:" element.
69+
child-prop-1:
70+
const: 0xf1
71+
# Amend this "child-binding: include:" element.
72+
prop-1:
73+
const: 0xf1
74+
prop-2:
75+
description: New description (child).
76+
prop-enum:
77+
required: true
78+
default: FOO
79+
80+
child-binding:
81+
include:
82+
- name: base.yaml
83+
property-allowlist: [prop-1, prop-2, prop-enum]
84+
child-binding:
85+
property-allowlist: [child-prop-1, child-prop-2, child-prop-enum]
86+
child-binding:
87+
property-allowlist: [grandchild-prop-1, grandchild-prop-2, grandchild-prop-enum]
88+
89+
properties:
90+
# Amend above top-level "include:" element.
91+
grandchild-prop-1:
92+
const: 0xf2
93+
# Amend above "child-binding: include:" element.
94+
child-prop-1:
95+
const: 0xf2
96+
# Amend this "child-binding: child-binding: include:" element.
97+
prop-1:
98+
const: 0xf2
99+
prop-2:
100+
description: New description (grandchild).
101+
prop-enum:
102+
required: true
103+
default: FOO
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
#
3+
# Test inheritance rules applied to compatible strings
4+
# and bindings descriptions.
5+
6+
description: Binding description.
7+
8+
compatible: vnd,compat-desc
9+
10+
include: compat_desc_base.yaml
11+
12+
child-binding:
13+
description: Child-binding description.
14+
compatible: vnd,child-compat-desc
15+
16+
child-binding:
17+
description: Grandchild-binding description.
18+
compatible: vnd,grandchild-compat-desc
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
#
3+
# Base file for testing inheritance rules applied to
4+
# compatible strings and bindings descriptions.
5+
6+
description: Binding description (base).
7+
8+
compatible: vnd,compat-desc-base
9+
10+
child-binding:
11+
description: Child-binding description (base).
12+
compatible: vnd,child-compat-desc-base
13+
14+
child-binding:
15+
description: Grandchild-binding description (base).
16+
compatible: vnd,grandchild-compat-desc-base
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
#
3+
# Test consequences of inclusion order on inherited
4+
# compatible strings and descriptions.
5+
6+
description: Binding description (multi).
7+
8+
compatible: vnd,compat-desc-multi
9+
10+
# Descriptions at the child-binding level and bellow
11+
# will depend on inclusion order: the first wins.
12+
include:
13+
- compat_desc_base.yaml
14+
- compat_desc.yaml

0 commit comments

Comments
 (0)