[PATCH 0/3] sysinfotest: rename output XMLs with .xml suffix and introduce schema testing

As noticed in: https://gitlab.com/libvirt/libvirt-go-xml-module/-/issues/10#note_2608097257 This series: - renames the output files with .xml suffix - refactors the schema for the domain <sysinfo> to be reusable - introduces schema to validate the host sysinfo document and tests the output files in virschematest Peter Krempa (3): sysinfotest: Use '.xml' suffix for output files conf: schemas: Split out common parts of 'sysinfo' schema schema: Schema validate host '<sysinfo>' XML test documents src/conf/schemas/domaincommon.rng | 126 +---------- src/conf/schemas/sysinfo.rng | 34 +++ src/conf/schemas/sysinfocommon.rng | 204 ++++++++++++++++++ ...nfo.expect => aarch64-gigabytesysinfo.xml} | 0 ...o.expect => aarch64-hpe-apollosysinfo.xml} | 0 ...nfo.expect => aarch64-moonshotsysinfo.xml} | 0 ...rch64sysinfo.expect => aarch64sysinfo.xml} | 0 ...rpi2sysinfo.expect => arm-rpi2sysinfo.xml} | 0 .../{armsysinfo.expect => armsysinfo.xml} | 0 .../{ppcsysinfo.expect => ppcsysinfo.xml} | 0 ...reqsysinfo.expect => s390-freqsysinfo.xml} | 0 .../{s390sysinfo.expect => s390sysinfo.xml} | 0 .../{x86sysinfo.expect => x86sysinfo.xml} | 0 tests/sysinfotest.c | 2 +- tests/virschematest.c | 5 + 15 files changed, 251 insertions(+), 120 deletions(-) create mode 100644 src/conf/schemas/sysinfo.rng create mode 100644 src/conf/schemas/sysinfocommon.rng rename tests/sysinfodata/{aarch64-gigabytesysinfo.expect => aarch64-gigabytesysinfo.xml} (100%) rename tests/sysinfodata/{aarch64-hpe-apollosysinfo.expect => aarch64-hpe-apollosysinfo.xml} (100%) rename tests/sysinfodata/{aarch64-moonshotsysinfo.expect => aarch64-moonshotsysinfo.xml} (100%) rename tests/sysinfodata/{aarch64sysinfo.expect => aarch64sysinfo.xml} (100%) rename tests/sysinfodata/{arm-rpi2sysinfo.expect => arm-rpi2sysinfo.xml} (100%) rename tests/sysinfodata/{armsysinfo.expect => armsysinfo.xml} (100%) rename tests/sysinfodata/{ppcsysinfo.expect => ppcsysinfo.xml} (100%) rename tests/sysinfodata/{s390-freqsysinfo.expect => s390-freqsysinfo.xml} (100%) rename tests/sysinfodata/{s390sysinfo.expect => s390sysinfo.xml} (100%) rename tests/sysinfodata/{x86sysinfo.expect => x86sysinfo.xml} (100%) -- 2.50.0

