Ejemplo n.º 1
0
static int
test_virCapabilitiesFormat(const void *opaque)
{
    struct virCapabilitiesFormatData *data = (struct virCapabilitiesFormatData *) opaque;
    virCapsPtr caps = NULL;
    char *capsXML = NULL;
    char *path = NULL;
    int ret = -1;

    if (!(caps = buildVirCapabilities(data->max_cells, data->max_cpus_in_cell,
                                      data->max_mem_in_cell)))
        goto cleanup;

    if (!(capsXML = virCapabilitiesFormatXML(caps)))
        goto cleanup;

    if (virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s.xml",
                    abs_srcdir, data->filename) < 0)
        goto cleanup;

    if (virTestCompareToFile(capsXML, path) < 0)
        goto cleanup;

    ret = 0;

 cleanup:
    VIR_FREE(path);
    VIR_FREE(capsXML);
    virObjectUnref(caps);
    return ret;
}
Ejemplo n.º 2
0
static int
test_virCapabilitiesFormat(const void *opaque)
{
    struct virCapabilitiesFormatData *data = (struct virCapabilitiesFormatData *) opaque;
    virCapsPtr caps = NULL;
    char *capsXML = NULL;
    char *capsFromFile = NULL;
    char *path = NULL;
    int ret = -1;

    if (!(caps = buildVirCapabilities(data->max_cells, data->max_cpus_in_cell,
                                      data->max_mem_in_cell)))
        goto cleanup;

    if (!(capsXML = virCapabilitiesFormatXML(caps))) {
        fprintf(stderr, "Unable to format capabilities XML");
        goto cleanup;
    }

    if (virAsprintf(&path, "%s/vircaps2xmldata/vircaps-%s.xml",
                    abs_srcdir, data->filename) < 0)
        goto cleanup;

    if (virFileReadAll(path, 8192, &capsFromFile) < 0)
        goto cleanup;


    if (STRNEQ(capsXML, capsFromFile)) {
        virtTestDifference(stderr, capsFromFile, capsXML);
        goto cleanup;
    }

    ret = 0;

 cleanup:
    VIR_FREE(path);
    VIR_FREE(capsFromFile);
    VIR_FREE(capsXML);
    virObjectUnref(caps);
    return ret;
}