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

cpuid: add custom_family test

Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
---
v2:
    * s/TestFail/TestNAError/
    * s/custom_family/custom.family/ in config
上级 330128bc
......@@ -89,3 +89,21 @@
xfail = "yes"
level = "five"
test_type = "custom_level"
- cpuid.custom.family:
family = 6
test_type = "custom_family"
- cpuid.custom.family.ext:
family = 21
test_type = "custom_family"
- cpuid.custom.family.max:
# 0xff + 0xf = 270
family = 270
test_type = "custom_family"
- cpuid.custom.family.NaN:
xfail = "yes"
family = foo
test_type = "custom_family"
- cpuid.custom.family.out_of_range:
xfail = "yes"
family = 271
test_type = "custom_family"
......@@ -266,6 +266,41 @@ def run_cpuid(test, params, env):
if (has_error is False) and (xfail is True):
raise error.TestFail("Test was expected to fail, but it didn't")
def cpuid_to_family(cpuid_dump):
# Intel Processor Identification and the CPUID Instruction
# http://www.intel.com/Assets/PDF/appnote/241618.pdf
# 5.1.2 Feature Information (Function 01h)
eax = cpuid_regs_to_dic('0x00000001 0x00', cpuid_dump)['eax']
family = (eax >> 8) & 0xf
if family == 0xf:
# extract extendend family
return family + ((eax >> 20) & 0xff)
return family
class custom_family(MiniSubtest):
"""
Boot qemu with specified family
"""
def test(self):
has_error = False
if params.get("family") is None:
raise error.TestNAError("'family' must be specified in config"
" for this test")
try:
out = get_guest_cpuid(self, cpu_model, "family=" +
params.get("family"))
guest_family = str(cpuid_to_family(out))
if guest_family != params.get("family"):
raise error.TestFail("Guest's family [%s], doesn't match "
"required family [%s]" %
(guest_family, params.get("family")))
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.
先完成此消息的编辑!
想要评论请 注册