mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
vircgrouptest: add cgroup v2 tests
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
2a3df5fac5
commit
edf59855cf
@ -569,14 +569,35 @@ static int testCgroupNewForSelfAllInOne(const void *args ATTRIBUTE_UNUSED)
|
|||||||
static int testCgroupNewForSelfLogind(const void *args ATTRIBUTE_UNUSED)
|
static int testCgroupNewForSelfLogind(const void *args ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
virCgroupPtr cgroup = NULL;
|
virCgroupPtr cgroup = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (virCgroupNewSelf(&cgroup) == 0) {
|
if (virCgroupNewSelf(&cgroup) >= 0) {
|
||||||
fprintf(stderr, "Expected cgroup creation to fail.\n");
|
fprintf(stderr, "Expected to fail, only systemd cgroup available.\n");
|
||||||
|
virCgroupFree(&cgroup);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int testCgroupNewForSelfUnified(const void *args ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
virCgroupPtr cgroup = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
const char *empty[VIR_CGROUP_CONTROLLER_LAST] = { 0 };
|
||||||
|
unsigned int controllers =
|
||||||
|
(1 << VIR_CGROUP_CONTROLLER_CPU) |
|
||||||
|
(1 << VIR_CGROUP_CONTROLLER_CPUACCT) |
|
||||||
|
(1 << VIR_CGROUP_CONTROLLER_MEMORY) |
|
||||||
|
(1 << VIR_CGROUP_CONTROLLER_BLKIO);
|
||||||
|
|
||||||
|
if (virCgroupNewSelf(&cgroup) < 0) {
|
||||||
|
fprintf(stderr, "Cannot create cgroup for self\n");
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = validateCgroup(cgroup, "", empty, empty, empty,
|
||||||
|
"/not/really/sys/fs/cgroup", "/", controllers);
|
||||||
cleanup:
|
cleanup:
|
||||||
virCgroupFree(&cgroup);
|
virCgroupFree(&cgroup);
|
||||||
return ret;
|
return ret;
|
||||||
@ -993,7 +1014,14 @@ mymain(void)
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
cleanupFakeFS(fakerootdir);
|
cleanupFakeFS(fakerootdir);
|
||||||
|
|
||||||
|
/* cgroup unified */
|
||||||
|
|
||||||
|
fakerootdir = initFakeFS("unified", "unified");
|
||||||
|
if (virTestRun("New cgroup for self (unified)", testCgroupNewForSelfUnified, NULL) < 0)
|
||||||
|
ret = -1;
|
||||||
|
if (virTestRun("Cgroup available (unified)", testCgroupAvailable, (void*)0x1) < 0)
|
||||||
|
ret = -1;
|
||||||
|
cleanupFakeFS(fakerootdir);
|
||||||
|
|
||||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user