tests: libxl: remove pointless labels

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
Ján Tomko 2021-09-04 22:39:45 +02:00
parent 583a561a4f
commit 4739de290d
2 changed files with 34 additions and 51 deletions

View File

@ -68,47 +68,43 @@ testCompareParseXML(const char *xlcfg, const char *xml, bool replaceVars)
g_autoptr(virConf) conf = NULL; g_autoptr(virConf) conf = NULL;
g_autoptr(virConnect) conn = NULL; g_autoptr(virConnect) conn = NULL;
int wrote = 4096; int wrote = 4096;
int ret = -1;
g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) def = NULL;
g_autofree char *replacedXML = NULL; g_autofree char *replacedXML = NULL;
gotxlcfgData = g_new0(char, wrote); gotxlcfgData = g_new0(char, wrote);
conn = virGetConnect(); conn = virGetConnect();
if (!conn) goto fail; if (!conn)
return -1;
if (replaceVars) { if (replaceVars) {
if (!(replacedXML = testReplaceVarsXML(xml))) if (!(replacedXML = testReplaceVarsXML(xml)))
goto fail; return -1;
if (!(def = virDomainDefParseString(replacedXML, driver->xmlopt, if (!(def = virDomainDefParseString(replacedXML, driver->xmlopt,
NULL, VIR_DOMAIN_XML_INACTIVE))) NULL, VIR_DOMAIN_XML_INACTIVE)))
goto fail; return -1;
} else { } else {
if (!(def = virDomainDefParseFile(xml, driver->xmlopt, if (!(def = virDomainDefParseFile(xml, driver->xmlopt,
NULL, VIR_DOMAIN_XML_INACTIVE))) NULL, VIR_DOMAIN_XML_INACTIVE)))
goto fail; return -1;
} }
if (!virDomainDefCheckABIStability(def, def, driver->xmlopt)) { if (!virDomainDefCheckABIStability(def, def, driver->xmlopt)) {
fprintf(stderr, "ABI stability check failed on %s", xml); fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail; return -1;
} }
if (!(conf = xenFormatXL(def, conn))) if (!(conf = xenFormatXL(def, conn)))
goto fail; return -1;
if (virConfWriteMem(gotxlcfgData, &wrote, conf) < 0) if (virConfWriteMem(gotxlcfgData, &wrote, conf) < 0)
goto fail; return -1;
gotxlcfgData[wrote] = '\0'; gotxlcfgData[wrote] = '\0';
if (virTestCompareToFile(gotxlcfgData, xlcfg) < 0) if (virTestCompareToFile(gotxlcfgData, xlcfg) < 0)
goto fail; return -1;
ret = 0; return 0;
fail:
return ret;
} }
/* /*
@ -121,44 +117,40 @@ testCompareFormatXML(const char *xlcfg, const char *xml, bool replaceVars)
g_autofree char *xlcfgData = NULL; g_autofree char *xlcfgData = NULL;
g_autofree char *gotxml = NULL; g_autofree char *gotxml = NULL;
g_autoptr(virConf) conf = NULL; g_autoptr(virConf) conf = NULL;
int ret = -1;
g_autoptr(virConnect) conn = NULL; g_autoptr(virConnect) conn = NULL;
g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) def = NULL;
g_autofree char *replacedXML = NULL; g_autofree char *replacedXML = NULL;
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver); g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
conn = virGetConnect(); conn = virGetConnect();
if (!conn) goto fail; if (!conn)
return -1;
if (virTestLoadFile(xlcfg, &xlcfgData) < 0) if (virTestLoadFile(xlcfg, &xlcfgData) < 0)
goto fail; return -1;
if (!(conf = virConfReadString(xlcfgData, 0))) if (!(conf = virConfReadString(xlcfgData, 0)))
goto fail; return -1;
if (!(def = xenParseXL(conf, cfg->caps, driver->xmlopt))) if (!(def = xenParseXL(conf, cfg->caps, driver->xmlopt)))
goto fail; return -1;
if (!(gotxml = virDomainDefFormat(def, driver->xmlopt, if (!(gotxml = virDomainDefFormat(def, driver->xmlopt,
VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_INACTIVE |
VIR_DOMAIN_XML_SECURE))) VIR_DOMAIN_XML_SECURE)))
goto fail; return -1;
if (replaceVars) { if (replaceVars) {
if (!(replacedXML = testReplaceVarsXML(xml))) if (!(replacedXML = testReplaceVarsXML(xml)))
goto fail; return -1;
if (virTestCompareToString(gotxml, replacedXML) < 0) if (virTestCompareToString(gotxml, replacedXML) < 0)
goto fail; return -1;
} else { } else {
if (virTestCompareToFile(gotxml, xml) < 0) if (virTestCompareToFile(gotxml, xml) < 0)
goto fail; return -1;
} }
ret = 0; return 0;
fail:
return ret;
} }

View File

@ -41,7 +41,6 @@ testCompareParseXML(const char *xmcfg, const char *xml)
{ {
g_autofree char *gotxmcfgData = NULL; g_autofree char *gotxmcfgData = NULL;
g_autoptr(virConf) conf = NULL; g_autoptr(virConf) conf = NULL;
int ret = -1;
g_autoptr(virConnect) conn = NULL; g_autoptr(virConnect) conn = NULL;
int wrote = 4096; int wrote = 4096;
g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) def = NULL;
@ -49,32 +48,29 @@ testCompareParseXML(const char *xmcfg, const char *xml)
gotxmcfgData = g_new0(char, wrote); gotxmcfgData = g_new0(char, wrote);
conn = virGetConnect(); conn = virGetConnect();
if (!conn) goto fail; if (!conn)
return -1;
if (!(def = virDomainDefParseFile(xml, driver->xmlopt, NULL, if (!(def = virDomainDefParseFile(xml, driver->xmlopt, NULL,
VIR_DOMAIN_DEF_PARSE_INACTIVE))) VIR_DOMAIN_DEF_PARSE_INACTIVE)))
goto fail; return -1;
if (!virDomainDefCheckABIStability(def, def, driver->xmlopt)) { if (!virDomainDefCheckABIStability(def, def, driver->xmlopt)) {
fprintf(stderr, "ABI stability check failed on %s", xml); fprintf(stderr, "ABI stability check failed on %s", xml);
goto fail; return -1;
} }
if (!(conf = xenFormatXM(conn, def))) if (!(conf = xenFormatXM(conn, def)))
goto fail; return -1;
if (virConfWriteMem(gotxmcfgData, &wrote, conf) < 0) if (virConfWriteMem(gotxmcfgData, &wrote, conf) < 0)
goto fail; return -1;
gotxmcfgData[wrote] = '\0'; gotxmcfgData[wrote] = '\0';
if (virTestCompareToFile(gotxmcfgData, xmcfg) < 0) if (virTestCompareToFile(gotxmcfgData, xmcfg) < 0)
goto fail; return -1;
ret = 0; return 0;
fail:
return ret;
} }
static int static int
@ -83,30 +79,25 @@ testCompareFormatXML(const char *xmcfg, const char *xml)
g_autofree char *xmcfgData = NULL; g_autofree char *xmcfgData = NULL;
g_autofree char *gotxml = NULL; g_autofree char *gotxml = NULL;
g_autoptr(virConf) conf = NULL; g_autoptr(virConf) conf = NULL;
int ret = -1;
g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) def = NULL;
g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver); g_autoptr(libxlDriverConfig) cfg = libxlDriverConfigGet(driver);
if (virTestLoadFile(xmcfg, &xmcfgData) < 0) if (virTestLoadFile(xmcfg, &xmcfgData) < 0)
goto fail; return -1;
if (!(conf = virConfReadString(xmcfgData, 0))) if (!(conf = virConfReadString(xmcfgData, 0)))
goto fail; return -1;
if (!(def = xenParseXM(conf, cfg->caps, driver->xmlopt))) if (!(def = xenParseXM(conf, cfg->caps, driver->xmlopt)))
goto fail; return -1;
if (!(gotxml = virDomainDefFormat(def, driver->xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE))) if (!(gotxml = virDomainDefFormat(def, driver->xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE)))
goto fail; return -1;
if (virTestCompareToFile(gotxml, xml) < 0) if (virTestCompareToFile(gotxml, xml) < 0)
goto fail; return -1;
ret = 0; return 0;
fail:
return ret;
} }