Revert "scripts: Removing init function pointer from check_init_priorities.py"
This reverts commit 653f1bf123.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
f2a9bf968d
commit
7d3a33afd4
@ -202,14 +202,15 @@ class ZephyrInitLevels:
|
||||
raise ValueError(f"no symbol at addr {addr:08x}")
|
||||
obj, size, shidx = self._objects[addr]
|
||||
|
||||
arg_name = self._object_name(self._initlevel_pointer(addr, 0, shidx))
|
||||
arg0_name = self._object_name(self._initlevel_pointer(addr, 0, shidx))
|
||||
arg1_name = self._object_name(self._initlevel_pointer(addr, 1, shidx))
|
||||
|
||||
self.initlevels[level].append(f"{obj}: {arg_name}")
|
||||
self.initlevels[level].append(f"{obj}: {arg0_name}({arg1_name})")
|
||||
|
||||
ordinal = self._device_ord_from_name(arg_name)
|
||||
ordinal = self._device_ord_from_name(arg1_name)
|
||||
if ordinal:
|
||||
prio = Priority(level, priority)
|
||||
self.devices[ordinal] = prio
|
||||
self.devices[ordinal] = (prio, arg0_name)
|
||||
|
||||
addr += size
|
||||
priority += 1
|
||||
@ -255,8 +256,8 @@ class Validator():
|
||||
self.log.info(f"Ignoring priority: {dev_node._binding.compatible}")
|
||||
return
|
||||
|
||||
dev_prio = self._obj.devices.get(dev_ord, None)
|
||||
dep_prio = self._obj.devices.get(dep_ord, None)
|
||||
dev_prio, dev_init = self._obj.devices.get(dev_ord, (None, None))
|
||||
dep_prio, dep_init = self._obj.devices.get(dep_ord, (None, None))
|
||||
|
||||
if not dev_prio or not dep_prio:
|
||||
return
|
||||
@ -271,12 +272,12 @@ class Validator():
|
||||
"the devicetree dependencies.")
|
||||
self.errors += 1
|
||||
self.log.error(
|
||||
f"{dev_node.path} is initialized before its dependency "
|
||||
f"{dep_node.path} ({dev_prio} < {dep_prio})")
|
||||
f"{dev_node.path} <{dev_init}> is initialized before its dependency "
|
||||
f"{dep_node.path} <{dep_init}> ({dev_prio} < {dep_prio})")
|
||||
else:
|
||||
self.log.info(
|
||||
f"{dev_node.path} {dev_prio} > "
|
||||
f"{dep_node.path} {dep_prio}")
|
||||
f"{dev_node.path} <{dev_init}> {dev_prio} > "
|
||||
f"{dep_node.path} <{dep_init}> {dep_prio}")
|
||||
|
||||
def check_edt(self):
|
||||
"""Scan through all known devices and validate the init priorities."""
|
||||
|
||||
@ -215,8 +215,12 @@ class testZephyrInitLevels(unittest.TestCase):
|
||||
|
||||
def mock_obj_name(*args):
|
||||
if args[0] == (0, 0, 0):
|
||||
return "i0"
|
||||
elif args[0] == (0, 1, 0):
|
||||
return "__device_dts_ord_11"
|
||||
elif args[0] == (4, 0, 0):
|
||||
return "i1"
|
||||
elif args[0] == (4, 1, 0):
|
||||
return "__device_dts_ord_22"
|
||||
return f"name_{args[0][0]}_{args[0][1]}"
|
||||
mock_on.side_effect = mock_obj_name
|
||||
@ -226,15 +230,14 @@ class testZephyrInitLevels(unittest.TestCase):
|
||||
self.assertDictEqual(obj.initlevels, {
|
||||
"EARLY": [],
|
||||
"PRE_KERNEL_1": [],
|
||||
"PRE_KERNEL_2": ["a: __device_dts_ord_11", "b: __device_dts_ord_22"],
|
||||
"POST_KERNEL": ["c: name_8_0"],
|
||||
"PRE_KERNEL_2": ["a: i0(__device_dts_ord_11)", "b: i1(__device_dts_ord_22)"],
|
||||
"POST_KERNEL": ["c: name_8_0(name_8_1)"],
|
||||
"APPLICATION": [],
|
||||
"SMP": [],
|
||||
})
|
||||
|
||||
self.assertDictEqual(obj.devices, {
|
||||
11: check_init_priorities.Priority("PRE_KERNEL_2", 0),
|
||||
22: check_init_priorities.Priority("PRE_KERNEL_2", 1),
|
||||
11: (check_init_priorities.Priority("PRE_KERNEL_2", 0), "i0"),
|
||||
22: (check_init_priorities.Priority("PRE_KERNEL_2", 1), "i1"),
|
||||
})
|
||||
|
||||
class testValidator(unittest.TestCase):
|
||||
@ -300,14 +303,14 @@ class testValidator(unittest.TestCase):
|
||||
validator._ord2node[2]._binding = None
|
||||
validator._ord2node[2].path = "/2"
|
||||
|
||||
validator._obj.devices = {1: 10, 2: 20}
|
||||
validator._obj.devices = {1: (10, "i1"), 2: (20, "i2")}
|
||||
|
||||
validator._check_dep(2, 1)
|
||||
validator._check_dep(1, 2)
|
||||
|
||||
validator.log.info.assert_called_once_with("/2 20 > /1 10")
|
||||
validator.log.info.assert_called_once_with("/2 <i2> 20 > /1 <i1> 10")
|
||||
validator.log.error.assert_has_calls([
|
||||
mock.call("/1 is initialized before its dependency /2 (10 < 20)")
|
||||
mock.call("/1 <i1> is initialized before its dependency /2 <i2> (10 < 20)")
|
||||
])
|
||||
self.assertEqual(validator.errors, 1)
|
||||
|
||||
@ -324,7 +327,7 @@ class testValidator(unittest.TestCase):
|
||||
validator._ord2node[2]._binding = None
|
||||
validator._ord2node[2].path = "/2"
|
||||
|
||||
validator._obj.devices = {1: 10, 2: 10,}
|
||||
validator._obj.devices = {1: (10, "i1"), 2: (10, "i2")}
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
validator._check_dep(1, 2)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user