]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: ensure failure if input file doesn't exist
authorJonathon Jongsma <jjongsma@redhat.com>
Thu, 25 Jun 2020 20:18:23 +0000 (15:18 -0500)
committerLaine Stump <laine@redhat.com>
Thu, 25 Jun 2020 23:51:37 +0000 (19:51 -0400)
When using the DO_TEST_PARSE_ERROR() macro, a failure to parse the input
file is considered a successful test. However, if the input file is
totally missing, that should be distinguished from a parsing error and
not be treated as a test success.

The function virDomainDefParseFile() simply returns NULL for any parse
failure, including a missing file. So we need to explicitly check
whether the file exists first, and fail the test if it is missing.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
tests/qemuxml2argvtest.c

index f2522fa530f0dc57ed2334c7a90cf879f19f3ff8..248ce0781155605b773969458df1fa85a438b634 100644 (file)
@@ -608,6 +608,12 @@ testCompareXMLToArgv(const void *data)
     if (!(vm = virDomainObjNew(driver.xmlopt)))
         goto cleanup;
 
+    if (!virFileExists(info->infile)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "Input file '%s' not found", info->infile);
+        goto cleanup;
+    }
+
     parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
     if (!(vm->def = virDomainDefParseFile(info->infile,
                                           driver.xmlopt,