4 #include "virfilewrapper.h"
5 #define LIBVIRT_VIRRESCTRLPRIV_H_ALLOW
6 #include "virresctrlpriv.h"
9 #define VIR_FROM_THIS VIR_FROM_NONE
11 struct virResctrlData
{
18 test_virResctrlGetUnused(const void *opaque
)
20 struct virResctrlData
*data
= (struct virResctrlData
*) opaque
;
21 char *system_dir
= NULL
;
22 char *resctrl_dir
= NULL
;
24 virResctrlAllocPtr alloc
= NULL
;
25 char *schemata_str
= NULL
;
27 virCapsPtr caps
= NULL
;
29 if (virAsprintf(&system_dir
, "%s/vircaps2xmldata/linux-%s/system",
30 abs_srcdir
, data
->filename
) < 0)
33 if (virAsprintf(&resctrl_dir
, "%s/vircaps2xmldata/linux-%s/resctrl",
34 abs_srcdir
, data
->filename
) < 0)
37 if (virAsprintf(&schemata_file
, "%s/virresctrldata/%s.schemata",
38 abs_srcdir
, data
->filename
) < 0)
41 virFileWrapperAddPrefix("/sys/devices/system", system_dir
);
42 virFileWrapperAddPrefix("/sys/fs/resctrl", resctrl_dir
);
44 caps
= virCapabilitiesNew(VIR_ARCH_X86_64
, false, false);
45 if (!caps
|| virCapabilitiesInitCaches(caps
) < 0) {
46 fprintf(stderr
, "Could not initialize capabilities");
50 alloc
= virResctrlAllocGetUnused(caps
->host
.resctrl
);
52 virFileWrapperClearPrefixes();
58 } else if (data
->fail
) {
59 VIR_TEST_DEBUG("Error expected but there wasn't any.\n");
64 schemata_str
= virResctrlAllocFormat(alloc
);
66 if (virTestCompareToFile(schemata_str
, schemata_file
) < 0)
72 virObjectUnref(alloc
);
74 VIR_FREE(resctrl_dir
);
75 VIR_FREE(schemata_str
);
76 VIR_FREE(schemata_file
);
84 struct virResctrlData data
= {0};
87 #define DO_TEST_UNUSED(_filename) \
89 data = (struct virResctrlData) { .filename = _filename }; \
90 if (virTestRun("Free: " _filename, test_virResctrlGetUnused, &data) < 0) \
94 DO_TEST_UNUSED("resctrl");
95 DO_TEST_UNUSED("resctrl-cdp");
96 DO_TEST_UNUSED("resctrl-skx");
97 DO_TEST_UNUSED("resctrl-skx-twocaches");
102 VIR_TEST_MAIN(mymain
)