From: Jonathon Jongsma Date: Thu, 25 Jun 2020 20:18:23 +0000 (-0500) Subject: tests: ensure failure if input file doesn't exist X-Git-Tag: v6.5.0-rc1~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bac096fff0bf3414ebeb4306a32ad4dab20ccfdf;p=thirdparty%2Flibvirt.git tests: ensure failure if input file doesn't exist 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 --- diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index f2522fa530..248ce07811 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -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,