virschematest: Add infrastructure for testing single devices

Introduce an internal schema for a single device and use it to test the
various files in tests/qemuhotplugtestdevices and
tests/qemublocktestdata directories.

This also requires us to implement schema for (some) privateData bits
for the disk source.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-10-20 13:32:34 +02:00
parent d8ceacdc87
commit 8daa94cd8e
4 changed files with 128 additions and 0 deletions

View File

@ -0,0 +1,51 @@
<?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<include href="privatedata.rng"/>
<include href="@SCHEMADIR@/domainoverrides.rng"/>
<!-- This schema file describes a singular device. -->
<!-- allow also disk definitions without 'target' as they are used in some tests -->
<define name="diskTarget" combine="choice">
<optional>
<element name="target">
<empty/>
</element>
</optional>
</define>
<start>
<choice>
<ref name="disk"/>
<ref name="controller"/>
<ref name="lease"/>
<ref name="filesystem"/>
<ref name="interface"/>
<ref name="input"/>
<ref name="sound"/>
<ref name="audio"/>
<ref name="hostdev"/>
<ref name="graphic"/>
<ref name="video"/>
<ref name="console"/>
<ref name="parallel"/>
<ref name="serial"/>
<ref name="channel"/>
<ref name="smartcard"/>
<ref name="hub"/>
<ref name="redirdev"/>
<ref name="redirfilter"/>
<ref name="rng"/>
<ref name="tpm"/>
<ref name="shmem"/>
<ref name="memorydev"/>
<ref name="watchdog"/>
<ref name="memballoon"/>
<ref name="nvram"/>
<ref name="panic"/>
<ref name="iommu"/>
<ref name="vsock"/>
</choice>
</start>
</grammar>

View File

@ -5,6 +5,8 @@ virschematest_test_schemas_conf = configuration_data({
virschematest_schemas = [
'cpu-baseline.rng.in',
'device.rng.in',
'privatedata.rng.in',
]
foreach file : virschematest_schemas

View File

@ -0,0 +1,68 @@
<?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<define name="privateDataStorageSource" combine="choice">
<optional>
<element name="privateData">
<interleave>
<optional>
<ref name="privateDataStorageSourceNodenames"/>
</optional>
<optional>
<ref name="privateDataStorageSourceReservations"/>
</optional>
<optional>
<ref name="privateDataStorageSourceObjects"/>
</optional>
</interleave>
</element>
</optional>
</define>
<define name="privateDataDeviceDisk" combine="choice">
<optional>
<element name="privateData">
<notAllowed/>
</element>
</optional>
</define>
<define name="privateDataStorageSourceNodenames">
<element name="nodenames">
<oneOrMore>
<ref name="nodename"/>
</oneOrMore>
</element>
</define>
<define name="nodename">
<element name="nodename">
<attribute name="type">
<choice>
<value>storage</value>
<value>format</value>
</choice>
</attribute>
<attribute name="name"/>
</element>
</define>
<define name="privateDataStorageSourceReservations">
<element name="reservations">
<attribute name="mgralias"/>
</element>
</define>
<define name="privateDataStorageSourceObjects">
<element name="objects">
<interleave>
<optional>
<element name="TLSx509">
<attribute name="alias"/>
</element>
</optional>
</interleave>
</element>
</define>
</grammar>

View File

@ -322,6 +322,12 @@ static const struct testSchemaEntry testsCpuBaseline[] = {
{ . dir = "tests/cputestdata" },
};
static const struct testSchemaEntry testDevice[] = {
{ .dir = "tests/qemuhotplugtestdevices" },
{ .dir = "tests/qemublocktestdata/imagecreate" },
{ .dir = "tests/qemublocktestdata/xml2json" },
};
static int
mymain(void)
{
@ -352,6 +358,7 @@ mymain(void)
DO_TEST(SCHEMAS_PATH "storagevol.rng", schemaStorageVol);
DO_TEST(INTERNAL_SCHEMAS_PATH "cpu-baseline.rng", testsCpuBaseline);
DO_TEST(INTERNAL_SCHEMAS_PATH "device.rng", testDevice);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}