Commit 653f1bf1 authored by Tomasz Bursztyka's avatar Tomasz Bursztyka Committed by Benjamin Cabé
Browse files

scripts: Removing init function pointer from check_init_priorities.py



As the pointer has been removed from struct init_entry, there is no point
to look for it nor to display any information about it (obviously).

Fixing the test script as well.

Signed-off-by: default avatarTomasz Bursztyka <tobu@bang-olufsen.dk>
parent 175da6bd
Loading
Loading
Loading
Loading
+10 −11
Original line number Diff line number Diff line
@@ -202,15 +202,14 @@ class ZephyrInitLevels:
                    raise ValueError(f"no symbol at addr {addr:08x}")
                obj, size, shidx = self._objects[addr]

                arg0_name = self._object_name(self._initlevel_pointer(addr, 0, shidx))
                arg1_name = self._object_name(self._initlevel_pointer(addr, 1, shidx))
                arg_name = self._object_name(self._initlevel_pointer(addr, 0, shidx))

                self.initlevels[level].append(f"{obj}: {arg0_name}({arg1_name})")
                self.initlevels[level].append(f"{obj}: {arg_name}")

                ordinal = self._device_ord_from_name(arg1_name)
                ordinal = self._device_ord_from_name(arg_name)
                if ordinal:
                    prio = Priority(level, priority)
                    self.devices[ordinal] = (prio, arg0_name)
                    self.devices[ordinal] = prio

                addr += size
                priority += 1
@@ -256,8 +255,8 @@ class Validator():
                self.log.info(f"Ignoring priority: {dev_node._binding.compatible}")
                return

        dev_prio, dev_init = self._obj.devices.get(dev_ord, (None, None))
        dep_prio, dep_init = self._obj.devices.get(dep_ord, (None, None))
        dev_prio = self._obj.devices.get(dev_ord, None)
        dep_prio = self._obj.devices.get(dep_ord, None)

        if not dev_prio or not dep_prio:
            return
@@ -272,12 +271,12 @@ class Validator():
                               "the devicetree dependencies.")
            self.errors += 1
            self.log.error(
                    f"{dev_node.path} <{dev_init}> is initialized before its dependency "
                    f"{dep_node.path} <{dep_init}> ({dev_prio} < {dep_prio})")
                    f"{dev_node.path} is initialized before its dependency "
                    f"{dep_node.path} ({dev_prio} < {dep_prio})")
        else:
            self.log.info(
                    f"{dev_node.path} <{dev_init}> {dev_prio} > "
                    f"{dep_node.path} <{dep_init}> {dep_prio}")
                    f"{dev_node.path} {dev_prio} > "
                    f"{dep_node.path} {dep_prio}")

    def check_edt(self):
        """Scan through all known devices and validate the init priorities."""
+9 −12
Original line number Diff line number Diff line
@@ -215,12 +215,8 @@ 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
@@ -230,14 +226,15 @@ class testZephyrInitLevels(unittest.TestCase):
        self.assertDictEqual(obj.initlevels, {
            "EARLY": [],
            "PRE_KERNEL_1": [],
            "PRE_KERNEL_2": ["a: i0(__device_dts_ord_11)", "b: i1(__device_dts_ord_22)"],
            "POST_KERNEL": ["c: name_8_0(name_8_1)"],
            "PRE_KERNEL_2": ["a: __device_dts_ord_11", "b: __device_dts_ord_22"],
            "POST_KERNEL": ["c: name_8_0"],
            "APPLICATION": [],
            "SMP": [],
            })

        self.assertDictEqual(obj.devices, {
            11: (check_init_priorities.Priority("PRE_KERNEL_2", 0), "i0"),
            22: (check_init_priorities.Priority("PRE_KERNEL_2", 1), "i1"),
            11: check_init_priorities.Priority("PRE_KERNEL_2", 0),
            22: check_init_priorities.Priority("PRE_KERNEL_2", 1),
            })

class testValidator(unittest.TestCase):
@@ -303,14 +300,14 @@ class testValidator(unittest.TestCase):
        validator._ord2node[2]._binding = None
        validator._ord2node[2].path = "/2"

        validator._obj.devices = {1: (10, "i1"), 2: (20, "i2")}
        validator._obj.devices = {1: 10, 2: 20}

        validator._check_dep(2, 1)
        validator._check_dep(1, 2)

        validator.log.info.assert_called_once_with("/2 <i2> 20 > /1 <i1> 10")
        validator.log.info.assert_called_once_with("/2 20 > /1 10")
        validator.log.error.assert_has_calls([
            mock.call("/1 <i1> is initialized before its dependency /2 <i2> (10 < 20)")
            mock.call("/1 is initialized before its dependency /2 (10 < 20)")
            ])
        self.assertEqual(validator.errors, 1)

@@ -327,7 +324,7 @@ class testValidator(unittest.TestCase):
        validator._ord2node[2]._binding = None
        validator._ord2node[2].path = "/2"

        validator._obj.devices = {1: (10, "i1"), 2: (10, "i2")}
        validator._obj.devices = {1: 10, 2: 10,}

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