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@xxxxxxxxxx> --- tests/schemas/device.rng.in | 51 ++++++++++++++++++++++++ tests/schemas/meson.build | 2 + tests/schemas/privatedata.rng.in | 68 ++++++++++++++++++++++++++++++++ tests/virschematest.c | 7 ++++ 4 files changed, 128 insertions(+) create mode 100644 tests/schemas/device.rng.in create mode 100644 tests/schemas/privatedata.rng.in diff --git a/tests/schemas/device.rng.in b/tests/schemas/device.rng.in new file mode 100644 index 0000000000..b322b5275e --- /dev/null +++ b/tests/schemas/device.rng.in @@ -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> diff --git a/tests/schemas/meson.build b/tests/schemas/meson.build index 33c16bb2fb..851355d4e9 100644 --- a/tests/schemas/meson.build +++ b/tests/schemas/meson.build @@ -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 diff --git a/tests/schemas/privatedata.rng.in b/tests/schemas/privatedata.rng.in new file mode 100644 index 0000000000..945f7a06b3 --- /dev/null +++ b/tests/schemas/privatedata.rng.in @@ -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> diff --git a/tests/virschematest.c b/tests/virschematest.c index 29a1d59134..fcf3838630 100644 --- a/tests/virschematest.c +++ b/tests/virschematest.c @@ -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; } -- 2.38.1