提交 5099b46b 编写于 作者: I Igor Mammedov 提交者: Lucas Meneghel Rodrigues

cpuid: add custom_vendor test

Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
---
v2:
    * s/TestFail/TestNAError/
    * s/custom_vendor/custom.vendor/ in config
上级 1a44ee36
......@@ -71,3 +71,14 @@
cpu_models += " cpu64-rhel6 cpu64-rhel5"
vendor = "AuthenticAMD"
test_type = "default_vendor"
- cpuid.custom.vendor:
vendor = "QWERasdfZXCV"
test_type = "custom_vendor"
- cpuid.custom.vendor.too_short:
xfail = "yes"
vendor = "Q"
test_type = "custom_vendor"
- cpuid.custom.vendor.empty:
xfail = "yes"
vendor = ""
test_type = "custom_vendor"
......@@ -17,6 +17,12 @@ def run_cpuid(test, params, env):
"""
qemu_binary = utils_misc.get_path('.', params.get("qemu_binary", "qemu"))
cpu_model = params.get("cpu_model", "qemu64")
xfail = False
if (params.get("xfail") is not None) and (params.get("xfail") == "yes"):
xfail = True
class MiniSubtest(test_module.Subtest):
"""
subtest base class for actual tests
......@@ -159,9 +165,12 @@ def run_cpuid(test, params, env):
def cpuid_to_vendor(cpuid_dump, idx):
r = cpuid_regs_to_dic(idx + ' 0x00', cpuid_dump)
dst = []
map(lambda i: dst.append((chr(r['ebx'] >> (8 * i) & 0xff))), range(0,4))
map(lambda i: dst.append((chr(r['edx'] >> (8 * i) & 0xff))), range(0,4))
map(lambda i: dst.append((chr(r['ecx'] >> (8 * i) & 0xff))), range(0,4))
map(lambda i:
dst.append((chr(r['ebx'] >> (8 * i) & 0xff))), range(0, 4))
map(lambda i:
dst.append((chr(r['edx'] >> (8 * i) & 0xff))), range(0, 4))
map(lambda i:
dst.append((chr(r['ecx'] >> (8 * i) & 0xff))), range(0, 4))
return ''.join(dst)
class default_vendor(MiniSubtest):
......@@ -194,6 +203,41 @@ def run_cpuid(test, params, env):
"required vendor [%s] for CPU [%s]" %
(guest_vendor, vendor, cpu_model))
class custom_vendor(MiniSubtest):
"""
Boot qemu with specified vendor
"""
def test(self):
has_error = False
if params.get("vendor") is None:
raise error.TestNAError("'vendor' must be specified in config"
" for this test")
vendor = params.get("vendor")
try:
out = get_guest_cpuid(self, cpu_model, "vendor=" + vendor)
guest_vendor0 = cpuid_to_vendor(out, '0x00000000')
guest_vendor80000000 = cpuid_to_vendor(out, '0x80000000')
logging.debug("Guest's vendor[0]: " + guest_vendor0)
logging.debug("Guest's vendor[0x80000000]: " +
guest_vendor80000000)
if guest_vendor0 != params.get("vendor"):
raise error.TestFail("Guest vendor[0] [%s], doesn't match "
"required vendor [%s] for CPU [%s]" %
(guest_vendor0, vendor, cpu_model))
if guest_vendor80000000 != params.get("vendor"):
raise error.TestFail("Guest vendor[0x80000000] [%s], "
"doesn't match required vendor "
"[%s] for CPU [%s]" %
(guest_vendor80000000, vendor,
cpu_model))
except:
has_error = True
if xfail is False:
raise
if (has_error is False) and (xfail is True):
raise error.TestFail("Test was expected to fail, but it didn't")
# subtests runner
test_type = params.get("test_type")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册