From: Peter Krempa <pkre...@redhat.com> Introduce schema for the host '<sysinfo>' output XMLs and validate our test data against the schema.
This requires introduction of schema for '<processor>' and '<memory_device>' elements which are not supported when sysinfo is set explicitly for a domian definition. Signed-off-by: Peter Krempa <pkre...@redhat.com> --- src/conf/schemas/sysinfo.rng | 34 +++++++++++++++++ src/conf/schemas/sysinfocommon.rng | 61 ++++++++++++++++++++++++++++++ tests/virschematest.c | 5 +++ 3 files changed, 100 insertions(+) create mode 100644 src/conf/schemas/sysinfo.rng diff --git a/src/conf/schemas/sysinfo.rng b/src/conf/schemas/sysinfo.rng new file mode 100644 index 0000000000..01d305b9d6 --- /dev/null +++ b/src/conf/schemas/sysinfo.rng @@ -0,0 +1,34 @@ +<?xml version="1.0"?> +<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + <start> + <element name="sysinfo"> + <choice> + <group> + <attribute name="type"> + <value>smbios</value> + </attribute> + <interleave> + <ref name="sysinfo-smbios-group-bios"/> + <ref name="sysinfo-smbios-group-system"/> + <ref name="sysinfo-smbios-group-baseboard"/> + <ref name="sysinfo-smbios-group-processor"/> + <ref name="sysinfo-smbios-group-memory"/> + <ref name="sysinfo-smbios-group-chassis"/> + <ref name="sysinfo-smbios-group-oemstrings"/> + </interleave> + </group> + <group> + <attribute name="type"> + <value>fwcfg</value> + </attribute> + <zeroOrMore> + <ref name="sysinfo-fwcfg-entry"/> + </zeroOrMore> + </group> + </choice> + </element> + </start> + + <include href="sysinfocommon.rng"/> + +</grammar> diff --git a/src/conf/schemas/sysinfocommon.rng b/src/conf/schemas/sysinfocommon.rng index dc3b761206..41296ea95e 100644 --- a/src/conf/schemas/sysinfocommon.rng +++ b/src/conf/schemas/sysinfocommon.rng @@ -63,6 +63,36 @@ </optional> </define> + <define name="sysinfo-smbios-group-processor"> + <zeroOrMore> + <element name="processor"> + <oneOrMore> + <element name="entry"> + <attribute name="name"> + <ref name="sysinfo-processor-name"/> + </attribute> + <ref name="sysinfo-value"/> + </element> + </oneOrMore> + </element> + </zeroOrMore> + </define> + + <define name="sysinfo-smbios-group-memory"> + <zeroOrMore> + <element name="memory_device"> + <oneOrMore> + <element name="entry"> + <attribute name="name"> + <ref name="sysinfo-memory-name"/> + </attribute> + <ref name="sysinfo-value"/> + </element> + </oneOrMore> + </element> + </zeroOrMore> + </define> + <define name="sysinfo-smbios-group-oemstrings"> <optional> <element name="oemStrings"> @@ -136,6 +166,37 @@ </choice> </define> + <define name="sysinfo-processor-name"> + <choice> + <value>socket_destination</value> + <value>type</value> + <value>family</value> + <value>manufacturer</value> + <value>signature</value> + <value>version</value> + <value>external_clock</value> + <value>max_speed</value> + <value>status</value> + <value>serial_number</value> + <value>part_number</value> + </choice> + </define> + + <define name="sysinfo-memory-name"> + <choice> + <value>size</value> + <value>form_factor</value> + <value>locator</value> + <value>bank_locator</value> + <value>type</value> + <value>type_detail</value> + <value>speed</value> + <value>manufacturer</value> + <value>serial_number</value> + <value>part_number</value> + </choice> + </define> + <define name="sysinfo-value"> <data type="string"/> </define> diff --git a/tests/virschematest.c b/tests/virschematest.c index e08ae21738..57a49c270c 100644 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -369,6 +369,10 @@ static const struct testSchemaEntry testDevice[] = { { .dir = "tests/qemublocktestdata/xml2json" }, }; +static const struct testSchemaEntry schemaSysinfo[] = { + { .dir = "tests/sysinfodata" }, +}; + static int mymain(void) { @@ -397,6 +401,7 @@ mymain(void) DO_TEST(SCHEMAS_PATH "storagepoolcaps.rng", schemaStoragepoolcaps); DO_TEST(SCHEMAS_PATH "storagepool.rng", schemaStoragePool); DO_TEST(SCHEMAS_PATH "storagevol.rng", schemaStorageVol); + DO_TEST(SCHEMAS_PATH "sysinfo.rng", schemaSysinfo); DO_TEST(INTERNAL_SCHEMAS_PATH "cpu-baseline.rng", testsCpuBaseline); DO_TEST(INTERNAL_SCHEMAS_PATH "device.rng", testDevice); -- 2.50.0