aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/cgroup/cgroup_util.c
diff options
context:
space:
mode:
authorMike Rapoport <rppt@linux.vnet.ibm.com>2018-05-15 19:05:53 +0300
committerShuah Khan (Samsung OSG) <shuah@kernel.org>2018-05-30 15:29:07 -0600
commit478b27844e9ee5660f4d4fa477e85514c51fc6d8 (patch)
treef7a4572220ee251de9487e1129c8d3a813b7cc04 /tools/testing/selftests/cgroup/cgroup_util.c
parentselftests: cgroup: add memory controller self-tests (diff)
downloadlinux-dev-478b27844e9ee5660f4d4fa477e85514c51fc6d8.tar.xz
linux-dev-478b27844e9ee5660f4d4fa477e85514c51fc6d8.zip
selftests: cgroup/memcontrol: add basic test for swap controls
The new test verifies that memory.swap.max and memory.swap.current behave as expected for simple allocation scenarios Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Acked-by: Tejun Heo <tj@kernel.org> Acked-by: Roman Gushchin <guro@fb.com> Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Diffstat (limited to 'tools/testing/selftests/cgroup/cgroup_util.c')
-rw-r--r--tools/testing/selftests/cgroup/cgroup_util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c
index a938b6c8b55a..41cc3b5e5be1 100644
--- a/tools/testing/selftests/cgroup/cgroup_util.c
+++ b/tools/testing/selftests/cgroup/cgroup_util.c
@@ -315,3 +315,19 @@ int alloc_anon(const char *cgroup, void *arg)
free(buf);
return 0;
}
+
+int is_swap_enabled(void)
+{
+ char buf[PAGE_SIZE];
+ const char delim[] = "\n";
+ int cnt = 0;
+ char *line;
+
+ if (read_text("/proc/swaps", buf, sizeof(buf)) <= 0)
+ return -1;
+
+ for (line = strtok(buf, delim); line; line = strtok(NULL, delim))
+ cnt++;
+
+ return cnt > 1;
+}