Ejemplo n.º 1
0
    def test_qtree(self):
        """ Correct workflow """
        reference_nodes = [qemu_qtree.QtreeDisk, qemu_qtree.QtreeBus,
                           qemu_qtree.QtreeDev, qemu_qtree.QtreeDev,
                           qemu_qtree.QtreeDev, qemu_qtree.QtreeDisk,
                           qemu_qtree.QtreeBus, qemu_qtree.QtreeDev,
                           qemu_qtree.QtreeBus, qemu_qtree.QtreeDev,
                           qemu_qtree.QtreeDev, qemu_qtree.QtreeBus]

        info = qtree_header
        info = combine(info, dev_ide_disk, 1)
        info = combine(info, dev_usb_disk, 1)
        info = combine(info, dev_dummy_mmio, 1)
        info += "\n"

        qtree = qemu_qtree.QtreeContainer()
        qtree.parse_info_qtree(info)
        nodes = qtree.get_nodes()

        self.assertEqual(len(nodes), len(reference_nodes), ("Number of parsed "
                                                            "nodes is not equal to the number of qtree nodes. "
                                                            "%s != %s" % (len(nodes), len(reference_nodes))))

        for i in xrange(len(nodes)):
            self.assertTrue(isinstance(nodes[i], reference_nodes[i]),
                            ("Node %d should be class %s but is %s instead" %
                             (i, reference_nodes[i], type(reference_nodes))))

        tree = qtree.get_qtree()
        self.assertTrue(isinstance(tree.str_qtree(), str),
                        "qtree.str_qtree() returns nonstring output.")

        self.assertTrue(isinstance(str(tree), str),
                        "str(qtree) returns nonstring output.")
Ejemplo n.º 2
0
    def setUp(self):
        # Get rid of logging errors
        def dumm(*args, **kvargs):
            pass
        self.god = mock.mock_god(ut=self)
        self.god.stub_with(qemu_qtree.logging, 'error', dumm)

        info = qtree_header
        info = combine(info, dev_ide_disk, 1)
        info = combine(info, dev_usb_disk, 1)
        info = combine(info, dev_dummy_mmio, 1)
        info += "\n"

        self.no_disks = 2

        self.qtree = qemu_qtree.QtreeContainer()
        self.qtree.parse_info_qtree(info)

        self.disks = qemu_qtree.QtreeDisksContainer(self.qtree.get_nodes())
Ejemplo n.º 3
0
 def test_bad_qtree(self):
     """ Incorrect qtree """
     qtree = qemu_qtree.QtreeContainer()
     info = combine(qtree_header, "Very_bad_line", 1)
     self.assertRaises(ValueError, qtree.parse_info_qtree, info)