static int testQemuCaps(const void *opaque) { int ret = -1; const testQemuData *data = opaque; char *repliesFile = NULL; char *capsFile = NULL; qemuMonitorTestPtr mon = NULL; virQEMUCapsPtr capsActual = NULL; char *actual = NULL; if (virAsprintf(&repliesFile, "%s/qemucapabilitiesdata/%s.%s.replies", abs_srcdir, data->base, data->archName) < 0 || virAsprintf(&capsFile, "%s/qemucapabilitiesdata/%s.%s.xml", abs_srcdir, data->base, data->archName) < 0) goto cleanup; if (!(mon = qemuMonitorTestNewFromFile(repliesFile, data->xmlopt, false))) goto cleanup; if (!(capsActual = virQEMUCapsNew()) || virQEMUCapsInitQMPMonitor(capsActual, qemuMonitorTestGetMonitor(mon)) < 0) goto cleanup; if (virQEMUCapsGet(capsActual, QEMU_CAPS_KVM)) { if (virQEMUCapsInitQMPMonitorTCG(capsActual, qemuMonitorTestGetMonitor(mon)) < 0) goto cleanup; /* Fill microcodeVersion with a "random" value which is the file * length to provide a reproducible number for testing. */ virQEMUCapsSetMicrocodeVersion(capsActual, virFileLength(repliesFile, -1)); } if (!(actual = virQEMUCapsFormatCache(capsActual))) goto cleanup; if (virTestCompareToFile(actual, capsFile) < 0) goto cleanup; ret = 0; cleanup: VIR_FREE(repliesFile); VIR_FREE(capsFile); VIR_FREE(actual); qemuMonitorTestFree(mon); virObjectUnref(capsActual); 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(caps, capsFile))) goto cleanup; if (!(copy = virQEMUCapsNewCopy(orig))) goto cleanup; if (!(actual = virQEMUCapsFormatCache(copy))) 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 testQemuCaps(const void *opaque) { int ret = -1; const testQemuData *data = opaque; char *repliesFile = NULL; char *capsFile = NULL; qemuMonitorTestPtr mon = NULL; virQEMUCapsPtr capsActual = NULL; char *actual = NULL; if (virAsprintf(&repliesFile, "%s/qemucapabilitiesdata/%s.%s.replies", abs_srcdir, data->base, data->archName) < 0 || virAsprintf(&capsFile, "%s/qemucapabilitiesdata/%s.%s.xml", abs_srcdir, data->base, data->archName) < 0) goto cleanup; if (!(mon = qemuMonitorTestNewFromFile(repliesFile, data->xmlopt, false))) goto cleanup; if (!(capsActual = virQEMUCapsNew()) || virQEMUCapsInitQMPMonitor(capsActual, qemuMonitorTestGetMonitor(mon)) < 0) goto cleanup; if (!(actual = virQEMUCapsFormatCache(capsActual, 0, 0))) goto cleanup; if (virTestCompareToFile(actual, capsFile) < 0) goto cleanup; ret = 0; cleanup: VIR_FREE(repliesFile); VIR_FREE(capsFile); VIR_FREE(actual); qemuMonitorTestFree(mon); virObjectUnref(capsActual); return ret; }