From: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- ...rch64-gigabytesysinfo.expect => aarch64-gigabytesysinfo.xml} | 0 ...4-hpe-apollosysinfo.expect => aarch64-hpe-apollosysinfo.xml} | 0 ...rch64-moonshotsysinfo.expect => aarch64-moonshotsysinfo.xml} | 0 tests/sysinfodata/{aarch64sysinfo.expect => aarch64sysinfo.xml} | 0 .../sysinfodata/{arm-rpi2sysinfo.expect => arm-rpi2sysinfo.xml} | 0 tests/sysinfodata/{armsysinfo.expect => armsysinfo.xml} | 0 tests/sysinfodata/{ppcsysinfo.expect => ppcsysinfo.xml} | 0 .../{s390-freqsysinfo.expect => s390-freqsysinfo.xml} | 0 tests/sysinfodata/{s390sysinfo.expect => s390sysinfo.xml} | 0 tests/sysinfodata/{x86sysinfo.expect => x86sysinfo.xml} | 0 tests/sysinfotest.c | 2 +- 11 files changed, 1 insertion(+), 1 deletion(-) rename tests/sysinfodata/{aarch64-gigabytesysinfo.expect => aarch64-gigabytesysinfo.xml} (100%) rename tests/sysinfodata/{aarch64-hpe-apollosysinfo.expect => aarch64-hpe-apollosysinfo.xml} (100%) rename tests/sysinfodata/{aarch64-moonshotsysinfo.expect => aarch64-moonshotsysinfo.xml} (100%) rename tests/sysinfodata/{aarch64sysinfo.expect => aarch64sysinfo.xml} (100%) rename tests/sysinfodata/{arm-rpi2sysinfo.expect => arm-rpi2sysinfo.xml} (100%) rename tests/sysinfodata/{armsysinfo.expect => armsysinfo.xml} (100%) rename tests/sysinfodata/{ppcsysinfo.expect => ppcsysinfo.xml} (100%) rename tests/sysinfodata/{s390-freqsysinfo.expect => s390-freqsysinfo.xml} (100%) rename tests/sysinfodata/{s390sysinfo.expect => s390sysinfo.xml} (100%) rename tests/sysinfodata/{x86sysinfo.expect => x86sysinfo.xml} (100%) diff --git a/tests/sysinfodata/aarch64-gigabytesysinfo.expect b/tests/sysinfodata/aarch64-gigabytesysinfo.xml similarity index 100% rename from tests/sysinfodata/aarch64-gigabytesysinfo.expect rename to tests/sysinfodata/aarch64-gigabytesysinfo.xml diff --git a/tests/sysinfodata/aarch64-hpe-apollosysinfo.expect b/tests/sysinfodata/aarch64-hpe-apollosysinfo.xml similarity index 100% rename from tests/sysinfodata/aarch64-hpe-apollosysinfo.expect rename to tests/sysinfodata/aarch64-hpe-apollosysinfo.xml diff --git a/tests/sysinfodata/aarch64-moonshotsysinfo.expect b/tests/sysinfodata/aarch64-moonshotsysinfo.xml similarity index 100% rename from tests/sysinfodata/aarch64-moonshotsysinfo.expect rename to tests/sysinfodata/aarch64-moonshotsysinfo.xml diff --git a/tests/sysinfodata/aarch64sysinfo.expect b/tests/sysinfodata/aarch64sysinfo.xml similarity index 100% rename from tests/sysinfodata/aarch64sysinfo.expect rename to tests/sysinfodata/aarch64sysinfo.xml diff --git a/tests/sysinfodata/arm-rpi2sysinfo.expect b/tests/sysinfodata/arm-rpi2sysinfo.xml similarity index 100% rename from tests/sysinfodata/arm-rpi2sysinfo.expect rename to tests/sysinfodata/arm-rpi2sysinfo.xml diff --git a/tests/sysinfodata/armsysinfo.expect b/tests/sysinfodata/armsysinfo.xml similarity index 100% rename from tests/sysinfodata/armsysinfo.expect rename to tests/sysinfodata/armsysinfo.xml diff --git a/tests/sysinfodata/ppcsysinfo.expect b/tests/sysinfodata/ppcsysinfo.xml similarity index 100% rename from tests/sysinfodata/ppcsysinfo.expect rename to tests/sysinfodata/ppcsysinfo.xml diff --git a/tests/sysinfodata/s390-freqsysinfo.expect b/tests/sysinfodata/s390-freqsysinfo.xml similarity index 100% rename from tests/sysinfodata/s390-freqsysinfo.expect rename to tests/sysinfodata/s390-freqsysinfo.xml diff --git a/tests/sysinfodata/s390sysinfo.expect b/tests/sysinfodata/s390sysinfo.xml similarity index 100% rename from tests/sysinfodata/s390sysinfo.expect rename to tests/sysinfodata/s390sysinfo.xml diff --git a/tests/sysinfodata/x86sysinfo.expect b/tests/sysinfodata/x86sysinfo.xml similarity index 100% rename from tests/sysinfodata/x86sysinfo.expect rename to tests/sysinfodata/x86sysinfo.xml diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c index b666847379..6828466f7a 100644 --- a/tests/sysinfotest.c +++ b/tests/sysinfotest.c @@ -103,7 +103,7 @@ testSysinfo(const void *data) sysinfo = g_strdup_printf("%s/sysinfodata/%ssysinfo.data", abs_srcdir, testdata->name); cpuinfo = g_strdup_printf("%s/sysinfodata/%scpuinfo.data", abs_srcdir, testdata->name); - expected = g_strdup_printf("%s/sysinfodata/%ssysinfo.expect", abs_srcdir, testdata->name); + expected = g_strdup_printf("%s/sysinfodata/%ssysinfo.xml", abs_srcdir, testdata->name); virCommandSetDryRun(dryRunToken, NULL, false, false, testDMIDecodeDryRun, sysinfo); -- 2.50.0

