Skip to content

Commit

Permalink
Merge pull request #4770 from smitterl/xml_attribute_order
Browse files Browse the repository at this point in the history
input_devices, virsh_boot_sysinfo: improve xml check
  • Loading branch information
chunfuwen authored Feb 28, 2023
2 parents 76ad484 + 9b616bc commit ed7dc99
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
13 changes: 10 additions & 3 deletions libvirt/tests/src/bios/virsh_boot_sysinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,19 @@ def run(test, params, env):
if not status_error:
# Check result in dumpxml and qemu cmdline
if with_file:
expect_xml_line = "<entry file=\"%s\" name=\"%s\" />" % (entry_file, entry_name)
xpaths = [
".//entry[@file='%s']" % entry_file,
".//entry[@name='%s']" % entry_name
]
text = None
expect_qemu_line = "-fw_cfg name=%s,file=%s" % (entry_name, entry_file)
if with_value:
expect_xml_line = "<entry name=\"%s\">%s</entry>" % (entry_name, value_string)
xpaths = [
".//entry[@name='%s']" % entry_name
]
text = value_string
expect_qemu_line = "-fw_cfg name=%s,string=%s" % (entry_name, value_string)
libvirt.check_dumpxml(vm, expect_xml_line)
libvirt.check_xpaths(vmxml, xpaths, text)
libvirt.check_qemu_cmd_line(expect_qemu_line)

# Check result in guest
Expand Down
14 changes: 8 additions & 6 deletions libvirt/tests/src/virtual_device/input_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from virttest.libvirt_xml.devices.input import Input
from virttest.libvirt_xml.vm_xml import VMXML
from virttest.utils_test import libvirt
from virttest import virsh

from virttest import libvirt_version
Expand All @@ -27,15 +28,16 @@ def check_dumpxml():
"""
Check whether the added devices are shown in the guest xml
"""
pattern = "<input type=\"%s\" bus=\"%s\">" % (input_type, bus_type)
expected = [
".//input[@type='%s']" % input_type,
".//input[@bus='%s']" % bus_type
]
if with_packed:
pattern = "<driver packed=\"%s\"" % (driver_packed)
logging.debug('Searching for %s in vm xml', pattern)
expected.append(".//driver[@packed='%s']" % driver_packed)
logging.debug('Searching vm xml for values %s', expected)
xml_after_adding_device = VMXML.new_from_dumpxml(vm_name)
logging.debug('xml_after_adding_device:\n%s', xml_after_adding_device)
if pattern not in str(xml_after_adding_device):
test.fail("Can not find the %s input device xml "
"in the guest xml file." % input_type)
libvirt.check_xpaths(xml_after_adding_device, expected)

def check_qemu_cmd_line():
"""
Expand Down

0 comments on commit ed7dc99

Please sign in to comment.