tests: Use virAsprintf() to build titles

We're using static string concatenation at the moment, but
that will no longer be a possibility in a bit.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Andrea Bolognani 2019-03-07 15:37:40 +01:00
parent 0c744afe1a
commit 5a8ceba2f3
2 changed files with 17 additions and 7 deletions

View File

@ -196,12 +196,17 @@ mymain(void)
#define DO_TEST(arch, name) \
do { \
VIR_AUTOFREE(char *) title = NULL; \
VIR_AUTOFREE(char *) copyTitle = NULL; \
if (virAsprintf(&title, "%s (%s)", name, arch) < 0 || \
virAsprintf(&copyTitle, "copy %s (%s)", name, arch) < 0) { \
return -EXIT_FAILURE; \
} \
data.archName = arch; \
data.base = name; \
if (virTestRun(name "(" arch ")", testQemuCaps, &data) < 0) \
if (virTestRun(title, testQemuCaps, &data) < 0) \
data.ret = -1; \
if (virTestRun("copy " name "(" arch ")", \
testQemuCapsCopy, &data) < 0) \
if (virTestRun(copyTitle, testQemuCapsCopy, &data) < 0) \
data.ret = -1; \
} while (0)

View File

@ -192,10 +192,15 @@ mymain(void)
return EXIT_FAILURE;
#define DO_TEST(arch, name) \
do { \
VIR_AUTOFREE(char *) title = NULL; \
if (virAsprintf(&title, "%s (%s)", name, arch) < 0) \
return -EXIT_FAILURE; \
data.archName = arch; \
data.base = name; \
if (virTestRun(name "(" arch ")", testQemuCapsXML, &data) < 0) \
data.ret = -1
if (virTestRun(title, testQemuCapsXML, &data) < 0) \
data.ret = -1; \
} while (0)
/* Keep this in sync with qemucapabilitiestest */
DO_TEST("x86_64", "caps_1.5.3");