From: Peter Krempa <pkrempa@redhat.com> Extract the common bits of the domain definition <sysinfo> schema which will be also later reused to construct schema for the host <sysinfo> top level element. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/conf/schemas/domaincommon.rng | 126 ++----------------------- src/conf/schemas/sysinfocommon.rng | 143 +++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 119 deletions(-) create mode 100644 src/conf/schemas/sysinfocommon.rng diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index 183dd5db5e..2d6e15f144 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -7,6 +7,7 @@ <include href="cputypes.rng"/> <include href="nwfilter_params.rng"/> <include href="privatedata.rng"/> + <include href="sysinfocommon.rng"/> <define name="createMode"> <data type="unsignedInt"> @@ -7125,63 +7126,11 @@ <value>smbios</value> </attribute> <interleave> - <optional> - <element name="bios"> - <oneOrMore> - <element name="entry"> - <attribute name="name"> - <ref name="sysinfo-bios-name"/> - </attribute> - <ref name="sysinfo-value"/> - </element> - </oneOrMore> - </element> - </optional> - <optional> - <element name="system"> - <oneOrMore> - <element name="entry"> - <attribute name="name"> - <ref name="sysinfo-system-name"/> - </attribute> - <ref name="sysinfo-value"/> - </element> - </oneOrMore> - </element> - </optional> - <zeroOrMore> - <element name="baseBoard"> - <oneOrMore> - <element name="entry"> - <attribute name="name"> - <ref name="sysinfo-baseBoard-name"/> - </attribute> - <ref name="sysinfo-value"/> - </element> - </oneOrMore> - </element> - </zeroOrMore> - <optional> - <element name="chassis"> - <oneOrMore> - <element name="entry"> - <attribute name="name"> - <ref name="sysinfo-chassis-name"/> - </attribute> - <ref name="sysinfo-value"/> - </element> - </oneOrMore> - </element> - </optional> - <optional> - <element name="oemStrings"> - <oneOrMore> - <element name="entry"> - <ref name="sysinfo-value"/> - </element> - </oneOrMore> - </element> - </optional> + <ref name="sysinfo-smbios-group-bios"/> + <ref name="sysinfo-smbios-group-system"/> + <ref name="sysinfo-smbios-group-baseboard"/> + <ref name="sysinfo-smbios-group-chassis"/> + <ref name="sysinfo-smbios-group-oemstrings"/> </interleave> </group> <group> @@ -7189,74 +7138,13 @@ <value>fwcfg</value> </attribute> <zeroOrMore> - <element name="entry"> - <attribute name="name"> - <data type="string"/> - </attribute> - <choice> - <group> - <attribute name="file"> - <data type="string"/> - </attribute> - <empty/> - </group> - <group> - <ref name="sysinfo-value"/> - </group> - </choice> - </element> + <ref name="sysinfo-fwcfg-entry"/> </zeroOrMore> </group> </choice> </element> </define> - <define name="sysinfo-bios-name"> - <choice> - <value>vendor</value> - <value>version</value> - <value>date</value> - <value>release</value> - </choice> - </define> - - <define name="sysinfo-system-name"> - <choice> - <value>manufacturer</value> - <value>product</value> - <value>version</value> - <value>serial</value> - <value>uuid</value> - <value>sku</value> - <value>family</value> - </choice> - </define> - - <define name="sysinfo-baseBoard-name"> - <choice> - <value>manufacturer</value> - <value>product</value> - <value>version</value> - <value>serial</value> - <value>asset</value> - <value>location</value> - </choice> - </define> - - <define name="sysinfo-chassis-name"> - <choice> - <value>manufacturer</value> - <value>version</value> - <value>serial</value> - <value>asset</value> - <value>sku</value> - </choice> - </define> - - <define name="sysinfo-value"> - <data type="string"/> - </define> - <define name="acpiTable"> <element name="acpi"> <zeroOrMore> diff --git a/src/conf/schemas/sysinfocommon.rng b/src/conf/schemas/sysinfocommon.rng new file mode 100644 index 0000000000..dc3b761206 --- /dev/null +++ b/src/conf/schemas/sysinfocommon.rng @@ -0,0 +1,143 @@ +<?xml version="1.0"?> +<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"> + + <!-- This schema is not designed for standalone use --> + + <define name="sysinfo-smbios-group-bios"> + <optional> + <element name="bios"> + <oneOrMore> + <element name="entry"> + <attribute name="name"> + <ref name="sysinfo-bios-name"/> + </attribute> + <ref name="sysinfo-value"/> + </element> + </oneOrMore> + </element> + </optional> + </define> + + <define name="sysinfo-smbios-group-system"> + <optional> + <element name="system"> + <oneOrMore> + <element name="entry"> + <attribute name="name"> + <ref name="sysinfo-system-name"/> + </attribute> + <ref name="sysinfo-value"/> + </element> + </oneOrMore> + </element> + </optional> + </define> + + <define name="sysinfo-smbios-group-baseboard"> + <zeroOrMore> + <element name="baseBoard"> + <oneOrMore> + <element name="entry"> + <attribute name="name"> + <ref name="sysinfo-baseBoard-name"/> + </attribute> + <ref name="sysinfo-value"/> + </element> + </oneOrMore> + </element> + </zeroOrMore> + </define> + + <define name="sysinfo-smbios-group-chassis"> + <optional> + <element name="chassis"> + <oneOrMore> + <element name="entry"> + <attribute name="name"> + <ref name="sysinfo-chassis-name"/> + </attribute> + <ref name="sysinfo-value"/> + </element> + </oneOrMore> + </element> + </optional> + </define> + + <define name="sysinfo-smbios-group-oemstrings"> + <optional> + <element name="oemStrings"> + <oneOrMore> + <element name="entry"> + <ref name="sysinfo-value"/> + </element> + </oneOrMore> + </element> + </optional> + </define> + + <define name="sysinfo-fwcfg-entry"> + <element name="entry"> + <attribute name="name"> + <data type="string"/> + </attribute> + <choice> + <group> + <attribute name="file"> + <data type="string"/> + </attribute> + <empty/> + </group> + <group> + <ref name="sysinfo-value"/> + </group> + </choice> + </element> + </define> + + <define name="sysinfo-bios-name"> + <choice> + <value>vendor</value> + <value>version</value> + <value>date</value> + <value>release</value> + </choice> + </define> + + <define name="sysinfo-system-name"> + <choice> + <value>manufacturer</value> + <value>product</value> + <value>version</value> + <value>serial</value> + <value>uuid</value> + <value>sku</value> + <value>family</value> + </choice> + </define> + + <define name="sysinfo-baseBoard-name"> + <choice> + <value>manufacturer</value> + <value>product</value> + <value>version</value> + <value>serial</value> + <value>asset</value> + <value>location</value> + </choice> + </define> + + <define name="sysinfo-chassis-name"> + <choice> + <value>manufacturer</value> + <value>version</value> + <value>serial</value> + <value>asset</value> + <value>sku</value> + </choice> + </define> + + <define name="sysinfo-value"> + <data type="string"/> + </define> + +</grammar> -- 2.50.0

