+++ /dev/null
-<domain type='qemu'>
- <name>QEMUGuest1</name>
- <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
- <memory unit='KiB'>219100</memory>
- <currentMemory unit='KiB'>219100</currentMemory>
- <vcpu placement='static'>1</vcpu>
- <os>
- <type arch='x86_64' machine='pc'>hvm</type>
- <boot dev='hd'/>
- </os>
- <cpu mode='custom' match='exact' check='none'>
- <model fallback='forbid'>qemu64</model>
- </cpu>
- <clock offset='utc'/>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>restart</on_reboot>
- <on_crash>destroy</on_crash>
- <devices>
- <emulator>/usr/bin/qemu-system-x86_64</emulator>
- <disk type='file' device='cdrom'>
- <driver name='qemu' type='raw'/>
- <target dev='hdd' bus='ide'/>
- <readonly/>
- <address type='drive' controller='0' bus='1' target='0' unit='1'/>
- </disk>
- <controller type='usb' index='0' model='piix3-uhci'>
- <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
- </controller>
- <controller type='ide' index='0'>
- <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
- </controller>
- <controller type='pci' index='0' model='pci-root'/>
- <input type='mouse' bus='ps2'/>
- <input type='keyboard' bus='ps2'/>
- <audio id='1' type='none'/>
- <memballoon model='none'/>
- </devices>
-</domain>
--- /dev/null
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <target dev='hdd' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' target='0' unit='1'/>
+ </disk>
+ <controller type='usb' index='0' model='piix3-uhci'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='none'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
/* if dirRegex is non-NULL the provided regular expression is used to match
* the file names in a directory (without path prefixed) and only matching
* files are validated */
+ const char **exceptions; /* optional NULL terminated list of filenames inside
+ directory where the expected validation result is
+ inverted */
const char *dirRegex;
const char *file;
};
struct testSchemaData {
virXMLValidator *validator;
+ bool exception;
const char *xml_path;
};
bool shouldFail = !!strstr(data->xml_path, "-invalid.");
g_autoptr(xmlDoc) xml = NULL;
+ if (data->exception)
+ shouldFail = !shouldFail;
+
if (!(xml = virXMLParseFileCtxt(data->xml_path, NULL)))
return -1;
static int
testSchemaFile(const char *schema,
virXMLValidator *validator,
- const char *path)
+ const char *path,
+ bool exception)
{
g_autofree char *test_name = NULL;
struct testSchemaData data = {
.validator = validator,
.xml_path = path,
+ .exception = exception,
};
test_name = g_strdup_printf("Checking %s against %s", path, schema);
testSchemaDir(const char *schema,
virXMLValidator *validator,
const char *dir_path,
- const char *filterstr)
+ const struct testSchemaEntry *entry)
{
g_autoptr(DIR) dir = NULL;
struct dirent *ent;
return -1;
}
- if (filterstr) {
+ if (entry->dirRegex) {
g_autoptr(GError) err = NULL;
- if (!(filter = g_regex_new(filterstr, 0, 0, &err))) {
- VIR_TEST_VERBOSE("\nfailed to compile regex '%s': %s", filterstr, err->message);
+ if (!(filter = g_regex_new(entry->dirRegex, 0, 0, &err))) {
+ VIR_TEST_VERBOSE("\nfailed to compile regex '%s': %s", entry->dirRegex, err->message);
return -1;
}
}
while ((rc = virDirRead(dir, &ent, dir_path)) > 0) {
g_autofree char *xml_path = NULL;
+ bool exception = false;
if (!virStringHasSuffix(ent->d_name, ".xml"))
continue;
!g_regex_match(filter, ent->d_name, 0, NULL))
continue;
+ if (entry->exceptions)
+ exception = g_strv_contains(entry->exceptions, ent->d_name);
+
xml_path = g_strdup_printf("%s/%s", dir_path, ent->d_name);
- if (testSchemaFile(schema, validator, xml_path) < 0)
+ if (testSchemaFile(schema, validator, xml_path, exception) < 0)
ret = -1;
}
if (entry->dir) {
g_autofree char *path = g_strdup_printf("%s/%s", abs_top_srcdir, entry->dir);
- if (testSchemaDir(schema, validator, path, entry->dirRegex) < 0)
+ if (testSchemaDir(schema, validator, path, entry) < 0)
ret = -1;
}
if (entry->file) {
g_autofree char *path = g_strdup_printf("%s/%s", abs_top_srcdir, entry->file);
- if (testSchemaFile(schema, validator, path) < 0)
+ if (testSchemaFile(schema, validator, path, false) < 0)
ret = -1;
}
}
{ .dir = "tests/qemucaps2xmloutdata" },
};
+
+/* give exceptions for output files of invalid input XMLs */
+static const char *exceptions_qemuxml2xmloutdata[] = {
+ "disk-cdrom-empty-network-invalid.x86_64-latest.xml",
+ NULL
+};
+
static const struct testSchemaEntry schemaDomain[] = {
{ .dir = "tests/domainschemadata" },
{ .dir = "tests/qemuxml2argvdata" },
{ .dir = "tests/xmconfigdata" },
- { .dir = "tests/qemuxml2xmloutdata" },
+ { .dir = "tests/qemuxml2xmloutdata",
+ .exceptions = exceptions_qemuxml2xmloutdata,
+ },
{ .dir = "tests/lxcxml2xmldata" },
{ .dir = "tests/lxcxml2xmloutdata" },
{ .dir = "tests/bhyvexml2argvdata" },