提交 352dd945 编写于 作者: C Cole Robinson

tests: qemuxml2xml: Set name in testQemuInfo

Use the same pattern that is used in qemuxml2argvtest, setting the
name in a static testQemuInfo instance inside the test macros
Reviewed-by: NAndrea Bolognani <abologna@redhat.com>
Signed-off-by: NCole Robinson <crobinso@redhat.com>
上级 3e213d43
...@@ -90,19 +90,18 @@ testCompareStatusXMLToXMLFiles(const void *opaque) ...@@ -90,19 +90,18 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
static int static int
testInfoSetPaths(struct testQemuInfo *info, testInfoSetPaths(struct testQemuInfo *info,
const char *name,
int when) int when)
{ {
VIR_FREE(info->infile); VIR_FREE(info->infile);
VIR_FREE(info->outfile); VIR_FREE(info->outfile);
if (virAsprintf(&info->infile, "%s/qemuxml2argvdata/%s.xml", if (virAsprintf(&info->infile, "%s/qemuxml2argvdata/%s.xml",
abs_srcdir, name) < 0) abs_srcdir, info->name) < 0)
goto error; goto error;
if (virAsprintf(&info->outfile, if (virAsprintf(&info->outfile,
"%s/qemuxml2xmloutdata/%s-%s.xml", "%s/qemuxml2xmloutdata/%s-%s.xml",
abs_srcdir, name, abs_srcdir, info->name,
when == WHEN_ACTIVE ? "active" : "inactive") < 0) when == WHEN_ACTIVE ? "active" : "inactive") < 0)
goto error; goto error;
...@@ -111,7 +110,7 @@ testInfoSetPaths(struct testQemuInfo *info, ...@@ -111,7 +110,7 @@ testInfoSetPaths(struct testQemuInfo *info,
if (virAsprintf(&info->outfile, if (virAsprintf(&info->outfile,
"%s/qemuxml2xmloutdata/%s.xml", "%s/qemuxml2xmloutdata/%s.xml",
abs_srcdir, name) < 0) abs_srcdir, info->name) < 0)
goto error; goto error;
} }
...@@ -126,11 +125,10 @@ testInfoSetPaths(struct testQemuInfo *info, ...@@ -126,11 +125,10 @@ testInfoSetPaths(struct testQemuInfo *info,
static const char *statusPath = abs_srcdir "/qemustatusxml2xmldata/"; static const char *statusPath = abs_srcdir "/qemustatusxml2xmldata/";
static int static int
testInfoSetStatusPaths(struct testQemuInfo *info, testInfoSetStatusPaths(struct testQemuInfo *info)
const char *name)
{ {
if (virAsprintf(&info->infile, "%s%s-in.xml", statusPath, name) < 0 || if (virAsprintf(&info->infile, "%s%s-in.xml", statusPath, info->name) < 0 ||
virAsprintf(&info->outfile, "%s%s-out.xml", statusPath, name) < 0) virAsprintf(&info->outfile, "%s%s-out.xml", statusPath, info->name) < 0)
goto error; goto error;
return 0; return 0;
...@@ -148,7 +146,6 @@ mymain(void) ...@@ -148,7 +146,6 @@ mymain(void)
{ {
int ret = 0; int ret = 0;
char *fakerootdir; char *fakerootdir;
struct testQemuInfo info;
virQEMUDriverConfigPtr cfg = NULL; virQEMUDriverConfigPtr cfg = NULL;
virHashTablePtr capslatest = NULL; virHashTablePtr capslatest = NULL;
...@@ -168,39 +165,40 @@ mymain(void) ...@@ -168,39 +165,40 @@ mymain(void)
setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1); setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
memset(&info, 0, sizeof(info));
if (qemuTestDriverInit(&driver) < 0) if (qemuTestDriverInit(&driver) < 0)
return EXIT_FAILURE; return EXIT_FAILURE;
cfg = virQEMUDriverGetConfig(&driver); cfg = virQEMUDriverGetConfig(&driver);
# define DO_TEST_FULL(name, when, ...) \ # define DO_TEST_FULL(_name, when, ...) \
do { \ do { \
static struct testQemuInfo info = { \
.name = _name, \
}; \
if (testQemuInfoSetArgs(&info, capslatest, \ if (testQemuInfoSetArgs(&info, capslatest, \
__VA_ARGS__, \ __VA_ARGS__, \
ARG_END) < 0 || \ ARG_END) < 0 || \
qemuTestCapsCacheInsert(driver.qemuCapsCache, info.qemuCaps) < 0) { \ qemuTestCapsCacheInsert(driver.qemuCapsCache, info.qemuCaps) < 0) { \
VIR_TEST_DEBUG("Failed to generate test data for '%s'", name); \ VIR_TEST_DEBUG("Failed to generate test data for '%s'", _name); \
return -1; \ return -1; \
} \ } \
\ \
if (when & WHEN_INACTIVE) { \ if (when & WHEN_INACTIVE) { \
if (testInfoSetPaths(&info, name, WHEN_INACTIVE) < 0) { \ if (testInfoSetPaths(&info, WHEN_INACTIVE) < 0) { \
VIR_TEST_DEBUG("Failed to generate inactive paths for '%s'", name); \ VIR_TEST_DEBUG("Failed to generate inactive paths for '%s'", _name); \
return -1; \ return -1; \
} \ } \
if (virTestRun("QEMU XML-2-XML-inactive " name, \ if (virTestRun("QEMU XML-2-XML-inactive " _name, \
testXML2XMLInactive, &info) < 0) \ testXML2XMLInactive, &info) < 0) \
ret = -1; \ ret = -1; \
} \ } \
\ \
if (when & WHEN_ACTIVE) { \ if (when & WHEN_ACTIVE) { \
if (testInfoSetPaths(&info, name, WHEN_ACTIVE) < 0) { \ if (testInfoSetPaths(&info, WHEN_ACTIVE) < 0) { \
VIR_TEST_DEBUG("Failed to generate active paths for '%s'", name); \ VIR_TEST_DEBUG("Failed to generate active paths for '%s'", _name); \
return -1; \ return -1; \
} \ } \
if (virTestRun("QEMU XML-2-XML-active " name, \ if (virTestRun("QEMU XML-2-XML-active " _name, \
testXML2XMLActive, &info) < 0) \ testXML2XMLActive, &info) < 0) \
ret = -1; \ ret = -1; \
} \ } \
...@@ -1253,18 +1251,21 @@ mymain(void) ...@@ -1253,18 +1251,21 @@ mymain(void)
QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES); QEMU_CAPS_MCH_EXTENDED_TSEG_MBYTES);
# define DO_TEST_STATUS(name) \ # define DO_TEST_STATUS(_name) \
do { \ do { \
static struct testQemuInfo info = { \
.name = _name, \
}; \
if (testQemuInfoSetArgs(&info, capslatest, \ if (testQemuInfoSetArgs(&info, capslatest, \
ARG_QEMU_CAPS, QEMU_CAPS_LAST, \ ARG_QEMU_CAPS, QEMU_CAPS_LAST, \
ARG_END) < 0 || \ ARG_END) < 0 || \
qemuTestCapsCacheInsert(driver.qemuCapsCache, info.qemuCaps) < 0 || \ qemuTestCapsCacheInsert(driver.qemuCapsCache, info.qemuCaps) < 0 || \
testInfoSetStatusPaths(&info, name) < 0) { \ testInfoSetStatusPaths(&info) < 0) { \
VIR_TEST_DEBUG("Failed to generate status test data for '%s'", name); \ VIR_TEST_DEBUG("Failed to generate status test data for '%s'", _name); \
return -1; \ return -1; \
} \ } \
\ \
if (virTestRun("QEMU status XML-2-XML " name, \ if (virTestRun("QEMU status XML-2-XML " _name, \
testCompareStatusXMLToXMLFiles, &info) < 0) \ testCompareStatusXMLToXMLFiles, &info) < 0) \
ret = -1; \ ret = -1; \
\ \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册