]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virschematest: Improve detection of 'invalid' XMLs
authorPeter Krempa <pkrempa@redhat.com>
Tue, 15 Aug 2023 12:20:58 +0000 (14:20 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 22 Aug 2023 12:04:41 +0000 (14:04 +0200)
The output files from 'qemuxml2argvtest' may have the real capability
suffix e.g. 'pci-rom-disabled-invalid.x86_64-latest.xml' which would not
be detected as being invalid and thus causing a test failure.

Change the logic to find '-invalid.' so that we can properly use
'virschematest' with test cases using real capabilities.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/virschematest.c

index fcf3838630c52793d4de407607f33e2d1f12128d..c8c15276131aaaa0ba1c4766119c5b26ebee3832 100644 (file)
@@ -48,7 +48,9 @@ static int
 testSchemaValidateXML(const void *args)
 {
     const struct testSchemaData *data = args;
-    bool shouldFail = virStringHasSuffix(data->xml_path, "-invalid.xml");
+    /* invalid XMLs have a '-invalid.' suffix, but not necessarily at the end
+     * of the file name e.g. in case of qemuxml2xmltest with real capabilities */
+    bool shouldFail = !!strstr(data->xml_path, "-invalid.");
     g_autoptr(xmlDoc) xml = NULL;
 
     if (!(xml = virXMLParseFileCtxt(data->xml_path, NULL)))