Skip to content

Commit 7d3a33a

Browse files
nashifdanieldegrasse
authored andcommitted
Revert "scripts: Removing init function pointer from check_init_priorities.py"
This reverts commit 653f1bf. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
1 parent f2a9bf9 commit 7d3a33a

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

scripts/build/check_init_priorities.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,15 @@ def _process_initlevels(self):
202202
raise ValueError(f"no symbol at addr {addr:08x}")
203203
obj, size, shidx = self._objects[addr]
204204

205-
arg_name = self._object_name(self._initlevel_pointer(addr, 0, shidx))
205+
arg0_name = self._object_name(self._initlevel_pointer(addr, 0, shidx))
206+
arg1_name = self._object_name(self._initlevel_pointer(addr, 1, shidx))
206207

207-
self.initlevels[level].append(f"{obj}: {arg_name}")
208+
self.initlevels[level].append(f"{obj}: {arg0_name}({arg1_name})")
208209

209-
ordinal = self._device_ord_from_name(arg_name)
210+
ordinal = self._device_ord_from_name(arg1_name)
210211
if ordinal:
211212
prio = Priority(level, priority)
212-
self.devices[ordinal] = prio
213+
self.devices[ordinal] = (prio, arg0_name)
213214

214215
addr += size
215216
priority += 1
@@ -255,8 +256,8 @@ def _check_dep(self, dev_ord, dep_ord):
255256
self.log.info(f"Ignoring priority: {dev_node._binding.compatible}")
256257
return
257258

258-
dev_prio = self._obj.devices.get(dev_ord, None)
259-
dep_prio = self._obj.devices.get(dep_ord, None)
259+
dev_prio, dev_init = self._obj.devices.get(dev_ord, (None, None))
260+
dep_prio, dep_init = self._obj.devices.get(dep_ord, (None, None))
260261

261262
if not dev_prio or not dep_prio:
262263
return
@@ -271,12 +272,12 @@ def _check_dep(self, dev_ord, dep_ord):
271272
"the devicetree dependencies.")
272273
self.errors += 1
273274
self.log.error(
274-
f"{dev_node.path} is initialized before its dependency "
275-
f"{dep_node.path} ({dev_prio} < {dep_prio})")
275+
f"{dev_node.path} <{dev_init}> is initialized before its dependency "
276+
f"{dep_node.path} <{dep_init}> ({dev_prio} < {dep_prio})")
276277
else:
277278
self.log.info(
278-
f"{dev_node.path} {dev_prio} > "
279-
f"{dep_node.path} {dep_prio}")
279+
f"{dev_node.path} <{dev_init}> {dev_prio} > "
280+
f"{dep_node.path} <{dep_init}> {dep_prio}")
280281

281282
def check_edt(self):
282283
"""Scan through all known devices and validate the init priorities."""

scripts/build/check_init_priorities_test.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,12 @@ def test_process_initlevels(self, mock_zilinit, mock_ip, mock_on):
215215

216216
def mock_obj_name(*args):
217217
if args[0] == (0, 0, 0):
218+
return "i0"
219+
elif args[0] == (0, 1, 0):
218220
return "__device_dts_ord_11"
219221
elif args[0] == (4, 0, 0):
222+
return "i1"
223+
elif args[0] == (4, 1, 0):
220224
return "__device_dts_ord_22"
221225
return f"name_{args[0][0]}_{args[0][1]}"
222226
mock_on.side_effect = mock_obj_name
@@ -226,15 +230,14 @@ def mock_obj_name(*args):
226230
self.assertDictEqual(obj.initlevels, {
227231
"EARLY": [],
228232
"PRE_KERNEL_1": [],
229-
"PRE_KERNEL_2": ["a: __device_dts_ord_11", "b: __device_dts_ord_22"],
230-
"POST_KERNEL": ["c: name_8_0"],
233+
"PRE_KERNEL_2": ["a: i0(__device_dts_ord_11)", "b: i1(__device_dts_ord_22)"],
234+
"POST_KERNEL": ["c: name_8_0(name_8_1)"],
231235
"APPLICATION": [],
232236
"SMP": [],
233237
})
234-
235238
self.assertDictEqual(obj.devices, {
236-
11: check_init_priorities.Priority("PRE_KERNEL_2", 0),
237-
22: check_init_priorities.Priority("PRE_KERNEL_2", 1),
239+
11: (check_init_priorities.Priority("PRE_KERNEL_2", 0), "i0"),
240+
22: (check_init_priorities.Priority("PRE_KERNEL_2", 1), "i1"),
238241
})
239242

240243
class testValidator(unittest.TestCase):
@@ -300,14 +303,14 @@ def test_check(self, mock_vinit):
300303
validator._ord2node[2]._binding = None
301304
validator._ord2node[2].path = "/2"
302305

303-
validator._obj.devices = {1: 10, 2: 20}
306+
validator._obj.devices = {1: (10, "i1"), 2: (20, "i2")}
304307

305308
validator._check_dep(2, 1)
306309
validator._check_dep(1, 2)
307310

308-
validator.log.info.assert_called_once_with("/2 20 > /1 10")
311+
validator.log.info.assert_called_once_with("/2 <i2> 20 > /1 <i1> 10")
309312
validator.log.error.assert_has_calls([
310-
mock.call("/1 is initialized before its dependency /2 (10 < 20)")
313+
mock.call("/1 <i1> is initialized before its dependency /2 <i2> (10 < 20)")
311314
])
312315
self.assertEqual(validator.errors, 1)
313316

@@ -324,7 +327,7 @@ def test_check_same_prio_assert(self, mock_vinit):
324327
validator._ord2node[2]._binding = None
325328
validator._ord2node[2].path = "/2"
326329

327-
validator._obj.devices = {1: 10, 2: 10,}
330+
validator._obj.devices = {1: (10, "i1"), 2: (10, "i2")}
328331

329332
with self.assertRaises(ValueError):
330333
validator._check_dep(1, 2)

0 commit comments

Comments
 (0)