|
4 | 4 | #include <test_progs.h>
|
5 | 5 | #include <bpf/libbpf.h>
|
6 | 6 | #include <bpf/btf.h>
|
| 7 | +#include "iters_css_task.skel.h" |
7 | 8 | #include "cgroup_iter.skel.h"
|
8 | 9 | #include "cgroup_helpers.h"
|
9 | 10 |
|
@@ -263,6 +264,35 @@ static void test_walk_dead_self_only(struct cgroup_iter *skel)
|
263 | 264 | close(cgrp_fd);
|
264 | 265 | }
|
265 | 266 |
|
| 267 | +static void test_walk_self_only_css_task(void) |
| 268 | +{ |
| 269 | + struct iters_css_task *skel; |
| 270 | + int err; |
| 271 | + |
| 272 | + skel = iters_css_task__open(); |
| 273 | + if (!ASSERT_OK_PTR(skel, "skel_open")) |
| 274 | + return; |
| 275 | + |
| 276 | + bpf_program__set_autoload(skel->progs.cgroup_id_printer, true); |
| 277 | + |
| 278 | + err = iters_css_task__load(skel); |
| 279 | + if (!ASSERT_OK(err, "skel_load")) |
| 280 | + goto cleanup; |
| 281 | + |
| 282 | + err = join_cgroup(cg_path[CHILD2]); |
| 283 | + if (!ASSERT_OK(err, "join_cgroup")) |
| 284 | + goto cleanup; |
| 285 | + |
| 286 | + skel->bss->target_pid = getpid(); |
| 287 | + snprintf(expected_output, sizeof(expected_output), |
| 288 | + PROLOGUE "%8llu\n" EPILOGUE, cg_id[CHILD2]); |
| 289 | + read_from_cgroup_iter(skel->progs.cgroup_id_printer, cg_fd[CHILD2], |
| 290 | + BPF_CGROUP_ITER_SELF_ONLY, "test_walk_self_only_css_task"); |
| 291 | + ASSERT_EQ(skel->bss->css_task_cnt, 1, "css_task_cnt"); |
| 292 | +cleanup: |
| 293 | + iters_css_task__destroy(skel); |
| 294 | +} |
| 295 | + |
266 | 296 | void test_cgroup_iter(void)
|
267 | 297 | {
|
268 | 298 | struct cgroup_iter *skel = NULL;
|
@@ -293,6 +323,9 @@ void test_cgroup_iter(void)
|
293 | 323 | test_walk_self_only(skel);
|
294 | 324 | if (test__start_subtest("cgroup_iter__dead_self_only"))
|
295 | 325 | test_walk_dead_self_only(skel);
|
| 326 | + if (test__start_subtest("cgroup_iter__self_only_css_task")) |
| 327 | + test_walk_self_only_css_task(); |
| 328 | + |
296 | 329 | out:
|
297 | 330 | cgroup_iter__destroy(skel);
|
298 | 331 | cleanup_cgroups();
|
|
0 commit comments