mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 14:35:18 +00:00
tests: Use VIR_AUTOFREE for various storage tests
Let's make use of the auto __cleanup capabilities cleaning up any now unnecessary goto paths. Signed-off-by: John Ferlan <jferlan@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ceb3255cdf
commit
5f02df444b
@ -57,32 +57,27 @@ test_node_info_parser(const void *opaque)
|
|||||||
{
|
{
|
||||||
const struct testNodeInfoParserData *data = opaque;
|
const struct testNodeInfoParserData *data = opaque;
|
||||||
collie_test test = data->data;
|
collie_test test = data->data;
|
||||||
int ret = -1;
|
VIR_AUTOFREE(char *) output = NULL;
|
||||||
char *output = NULL;
|
|
||||||
VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
|
VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
|
||||||
|
|
||||||
if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
|
if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (VIR_STRDUP(output, test.output) < 0)
|
if (VIR_STRDUP(output, test.output) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virStorageBackendSheepdogParseNodeInfo(pool, output) !=
|
if (virStorageBackendSheepdogParseNodeInfo(pool, output) !=
|
||||||
test.expected_return)
|
test.expected_return)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (test.expected_return) {
|
if (test.expected_return)
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pool->capacity == test.expected_capacity &&
|
if (pool->capacity == test.expected_capacity &&
|
||||||
pool->allocation == test.expected_allocation)
|
pool->allocation == test.expected_allocation)
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
return -1;
|
||||||
VIR_FREE(output);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -90,36 +85,31 @@ test_vdi_list_parser(const void *opaque)
|
|||||||
{
|
{
|
||||||
const struct testVDIListParserData *data = opaque;
|
const struct testVDIListParserData *data = opaque;
|
||||||
collie_test test = data->data;
|
collie_test test = data->data;
|
||||||
int ret = -1;
|
VIR_AUTOFREE(char *) output = NULL;
|
||||||
char *output = NULL;
|
|
||||||
VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
|
VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
|
||||||
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
|
|
||||||
if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
|
if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(vol = virStorageVolDefParseFile(pool, data->volxml, 0)))
|
if (!(vol = virStorageVolDefParseFile(pool, data->volxml, 0)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (VIR_STRDUP(output, test.output) < 0)
|
if (VIR_STRDUP(output, test.output) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virStorageBackendSheepdogParseVdiList(vol, output) !=
|
if (virStorageBackendSheepdogParseVdiList(vol, output) !=
|
||||||
test.expected_return)
|
test.expected_return)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (test.expected_return) {
|
if (test.expected_return)
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vol->target.capacity == test.expected_capacity &&
|
if (vol->target.capacity == test.expected_capacity &&
|
||||||
vol->target.allocation == test.expected_allocation)
|
vol->target.allocation == test.expected_allocation)
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
return -1;
|
||||||
VIR_FREE(output);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -127,8 +117,8 @@ static int
|
|||||||
mymain(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char *poolxml = NULL;
|
VIR_AUTOFREE(char *) poolxml = NULL;
|
||||||
char *volxml = NULL;
|
VIR_AUTOFREE(char *) volxml = NULL;
|
||||||
|
|
||||||
collie_test node_info_tests[] = {
|
collie_test node_info_tests[] = {
|
||||||
{"", -1, 0, 0},
|
{"", -1, 0, 0},
|
||||||
@ -215,8 +205,6 @@ mymain(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(poolxml);
|
|
||||||
VIR_FREE(volxml);
|
|
||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,6 @@ testCompareXMLToArgvFiles(bool shouldFail,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(actualCmdline);
|
|
||||||
virStoragePoolObjEndAPI(&pool);
|
virStoragePoolObjEndAPI(&pool);
|
||||||
if (shouldFail) {
|
if (shouldFail) {
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
@ -101,27 +100,20 @@ struct testInfo {
|
|||||||
static int
|
static int
|
||||||
testCompareXMLToArgvHelper(const void *data)
|
testCompareXMLToArgvHelper(const void *data)
|
||||||
{
|
{
|
||||||
int result = -1;
|
|
||||||
const struct testInfo *info = data;
|
const struct testInfo *info = data;
|
||||||
char *poolxml = NULL;
|
VIR_AUTOFREE(char *) poolxml = NULL;
|
||||||
char *cmdline = NULL;
|
VIR_AUTOFREE(char *) cmdline = NULL;
|
||||||
|
|
||||||
if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
|
if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
|
||||||
abs_srcdir, info->pool) < 0)
|
abs_srcdir, info->pool) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s%s.argv",
|
if (virAsprintf(&cmdline, "%s/storagepoolxml2argvdata/%s%s.argv",
|
||||||
abs_srcdir, info->pool, info->platformSuffix) < 0 &&
|
abs_srcdir, info->pool, info->platformSuffix) < 0 &&
|
||||||
!info->shouldFail)
|
!info->shouldFail)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
result = testCompareXMLToArgvFiles(info->shouldFail, poolxml, cmdline);
|
return testCompareXMLToArgvFiles(info->shouldFail, poolxml, cmdline);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(poolxml);
|
|
||||||
VIR_FREE(cmdline);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,47 +18,34 @@
|
|||||||
static int
|
static int
|
||||||
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
|
testCompareXMLToXMLFiles(const char *inxml, const char *outxml)
|
||||||
{
|
{
|
||||||
char *actual = NULL;
|
VIR_AUTOFREE(char *) actual = NULL;
|
||||||
int ret = -1;
|
|
||||||
VIR_AUTOPTR(virStoragePoolDef) dev = NULL;
|
VIR_AUTOPTR(virStoragePoolDef) dev = NULL;
|
||||||
|
|
||||||
if (!(dev = virStoragePoolDefParseFile(inxml)))
|
if (!(dev = virStoragePoolDefParseFile(inxml)))
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
if (!(actual = virStoragePoolDefFormat(dev)))
|
if (!(actual = virStoragePoolDefFormat(dev)))
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(actual, outxml) < 0)
|
if (virTestCompareToFile(actual, outxml) < 0)
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
VIR_FREE(actual);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testCompareXMLToXMLHelper(const void *data)
|
testCompareXMLToXMLHelper(const void *data)
|
||||||
{
|
{
|
||||||
int result = -1;
|
VIR_AUTOFREE(char *) inxml = NULL;
|
||||||
char *inxml = NULL;
|
VIR_AUTOFREE(char *) outxml = NULL;
|
||||||
char *outxml = NULL;
|
|
||||||
|
|
||||||
if (virAsprintf(&inxml, "%s/storagepoolxml2xmlin/%s.xml",
|
if (virAsprintf(&inxml, "%s/storagepoolxml2xmlin/%s.xml",
|
||||||
abs_srcdir, (const char*)data) < 0 ||
|
abs_srcdir, (const char*)data) < 0 ||
|
||||||
virAsprintf(&outxml, "%s/storagepoolxml2xmlout/%s.xml",
|
virAsprintf(&outxml, "%s/storagepoolxml2xmlout/%s.xml",
|
||||||
abs_srcdir, (const char*)data) < 0) {
|
abs_srcdir, (const char*)data) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
result = testCompareXMLToXMLFiles(inxml, outxml);
|
return testCompareXMLToXMLFiles(inxml, outxml);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(inxml);
|
|
||||||
VIR_FREE(outxml);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -42,11 +42,11 @@ testCompareXMLToArgvFiles(bool shouldFail,
|
|||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
unsigned long parse_flags)
|
unsigned long parse_flags)
|
||||||
{
|
{
|
||||||
char *actualCmdline = NULL;
|
|
||||||
virStorageVolEncryptConvertStep convertStep = VIR_STORAGE_VOL_ENCRYPT_NONE;
|
virStorageVolEncryptConvertStep convertStep = VIR_STORAGE_VOL_ENCRYPT_NONE;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virStoragePoolDefPtr def = NULL;
|
virStoragePoolDefPtr def = NULL;
|
||||||
virStoragePoolObjPtr obj = NULL;
|
virStoragePoolObjPtr obj = NULL;
|
||||||
|
VIR_AUTOFREE(char *) actualCmdline = NULL;
|
||||||
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||||
VIR_AUTOPTR(virStorageVolDef) inputvol = NULL;
|
VIR_AUTOPTR(virStorageVolDef) inputvol = NULL;
|
||||||
VIR_AUTOPTR(virStoragePoolDef) inputpool = NULL;
|
VIR_AUTOPTR(virStoragePoolDef) inputpool = NULL;
|
||||||
@ -108,7 +108,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
char *createCmdline = actualCmdline;
|
char *createCmdline = actualCmdline;
|
||||||
char *cvtCmdline;
|
VIR_AUTOFREE(char *) cvtCmdline = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!(cvtCmdline = virCommandToString(cmd, false)))
|
if (!(cvtCmdline = virCommandToString(cmd, false)))
|
||||||
@ -118,7 +118,6 @@ testCompareXMLToArgvFiles(bool shouldFail,
|
|||||||
createCmdline, cvtCmdline);
|
createCmdline, cvtCmdline);
|
||||||
|
|
||||||
VIR_FREE(createCmdline);
|
VIR_FREE(createCmdline);
|
||||||
VIR_FREE(cvtCmdline);
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -138,7 +137,6 @@ testCompareXMLToArgvFiles(bool shouldFail,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(actualCmdline);
|
|
||||||
virStoragePoolObjEndAPI(&obj);
|
virStoragePoolObjEndAPI(&obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -157,45 +155,35 @@ struct testInfo {
|
|||||||
static int
|
static int
|
||||||
testCompareXMLToArgvHelper(const void *data)
|
testCompareXMLToArgvHelper(const void *data)
|
||||||
{
|
{
|
||||||
int result = -1;
|
|
||||||
const struct testInfo *info = data;
|
const struct testInfo *info = data;
|
||||||
char *poolxml = NULL;
|
VIR_AUTOFREE(char *) poolxml = NULL;
|
||||||
char *inputpoolxml = NULL;
|
VIR_AUTOFREE(char *) inputpoolxml = NULL;
|
||||||
char *volxml = NULL;
|
VIR_AUTOFREE(char *) volxml = NULL;
|
||||||
char *inputvolxml = NULL;
|
VIR_AUTOFREE(char *) inputvolxml = NULL;
|
||||||
char *cmdline = NULL;
|
VIR_AUTOFREE(char *) cmdline = NULL;
|
||||||
|
|
||||||
if (info->inputvol &&
|
if (info->inputvol &&
|
||||||
virAsprintf(&inputvolxml, "%s/storagevolxml2xmlin/%s.xml",
|
virAsprintf(&inputvolxml, "%s/storagevolxml2xmlin/%s.xml",
|
||||||
abs_srcdir, info->inputvol) < 0)
|
abs_srcdir, info->inputvol) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (info->inputpool &&
|
if (info->inputpool &&
|
||||||
virAsprintf(&inputpoolxml, "%s/storagepoolxml2xmlin/%s.xml",
|
virAsprintf(&inputpoolxml, "%s/storagepoolxml2xmlin/%s.xml",
|
||||||
abs_srcdir, info->inputpool) < 0)
|
abs_srcdir, info->inputpool) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
|
if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
|
||||||
abs_srcdir, info->pool) < 0 ||
|
abs_srcdir, info->pool) < 0 ||
|
||||||
virAsprintf(&volxml, "%s/storagevolxml2xmlin/%s.xml",
|
virAsprintf(&volxml, "%s/storagevolxml2xmlin/%s.xml",
|
||||||
abs_srcdir, info->vol) < 0) {
|
abs_srcdir, info->vol) < 0) {
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
if (virAsprintf(&cmdline, "%s/storagevolxml2argvdata/%s.argv",
|
if (virAsprintf(&cmdline, "%s/storagevolxml2argvdata/%s.argv",
|
||||||
abs_srcdir, info->cmdline) < 0 && !info->shouldFail)
|
abs_srcdir, info->cmdline) < 0 && !info->shouldFail)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
result = testCompareXMLToArgvFiles(info->shouldFail, poolxml, volxml,
|
return testCompareXMLToArgvFiles(info->shouldFail, poolxml, volxml,
|
||||||
inputpoolxml, inputvolxml,
|
inputpoolxml, inputvolxml,
|
||||||
cmdline, info->flags,
|
cmdline, info->flags,
|
||||||
info->parseflags);
|
info->parseflags);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(poolxml);
|
|
||||||
VIR_FREE(volxml);
|
|
||||||
VIR_FREE(inputvolxml);
|
|
||||||
VIR_FREE(inputpoolxml);
|
|
||||||
VIR_FREE(cmdline);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,28 +17,23 @@ static int
|
|||||||
testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
|
testCompareXMLToXMLFiles(const char *poolxml, const char *inxml,
|
||||||
const char *outxml, unsigned int flags)
|
const char *outxml, unsigned int flags)
|
||||||
{
|
{
|
||||||
char *actual = NULL;
|
VIR_AUTOFREE(char *) actual = NULL;
|
||||||
int ret = -1;
|
|
||||||
VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
|
VIR_AUTOPTR(virStoragePoolDef) pool = NULL;
|
||||||
VIR_AUTOPTR(virStorageVolDef) dev = NULL;
|
VIR_AUTOPTR(virStorageVolDef) dev = NULL;
|
||||||
|
|
||||||
if (!(pool = virStoragePoolDefParseFile(poolxml)))
|
if (!(pool = virStoragePoolDefParseFile(poolxml)))
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
if (!(dev = virStorageVolDefParseFile(pool, inxml, flags)))
|
if (!(dev = virStorageVolDefParseFile(pool, inxml, flags)))
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
if (!(actual = virStorageVolDefFormat(pool, dev)))
|
if (!(actual = virStorageVolDefFormat(pool, dev)))
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
if (virTestCompareToFile(actual, outxml) < 0)
|
if (virTestCompareToFile(actual, outxml) < 0)
|
||||||
goto fail;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
VIR_FREE(actual);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct testInfo {
|
struct testInfo {
|
||||||
@ -50,29 +45,20 @@ struct testInfo {
|
|||||||
static int
|
static int
|
||||||
testCompareXMLToXMLHelper(const void *data)
|
testCompareXMLToXMLHelper(const void *data)
|
||||||
{
|
{
|
||||||
int result = -1;
|
|
||||||
const struct testInfo *info = data;
|
const struct testInfo *info = data;
|
||||||
char *poolxml = NULL;
|
VIR_AUTOFREE(char *) poolxml = NULL;
|
||||||
char *inxml = NULL;
|
VIR_AUTOFREE(char *) inxml = NULL;
|
||||||
char *outxml = NULL;
|
VIR_AUTOFREE(char *) outxml = NULL;
|
||||||
|
|
||||||
if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
|
if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml",
|
||||||
abs_srcdir, info->pool) < 0 ||
|
abs_srcdir, info->pool) < 0 ||
|
||||||
virAsprintf(&inxml, "%s/storagevolxml2xmlin/%s.xml",
|
virAsprintf(&inxml, "%s/storagevolxml2xmlin/%s.xml",
|
||||||
abs_srcdir, info->name) < 0 ||
|
abs_srcdir, info->name) < 0 ||
|
||||||
virAsprintf(&outxml, "%s/storagevolxml2xmlout/%s.xml",
|
virAsprintf(&outxml, "%s/storagevolxml2xmlout/%s.xml",
|
||||||
abs_srcdir, info->name) < 0) {
|
abs_srcdir, info->name) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
result = testCompareXMLToXMLFiles(poolxml, inxml, outxml, info->flags);
|
return testCompareXMLToXMLFiles(poolxml, inxml, outxml, info->flags);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(poolxml);
|
|
||||||
VIR_FREE(inxml);
|
|
||||||
VIR_FREE(outxml);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,9 +128,9 @@ static int
|
|||||||
testPrepImages(void)
|
testPrepImages(void)
|
||||||
{
|
{
|
||||||
int ret = EXIT_FAILURE;
|
int ret = EXIT_FAILURE;
|
||||||
char *buf = NULL;
|
|
||||||
bool compat = false;
|
bool compat = false;
|
||||||
VIR_AUTOPTR(virCommand) cmd = NULL;
|
VIR_AUTOPTR(virCommand) cmd = NULL;
|
||||||
|
VIR_AUTOFREE(char *) buf = NULL;
|
||||||
|
|
||||||
qemuimg = virFindFileInPath("qemu-img");
|
qemuimg = virFindFileInPath("qemu-img");
|
||||||
if (!qemuimg)
|
if (!qemuimg)
|
||||||
@ -245,7 +245,6 @@ testPrepImages(void)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(buf);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
testCleanupImages();
|
testCleanupImages();
|
||||||
return ret;
|
return ret;
|
||||||
@ -313,7 +312,7 @@ testStorageChain(const void *args)
|
|||||||
virStorageSourcePtr meta;
|
virStorageSourcePtr meta;
|
||||||
virStorageSourcePtr elt;
|
virStorageSourcePtr elt;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
char *broken = NULL;
|
VIR_AUTOFREE(char *) broken = NULL;
|
||||||
|
|
||||||
meta = testStorageFileGetMetadata(data->start, data->format, -1, -1);
|
meta = testStorageFileGetMetadata(data->start, data->format, -1, -1);
|
||||||
if (!meta) {
|
if (!meta) {
|
||||||
@ -349,8 +348,8 @@ testStorageChain(const void *args)
|
|||||||
|
|
||||||
elt = meta;
|
elt = meta;
|
||||||
while (virStorageSourceIsBacking(elt)) {
|
while (virStorageSourceIsBacking(elt)) {
|
||||||
char *expect = NULL;
|
VIR_AUTOFREE(char *) expect = NULL;
|
||||||
char *actual = NULL;
|
VIR_AUTOFREE(char *) actual = NULL;
|
||||||
|
|
||||||
if (i == data->nfiles) {
|
if (i == data->nfiles) {
|
||||||
fprintf(stderr, "probed chain was too long\n");
|
fprintf(stderr, "probed chain was too long\n");
|
||||||
@ -379,18 +378,12 @@ testStorageChain(const void *args)
|
|||||||
elt->format,
|
elt->format,
|
||||||
virStorageNetProtocolTypeToString(elt->protocol),
|
virStorageNetProtocolTypeToString(elt->protocol),
|
||||||
NULLSTR(elt->nhosts ? elt->hosts[0].name : NULL)) < 0) {
|
NULLSTR(elt->nhosts ? elt->hosts[0].name : NULL)) < 0) {
|
||||||
VIR_FREE(expect);
|
|
||||||
VIR_FREE(actual);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (STRNEQ(expect, actual)) {
|
if (STRNEQ(expect, actual)) {
|
||||||
virTestDifference(stderr, expect, actual);
|
virTestDifference(stderr, expect, actual);
|
||||||
VIR_FREE(expect);
|
|
||||||
VIR_FREE(actual);
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
VIR_FREE(expect);
|
|
||||||
VIR_FREE(actual);
|
|
||||||
elt = elt->backingStore;
|
elt = elt->backingStore;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -401,7 +394,6 @@ testStorageChain(const void *args)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(broken);
|
|
||||||
virStorageSourceFree(meta);
|
virStorageSourceFree(meta);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -539,8 +531,7 @@ static int
|
|||||||
testPathCanonicalize(const void *args)
|
testPathCanonicalize(const void *args)
|
||||||
{
|
{
|
||||||
const struct testPathCanonicalizeData *data = args;
|
const struct testPathCanonicalizeData *data = args;
|
||||||
char *canon = NULL;
|
VIR_AUTOFREE(char *) canon = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
canon = virStorageFileCanonicalizePath(data->path,
|
canon = virStorageFileCanonicalizePath(data->path,
|
||||||
testPathCanonicalizeReadlink,
|
testPathCanonicalizeReadlink,
|
||||||
@ -551,15 +542,10 @@ testPathCanonicalize(const void *args)
|
|||||||
"path canonicalization of '%s' failed: expected '%s' got '%s'\n",
|
"path canonicalization of '%s' failed: expected '%s' got '%s'\n",
|
||||||
data->path, NULLSTR(data->expect), NULLSTR(canon));
|
data->path, NULLSTR(data->expect), NULLSTR(canon));
|
||||||
|
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(canon);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static virStorageSource backingchain[12];
|
static virStorageSource backingchain[12];
|
||||||
@ -629,14 +615,13 @@ static int
|
|||||||
testPathRelative(const void *args)
|
testPathRelative(const void *args)
|
||||||
{
|
{
|
||||||
const struct testPathRelativeBacking *data = args;
|
const struct testPathRelativeBacking *data = args;
|
||||||
char *actual = NULL;
|
VIR_AUTOFREE(char *) actual = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (virStorageFileGetRelativeBackingPath(data->top,
|
if (virStorageFileGetRelativeBackingPath(data->top,
|
||||||
data->base,
|
data->base,
|
||||||
&actual) < 0) {
|
&actual) < 0) {
|
||||||
fprintf(stderr, "relative backing path resolution failed\n");
|
fprintf(stderr, "relative backing path resolution failed\n");
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (STRNEQ_NULLABLE(data->expect, actual)) {
|
if (STRNEQ_NULLABLE(data->expect, actual)) {
|
||||||
@ -644,15 +629,10 @@ testPathRelative(const void *args)
|
|||||||
"expected '%s', got '%s'\n",
|
"expected '%s', got '%s'\n",
|
||||||
data->top->path, data->base->path,
|
data->top->path, data->base->path,
|
||||||
NULLSTR(data->expect), NULLSTR(actual));
|
NULLSTR(data->expect), NULLSTR(actual));
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(actual);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -667,8 +647,8 @@ testBackingParse(const void *args)
|
|||||||
const struct testBackingParseData *data = args;
|
const struct testBackingParseData *data = args;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
virStorageSourcePtr src = NULL;
|
virStorageSourcePtr src = NULL;
|
||||||
char *xml = NULL;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
VIR_AUTOFREE(char *) xml = NULL;
|
||||||
|
|
||||||
if (!(src = virStorageSourceNewFromBackingAbsolute(data->backing))) {
|
if (!(src = virStorageSourceNewFromBackingAbsolute(data->backing))) {
|
||||||
if (!data->expect)
|
if (!data->expect)
|
||||||
@ -702,7 +682,6 @@ testBackingParse(const void *args)
|
|||||||
cleanup:
|
cleanup:
|
||||||
virStorageSourceFree(src);
|
virStorageSourceFree(src);
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
VIR_FREE(xml);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,9 @@ testGlusterExtractPoolSources(const void *opaque)
|
|||||||
.sources = NULL
|
.sources = NULL
|
||||||
};
|
};
|
||||||
size_t i;
|
size_t i;
|
||||||
char *srcxmldata = NULL;
|
|
||||||
char *actual = NULL;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
VIR_AUTOFREE(char *) srcxmldata = NULL;
|
||||||
|
VIR_AUTOFREE(char *) actual = NULL;
|
||||||
|
|
||||||
if (virTestLoadFile(data->srcxml, &srcxmldata) < 0)
|
if (virTestLoadFile(data->srcxml, &srcxmldata) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -62,9 +62,6 @@ testGlusterExtractPoolSources(const void *opaque)
|
|||||||
ret = virTestCompareToFile(actual, data->dstxml);
|
ret = virTestCompareToFile(actual, data->dstxml);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(srcxmldata);
|
|
||||||
VIR_FREE(actual);
|
|
||||||
|
|
||||||
for (i = 0; i < list.nsources; i++)
|
for (i = 0; i < list.nsources; i++)
|
||||||
virStoragePoolSourceClear(&list.sources[i]);
|
virStoragePoolSourceClear(&list.sources[i]);
|
||||||
VIR_FREE(list.sources);
|
VIR_FREE(list.sources);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user