Example #1
0
    def test_holders(self, device):
        """
        Verify holders graph has same number of nodes as traversal.

        Traversal may contain duplicates, while graph should eliminate
        duplicates during its construction. Traversal results does not
        include origin device, graph nodes do.
        """
        holders = list(pydevDAG.holders(CONTEXT, device))
        graph = pydevDAG.SysfsTraversal.holders(CONTEXT, device)
        graph_len = len(graph)
        assert len(set(holders)) == (graph_len - 1 if graph_len else 0)
Example #2
0
    def test_inverse(self, device, recursive):
        """
        Verify that a round-trip traversal will encounter the original
        device.

        :param device: the device to test
        :param bool recursive: if True, test recursive relationship

        If recursive is True, test ancestor/descendant relationship.
        If recursive is False, tests parent/child relationship.
        """
        # pylint: disable=too-many-function-args
        slaves = list(pydevDAG.slaves(CONTEXT, device, recursive))
        for slave in slaves:
            assert device in list(
               pydevDAG.holders(CONTEXT, slave, recursive)
            )

        holders = list(pydevDAG.holders(CONTEXT, device, recursive))
        for holder in holders:
            assert device in list(
               pydevDAG.slaves(CONTEXT, holder, recursive)
            )
Example #3
0
 def test_holders(self, device):
     """
     Verify holders do not contain originating device.
     """
     assert device not in pydevDAG.holders(CONTEXT, device)