mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
tests: remove pointless labels
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
2ef57217f8
commit
05e71df9f3
@ -520,7 +520,6 @@ static int
|
|||||||
cpuTestCPUID(bool guest, const void *arg)
|
cpuTestCPUID(bool guest, const void *arg)
|
||||||
{
|
{
|
||||||
const struct data *data = arg;
|
const struct data *data = arg;
|
||||||
int ret = -1;
|
|
||||||
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;
|
||||||
@ -533,7 +532,7 @@ cpuTestCPUID(bool guest, const void *arg)
|
|||||||
|
|
||||||
if (virTestLoadFile(hostFile, &host) < 0 ||
|
if (virTestLoadFile(hostFile, &host) < 0 ||
|
||||||
!(hostData = virCPUDataParse(host)))
|
!(hostData = virCPUDataParse(host)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
cpu = virCPUDefNew();
|
cpu = virCPUDefNew();
|
||||||
cpu->arch = hostData->arch;
|
cpu->arch = hostData->arch;
|
||||||
@ -549,21 +548,16 @@ cpuTestCPUID(bool guest, const void *arg)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = cpuTestGetCPUModels(data, &models);
|
rc = cpuTestGetCPUModels(data, &models);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
ret = rc;
|
return rc;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpuDecode(cpu, hostData, models) < 0)
|
if (cpuDecode(cpu, hostData, models) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
result = g_strdup_printf("cpuid-%s-%s", data->host, guest ? "guest" : "host");
|
result = g_strdup_printf("cpuid-%s-%s", data->host, guest ? "guest" : "host");
|
||||||
|
|
||||||
ret = cpuTestCompareXML(data->arch, cpu, result);
|
return cpuTestCompareXML(data->arch, cpu, result);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -729,27 +723,26 @@ cpuTestUpdateLive(const void *arg)
|
|||||||
g_autoptr(virCPUDef) expected = NULL;
|
g_autoptr(virCPUDef) expected = NULL;
|
||||||
g_autoptr(virDomainCapsCPUModels) hvModels = NULL;
|
g_autoptr(virDomainCapsCPUModels) hvModels = NULL;
|
||||||
g_autoptr(virDomainCapsCPUModels) models = NULL;
|
g_autoptr(virDomainCapsCPUModels) models = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
cpuFile = g_strdup_printf("cpuid-%s-guest", data->host);
|
cpuFile = g_strdup_printf("cpuid-%s-guest", data->host);
|
||||||
if (!(cpu = cpuTestLoadXML(data->arch, cpuFile)))
|
if (!(cpu = cpuTestLoadXML(data->arch, cpuFile)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
enabledFile = g_strdup_printf("%s/cputestdata/%s-cpuid-%s-enabled.xml",
|
enabledFile = g_strdup_printf("%s/cputestdata/%s-cpuid-%s-enabled.xml",
|
||||||
abs_srcdir, virArchToString(data->arch), data->host);
|
abs_srcdir, virArchToString(data->arch), data->host);
|
||||||
if (virTestLoadFile(enabledFile, &enabled) < 0 ||
|
if (virTestLoadFile(enabledFile, &enabled) < 0 ||
|
||||||
!(enabledData = virCPUDataParse(enabled)))
|
!(enabledData = virCPUDataParse(enabled)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
disabledFile = g_strdup_printf("%s/cputestdata/%s-cpuid-%s-disabled.xml",
|
disabledFile = g_strdup_printf("%s/cputestdata/%s-cpuid-%s-disabled.xml",
|
||||||
abs_srcdir, virArchToString(data->arch), data->host);
|
abs_srcdir, virArchToString(data->arch), data->host);
|
||||||
if (virTestLoadFile(disabledFile, &disabled) < 0 ||
|
if (virTestLoadFile(disabledFile, &disabled) < 0 ||
|
||||||
!(disabledData = virCPUDataParse(disabled)))
|
!(disabledData = virCPUDataParse(disabled)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
expectedFile = g_strdup_printf("cpuid-%s-json", data->host);
|
expectedFile = g_strdup_printf("cpuid-%s-json", data->host);
|
||||||
if (!(expected = cpuTestLoadXML(data->arch, expectedFile)))
|
if (!(expected = cpuTestLoadXML(data->arch, expectedFile)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* In case the host CPU signature does not exactly match any CPU model in
|
/* In case the host CPU signature does not exactly match any CPU model in
|
||||||
* src/cpu_map, the CPU model we detect from CPUID may differ from the one
|
* src/cpu_map, the CPU model we detect from CPUID may differ from the one
|
||||||
@ -764,13 +757,11 @@ cpuTestUpdateLive(const void *arg)
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!(models = virDomainCapsCPUModelsNew(0)))
|
if (!(models = virDomainCapsCPUModelsNew(0)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
rc = cpuTestGetCPUModels(data, &hvModels);
|
rc = cpuTestGetCPUModels(data, &hvModels);
|
||||||
if (rc != 0) {
|
if (rc != 0)
|
||||||
ret = rc;
|
return rc;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
hvModel = virDomainCapsCPUModelsGet(hvModels, expected->model);
|
hvModel = virDomainCapsCPUModelsGet(hvModels, expected->model);
|
||||||
|
|
||||||
@ -781,7 +772,7 @@ cpuTestUpdateLive(const void *arg)
|
|||||||
|
|
||||||
if (virDomainCapsCPUModelsAdd(models, expected->model,
|
if (virDomainCapsCPUModelsAdd(models, expected->model,
|
||||||
usable, blockers, false) < 0)
|
usable, blockers, false) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
|
cpu->fallback = VIR_CPU_FALLBACK_ALLOW;
|
||||||
ignore_value(virCPUTranslate(data->arch, cpu, models));
|
ignore_value(virCPUTranslate(data->arch, cpu, models));
|
||||||
@ -789,12 +780,9 @@ cpuTestUpdateLive(const void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (virCPUUpdateLive(data->arch, cpu, enabledData, disabledData) < 0)
|
if (virCPUUpdateLive(data->arch, cpu, enabledData, disabledData) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = cpuTestUpdateLiveCompare(data->arch, cpu, expected);
|
return cpuTestUpdateLiveCompare(data->arch, cpu, expected);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,18 +73,17 @@ fillQemuCaps(virDomainCaps *domCaps,
|
|||||||
const char *machine,
|
const char *machine,
|
||||||
virQEMUDriverConfig *cfg)
|
virQEMUDriverConfig *cfg)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
g_autofree char *path = NULL;
|
g_autofree char *path = NULL;
|
||||||
g_autoptr(virQEMUCaps) qemuCaps = NULL;
|
g_autoptr(virQEMUCaps) qemuCaps = NULL;
|
||||||
virDomainCapsLoader *loader = &domCaps->os.loader;
|
virDomainCapsLoader *loader = &domCaps->os.loader;
|
||||||
virDomainVirtType virtType;
|
virDomainVirtType virtType;
|
||||||
|
|
||||||
if (fakeHostCPU(domCaps->arch) < 0)
|
if (fakeHostCPU(domCaps->arch) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
path = g_strdup_printf("%s/%s.%s.xml", TEST_QEMU_CAPS_PATH, name, arch);
|
path = g_strdup_printf("%s/%s.%s.xml", TEST_QEMU_CAPS_PATH, name, arch);
|
||||||
if (!(qemuCaps = qemuTestParseCapabilitiesArch(domCaps->arch, path)))
|
if (!(qemuCaps = qemuTestParseCapabilitiesArch(domCaps->arch, path)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
||||||
virtType = VIR_DOMAIN_VIRT_KVM;
|
virtType = VIR_DOMAIN_VIRT_KVM;
|
||||||
@ -103,7 +102,7 @@ fillQemuCaps(virDomainCaps *domCaps,
|
|||||||
false,
|
false,
|
||||||
cfg->firmwares,
|
cfg->firmwares,
|
||||||
cfg->nfirmwares) < 0)
|
cfg->nfirmwares) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* The function above tries to query host's VFIO capabilities by calling
|
/* The function above tries to query host's VFIO capabilities by calling
|
||||||
* qemuHostdevHostSupportsPassthroughVFIO() which, however, can't be
|
* qemuHostdevHostSupportsPassthroughVFIO() which, however, can't be
|
||||||
@ -123,11 +122,9 @@ fillQemuCaps(virDomainCaps *domCaps,
|
|||||||
"/usr/share/AAVMF/AAVMF32_CODE.fd",
|
"/usr/share/AAVMF/AAVMF32_CODE.fd",
|
||||||
"/usr/share/OVMF/OVMF_CODE.fd",
|
"/usr/share/OVMF/OVMF_CODE.fd",
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
#endif /* WITH_QEMU */
|
#endif /* WITH_QEMU */
|
||||||
|
|
||||||
@ -167,19 +164,16 @@ static int
|
|||||||
fillBhyveCaps(virDomainCaps *domCaps, unsigned int *bhyve_caps)
|
fillBhyveCaps(virDomainCaps *domCaps, unsigned int *bhyve_caps)
|
||||||
{
|
{
|
||||||
g_autofree virDomainCapsStringValues *firmwares = NULL;
|
g_autofree virDomainCapsStringValues *firmwares = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
firmwares = g_new0(virDomainCapsStringValues, 1);
|
firmwares = g_new0(virDomainCapsStringValues, 1);
|
||||||
|
|
||||||
if (fillStringValues(firmwares, "/foo/bar", "/foo/baz", NULL) < 0)
|
if (fillStringValues(firmwares, "/foo/bar", "/foo/baz", NULL) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virBhyveDomainCapsFill(domCaps, *bhyve_caps, firmwares) < 0)
|
if (virBhyveDomainCapsFill(domCaps, *bhyve_caps, firmwares) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
#endif /* WITH_BHYVE */
|
#endif /* WITH_BHYVE */
|
||||||
|
|
||||||
@ -208,14 +202,13 @@ test_virDomainCapsFormat(const void *opaque)
|
|||||||
g_autoptr(virDomainCaps) domCaps = NULL;
|
g_autoptr(virDomainCaps) domCaps = NULL;
|
||||||
g_autofree char *path = NULL;
|
g_autofree char *path = NULL;
|
||||||
g_autofree char *domCapsXML = NULL;
|
g_autofree char *domCapsXML = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
path = g_strdup_printf("%s/domaincapsdata/%s.xml", abs_srcdir, data->name);
|
path = g_strdup_printf("%s/domaincapsdata/%s.xml", abs_srcdir, data->name);
|
||||||
|
|
||||||
if (!(domCaps = virDomainCapsNew(data->emulator, data->machine,
|
if (!(domCaps = virDomainCapsNew(data->emulator, data->machine,
|
||||||
virArchFromString(data->arch),
|
virArchFromString(data->arch),
|
||||||
data->type)))
|
data->type)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
switch (data->capsType) {
|
switch (data->capsType) {
|
||||||
case CAPS_NONE:
|
case CAPS_NONE:
|
||||||
@ -225,33 +218,31 @@ test_virDomainCapsFormat(const void *opaque)
|
|||||||
#if WITH_QEMU
|
#if WITH_QEMU
|
||||||
if (fillQemuCaps(domCaps, data->capsName, data->arch, data->machine,
|
if (fillQemuCaps(domCaps, data->capsName, data->arch, data->machine,
|
||||||
data->capsOpaque) < 0)
|
data->capsOpaque) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAPS_LIBXL:
|
case CAPS_LIBXL:
|
||||||
#if WITH_LIBXL
|
#if WITH_LIBXL
|
||||||
if (fillXenCaps(domCaps) < 0)
|
if (fillXenCaps(domCaps) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case CAPS_BHYVE:
|
case CAPS_BHYVE:
|
||||||
#if WITH_BHYVE
|
#if WITH_BHYVE
|
||||||
if (fillBhyveCaps(domCaps, data->capsOpaque) < 0)
|
if (fillBhyveCaps(domCaps, data->capsOpaque) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(domCapsXML = virDomainCapsFormat(domCaps)))
|
if (!(domCapsXML = virDomainCapsFormat(domCaps)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(domCapsXML, path) < 0)
|
if (virTestCompareToFile(domCapsXML, path) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ struct testGetFilesystemData {
|
|||||||
|
|
||||||
static int testGetFilesystem(const void *opaque)
|
static int testGetFilesystem(const void *opaque)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
g_autoptr(virDomainDef) def = NULL;
|
g_autoptr(virDomainDef) def = NULL;
|
||||||
g_autofree char *filename = NULL;
|
g_autofree char *filename = NULL;
|
||||||
const struct testGetFilesystemData *data = opaque;
|
const struct testGetFilesystemData *data = opaque;
|
||||||
@ -50,7 +49,7 @@ static int testGetFilesystem(const void *opaque)
|
|||||||
data->filename);
|
data->filename);
|
||||||
|
|
||||||
if (!(def = virDomainDefParseFile(filename, xmlopt, NULL, 0)))
|
if (!(def = virDomainDefParseFile(filename, xmlopt, NULL, 0)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
fsdef = virDomainGetFilesystemForTarget(def,
|
fsdef = virDomainGetFilesystemForTarget(def,
|
||||||
data->path);
|
data->path);
|
||||||
@ -58,20 +57,17 @@ static int testGetFilesystem(const void *opaque)
|
|||||||
if (data->expectEntry) {
|
if (data->expectEntry) {
|
||||||
fprintf(stderr, "Expected FS for path '%s' in '%s'\n",
|
fprintf(stderr, "Expected FS for path '%s' in '%s'\n",
|
||||||
data->path, filename);
|
data->path, filename);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!data->expectEntry) {
|
if (!data->expectEntry) {
|
||||||
fprintf(stderr, "Unexpected FS for path '%s' in '%s'\n",
|
fprintf(stderr, "Unexpected FS for path '%s' in '%s'\n",
|
||||||
data->path, filename);
|
data->path, filename);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -123,7 +123,6 @@ test3(const void *data G_GNUC_UNUSED)
|
|||||||
g_autofree char *fabric_wwn = NULL;
|
g_autofree char *fabric_wwn = NULL;
|
||||||
g_autofree char *max_vports = NULL;
|
g_autofree char *max_vports = NULL;
|
||||||
g_autofree char *vports = NULL;
|
g_autofree char *vports = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(wwnn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM,
|
if (!(wwnn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM,
|
||||||
"node_name")))
|
"node_name")))
|
||||||
@ -131,31 +130,29 @@ test3(const void *data G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (!(wwpn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM,
|
if (!(wwpn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM,
|
||||||
"port_name")))
|
"port_name")))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(fabric_wwn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM,
|
if (!(fabric_wwn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM,
|
||||||
"fabric_name")))
|
"fabric_name")))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(max_vports = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM,
|
if (!(max_vports = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM,
|
||||||
"max_npiv_vports")))
|
"max_npiv_vports")))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
if (!(vports = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM,
|
if (!(vports = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM,
|
||||||
"npiv_vports_inuse")))
|
"npiv_vports_inuse")))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (STRNEQ(expect_wwnn, wwnn) ||
|
if (STRNEQ(expect_wwnn, wwnn) ||
|
||||||
STRNEQ(expect_wwpn, wwpn) ||
|
STRNEQ(expect_wwpn, wwpn) ||
|
||||||
STRNEQ(expect_fabric_wwn, fabric_wwn) ||
|
STRNEQ(expect_fabric_wwn, fabric_wwn) ||
|
||||||
STRNEQ(expect_max_vports, max_vports) ||
|
STRNEQ(expect_max_vports, max_vports) ||
|
||||||
STRNEQ(expect_vports, vports))
|
STRNEQ(expect_vports, vports))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test virVHBAGetHostByWWN */
|
/* Test virVHBAGetHostByWWN */
|
||||||
@ -164,7 +161,6 @@ test4(const void *data G_GNUC_UNUSED)
|
|||||||
{
|
{
|
||||||
const char *expect_hostname = "host5";
|
const char *expect_hostname = "host5";
|
||||||
g_autofree char *hostname = NULL;
|
g_autofree char *hostname = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(hostname = virVHBAGetHostByWWN(TEST_FC_HOST_PREFIX,
|
if (!(hostname = virVHBAGetHostByWWN(TEST_FC_HOST_PREFIX,
|
||||||
"2001001b32a9da4e",
|
"2001001b32a9da4e",
|
||||||
@ -172,11 +168,9 @@ test4(const void *data G_GNUC_UNUSED)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (STRNEQ(hostname, expect_hostname))
|
if (STRNEQ(hostname, expect_hostname))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test virVHBAFindVportHost
|
/* Test virVHBAFindVportHost
|
||||||
@ -188,17 +182,14 @@ test5(const void *data G_GNUC_UNUSED)
|
|||||||
{
|
{
|
||||||
const char *expect_hostname = "host5";
|
const char *expect_hostname = "host5";
|
||||||
g_autofree char *hostname = NULL;
|
g_autofree char *hostname = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(hostname = virVHBAFindVportHost(TEST_FC_HOST_PREFIX)))
|
if (!(hostname = virVHBAFindVportHost(TEST_FC_HOST_PREFIX)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (STRNEQ(hostname, expect_hostname))
|
if (STRNEQ(hostname, expect_hostname))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test virVHBAGetConfig fabric name optional */
|
/* Test virVHBAGetConfig fabric name optional */
|
||||||
@ -210,7 +201,6 @@ test6(const void *data G_GNUC_UNUSED)
|
|||||||
g_autofree char *wwnn = NULL;
|
g_autofree char *wwnn = NULL;
|
||||||
g_autofree char *wwpn = NULL;
|
g_autofree char *wwpn = NULL;
|
||||||
g_autofree char *fabric_wwn = NULL;
|
g_autofree char *fabric_wwn = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(wwnn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_NO_FAB,
|
if (!(wwnn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_NO_FAB,
|
||||||
"node_name")))
|
"node_name")))
|
||||||
@ -218,20 +208,18 @@ test6(const void *data G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (!(wwpn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_NO_FAB,
|
if (!(wwpn = virVHBAGetConfig(TEST_FC_HOST_PREFIX, TEST_FC_HOST_NUM_NO_FAB,
|
||||||
"port_name")))
|
"port_name")))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if ((fabric_wwn = virVHBAGetConfig(TEST_FC_HOST_PREFIX,
|
if ((fabric_wwn = virVHBAGetConfig(TEST_FC_HOST_PREFIX,
|
||||||
TEST_FC_HOST_NUM_NO_FAB,
|
TEST_FC_HOST_NUM_NO_FAB,
|
||||||
"fabric_name")))
|
"fabric_name")))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (STRNEQ(expect_wwnn, wwnn) ||
|
if (STRNEQ(expect_wwnn, wwnn) ||
|
||||||
STRNEQ(expect_wwpn, wwpn))
|
STRNEQ(expect_wwpn, wwpn))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,33 +25,29 @@ testCompareXMLToConfigFiles(const char *xmlfile,
|
|||||||
const char *configfile,
|
const char *configfile,
|
||||||
bool expectError)
|
bool expectError)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
g_autofree char *config = NULL;
|
g_autofree char *config = NULL;
|
||||||
g_autofree char *actualxml = NULL;
|
g_autofree char *actualxml = NULL;
|
||||||
g_autoptr(virDomainDef) vmdef = NULL;
|
g_autoptr(virDomainDef) vmdef = NULL;
|
||||||
|
|
||||||
if (virTestLoadFile(configfile, &config) < 0)
|
if (virTestLoadFile(configfile, &config) < 0)
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
vmdef = lxcParseConfigString(config, driver->caps, driver->xmlopt);
|
vmdef = lxcParseConfigString(config, driver->caps, driver->xmlopt);
|
||||||
if ((vmdef && expectError) || (!vmdef && !expectError))
|
if ((vmdef && expectError) || (!vmdef && !expectError))
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
if (vmdef) {
|
if (vmdef) {
|
||||||
if (testSanitizeDef(vmdef) < 0)
|
if (testSanitizeDef(vmdef) < 0)
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
if (!(actualxml = virDomainDefFormat(vmdef, driver->xmlopt, 0)))
|
if (!(actualxml = virDomainDefFormat(vmdef, driver->xmlopt, 0)))
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(actualxml, xmlfile) < 0)
|
if (virTestCompareToFile(actualxml, xmlfile) < 0)
|
||||||
goto fail;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct testInfo {
|
struct testInfo {
|
||||||
|
@ -91,7 +91,6 @@ verifyMetadata(virDomainPtr dom,
|
|||||||
const char *expectAPI,
|
const char *expectAPI,
|
||||||
const char *uri)
|
const char *uri)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
g_autofree char *metadataXML = NULL;
|
g_autofree char *metadataXML = NULL;
|
||||||
g_autofree char *metadataAPI = NULL;
|
g_autofree char *metadataAPI = NULL;
|
||||||
|
|
||||||
@ -102,13 +101,13 @@ verifyMetadata(virDomainPtr dom,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"expected no metadata in API, but got:\n[%s]",
|
"expected no metadata in API, but got:\n[%s]",
|
||||||
metadataAPI);
|
metadataAPI);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!(metadataAPI = virDomainGetMetadata(dom,
|
if (!(metadataAPI = virDomainGetMetadata(dom,
|
||||||
VIR_DOMAIN_METADATA_ELEMENT,
|
VIR_DOMAIN_METADATA_ELEMENT,
|
||||||
uri, 0)))
|
uri, 0)))
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
metadataXMLConvertApostrophe(metadataAPI);
|
metadataXMLConvertApostrophe(metadataAPI);
|
||||||
|
|
||||||
@ -117,7 +116,7 @@ verifyMetadata(virDomainPtr dom,
|
|||||||
"XML metadata in API doesn't match expected metadata: "
|
"XML metadata in API doesn't match expected metadata: "
|
||||||
"expected:\n[%s]\ngot:\n[%s]",
|
"expected:\n[%s]\ngot:\n[%s]",
|
||||||
expectAPI, metadataAPI);
|
expectAPI, metadataAPI);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -127,11 +126,11 @@ verifyMetadata(virDomainPtr dom,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"expected no metadata in XML, but got:\n[%s]",
|
"expected no metadata in XML, but got:\n[%s]",
|
||||||
metadataXML);
|
metadataXML);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!(metadataXML = getMetadataFromXML(dom)))
|
if (!(metadataXML = getMetadataFromXML(dom)))
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
metadataXMLConvertApostrophe(metadataXML);
|
metadataXMLConvertApostrophe(metadataXML);
|
||||||
|
|
||||||
@ -140,15 +139,11 @@ verifyMetadata(virDomainPtr dom,
|
|||||||
"XML in dump doesn't match expected metadata: "
|
"XML in dump doesn't match expected metadata: "
|
||||||
"expected:\n[%s]\ngot:\n[%s]",
|
"expected:\n[%s]\ngot:\n[%s]",
|
||||||
expectXML, metadataXML);
|
expectXML, metadataXML);
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -213,7 +208,6 @@ testTextMetadata(const void *data)
|
|||||||
{
|
{
|
||||||
const struct metadataTest *test = data;
|
const struct metadataTest *test = data;
|
||||||
g_autofree char *actual = NULL;
|
g_autofree char *actual = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (virDomainSetMetadata(test->dom, test->type, test->data, NULL, NULL, 0) < 0) {
|
if (virDomainSetMetadata(test->dom, test->type, test->data, NULL, NULL, 0) < 0) {
|
||||||
if (test->fail)
|
if (test->fail)
|
||||||
@ -228,14 +222,10 @@ testTextMetadata(const void *data)
|
|||||||
"expected metadata doesn't match actual: "
|
"expected metadata doesn't match actual: "
|
||||||
"expected:'%s'\ngot: '%s'",
|
"expected:'%s'\ngot: '%s'",
|
||||||
NULLSTR(test->data), NULLSTR(actual));
|
NULLSTR(test->data), NULLSTR(actual));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TEST_TEXT_METADATA(INDEX, TYPE, DATA, EXPECT, FAIL) \
|
#define TEST_TEXT_METADATA(INDEX, TYPE, DATA, EXPECT, FAIL) \
|
||||||
|
@ -36,7 +36,6 @@ static struct testConfigParam configParams[] = {
|
|||||||
static int
|
static int
|
||||||
testReadConfigParam(const void *data G_GNUC_UNUSED)
|
testReadConfigParam(const void *data G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
int result = -1;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
g_autofree char *conf = NULL;
|
g_autofree char *conf = NULL;
|
||||||
g_autofree char *value = NULL;
|
g_autofree char *value = NULL;
|
||||||
@ -46,7 +45,7 @@ testReadConfigParam(const void *data G_GNUC_UNUSED)
|
|||||||
for (i = 0; i < G_N_ELEMENTS(configParams); ++i) {
|
for (i = 0; i < G_N_ELEMENTS(configParams); ++i) {
|
||||||
if (openvzReadConfigParam(conf, configParams[i].param,
|
if (openvzReadConfigParam(conf, configParams[i].param,
|
||||||
&value) != configParams[i].ret) {
|
&value) != configParams[i].ret) {
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configParams[i].ret != 1)
|
if (configParams[i].ret != 1)
|
||||||
@ -54,15 +53,11 @@ testReadConfigParam(const void *data G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (STRNEQ(configParams[i].value, value)) {
|
if (STRNEQ(configParams[i].value, value)) {
|
||||||
virTestDifference(stderr, configParams[i].value, value);
|
virTestDifference(stderr, configParams[i].value, value);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -70,7 +70,6 @@ create_scsihost(const char *fakesysfsdir, const char *devicepath,
|
|||||||
g_autofree char *unique_id_path = NULL;
|
g_autofree char *unique_id_path = NULL;
|
||||||
g_autofree char *link_path = NULL;
|
g_autofree char *link_path = NULL;
|
||||||
char *spot;
|
char *spot;
|
||||||
int ret = -1;
|
|
||||||
VIR_AUTOCLOSE fd = -1;
|
VIR_AUTOCLOSE fd = -1;
|
||||||
|
|
||||||
unique_id_path = g_strdup_printf("%s/devices/pci0000:00/%s/unique_id",
|
unique_id_path = g_strdup_printf("%s/devices/pci0000:00/%s/unique_id",
|
||||||
@ -83,13 +82,13 @@ create_scsihost(const char *fakesysfsdir, const char *devicepath,
|
|||||||
*/
|
*/
|
||||||
if (!(spot = strstr(unique_id_path, "unique_id"))) {
|
if (!(spot = strstr(unique_id_path, "unique_id"))) {
|
||||||
fprintf(stderr, "Did not find unique_id in path\n");
|
fprintf(stderr, "Did not find unique_id in path\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
spot--;
|
spot--;
|
||||||
*spot = '\0';
|
*spot = '\0';
|
||||||
if (g_mkdir_with_parents(unique_id_path, 0755) < 0) {
|
if (g_mkdir_with_parents(unique_id_path, 0755) < 0) {
|
||||||
fprintf(stderr, "Unable to make path to '%s'\n", unique_id_path);
|
fprintf(stderr, "Unable to make path to '%s'\n", unique_id_path);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
*spot = '/';
|
*spot = '/';
|
||||||
|
|
||||||
@ -98,45 +97,42 @@ create_scsihost(const char *fakesysfsdir, const char *devicepath,
|
|||||||
*/
|
*/
|
||||||
if (!(spot = strstr(link_path, hostname))) {
|
if (!(spot = strstr(link_path, hostname))) {
|
||||||
fprintf(stderr, "Did not find hostname in path\n");
|
fprintf(stderr, "Did not find hostname in path\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
spot--;
|
spot--;
|
||||||
*spot = '\0';
|
*spot = '\0';
|
||||||
if (g_mkdir_with_parents(link_path, 0755) < 0) {
|
if (g_mkdir_with_parents(link_path, 0755) < 0) {
|
||||||
fprintf(stderr, "Unable to make path to '%s'\n", link_path);
|
fprintf(stderr, "Unable to make path to '%s'\n", link_path);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
*spot = '/';
|
*spot = '/';
|
||||||
|
|
||||||
if ((fd = open(unique_id_path, O_CREAT|O_WRONLY, 0444)) < 0) {
|
if ((fd = open(unique_id_path, O_CREAT|O_WRONLY, 0444)) < 0) {
|
||||||
fprintf(stderr, "Unable to create '%s'\n", unique_id_path);
|
fprintf(stderr, "Unable to create '%s'\n", unique_id_path);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (safewrite(fd, unique_id, 1) != 1) {
|
if (safewrite(fd, unique_id, 1) != 1) {
|
||||||
fprintf(stderr, "Unable to write '%s'\n", unique_id);
|
fprintf(stderr, "Unable to write '%s'\n", unique_id);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
VIR_DEBUG("Created unique_id '%s'", unique_id_path);
|
VIR_DEBUG("Created unique_id '%s'", unique_id_path);
|
||||||
|
|
||||||
/* The link is to the path not the file - so remove the file */
|
/* The link is to the path not the file - so remove the file */
|
||||||
if (!(spot = strstr(unique_id_path, "unique_id"))) {
|
if (!(spot = strstr(unique_id_path, "unique_id"))) {
|
||||||
fprintf(stderr, "Did not find unique_id in path\n");
|
fprintf(stderr, "Did not find unique_id in path\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
spot--;
|
spot--;
|
||||||
*spot = '\0';
|
*spot = '\0';
|
||||||
if (symlink(unique_id_path, link_path) < 0) {
|
if (symlink(unique_id_path, link_path) < 0) {
|
||||||
fprintf(stderr, "Unable to create symlink '%s' to '%s'\n",
|
fprintf(stderr, "Unable to create symlink '%s' to '%s'\n",
|
||||||
link_path, unique_id_path);
|
link_path, unique_id_path);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
VIR_DEBUG("Created symlink '%s'", link_path);
|
VIR_DEBUG("Created symlink '%s'", link_path);
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -99,7 +99,6 @@ testSELinuxLoadFileList(const char *testname,
|
|||||||
testSELinuxFile **files,
|
testSELinuxFile **files,
|
||||||
size_t *nfiles)
|
size_t *nfiles)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
g_autofree char *path = NULL;
|
g_autofree char *path = NULL;
|
||||||
g_autoptr(FILE) fp = NULL;
|
g_autoptr(FILE) fp = NULL;
|
||||||
g_autofree char *line = NULL;
|
g_autofree char *line = NULL;
|
||||||
@ -111,7 +110,7 @@ testSELinuxLoadFileList(const char *testname,
|
|||||||
testname);
|
testname);
|
||||||
|
|
||||||
if (!(fp = fopen(path, "r")))
|
if (!(fp = fopen(path, "r")))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
line = g_new0(char, 1024);
|
line = g_new0(char, 1024);
|
||||||
|
|
||||||
@ -119,7 +118,7 @@ testSELinuxLoadFileList(const char *testname,
|
|||||||
char *file = NULL, *context = NULL, *tmp;
|
char *file = NULL, *context = NULL, *tmp;
|
||||||
if (!fgets(line, 1024, fp)) {
|
if (!fgets(line, 1024, fp)) {
|
||||||
if (!feof(fp))
|
if (!feof(fp))
|
||||||
goto cleanup;
|
return -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +127,7 @@ testSELinuxLoadFileList(const char *testname,
|
|||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"unexpected format for line '%s'",
|
"unexpected format for line '%s'",
|
||||||
line);
|
line);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
tmp++;
|
tmp++;
|
||||||
@ -148,10 +147,7 @@ testSELinuxLoadFileList(const char *testname,
|
|||||||
(*files)[(*nfiles)-1].context = context;
|
(*files)[(*nfiles)-1].context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,7 +37,6 @@ static int
|
|||||||
testVerStrParse(const void *data)
|
testVerStrParse(const void *data)
|
||||||
{
|
{
|
||||||
const struct testInfo *info = data;
|
const struct testInfo *info = data;
|
||||||
int ret = -1;
|
|
||||||
g_autofree char *path = NULL;
|
g_autofree char *path = NULL;
|
||||||
g_autofree char *databuf = NULL;
|
g_autofree char *databuf = NULL;
|
||||||
unsigned long version;
|
unsigned long version;
|
||||||
@ -46,24 +45,21 @@ testVerStrParse(const void *data)
|
|||||||
path = g_strdup_printf("%s/vmwareverdata/%s.txt", abs_srcdir, info->name);
|
path = g_strdup_printf("%s/vmwareverdata/%s.txt", abs_srcdir, info->name);
|
||||||
|
|
||||||
if (virTestLoadFile(path, &databuf) < 0)
|
if (virTestLoadFile(path, &databuf) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if ((vmware_type = vmwareDriverTypeFromString(info->vmware_type)) < 0)
|
if ((vmware_type = vmwareDriverTypeFromString(info->vmware_type)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (vmwareParseVersionStr(vmware_type, databuf, &version) < 0)
|
if (vmwareParseVersionStr(vmware_type, databuf, &version) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (version != info->version) {
|
if (version != info->version) {
|
||||||
fprintf(stderr, "%s: parsed versions do not match: got %lu, "
|
fprintf(stderr, "%s: parsed versions do not match: got %lu, "
|
||||||
"expected %lu\n", info->name, version, info->version);
|
"expected %lu\n", info->name, version, info->version);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user