mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
tests: Move code from DO_TEST() to doCapsTest()
This removes the awkard escaping and will allow us to perform some more refactoring later on. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Acked-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
5a8ceba2f3
commit
ad340f225a
@ -176,6 +176,32 @@ testQemuCapsCopy(const void *opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
doCapsTest(const char *base,
|
||||||
|
const char *archName,
|
||||||
|
testQemuDataPtr data)
|
||||||
|
{
|
||||||
|
VIR_AUTOFREE(char *) title = NULL;
|
||||||
|
VIR_AUTOFREE(char *) copyTitle = NULL;
|
||||||
|
|
||||||
|
if (virAsprintf(&title, "%s (%s)", base, archName) < 0 ||
|
||||||
|
virAsprintf(©Title, "copy %s (%s)", base, archName) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
data->base = base;
|
||||||
|
data->archName = archName;
|
||||||
|
|
||||||
|
if (virTestRun(title, testQemuCaps, data) < 0)
|
||||||
|
data->ret = -1;
|
||||||
|
|
||||||
|
if (virTestRun(copyTitle, testQemuCapsCopy, data) < 0)
|
||||||
|
data->ret = -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
@ -196,18 +222,8 @@ mymain(void)
|
|||||||
|
|
||||||
#define DO_TEST(arch, name) \
|
#define DO_TEST(arch, name) \
|
||||||
do { \
|
do { \
|
||||||
VIR_AUTOFREE(char *) title = NULL; \
|
if (doCapsTest(name, arch, &data) < 0) \
|
||||||
VIR_AUTOFREE(char *) copyTitle = NULL; \
|
return EXIT_FAILURE; \
|
||||||
if (virAsprintf(&title, "%s (%s)", name, arch) < 0 || \
|
|
||||||
virAsprintf(©Title, "copy %s (%s)", name, arch) < 0) { \
|
|
||||||
return -EXIT_FAILURE; \
|
|
||||||
} \
|
|
||||||
data.archName = arch; \
|
|
||||||
data.base = name; \
|
|
||||||
if (virTestRun(title, testQemuCaps, &data) < 0) \
|
|
||||||
data.ret = -1; \
|
|
||||||
if (virTestRun(copyTitle, testQemuCapsCopy, &data) < 0) \
|
|
||||||
data.ret = -1; \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Keep this in sync with qemucaps2xmltest */
|
/* Keep this in sync with qemucaps2xmltest */
|
||||||
|
@ -173,6 +173,25 @@ testQemuCapsXML(const void *opaque)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
doCapsTest(const char *base,
|
||||||
|
const char *archName,
|
||||||
|
testQemuDataPtr data)
|
||||||
|
{
|
||||||
|
VIR_AUTOFREE(char *) title = NULL;
|
||||||
|
|
||||||
|
if (virAsprintf(&title, "%s (%s)", base, archName) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
data->base = base;
|
||||||
|
data->archName = archName;
|
||||||
|
|
||||||
|
if (virTestRun(title, testQemuCapsXML, data) < 0)
|
||||||
|
data->ret = -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
@ -193,13 +212,8 @@ mymain(void)
|
|||||||
|
|
||||||
#define DO_TEST(arch, name) \
|
#define DO_TEST(arch, name) \
|
||||||
do { \
|
do { \
|
||||||
VIR_AUTOFREE(char *) title = NULL; \
|
if (doCapsTest(name, arch, &data) < 0) \
|
||||||
if (virAsprintf(&title, "%s (%s)", name, arch) < 0) \
|
return EXIT_FAILURE; \
|
||||||
return -EXIT_FAILURE; \
|
|
||||||
data.archName = arch; \
|
|
||||||
data.base = name; \
|
|
||||||
if (virTestRun(title, testQemuCapsXML, &data) < 0) \
|
|
||||||
data.ret = -1; \
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Keep this in sync with qemucapabilitiestest */
|
/* Keep this in sync with qemucapabilitiestest */
|
||||||
|
Loading…
Reference in New Issue
Block a user