render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c480ed
From 0628a57a5b4a28d644970a2ad82cfadc14a3cd9f Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <0628a57a5b4a28d644970a2ad82cfadc14a3cd9f@dist-git>
c480ed
From: Pavel Hrdina <phrdina@redhat.com>
c480ed
Date: Mon, 1 Jul 2019 17:08:02 +0200
c480ed
Subject: [PATCH] vircgrouptest: add hybrid tests
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
(cherry picked from commit a26de856f98119bf651ed9928c64b6f96f78f185)
c480ed
c480ed
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
c480ed
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
Message-Id: <434692bd0df2a6f28c93e3cc071187144820d836.1561993100.git.phrdina@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 tests/vircgrouptest.c | 48 +++++++++++++++++++++++++++++++++++++++++++
c480ed
 1 file changed, 48 insertions(+)
c480ed
c480ed
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
c480ed
index 3b844f0fbf..7fde50b463 100644
c480ed
--- a/tests/vircgrouptest.c
c480ed
+++ b/tests/vircgrouptest.c
c480ed
@@ -605,6 +605,45 @@ static int testCgroupNewForSelfUnified(const void *args ATTRIBUTE_UNUSED)
c480ed
 }
c480ed
 
c480ed
 
c480ed
+static int testCgroupNewForSelfHybrid(const void *args ATTRIBUTE_UNUSED)
c480ed
+{
c480ed
+    virCgroupPtr cgroup = NULL;
c480ed
+    int ret = -1;
c480ed
+    const char *empty[VIR_CGROUP_CONTROLLER_LAST] = { 0 };
c480ed
+    const char *mounts[VIR_CGROUP_CONTROLLER_LAST] = {
c480ed
+        [VIR_CGROUP_CONTROLLER_CPUSET] = "/not/really/sys/fs/cgroup/cpuset",
c480ed
+        [VIR_CGROUP_CONTROLLER_DEVICES] = "/not/really/sys/fs/cgroup/devices",
c480ed
+        [VIR_CGROUP_CONTROLLER_FREEZER] = "/not/really/sys/fs/cgroup/freezer",
c480ed
+        [VIR_CGROUP_CONTROLLER_NET_CLS] = "/not/really/sys/fs/cgroup/net_cls",
c480ed
+        [VIR_CGROUP_CONTROLLER_PERF_EVENT] = "/not/really/sys/fs/cgroup/perf_event",
c480ed
+    };
c480ed
+    const char *placement[VIR_CGROUP_CONTROLLER_LAST] = {
c480ed
+        [VIR_CGROUP_CONTROLLER_CPUSET] = "/",
c480ed
+        [VIR_CGROUP_CONTROLLER_DEVICES] = "/",
c480ed
+        [VIR_CGROUP_CONTROLLER_FREEZER] = "/",
c480ed
+        [VIR_CGROUP_CONTROLLER_NET_CLS] = "/",
c480ed
+        [VIR_CGROUP_CONTROLLER_PERF_EVENT] = "/",
c480ed
+    };
c480ed
+    unsigned int controllers =
c480ed
+        (1 << VIR_CGROUP_CONTROLLER_CPU) |
c480ed
+        (1 << VIR_CGROUP_CONTROLLER_CPUACCT) |
c480ed
+        (1 << VIR_CGROUP_CONTROLLER_MEMORY) |
c480ed
+        (1 << VIR_CGROUP_CONTROLLER_BLKIO);
c480ed
+
c480ed
+    if (virCgroupNewSelf(&cgroup) < 0) {
c480ed
+        fprintf(stderr, "Cannot create cgroup for self\n");
c480ed
+        goto cleanup;
c480ed
+    }
c480ed
+
c480ed
+    ret = validateCgroup(cgroup, "", mounts, empty, placement,
c480ed
+                         "/not/really/sys/fs/cgroup/unified", "/", controllers);
c480ed
+
c480ed
+ cleanup:
c480ed
+    virCgroupFree(&cgroup);
c480ed
+    return ret;
c480ed
+}
c480ed
+
c480ed
+
c480ed
 static int testCgroupAvailable(const void *args)
c480ed
 {
c480ed
     bool got = virCgroupAvailable();
c480ed
@@ -1024,6 +1063,15 @@ mymain(void)
c480ed
         ret = -1;
c480ed
     cleanupFakeFS(fakerootdir);
c480ed
 
c480ed
+    /* cgroup hybrid */
c480ed
+
c480ed
+    fakerootdir = initFakeFS("hybrid", "hybrid");
c480ed
+    if (virTestRun("New cgroup for self (hybrid)", testCgroupNewForSelfHybrid, NULL) < 0)
c480ed
+        ret = -1;
c480ed
+    if (virTestRun("Cgroup available (hybrid)", testCgroupAvailable, (void*)0x1) < 0)
c480ed
+        ret = -1;
c480ed
+    cleanupFakeFS(fakerootdir);
c480ed
+
c480ed
     return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
c480ed
 }
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed