未验证 提交 8b54bf2c 编写于 作者: X Xu Han 提交者: GitHub

Merge pull request #1130 from aliang123/1506101

Correct logic for device's boot_fail
...@@ -4,7 +4,7 @@ import time ...@@ -4,7 +4,7 @@ import time
import logging import logging
from autotest.client import utils from autotest.client import utils
from autotest.client.shared import error from virttest import error_context
from virttest import utils_misc from virttest import utils_misc
from virttest import data_dir from virttest import data_dir
...@@ -12,7 +12,7 @@ from virttest import qemu_storage ...@@ -12,7 +12,7 @@ from virttest import qemu_storage
from virttest import env_process from virttest import env_process
@error.context_aware @error_context.context_aware
def run(test, params, env): def run(test, params, env):
""" """
QEMU boot from device: QEMU boot from device:
...@@ -74,49 +74,43 @@ def run(test, params, env): ...@@ -74,49 +74,43 @@ def run(test, params, env):
elif dev_name == "iscsi-dev": elif dev_name == "iscsi-dev":
postprocess_remote_storage() postprocess_remote_storage()
def check_boot_result(boot_fail_info, device_name): def check_boot_result(boot_entry_info, boot_fail_info, device_name):
""" """
Check boot result, and logout from iscsi device if boot from iscsi. Check boot result, and logout from iscsi device if boot from iscsi.
""" """
logging.info("Wait for display and check boot info.") logging.info("Wait for display and check boot info.")
infos = boot_fail_info.split(';')
start = time.time() start = time.time()
while True: while True:
try: try:
output = vm.serial_console.get_stripped_output() output = vm.serial_console.get_stripped_output()
except ValueError: except ValueError:
output = vm.serial_console.get_output() output = vm.serial_console.get_output()
match = re.search(infos[0], output) if boot_fail_info in output:
if match or time.time() > start + timeout: test.fail("Could not boot from"
" '%s'" % device_name)
elif boot_entry_info in output:
break break
if time.time() > start + timeout:
test.fail("No device for boot after %s" % timeout)
time.sleep(1) time.sleep(1)
logging.info("Try to boot from '%s'" % device_name) logging.info("Try to boot from '%s'" % device_name)
try: try:
if dev_name == "hard-drive" or (dev_name == "scsi-hd" and not if dev_name == "hard-drive" or (dev_name == "scsi-hd" and not
params.get("image_name_stg")): params.get("image_name_stg")):
error.context("Log into the guest to verify it's up", error_context.context("Log into the guest to verify it's up",
logging.info) logging.info)
session = vm.wait_for_login(timeout=timeout) session = vm.wait_for_login(timeout=timeout)
session.close() session.close()
vm.destroy() vm.destroy()
return return
try:
output = vm.serial_console.get_stripped_output()
except ValueError:
output = vm.serial_console.get_output()
for i in infos:
if not re.search(i, output):
raise error.TestFail("Could not boot from"
" '%s'" % device_name)
finally: finally:
cleanup(device_name) cleanup(device_name)
timeout = int(params.get("login_timeout", 360)) timeout = int(params.get("login_timeout", 360))
boot_menu_key = params.get("boot_menu_key", 'f12') boot_menu_key = params.get("boot_menu_key", 'f12')
boot_menu_hint = params.get("boot_menu_hint") boot_menu_hint = params.get("boot_menu_hint")
boot_entry_info = params.get("boot_entry_info")
boot_fail_info = params.get("boot_fail_info") boot_fail_info = params.get("boot_fail_info")
boot_device = params.get("boot_device") boot_device = params.get("boot_device")
dev_name = params.get("dev_name") dev_name = params.get("dev_name")
...@@ -151,7 +145,7 @@ def run(test, params, env): ...@@ -151,7 +145,7 @@ def run(test, params, env):
time.sleep(1) time.sleep(1)
if not match: if not match:
cleanup(dev_name) cleanup(dev_name)
raise error.TestFail("Could not get boot menu message. " test.fail("Could not get boot menu message. "
"Excepted Result: '%s', Actual result: '%s'" "Excepted Result: '%s', Actual result: '%s'"
% (boot_menu_hint, console_str)) % (boot_menu_hint, console_str))
...@@ -166,7 +160,7 @@ def run(test, params, env): ...@@ -166,7 +160,7 @@ def run(test, params, env):
if not boot_list: if not boot_list:
cleanup(dev_name) cleanup(dev_name)
raise error.TestFail("Could not get boot entries list.") test.fail("Could not get boot entries list.")
logging.info("Got boot menu entries: '%s'", boot_list) logging.info("Got boot menu entries: '%s'", boot_list)
for i, v in enumerate(boot_list, start=1): for i, v in enumerate(boot_list, start=1):
...@@ -175,7 +169,7 @@ def run(test, params, env): ...@@ -175,7 +169,7 @@ def run(test, params, env):
vm.send_key(str(i)) vm.send_key(str(i))
break break
else: else:
raise error.TestFail("Could not get any boot entry match " test.fail("Could not get any boot entry match "
"pattern '%s'" % boot_device) "pattern '%s'" % boot_device)
check_boot_result(boot_fail_info, dev_name) check_boot_result(boot_entry_info, boot_fail_info, dev_name)
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
Host_RHEL.m7: Host_RHEL.m7:
boot_menu_key = "esc" boot_menu_key = "esc"
boot_menu_hint = "Press .*(F12|ESC) for boot menu" boot_menu_hint = "Press .*(F12|ESC) for boot menu"
boot_fail_info = "Booting from Hard Disk...;" boot_entry_info = "Booting from Hard Disk..."
boot_fail_info += "Boot failed: not a bootable disk" boot_fail_info = "Boot failed: not a bootable disk"
variants: variants:
- boot_from_hard_drive: - boot_from_hard_drive:
dev_name = hard-drive dev_name = hard-drive
...@@ -65,8 +65,8 @@ ...@@ -65,8 +65,8 @@
cdroms = "test" cdroms = "test"
cdrom_test = /tmp/test.iso cdrom_test = /tmp/test.iso
cd_format = scsi-cd cd_format = scsi-cd
boot_fail_info = "Booting from DVD/CD...;" boot_entry_info = "Booting from DVD/CD..."
boot_fail_info += "Boot failed: Could not read from CDROM" boot_fail_info = "Boot failed: Could not read from CDROM"
variants: variants:
- with_local_iso: - with_local_iso:
bootindex_test = 0 bootindex_test = 0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册