diff options
author | Mike Rapoport <rppt@linux.vnet.ibm.com> | 2018-05-15 19:05:53 +0300 |
---|---|---|
committer | Shuah Khan (Samsung OSG) <shuah@kernel.org> | 2018-05-31 00:29:07 +0300 |
commit | 478b27844e9ee5660f4d4fa477e85514c51fc6d8 (patch) | |
tree | f7a4572220ee251de9487e1129c8d3a813b7cc04 /tools/testing/selftests/cgroup/cgroup_util.c | |
parent | 84092dbcf90176fcc258d74ad6ae8bb28d7df31a (diff) | |
download | linux-478b27844e9ee5660f4d4fa477e85514c51fc6d8.tar.xz |
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.c | 16 |
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; +} |