提交 7020fc74 编写于 作者: Q Qingtang Zhou 提交者: Lucas Meneghel Rodrigues

virttest.usb_boot: make this case run on windows guest

The previous usb boot test only works on linux guest.
This patch updates them and make them work on windows guest.

Also changes:
 - Add error context to check usb device functions.
Signed-off-by: NQingtang Zhou <qzhou@redhat.com>
上级 1ca98910
......@@ -55,7 +55,7 @@
only usb_boot, usb_reboot, usb_hotplug
usb_type_testdev = "usb-ccid"
info_usb_name = "QEMU USB CCID"
vendor_id = "08e6"
vendor_id = "08E6"
product_id = "4433"
vendor = "Gemplus"
product = "QEMU USB CCID"
......@@ -63,7 +63,7 @@
only usb_boot, usb_reboot, usb_hotplug
usb_type_testdev = usb-audio
info_usb_name = "QEMU USB Audio"
vendor_id = "46f4"
vendor_id = "46F4"
product_id = "0002"
vendor = ""
product = "QEMU USB Audio"
......@@ -81,12 +81,24 @@
- usb_boot:
type = usb_basic_check
usb_devices += " testdev"
check_func = "check_usb_device"
deviceid_str = "%s:%s"
chk_usb_info_cmd = "lsusb -v"
Windows:
deviceid_str = "VID_%s&PID_%s"
chk_usb_info_cmd = 'wmic path Win32_USBControllerDevice get Dependent | find "USB"'
vendor_equal = ""
product_equal = ""
- usb_reboot:
type = usb_basic_check
reboot_method = shell
usb_devices += " testdev"
check_func = "check_usb_device"
deviceid_str = "%s:%s"
chk_usb_info_cmd = "lsusb -v"
Windows:
deviceid_str = "VID_%s&PID_%s"
chk_usb_info_cmd = 'wmic path Win32_USBControllerDevice get Dependent | find "USB"'
vendor_equal = ""
product_equal = ""
- usb_hotplug:
type = usb_hotplug
- usb_storage:
......
......@@ -2,10 +2,12 @@ import time, re, logging
from autotest.client.shared import error
def check_usb_device(test, params, env):
@error.context_aware
def check_usb_device_monitor(test, params, env):
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
error.context("Verify USB device in monitor.", logging.info)
o = vm.monitor.info("usb")
if isinstance(o, dict):
o = o.get("return")
......@@ -14,20 +16,34 @@ def check_usb_device(test, params, env):
raise error.TestFail("Could not find '%s' device, monitor "
"returns: \n%s" % (params.get("product"), o))
@error.context_aware
def check_usb_device(test, params, env):
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
check_usb_device_monitor(test, params, env)
timeout = float(params.get("login_timeout", 240))
session = vm.wait_for_login(timeout=timeout)
chk_list = ["%s:%s" % (params.get("vendor_id"), params.get("product_id"))]
if params.get("vendor"):
chk_list.append(params.get("vendor"))
if params.get("product"):
chk_list.append(params.get("product"))
deviceid_str = params.get("deviceid_str")
vendor_id = params.get("vendor_id")
product_id = params.get("product_id")
vendor = params.get("vendor")
product = params.get("product")
chk_list = [deviceid_str % (vendor_id, product_id)]
if vendor:
chk_list.append(vendor)
if product:
chk_list.append(product)
o = session.cmd("lsusb -v")
error.context("Verify USB device in guest.")
o = session.cmd_output(params.get("chk_usb_info_cmd"))
for item in chk_list:
if not re.findall(item, o):
if not re.findall(item, o, re.I):
raise error.TestFail("Could not find item '%s' in guest, "
"'lsusb -v' output:\n %s" % (item, o))
"Output:\n %s" % (item, o))
@error.context_aware
......@@ -63,7 +79,7 @@ def run_usb_basic_check(test, params, env):
_check_dev()
if params.get("reboot_method"):
error.context("Reboot guest.")
error.context("Reboot guest.", logging.info)
if params["reboot_method"] == "system_reset":
time.sleep(int(params.get("sleep_before_reset", 10)))
session = vm.reboot(session, params["reboot_method"], 0, timeout)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册