mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 20:14:06 +02:00
selftests: cgroup_util: Add helpers for testing named v1 hierarchies
Non-functional change, the control variable will be wired in a separate commit. Signed-off-by: Michal Koutný <mkoutny@suse.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
38b9342ee6
commit
0925275a17
|
|
@ -19,6 +19,8 @@
|
|||
#include "cgroup_util.h"
|
||||
#include "../../clone3/clone3_selftests.h"
|
||||
|
||||
bool cg_test_v1_named;
|
||||
|
||||
/* Returns read len on success, or -errno on failure. */
|
||||
ssize_t read_text(const char *path, char *buf, size_t max_len)
|
||||
{
|
||||
|
|
@ -361,7 +363,7 @@ int cg_enter_current(const char *cgroup)
|
|||
|
||||
int cg_enter_current_thread(const char *cgroup)
|
||||
{
|
||||
return cg_write(cgroup, "cgroup.threads", "0");
|
||||
return cg_write(cgroup, CG_THREADS_FILE, "0");
|
||||
}
|
||||
|
||||
int cg_run(const char *cgroup,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@
|
|||
|
||||
#define TEST_UID 65534 /* usually nobody, any !root is fine */
|
||||
|
||||
#define CG_THREADS_FILE (!cg_test_v1_named ? "cgroup.threads" : "tasks")
|
||||
#define CG_NAMED_NAME "selftest"
|
||||
#define CG_PATH_FORMAT (!cg_test_v1_named ? "0::%s" : (":name=" CG_NAMED_NAME ":%s"))
|
||||
|
||||
/*
|
||||
* Checks if two given values differ by less than err% of their sum.
|
||||
*/
|
||||
|
|
@ -65,3 +69,4 @@ extern int dirfd_open_opath(const char *dir);
|
|||
extern int cg_prepare_for_wait(const char *cgroup);
|
||||
extern int memcg_prepare_for_wait(const char *cgroup);
|
||||
extern int cg_wait_for(int fd);
|
||||
extern bool cg_test_v1_named;
|
||||
|
|
|
|||
|
|
@ -573,7 +573,7 @@ static int test_cgcore_proc_migration(const char *root)
|
|||
}
|
||||
|
||||
cg_enter_current(dst);
|
||||
if (cg_read_lc(dst, "cgroup.threads") != n_threads + 1)
|
||||
if (cg_read_lc(dst, CG_THREADS_FILE) != n_threads + 1)
|
||||
goto cleanup;
|
||||
|
||||
ret = KSFT_PASS;
|
||||
|
|
@ -605,7 +605,7 @@ static void *migrating_thread_fn(void *arg)
|
|||
char lines[3][PATH_MAX];
|
||||
|
||||
for (g = 1; g < 3; ++g)
|
||||
snprintf(lines[g], sizeof(lines[g]), "0::%s", grps[g] + strlen(grps[0]));
|
||||
snprintf(lines[g], sizeof(lines[g]), CG_PATH_FORMAT, grps[g] + strlen(grps[0]));
|
||||
|
||||
for (i = 0; i < n_iterations; ++i) {
|
||||
cg_enter_current_thread(grps[(i % 2) + 1]);
|
||||
|
|
@ -659,7 +659,7 @@ static int test_cgcore_thread_migration(const char *root)
|
|||
if (retval)
|
||||
goto cleanup;
|
||||
|
||||
snprintf(line, sizeof(line), "0::%s", grps[1] + strlen(grps[0]));
|
||||
snprintf(line, sizeof(line), CG_PATH_FORMAT, grps[1] + strlen(grps[0]));
|
||||
if (proc_read_strstr(0, 1, "cgroup", line))
|
||||
goto cleanup;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user