From: Peter Krempa <pkrempa@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 <pkrempa@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

On a Tuesday in 2025, Peter Krempa via Devel wrote:
As noticed in:
https://gitlab.com/libvirt/libvirt-go-xml-module/-/issues/10#note_2608097257
This series: - renames the output files with .xml suffix - refactors the schema for the domain <sysinfo> to be reusable - introduces schema to validate the host sysinfo document and tests the output files in virschematest
Peter Krempa (3): sysinfotest: Use '.xml' suffix for output files conf: schemas: Split out common parts of 'sysinfo' schema schema: Schema validate host '<sysinfo>' XML test documents
src/conf/schemas/domaincommon.rng | 126 +---------- src/conf/schemas/sysinfo.rng | 34 +++ src/conf/schemas/sysinfocommon.rng | 204 ++++++++++++++++++ ...nfo.expect => aarch64-gigabytesysinfo.xml} | 0 ...o.expect => aarch64-hpe-apollosysinfo.xml} | 0 ...nfo.expect => aarch64-moonshotsysinfo.xml} | 0 ...rch64sysinfo.expect => aarch64sysinfo.xml} | 0 ...rpi2sysinfo.expect => arm-rpi2sysinfo.xml} | 0 .../{armsysinfo.expect => armsysinfo.xml} | 0 .../{ppcsysinfo.expect => ppcsysinfo.xml} | 0 ...reqsysinfo.expect => s390-freqsysinfo.xml} | 0 .../{s390sysinfo.expect => s390sysinfo.xml} | 0 .../{x86sysinfo.expect => x86sysinfo.xml} | 0 tests/sysinfotest.c | 2 +- tests/virschematest.c | 5 + 15 files changed, 251 insertions(+), 120 deletions(-) create mode 100644 src/conf/schemas/sysinfo.rng create mode 100644 src/conf/schemas/sysinfocommon.rng rename tests/sysinfodata/{aarch64-gigabytesysinfo.expect => aarch64-gigabytesysinfo.xml} (100%) rename tests/sysinfodata/{aarch64-hpe-apollosysinfo.expect => aarch64-hpe-apollosysinfo.xml} (100%) rename tests/sysinfodata/{aarch64-moonshotsysinfo.expect => aarch64-moonshotsysinfo.xml} (100%) rename tests/sysinfodata/{aarch64sysinfo.expect => aarch64sysinfo.xml} (100%) rename tests/sysinfodata/{arm-rpi2sysinfo.expect => arm-rpi2sysinfo.xml} (100%) rename tests/sysinfodata/{armsysinfo.expect => armsysinfo.xml} (100%) rename tests/sysinfodata/{ppcsysinfo.expect => ppcsysinfo.xml} (100%) rename tests/sysinfodata/{s390-freqsysinfo.expect => s390-freqsysinfo.xml} (100%) rename tests/sysinfodata/{s390sysinfo.expect => s390sysinfo.xml} (100%) rename tests/sysinfodata/{x86sysinfo.expect => x86sysinfo.xml} (100%)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa