[PATCH 51/53] vircgrouptest: add hybrid tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 tests/vircgrouptest.c | 48 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
index fe0cb9585a..8fcee21bb2 100644
--- a/tests/vircgrouptest.c
+++ b/tests/vircgrouptest.c
@@ -604,6 +604,45 @@ static int testCgroupNewForSelfUnified(const void *args ATTRIBUTE_UNUSED)
 }
 
 
+static int testCgroupNewForSelfHybrid(const void *args ATTRIBUTE_UNUSED)
+{
+    virCgroupPtr cgroup = NULL;
+    int ret = -1;
+    const char *empty[VIR_CGROUP_CONTROLLER_LAST] = { 0 };
+    const char *mounts[VIR_CGROUP_CONTROLLER_LAST] = {
+        [VIR_CGROUP_CONTROLLER_CPUSET] = "/not/really/sys/fs/cgroup/cpuset",
+        [VIR_CGROUP_CONTROLLER_DEVICES] = "/not/really/sys/fs/cgroup/devices",
+        [VIR_CGROUP_CONTROLLER_FREEZER] = "/not/really/sys/fs/cgroup/freezer",
+        [VIR_CGROUP_CONTROLLER_NET_CLS] = "/not/really/sys/fs/cgroup/net_cls",
+        [VIR_CGROUP_CONTROLLER_PERF_EVENT] = "/not/really/sys/fs/cgroup/perf_event",
+    };
+    const char *placement[VIR_CGROUP_CONTROLLER_LAST] = {
+        [VIR_CGROUP_CONTROLLER_CPUSET] = "/",
+        [VIR_CGROUP_CONTROLLER_DEVICES] = "/",
+        [VIR_CGROUP_CONTROLLER_FREEZER] = "/",
+        [VIR_CGROUP_CONTROLLER_NET_CLS] = "/",
+        [VIR_CGROUP_CONTROLLER_PERF_EVENT] = "/",
+    };
+    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;
+    }
+
+    ret = validateCgroup(cgroup, "", mounts, empty, placement,
+                         "/not/really/sys/fs/cgroup/unified", "/", controllers);
+
+ cleanup:
+    virCgroupFree(&cgroup);
+    return ret;
+}
+
+
 static int testCgroupAvailable(const void *args)
 {
     bool got = virCgroupAvailable();
@@ -1023,6 +1062,15 @@ mymain(void)
         ret = -1;
     cleanupFakeFS(fakerootdir);
 
+    /* cgroup hybrid */
+
+    fakerootdir = initFakeFS("hybrid", "hybrid");
+    if (virTestRun("New cgroup for self (hybrid)", testCgroupNewForSelfHybrid, NULL) < 0)
+        ret = -1;
+    if (virTestRun("Cgroup available (hybrid)", testCgroupAvailable, (void*)0x1) < 0)
+        ret = -1;
+    cleanupFakeFS(fakerootdir);
+
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
-- 
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux