[libvirt PATCH v4 4/5] tests: Enable CPU XML validation in the tests.

Tim Wiederhake twiederh at redhat.com
Wed Oct 7 08:54:57 UTC 2020


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 docs/schemas/cpu_test.rng | 48 +++++++++++++++++++++++++++++++++++++++
 docs/schemas/meson.build  |  1 +
 tests/cputest.c           |  2 +-
 tests/virschematest.c     |  1 +
 4 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 docs/schemas/cpu_test.rng

diff --git a/docs/schemas/cpu_test.rng b/docs/schemas/cpu_test.rng
new file mode 100644
index 0000000000..471958bb7b
--- /dev/null
+++ b/docs/schemas/cpu_test.rng
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+  <include href="cpu.rng">
+    <start>
+      <choice>
+        <ref name="guestcpu"/>
+        <ref name="hostcpu"/>
+        <ref name="cpudata"/>
+        <ref name="cputest"/>
+      </choice>
+    </start>
+  </include>
+
+  <define name="cpudata">
+    <element name="cpudata">
+      <attribute name="arch"><text/></attribute>
+      <oneOrMore>
+        <choice>
+          <element name="cpuid">
+            <attribute name="eax_in"><ref name="hexuint"/></attribute>
+            <attribute name="ecx_in"><ref name="hexuint"/></attribute>
+            <attribute name="eax"><ref name="hexuint"/></attribute>
+            <attribute name="ebx"><ref name="hexuint"/></attribute>
+            <attribute name="ecx"><ref name="hexuint"/></attribute>
+            <attribute name="edx"><ref name="hexuint"/></attribute>
+          </element>
+          <element name="msr">
+            <attribute name="eax"><ref name="hexuint"/></attribute>
+            <attribute name="edx"><ref name="hexuint"/></attribute>
+            <attribute name="index"><ref name="hexuint"/></attribute>
+          </element>
+        </choice>
+      </oneOrMore>
+    </element>
+  </define>
+
+  <define name="cputest">
+    <element name="cpuTest">
+      <oneOrMore>
+        <choice>
+          <ref name="guestcpu"/>
+          <ref name="hostcpu"/>
+        </choice>
+      </oneOrMore>
+    </element>
+  </define>
+
+</grammar>
diff --git a/docs/schemas/meson.build b/docs/schemas/meson.build
index bb6a48787f..51c917d1ac 100644
--- a/docs/schemas/meson.build
+++ b/docs/schemas/meson.build
@@ -2,6 +2,7 @@ docs_schema_files = [
   'basictypes.rng',
   'capability.rng',
   'cpu.rng',
+  'cpu_test.rng',
   'cputypes.rng',
   'domainbackup.rng',
   'domaincaps.rng',
diff --git a/tests/cputest.c b/tests/cputest.c
index 90f319bf9c..e31c2c0820 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -81,7 +81,7 @@ cpuTestLoadXML(virArch arch, const char *name)
     if (!(doc = virXMLParseFileCtxt(xml, &ctxt)))
         goto cleanup;
 
-    virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, false);
+    virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu, true);
 
  cleanup:
     xmlXPathFreeContext(ctxt);
diff --git a/tests/virschematest.c b/tests/virschematest.c
index 17eb2a4b34..fa7c64c0b8 100644
--- a/tests/virschematest.c
+++ b/tests/virschematest.c
@@ -198,6 +198,7 @@ mymain(void)
     } while (0)
 
     DO_TEST_DIR("capability.rng", "capabilityschemadata", "vircaps2xmldata");
+    DO_TEST_DIR("cpu_test.rng", "cputestdata");
     DO_TEST_DIR("domain.rng", "domainschemadata",
                 "qemuxml2argvdata", "xmconfigdata",
                 "qemuxml2xmloutdata", "lxcxml2xmldata",
-- 
2.26.2




More information about the libvir-list mailing list