Skip to content

Commit 0da9709

Browse files
committed
scripts: dts: devicetree: tests: Add a map property test
Add a map property test for `test_edtlib.py`. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent 81c33ad commit 0da9709

File tree

2 files changed

+109
-1
lines changed

2 files changed

+109
-1
lines changed

scripts/dts/python-devicetree/tests/test.dts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,21 @@
7171
interrupt-controller;
7272
};
7373
nexus {
74+
#address-cells = <2>;
7475
#interrupt-cells = <2>;
7576
interrupt-map = <
7677
0 0 0 0 &{/interrupt-map-test/controller-0} 0 0
7778
0 0 0 1 &{/interrupt-map-test/controller-1} 0 0 0 1
7879
0 0 0 2 &{/interrupt-map-test/controller-2} 0 0 0 0 0 2
7980
0 1 0 0 &{/interrupt-map-test/controller-0} 0 3
8081
0 1 0 1 &{/interrupt-map-test/controller-1} 0 0 0 4
81-
0 1 0 2 &{/interrupt-map-test/controller-2} 0 0 0 0 0 5>;
82+
0 1 0 2 &{/interrupt-map-test/controller-2} 0 0 0 0 0 5
83+
0 1 1 0 &{/interrupt-map-no-address/controller} 6>;
84+
};
85+
empty {
86+
#address-cells = <2>;
87+
#interrupt-cells = <2>;
88+
interrupt-map = <>;
8289
};
8390
nexus-0 {
8491
#address-cells = <0>;
@@ -163,6 +170,14 @@
163170
};
164171
};
165172

173+
interrupt-map-no-address {
174+
controller {
175+
compatible = "interrupt-one-cell";
176+
#interrupt-cells = <1>;
177+
interrupt-controller;
178+
};
179+
};
180+
166181
//
167182
// 'ranges'
168183
//

scripts/dts/python-devicetree/tests/test_edtlib.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,99 @@ def test_interrupts():
130130
edtlib.ControllerAndData(node=node, controller=edt.get_node('/interrupt-map-bitops-test/controller'), data={'one': 3, 'two': 2}, name=None, basename=None)
131131
]
132132

133+
134+
def test_maps():
135+
'''Tests for the maps property.'''
136+
with from_here():
137+
edt = edtlib.EDT("test.dts", ["test-bindings"])
138+
139+
nexus = edt.get_node("/interrupt-map-test/nexus")
140+
controller_0 = edt.get_node("/interrupt-map-test/controller-0")
141+
controller_1 = edt.get_node("/interrupt-map-test/controller-1")
142+
controller_2 = edt.get_node("/interrupt-map-test/controller-2")
143+
controller_no_addr = edt.get_node("/interrupt-map-no-address/controller")
144+
145+
assert len(nexus.maps.keys()) == 1
146+
assert "interrupt" in nexus.maps
147+
148+
entries = nexus.maps["interrupt"]
149+
assert len(entries) == 7
150+
151+
assert entries[0] == edtlib.MapEntry(
152+
node=nexus,
153+
child_addresses=[0, 0],
154+
child_specifiers=[0, 0],
155+
parent=controller_0,
156+
parent_addresses=[0],
157+
parent_specifiers=[0],
158+
basename="interrupt",
159+
)
160+
161+
assert entries[1] == edtlib.MapEntry(
162+
node=nexus,
163+
child_addresses=[0, 0],
164+
child_specifiers=[0, 1],
165+
parent=controller_1,
166+
parent_addresses=[0, 0],
167+
parent_specifiers=[0, 1],
168+
basename="interrupt",
169+
)
170+
171+
assert entries[2] == edtlib.MapEntry(
172+
node=nexus,
173+
child_addresses=[0, 0],
174+
child_specifiers=[0, 2],
175+
parent=controller_2,
176+
parent_addresses=[0, 0, 0],
177+
parent_specifiers=[0, 0, 2],
178+
basename="interrupt",
179+
)
180+
181+
assert entries[3] == edtlib.MapEntry(
182+
node=nexus,
183+
child_addresses=[0, 1],
184+
child_specifiers=[0, 0],
185+
parent=controller_0,
186+
parent_addresses=[0],
187+
parent_specifiers=[3],
188+
basename="interrupt",
189+
)
190+
191+
assert entries[4] == edtlib.MapEntry(
192+
node=nexus,
193+
child_addresses=[0, 1],
194+
child_specifiers=[0, 1],
195+
parent=controller_1,
196+
parent_addresses=[0, 0],
197+
parent_specifiers=[0, 4],
198+
basename="interrupt",
199+
)
200+
201+
assert entries[5] == edtlib.MapEntry(
202+
node=nexus,
203+
child_addresses=[0, 1],
204+
child_specifiers=[0, 2],
205+
parent=controller_2,
206+
parent_addresses=[0, 0, 0],
207+
parent_specifiers=[0, 0, 5],
208+
basename="interrupt",
209+
)
210+
211+
assert entries[6] == edtlib.MapEntry(
212+
node=nexus,
213+
child_addresses=[0, 1],
214+
child_specifiers=[1, 0],
215+
parent=controller_no_addr,
216+
parent_addresses=[],
217+
parent_specifiers=[6],
218+
basename="interrupt",
219+
)
220+
221+
empty = edt.get_node("/interrupt-map-test/empty")
222+
assert len(empty.maps) == 1
223+
assert "interrupt" in empty.maps
224+
assert len(empty.maps["interrupt"]) == 0
225+
133226
def test_ranges():
134227
'''Tests for the ranges property'''
135228
with from_here():

0 commit comments

Comments
 (0)