提交 8ecaa8e7 编写于 作者: L Lukáš Doktor 提交者: Lucas Meneghel Rodrigues

qemu.tests.qmp_command: Fix and update qmp_cpu

This test previously only checked, if any CPU contains 'current=True'.
With this patch it goes through all cpus and checks, whether the
'current=True' is set only for the last CPU.

Additionally this verification method works with all smp setups.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 a9f6ccfc
......@@ -69,12 +69,11 @@
cmd_result_check = m_equal_q
event_cmd_type = monitor_cmd
- qmp_cpu:
only smp2
event_cmd_type = qmp_cmd
pre_cmd = "cpu index=1"
qmp_cmd = "query-cpus"
cmd_result_check = contain
cmd_return_value = 'current': True; u'CPU': 1
cmd_result_check = "qmp_cpu"
# Following params are dynamically created in test based on setup
# pre_cmd = "cpu index=1"
- qmp_query-vnc:
pre_cmd = change vnc 127.0.0.1:100
event_cmd_type = monitor_cmd
......
......@@ -143,6 +143,38 @@ def run_qmp_command(test, params, env):
msg = "Output does not match the pattern: %s" % output
raise error.TestFail(msg)
def qmp_cpu_check(output):
last_cpu = int(params['smp']) - 1
for out in output:
cpu = out.get('CPU')
if cpu is None:
raise error.TestFail("'CPU' index is missing in QMP output %s"
% out)
else:
current = out.get('current')
if current is None:
raise error.TestFail("'current' key is missing in QMP "
"output %s" % out)
elif cpu < last_cpu:
if current == False:
pass
else:
raise error.TestFail("Attribute 'current' should be "
"False, but is '%s' instead.\n%s"
% (current, out))
elif cpu == last_cpu:
if current == True:
pass
else:
raise error.TestFail("Attribute 'current' should be "
"True, but is '%s' instead.\n%s"
% (current, out))
elif cpu <= last_cpu:
continue
else:
raise error.TestFail("Incorrect CPU index '%s' (corrupted "
"or higher than no_cpus).\n%s"
% (cpu, out))
if not utils_misc.qemu_has_option("qmp"):
......@@ -186,11 +218,17 @@ def run_qmp_command(test, params, env):
result_check = params.get("cmd_result_check")
cmd_return_value = params.get("cmd_return_value")
# HOOKs
if result_check == 'qmp_cpu':
pre_cmd = "cpu index=%d" % (int(params['smp']) - 1)
# Pre command
if pre_cmd is not None:
error.context("Run prepare command '%s'." % pre_cmd, logging.info)
pre_o = send_cmd(pre_cmd)
logging.debug("Pre-command: %s\n Output: %s", pre_cmd, pre_o)
try:
# Testing command
error.context("Run qmp command '%s'." % qmp_cmd, logging.info)
output = qmp_port.send_args_cmd(qmp_cmd)
logging.debug("QMP command: %s \n Output: %s", qmp_cmd, output)
......@@ -210,6 +248,7 @@ def run_qmp_command(test, params, env):
except Exception, err:
raise error.TestFail(err)
# Post command
if post_cmd is not None:
error.context("Run post command '%s'." % post_cmd, logging.info)
post_o = send_cmd(post_cmd)
......@@ -218,7 +257,9 @@ def run_qmp_command(test, params, env):
if result_check is not None:
txt = "Verify that qmp command '%s' works as designed." % qmp_cmd
error.context(txt, logging.info)
if result_check == "equal" or result_check == "contain":
if result_check == 'qmp_cpu':
qmp_cpu_check(output)
elif result_check == "equal" or result_check == "contain":
check_result(output, cmd_return_value)
elif result_check == "m_format_q":
check_result(output, cmd_return_value)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册