Signed-off-by: Igor Mammedov <[email protected]>
---
 qemu/tests/cfg/qemu_cpu.cfg |   21 +++++++++++++++++++++
 qemu/tests/cpuid.py         |   29 +++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/qemu/tests/cfg/qemu_cpu.cfg b/qemu/tests/cfg/qemu_cpu.cfg
index f13c380..a210c09 100644
--- a/qemu/tests/cfg/qemu_cpu.cfg
+++ b/qemu/tests/cfg/qemu_cpu.cfg
@@ -143,6 +143,27 @@
                             leaf = "0x40000001"
                             flags = "hv_relaxed"
                             regs = "eax"
+                - hyperv:
+                    only kvm
+                    only cpu.unset
+                    test_type = "cpuid_bit_test"
+                    variants:
+                        - vapic40000003:
+                            bits = "4 5"
+                            leaf = "0x40000003"
+                            flags = "hv_vapic"
+                        - relaxed40000003:
+                            bits = "5"
+                            leaf = "0x40000003"
+                            flags = "hv_relaxed"
+                        - vapic40000004:
+                            bits = "3"
+                            leaf = "0x40000004"
+                            flags = "hv_vapic"
+                        - relaxed40000004:
+                            bits = "5"
+                            leaf = "0x40000004"
+                            flags = "hv_relaxed"
                 - custom:
                     # the checks below will be run without setting the CPU 
model
                     # explicitly. they can be repeated for each known CPU model
diff --git a/qemu/tests/cpuid.py b/qemu/tests/cpuid.py
index 99f70a0..f1556b7 100644
--- a/qemu/tests/cpuid.py
+++ b/qemu/tests/cpuid.py
@@ -487,6 +487,35 @@ 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")
 
+    class cpuid_bit_test(MiniSubtest):
+        """
+        test bits in specified leaf:func:reg
+        """
+        def test(self):
+            has_error = False
+            flags = params.get("flags","")
+            leaf = params.get("leaf","0x40000000")
+            idx = params.get("index","0x00")
+            reg = params.get("reg","eax")
+            if params.get("bits") is None:
+                raise error.TestNAError("'bits' must be specified in"
+                                        "config for this test")
+            bits = params.get("bits").split()
+            try:
+                out = get_guest_cpuid(self, cpu_model, flags)
+                r = cpuid_regs_to_dic('%s %s' % (leaf, idx), out)[reg]
+                logging.debug("CPUID(%s.%s).%s=0x%08x" % (leaf, idx, reg, r))
+                for i in bits:
+                    if (r & (1 << int(i))) == 0:
+                        raise error.TestFail("CPUID(%s.%s).%s[%s] is not set" %
+                                             (leaf, idx, reg, i))
+            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")
-- 
1.7.1

_______________________________________________
Virt-test-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-test-devel

Reply via email to