提交 a6e32b87 编写于 作者: G Golita Yue 提交者: Lucas Meneghel Rodrigues

qemu.tests: Add machine_type check in physical_resource_check

Add machine_type check function to check the guest's machine type

change from v1:
1. change 'extra_params' to 'machine type'
2. add try except block when compare the result
Signed-off-by: NGolita Yue <gyue@redhat.com>
上级 ec25ba2b
......@@ -11,7 +11,12 @@
# useless for linux guest.
vio_driver_chk_cmd = ""
mem_chk_re_str = (\b[0-9]+\b)
mtype_pattern = '\d.\d.\d'
cpu_cores_chk_cmd = "lscpu | grep '^Core'"
cpu_sockets_chk_cmd = "lscpu | grep -E '(^Socket|^CPU socket)'"
cpu_threads_chk_cmd = "lscpu | grep '^Thread'"
# So far not all guests support machine type check.
# Please update this command to suit the guest OS
RHEL:
check_machine_type_cmd = dmidecode | awk -F: '/Version: RHEL/'
chk_timeout = 240
......@@ -131,6 +131,38 @@ def run_physical_resources_check(test, params, env):
return f_fail
def verify_machine_type():
f_fail = []
pattern = params["mtype_pattern"]
cmd = params.get("check_machine_type_cmd")
if cmd is None:
return f_fail
s, o = session.cmd_status_output(cmd)
if s != 0:
raise error.TestError("Failed to get machine type from vm")
expect_mtype = re.findall(pattern, params['machine_type'])
actual_mtype = re.findall(pattern, o)
try:
if actual_mtype[0] != expect_mtype[0]:
fail_log = "Machine type mismatch:\n"
fail_log += " Assigned to VM: %s \n" % expect_mtype[0]
fail_log += " Reported by OS: %s" % actual_mtype[0]
f_fail.append(fail_log)
logging.error(fail_log)
else:
logging.info("MachineType check pass. Expected: %s, Actual: %s" %
(expect_mtype[0], actual_mtype[0]))
return f_fail
except IndexError, e:
fail_log = "Failed to get machine type, pls check script: %s" % e
f_fail.append(fail_log)
logging.error(fail_log)
return f_fail
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
timeout = int(params.get("login_timeout", 360))
......@@ -249,6 +281,10 @@ def run_physical_resources_check(test, params, env):
n_fail.append(fail_log)
logging.error(fail_log)
logging.info("Machine Type Check")
f_fail = verify_machine_type()
n_fail.extend(f_fail)
if n_fail:
session.close()
raise error.TestFail("Physical resources check test "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册