qemuxml2xmltest: Remove pointless inactive->active testing

'virDomainDefFormatInternalSetRootName' which is the top level XML
formatter function has the following condition as the very first thing:

     if (def->id == -1)
         flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;

This makes it pointless to separately do inactive->active and
inactive->inactive XML -> XML testing as both will be in the end treated
as inactive->inactive.

This patch adds a warning to virDomainDefFormatInternalSetRootName and
removes the second pointless invocation of the test from
qemuxml2xmtest.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-12-15 22:51:48 +01:00
parent b4e8196c50
commit eb994dee5b
2 changed files with 11 additions and 33 deletions

View File

@ -27722,6 +27722,8 @@ virDomainDefFormatInternalSetRootName(virDomainDef *def,
return -1;
}
/* When changing this condition, beware that tests such as qemuxml*test
* were optimized based on this predicate and may need to be fixed. */
if (def->id == -1)
flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE;

View File

@ -20,8 +20,10 @@
static virQEMUDriver driver;
static int
testXML2XMLCommon(const testQemuInfo *info)
testXML2XMLInactive(const void *opaque)
{
const testQemuInfo *info = opaque;
if (testQemuInfoInitArgs((testQemuInfo *) info) < 0)
return -1;
@ -30,17 +32,10 @@ testXML2XMLCommon(const testQemuInfo *info)
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
return -1;
return 0;
}
static int
testXML2XMLActive(const void *opaque)
{
const testQemuInfo *info = opaque;
if (testXML2XMLCommon(info) < 0 ||
testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
/* we deliberately format the XML as live to catch potential test regressions
* as virDomainDefFormatInternalSetRootName implies _INACTIVE if 'def->id'
* is -1, thus VM is inactive. */
if (testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
info->infile, info->outfile, true,
info->parseFlags | VIR_DOMAIN_DEF_PARSE_INACTIVE,
TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS) < 0) {
@ -51,23 +46,6 @@ testXML2XMLActive(const void *opaque)
}
static int
testXML2XMLInactive(const void *opaque)
{
const testQemuInfo *info = opaque;
if (testXML2XMLCommon(info) < 0 ||
testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt,
info->infile, info->outfile, false,
info->parseFlags | VIR_DOMAIN_DEF_PARSE_INACTIVE,
TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS) < 0) {
return -1;
}
return 0;
}
static void
testRun(const char *name,
const char *suffix,
@ -75,8 +53,7 @@ testRun(const char *name,
int *ret,
...)
{
g_autofree char *name_active = g_strdup_printf("QEMU XML-2-XML-active %s", name);
g_autofree char *name_inactive = g_strdup_printf("QEMU XML-2-XML-inactive %s", name);
g_autofree char *testname = g_strdup_printf("QEMU inactive-XML -> inactive-XML %s", name);
g_autoptr(testQemuInfo) info = g_new0(testQemuInfo, 1);
va_list ap;
@ -92,8 +69,7 @@ testRun(const char *name,
info->outfile = g_strdup_printf("%s/qemuxml2xmloutdata/%s%s.xml",
abs_srcdir, info->name, suffix);
virTestRunLog(ret, name_inactive, testXML2XMLInactive, info);
virTestRunLog(ret, name_active, testXML2XMLActive, info);
virTestRunLog(ret, testname, testXML2XMLInactive, info);
}