tests: cputest: remove unnecessary labels

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2021-08-20 16:12:04 +02:00
parent 32f1323cba
commit 0ee2cc3ad8

View File

@ -140,21 +140,17 @@ cpuTestCompareXML(virArch arch,
{ {
g_autofree char *xml = NULL; g_autofree char *xml = NULL;
g_autofree char *actual = NULL; g_autofree char *actual = NULL;
int ret = -1;
xml = g_strdup_printf("%s/cputestdata/%s-%s.xml", abs_srcdir, xml = g_strdup_printf("%s/cputestdata/%s-%s.xml", abs_srcdir,
virArchToString(arch), name); virArchToString(arch), name);
if (!(actual = virCPUDefFormat(cpu, NULL))) if (!(actual = virCPUDefFormat(cpu, NULL)))
goto cleanup; return -1;
if (virTestCompareToFile(actual, xml) < 0) if (virTestCompareToFile(actual, xml) < 0)
goto cleanup; return -1;
ret = 0; return 0;
cleanup:
return ret;
} }
@ -190,14 +186,13 @@ static int
cpuTestCompare(const void *arg) cpuTestCompare(const void *arg)
{ {
const struct data *data = arg; const struct data *data = arg;
int ret = -1;
g_autoptr(virCPUDef) host = NULL; g_autoptr(virCPUDef) host = NULL;
g_autoptr(virCPUDef) cpu = NULL; g_autoptr(virCPUDef) cpu = NULL;
virCPUCompareResult result; virCPUCompareResult result;
if (!(host = cpuTestLoadXML(data->arch, data->host)) || if (!(host = cpuTestLoadXML(data->arch, data->host)) ||
!(cpu = cpuTestLoadXML(data->arch, data->name))) !(cpu = cpuTestLoadXML(data->arch, data->name)))
goto cleanup; return -1;
result = virCPUCompare(host->arch, host, cpu, false); result = virCPUCompare(host->arch, host, cpu, false);
if (data->result == VIR_CPU_COMPARE_ERROR) if (data->result == VIR_CPU_COMPARE_ERROR)
@ -209,13 +204,10 @@ cpuTestCompare(const void *arg)
cpuTestCompResStr(result)); cpuTestCompResStr(result));
/* Pad to line up with test name ... in virTestRun */ /* Pad to line up with test name ... in virTestRun */
VIR_TEST_VERBOSE("%74s", "... "); VIR_TEST_VERBOSE("%74s", "... ");
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -360,7 +352,6 @@ static int
cpuTestUpdate(const void *arg) cpuTestUpdate(const void *arg)
{ {
const struct data *data = arg; const struct data *data = arg;
int ret = -1;
g_autoptr(virCPUDef) host = NULL; g_autoptr(virCPUDef) host = NULL;
g_autoptr(virCPUDef) migHost = NULL; g_autoptr(virCPUDef) migHost = NULL;
g_autoptr(virCPUDef) cpu = NULL; g_autoptr(virCPUDef) cpu = NULL;
@ -368,20 +359,17 @@ cpuTestUpdate(const void *arg)
if (!(host = cpuTestLoadXML(data->arch, data->host)) || if (!(host = cpuTestLoadXML(data->arch, data->host)) ||
!(cpu = cpuTestLoadXML(data->arch, data->name))) !(cpu = cpuTestLoadXML(data->arch, data->name)))
goto cleanup; return -1;
if (!(migHost = virCPUCopyMigratable(data->arch, host))) if (!(migHost = virCPUCopyMigratable(data->arch, host)))
goto cleanup; return -1;
if (virCPUUpdate(host->arch, cpu, migHost) < 0) if (virCPUUpdate(host->arch, cpu, migHost) < 0)
goto cleanup; return -1;
result = g_strdup_printf("%s+%s", data->host, data->name); result = g_strdup_printf("%s+%s", data->host, data->name);
ret = cpuTestCompareXML(data->arch, cpu, result); return cpuTestCompareXML(data->arch, cpu, result);
cleanup:
return ret;
} }
@ -389,17 +377,16 @@ static int
cpuTestHasFeature(const void *arg) cpuTestHasFeature(const void *arg)
{ {
const struct data *data = arg; const struct data *data = arg;
int ret = -1;
g_autoptr(virCPUDef) host = NULL; g_autoptr(virCPUDef) host = NULL;
g_autoptr(virCPUData) hostData = NULL; g_autoptr(virCPUData) hostData = NULL;
int result; int result;
if (!(host = cpuTestLoadXML(data->arch, data->host))) if (!(host = cpuTestLoadXML(data->arch, data->host)))
goto cleanup; return -1;
if (cpuEncode(host->arch, host, NULL, &hostData, if (cpuEncode(host->arch, host, NULL, &hostData,
NULL, NULL, NULL, NULL) < 0) NULL, NULL, NULL, NULL) < 0)
goto cleanup; return -1;
result = virCPUCheckFeature(host->arch, host, data->name); result = virCPUCheckFeature(host->arch, host, data->name);
@ -415,13 +402,10 @@ cpuTestHasFeature(const void *arg)
cpuTestBoolWithErrorStr(result)); cpuTestBoolWithErrorStr(result));
/* Pad to line up with test name ... in virTestRun */ /* Pad to line up with test name ... in virTestRun */
VIR_TEST_VERBOSE("%74s", "... "); VIR_TEST_VERBOSE("%74s", "... ");
goto cleanup; return -1;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -629,19 +613,15 @@ cpuTestCPUIDSignature(const void *arg)
g_autoptr(virCPUData) hostData = NULL; g_autoptr(virCPUData) hostData = NULL;
g_autofree char *hostFile = NULL; g_autofree char *hostFile = NULL;
g_autofree char *host = NULL; g_autofree char *host = NULL;
int ret = -1;
hostFile = g_strdup_printf("%s/cputestdata/%s-cpuid-%s.xml", abs_srcdir, hostFile = g_strdup_printf("%s/cputestdata/%s-cpuid-%s.xml", abs_srcdir,
virArchToString(data->arch), data->host); virArchToString(data->arch), data->host);
if (virTestLoadFile(hostFile, &host) < 0 || if (virTestLoadFile(hostFile, &host) < 0 ||
!(hostData = virCPUDataParse(host))) !(hostData = virCPUDataParse(host)))
goto cleanup; return -1;
ret = cpuTestCompareSignature(data, hostData); return cpuTestCompareSignature(data, hostData);
cleanup:
return ret;
} }
@ -829,12 +809,11 @@ cpuTestJSONCPUID(const void *arg)
g_autoptr(virQEMUCaps) qemuCaps = NULL; g_autoptr(virQEMUCaps) qemuCaps = NULL;
g_autoptr(virCPUDef) cpu = NULL; g_autoptr(virCPUDef) cpu = NULL;
g_autofree char *result = NULL; g_autofree char *result = NULL;
int ret = -1;
result = g_strdup_printf("cpuid-%s-json", data->host); result = g_strdup_printf("cpuid-%s-json", data->host);
if (!(qemuCaps = cpuTestMakeQEMUCaps(data))) if (!(qemuCaps = cpuTestMakeQEMUCaps(data)))
goto cleanup; return -1;
cpu = virCPUDefNew(); cpu = virCPUDefNew();
cpu->arch = data->arch; cpu->arch = data->arch;
@ -843,12 +822,9 @@ cpuTestJSONCPUID(const void *arg)
cpu->fallback = VIR_CPU_FALLBACK_FORBID; cpu->fallback = VIR_CPU_FALLBACK_FORBID;
if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu, false) != 0) if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu, false) != 0)
goto cleanup; return -1;
ret = cpuTestCompareXML(data->arch, cpu, result); return cpuTestCompareXML(data->arch, cpu, result);
cleanup:
return ret;
} }
@ -859,19 +835,15 @@ cpuTestJSONSignature(const void *arg)
g_autoptr(virQEMUCaps) qemuCaps = NULL; g_autoptr(virQEMUCaps) qemuCaps = NULL;
g_autoptr(virCPUData) hostData = NULL; g_autoptr(virCPUData) hostData = NULL;
qemuMonitorCPUModelInfo *modelInfo; qemuMonitorCPUModelInfo *modelInfo;
int ret = -1;
if (!(qemuCaps = cpuTestMakeQEMUCaps(data))) if (!(qemuCaps = cpuTestMakeQEMUCaps(data)))
goto cleanup; return -1;
modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM); modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, VIR_DOMAIN_VIRT_KVM);
if (!(hostData = virQEMUCapsGetCPUModelX86Data(qemuCaps, modelInfo, false))) if (!(hostData = virQEMUCapsGetCPUModelX86Data(qemuCaps, modelInfo, false)))
goto cleanup; return -1;
ret = cpuTestCompareSignature(data, hostData); return cpuTestCompareSignature(data, hostData);
cleanup:
return ret;
} }
#endif #endif