mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
tests: glib-ify vircaps2xmltest
Ideally, turning pointers into g_auto* would be done in one step and dropping cleanup label and unused @ret variable in second step, but since this is a test we don't care that much, do we? Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
3dab81cb21
commit
5899bfd795
@ -38,12 +38,11 @@ test_virCapabilities(const void *opaque)
|
||||
{
|
||||
struct virCapabilitiesData *data = (struct virCapabilitiesData *) opaque;
|
||||
const char *archStr = virArchToString(data->arch);
|
||||
virCaps *caps = NULL;
|
||||
char *capsXML = NULL;
|
||||
char *path = NULL;
|
||||
char *system = NULL;
|
||||
char *resctrl = NULL;
|
||||
int ret = -1;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
g_autofree char *capsXML = NULL;
|
||||
g_autofree char *path = NULL;
|
||||
g_autofree char *system = NULL;
|
||||
g_autofree char *resctrl = NULL;
|
||||
|
||||
system = g_strdup_printf("%s/vircaps2xmldata/linux-%s/system", abs_srcdir,
|
||||
data->filename);
|
||||
@ -56,34 +55,26 @@ test_virCapabilities(const void *opaque)
|
||||
caps = virCapabilitiesNew(data->arch, data->offlineMigrate, data->liveMigrate);
|
||||
|
||||
if (!caps)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (!(caps->host.numa = virCapabilitiesHostNUMANewHost()))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virCapabilitiesInitCaches(caps) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
virFileWrapperClearPrefixes();
|
||||
|
||||
if (!(capsXML = virCapabilitiesFormatXML(caps)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
path = g_strdup_printf("%s/vircaps2xmldata/vircaps-%s-%s.xml", abs_srcdir,
|
||||
archStr, data->filename);
|
||||
|
||||
if (virTestCompareToFile(capsXML, path) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
VIR_FREE(system);
|
||||
VIR_FREE(resctrl);
|
||||
VIR_FREE(path);
|
||||
VIR_FREE(capsXML);
|
||||
virObjectUnref(caps);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user