c480ed
From ab8447f6e6a5ab8e3d278be61bc9ccc93c435d3b Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <ab8447f6e6a5ab8e3d278be61bc9ccc93c435d3b@dist-git>
c480ed
From: Pavel Hrdina <phrdina@redhat.com>
c480ed
Date: Mon, 1 Jul 2019 17:07:58 +0200
c480ed
Subject: [PATCH] vircgrouptest: add detect mounts test for cgroup v2
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 8f43c7a698b7a360d508eccc82ffc08e930cc3f8)
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: <10b25253a0f4705093b96cfe56a0c64bb2114785.1561993100.git.phrdina@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 tests/vircgroupdata/unified.cgroups     | 13 +++++++++++++
c480ed
 tests/vircgroupdata/unified.mounts      | 20 ++++++++++++++++++++
c480ed
 tests/vircgroupdata/unified.parsed      | 11 +++++++++++
c480ed
 tests/vircgroupdata/unified.self.cgroup |  1 +
c480ed
 tests/vircgrouptest.c                   |  3 +++
c480ed
 5 files changed, 48 insertions(+)
c480ed
 create mode 100644 tests/vircgroupdata/unified.cgroups
c480ed
 create mode 100644 tests/vircgroupdata/unified.mounts
c480ed
 create mode 100644 tests/vircgroupdata/unified.parsed
c480ed
 create mode 100644 tests/vircgroupdata/unified.self.cgroup
c480ed
c480ed
diff --git a/tests/vircgroupdata/unified.cgroups b/tests/vircgroupdata/unified.cgroups
c480ed
new file mode 100644
c480ed
index 0000000000..e0d8a3561c
c480ed
--- /dev/null
c480ed
+++ b/tests/vircgroupdata/unified.cgroups
c480ed
@@ -0,0 +1,13 @@
c480ed
+#subsys_name	hierarchy	num_cgroups	enabled
c480ed
+cpuset      0       1       1
c480ed
+cpu         0       1       1
c480ed
+cpuacct     0       1       1
c480ed
+blkio       0       1       1
c480ed
+memory      0       1       1
c480ed
+devices     0       1       1
c480ed
+freezer     0       1       1
c480ed
+net_cls     0       1       1
c480ed
+perf_event  0       1       1
c480ed
+net_prio    0       1       1
c480ed
+hugetlb     0       1       1
c480ed
+pids        0       1       1
c480ed
diff --git a/tests/vircgroupdata/unified.mounts b/tests/vircgroupdata/unified.mounts
c480ed
new file mode 100644
c480ed
index 0000000000..b4ab94a2c3
c480ed
--- /dev/null
c480ed
+++ b/tests/vircgroupdata/unified.mounts
c480ed
@@ -0,0 +1,20 @@
c480ed
+sysfs /sys sysfs rw,seclabel,nosuid,nodev,noexec,relatime 0 0
c480ed
+proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
c480ed
+devtmpfs /dev devtmpfs rw,seclabel,nosuid,size=1009844k,nr_inodes=252461,mode=755 0 0
c480ed
+securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
c480ed
+tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev 0 0
c480ed
+devpts /dev/pts devpts rw,seclabel,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
c480ed
+tmpfs /run tmpfs rw,seclabel,nosuid,nodev,mode=755 0 0
c480ed
+cgroup2 /not/really/sys/fs/cgroup cgroup2 rw,seclabel,nosuid,nodev,noexec,relatime,nsdelegate 0 0
c480ed
+pstore /sys/fs/pstore pstore rw,seclabel,nosuid,nodev,noexec,relatime 0 0
c480ed
+bpf /sys/fs/bpf bpf rw,nosuid,nodev,noexec,relatime,mode=700 0 0
c480ed
+configfs /sys/kernel/config configfs rw,relatime 0 0
c480ed
+/dev/vda2 / ext4 rw,seclabel,relatime 0 0
c480ed
+selinuxfs /sys/fs/selinux selinuxfs rw,relatime 0 0
c480ed
+debugfs /sys/kernel/debug debugfs rw,seclabel,relatime 0 0
c480ed
+hugetlbfs /dev/hugepages hugetlbfs rw,seclabel,relatime,pagesize=2M 0 0
c480ed
+systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=40,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=14586 0 0
c480ed
+mqueue /dev/mqueue mqueue rw,seclabel,relatime 0 0
c480ed
+tmpfs /tmp tmpfs rw,seclabel,nosuid,nodev 0 0
c480ed
+sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
c480ed
+tmpfs /run/user/0 tmpfs rw,seclabel,nosuid,nodev,relatime,size=204000k,mode=700 0 0
c480ed
diff --git a/tests/vircgroupdata/unified.parsed b/tests/vircgroupdata/unified.parsed
c480ed
new file mode 100644
c480ed
index 0000000000..3de0fc643d
c480ed
--- /dev/null
c480ed
+++ b/tests/vircgroupdata/unified.parsed
c480ed
@@ -0,0 +1,11 @@
c480ed
+cpu          <null>
c480ed
+cpuacct      <null>
c480ed
+cpuset       <null>
c480ed
+memory       <null>
c480ed
+devices      <null>
c480ed
+freezer      <null>
c480ed
+blkio        <null>
c480ed
+net_cls      <null>
c480ed
+perf_event   <null>
c480ed
+name=systemd <null>
c480ed
+unified      /not/really/sys/fs/cgroup
c480ed
diff --git a/tests/vircgroupdata/unified.self.cgroup b/tests/vircgroupdata/unified.self.cgroup
c480ed
new file mode 100644
c480ed
index 0000000000..1e027b2a3c
c480ed
--- /dev/null
c480ed
+++ b/tests/vircgroupdata/unified.self.cgroup
c480ed
@@ -0,0 +1 @@
c480ed
+0::/
c480ed
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
c480ed
index b66682e6c8..1ce1371ddc 100644
c480ed
--- a/tests/vircgrouptest.c
c480ed
+++ b/tests/vircgrouptest.c
c480ed
@@ -900,6 +900,9 @@ mymain(void)
c480ed
     DETECT_MOUNTS("all-in-one");
c480ed
     DETECT_MOUNTS_FAIL("no-cgroups");
c480ed
     DETECT_MOUNTS("kubevirt");
c480ed
+    fakerootdir = initFakeFS("unified", NULL);
c480ed
+    DETECT_MOUNTS("unified");
c480ed
+    cleanupFakeFS(fakerootdir);
c480ed
 
c480ed
     fakerootdir = initFakeFS(NULL, "systemd");
c480ed
     if (virTestRun("New cgroup for self", testCgroupNewForSelf, NULL) < 0)
c480ed
-- 
c480ed
2.22.0
c480ed