提交 a80827a7 编写于 作者: J Jiri Denemark

qemu: Add tests for virQEMUCapsNewCopy

Doing a load, copy, format cycle on all QEMU capabilities XML files
should make sure we don't forget to update virQEMUCapsNewCopy when
adding new elements to QEMU capabilities.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 c611c886
......@@ -2864,8 +2864,12 @@ virQEMUCapsLoadCache(virQEMUCapsPtr qemuCaps, const char *filename,
goto cleanup;
}
/* Don't check for NULL, since it is optional and thus may be missing */
qemuCaps->package = virXPathString("string(./package)", ctxt);
if (virXPathBoolean("boolean(./package)", ctxt) > 0) {
qemuCaps->package = virXPathString("string(./package)", ctxt);
if (!qemuCaps->package &&
VIR_STRDUP(qemuCaps->package, "") < 0)
goto cleanup;
}
if (!(str = virXPathString("string(./arch)", ctxt))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
......
......@@ -384,7 +384,6 @@ typedef struct _virQEMUCapsCache virQEMUCapsCache;
typedef virQEMUCapsCache *virQEMUCapsCachePtr;
virQEMUCapsPtr virQEMUCapsNew(void);
virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps);
int virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
qemuMonitorPtr mon);
......
......@@ -37,6 +37,8 @@ struct _virQEMUCapsCache {
gid_t runGid;
};
virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps);
virQEMUCapsPtr
virQEMUCapsNewForBinaryInternal(const char *binary,
const char *libDir,
......
......@@ -77,6 +77,50 @@ testQemuCaps(const void *opaque)
return ret;
}
static int
testQemuCapsCopy(const void *opaque)
{
int ret = -1;
const testQemuData *data = opaque;
char *capsFile = NULL;
virCapsPtr caps = NULL;
virQEMUCapsPtr orig = NULL;
virQEMUCapsPtr copy = NULL;
char *actual = NULL;
if (virAsprintf(&capsFile, "%s/qemucapabilitiesdata/%s.%s.xml",
abs_srcdir, data->base, data->archName) < 0)
goto cleanup;
if (!(caps = virCapabilitiesNew(virArchFromString(data->archName),
false, false)))
goto cleanup;
if (!(orig = qemuTestParseCapabilities(capsFile)))
goto cleanup;
if (!(copy = virQEMUCapsNewCopy(orig)))
goto cleanup;
if (!(actual = virQEMUCapsFormatCache(copy, 0, 0)))
goto cleanup;
if (virTestCompareToFile(actual, capsFile) < 0)
goto cleanup;
ret = 0;
cleanup:
VIR_FREE(capsFile);
virObjectUnref(caps);
virObjectUnref(orig);
virObjectUnref(copy);
VIR_FREE(actual);
return ret;
}
static int
mymain(void)
{
......@@ -103,6 +147,9 @@ mymain(void)
data.base = name; \
if (virTestRun(name "(" arch ")", testQemuCaps, &data) < 0) \
ret = -1; \
if (virTestRun("copy " name "(" arch ")", \
testQemuCapsCopy, &data) < 0) \
ret = -1; \
} while (0)
DO_TEST("x86_64", "caps_1.2.2");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册