mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 19:02:25 +00:00
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: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
c611c886f5
commit
a80827a7f9
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user