From 804df2c86f609fee35603273329f773e6eead7a8 Mon Sep 17 00:00:00 2001
Message-Id: <804df2c86f609fee35603273329f773e6eead7a8@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:07:59 +0200
Subject: [PATCH] vircgrouptest: add detect mounts test for hybrid cgroups
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 1981c79c4b068b918c3f34093ed2e634811b4147)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <8692433b683cef60139ee0b11052fd7f0de9ea41.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
tests/vircgroupdata/hybrid.cgroups | 12 ++++++++++++
tests/vircgroupdata/hybrid.mounts | 23 +++++++++++++++++++++++
tests/vircgroupdata/hybrid.parsed | 11 +++++++++++
tests/vircgroupdata/hybrid.self.cgroup | 9 +++++++++
tests/vircgrouptest.c | 3 +++
5 files changed, 58 insertions(+)
create mode 100644 tests/vircgroupdata/hybrid.cgroups
create mode 100644 tests/vircgroupdata/hybrid.mounts
create mode 100644 tests/vircgroupdata/hybrid.parsed
create mode 100644 tests/vircgroupdata/hybrid.self.cgroup
diff --git a/tests/vircgroupdata/hybrid.cgroups b/tests/vircgroupdata/hybrid.cgroups
new file mode 100644
index 0000000000..7f3bc7b8cb
--- /dev/null
+++ b/tests/vircgroupdata/hybrid.cgroups
@@ -0,0 +1,12 @@
+#subsys_name hierarchy num_cgroups enabled
+cpuset 2 1 1
+cpu 0 1 1
+cpuacct 0 1 1
+blkio 0 1 1
+memory 0 1 1
+devices 3 1 1
+freezer 5 1 1
+net_cls 4 1 1
+perf_event 6 1 1
+hugetlb 7 1 1
+pids 8 1 1
diff --git a/tests/vircgroupdata/hybrid.mounts b/tests/vircgroupdata/hybrid.mounts
new file mode 100644
index 0000000000..d6f5f82115
--- /dev/null
+++ b/tests/vircgroupdata/hybrid.mounts
@@ -0,0 +1,23 @@
+proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
+sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
+devtmpfs /dev devtmpfs rw,nosuid,size=10240k,nr_inodes=502705,mode=755 0 0
+devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
+tmpfs /dev/shm tmpfs rw,nosuid,nodev,noexec 0 0
+tmpfs /run tmpfs rw,nosuid,nodev,noexec,mode=755 0 0
+mqueue /dev/mqueue mqueue rw,nosuid,nodev,noexec,relatime 0 0
+securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
+debugfs /sys/kernel/debug debugfs rw,nosuid,nodev,noexec,relatime 0 0
+configfs /sys/kernel/config configfs rw,nosuid,nodev,noexec,relatime 0 0
+fusectl /sys/fs/fuse/connections fusectl rw,nosuid,nodev,noexec,relatime 0 0
+selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
+pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
+cgroup_root /not/really/sys/fs/cgroup tmpfs rw,nosuid,nodev,noexec,relatime,size=10240k,mode=755 0 0
+openrc /not/really/sys/fs/cgroup/openrc cgroup rw,nosuid,nodev,noexec,relatime,release_agent=/lib64/rc/sh/cgroup-release-agent.sh,name=openrc 0 0
+none /not/really/sys/fs/cgroup/unified cgroup2 rw,nosuid,nodev,noexec,relatime,nsdelegate 0 0
+cpuset /not/really/sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
+devices /not/really/sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
+net_cls /not/really/sys/fs/cgroup/net_cls cgroup rw,nosuid,nodev,noexec,relatime,net_cls 0 0
+freezer /not/really/sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
+perf_event /not/really/sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
+hugetlb /not/really/sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0
+pids /not/really/sys/fs/cgroup/pids cgroup rw,nosuid,nodev,noexec,relatime,pids 0 0
diff --git a/tests/vircgroupdata/hybrid.parsed b/tests/vircgroupdata/hybrid.parsed
new file mode 100644
index 0000000000..7600de5f45
--- /dev/null
+++ b/tests/vircgroupdata/hybrid.parsed
@@ -0,0 +1,11 @@
+cpu <null>
+cpuacct <null>
+cpuset /not/really/sys/fs/cgroup/cpuset
+memory <null>
+devices /not/really/sys/fs/cgroup/devices
+freezer /not/really/sys/fs/cgroup/freezer
+blkio <null>
+net_cls /not/really/sys/fs/cgroup/net_cls
+perf_event /not/really/sys/fs/cgroup/perf_event
+name=systemd <null>
+unified /not/really/sys/fs/cgroup/unified
diff --git a/tests/vircgroupdata/hybrid.self.cgroup b/tests/vircgroupdata/hybrid.self.cgroup
new file mode 100644
index 0000000000..2a08905c91
--- /dev/null
+++ b/tests/vircgroupdata/hybrid.self.cgroup
@@ -0,0 +1,9 @@
+8:pids:/
+7:hugetlb:/
+6:perf_event:/
+5:freezer:/
+4:net_cls:/
+3:devices:/
+2:cpuset:/
+1:name=openrc:/
+0::/
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
index 1ce1371ddc..aeb2840823 100644
--- a/tests/vircgrouptest.c
+++ b/tests/vircgrouptest.c
@@ -903,6 +903,9 @@ mymain(void)
fakerootdir = initFakeFS("unified", NULL);
DETECT_MOUNTS("unified");
cleanupFakeFS(fakerootdir);
+ fakerootdir = initFakeFS("hybrid", NULL);
+ DETECT_MOUNTS("hybrid");
+ cleanupFakeFS(fakerootdir);
fakerootdir = initFakeFS(NULL, "systemd");
if (virTestRun("New cgroup for self", testCgroupNewForSelf, NULL) < 0)
--
2.22.0