1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */
4 #include <test_progs.h>
5 #include "cpumask_failure.skel.h"
6 #include "cpumask_success.skel.h"
8 static const char * const cpumask_success_testcases[] = {
9 "test_alloc_free_cpumask",
11 "test_setall_clear_cpu",
12 "test_first_firstzero_cpu",
13 "test_firstand_nocpu",
14 "test_test_and_set_clear",
16 "test_intersects_subset",
17 "test_copy_any_anyand",
19 "test_insert_remove_release",
20 "test_global_mask_rcu",
21 "test_global_mask_array_one_rcu",
22 "test_global_mask_array_rcu",
23 "test_global_mask_array_l2_rcu",
24 "test_global_mask_nested_rcu",
25 "test_global_mask_nested_deep_rcu",
26 "test_global_mask_nested_deep_array_rcu",
27 "test_cpumask_weight",
30 static void verify_success(const char *prog_name)
32 struct cpumask_success *skel;
33 struct bpf_program *prog;
34 struct bpf_link *link = NULL;
38 skel = cpumask_success__open();
39 if (!ASSERT_OK_PTR(skel, "cpumask_success__open"))
42 skel->bss->pid = getpid();
43 skel->bss->nr_cpus = libbpf_num_possible_cpus();
45 err = cpumask_success__load(skel);
46 if (!ASSERT_OK(err, "cpumask_success__load"))
49 prog = bpf_object__find_program_by_name(skel->obj, prog_name);
50 if (!ASSERT_OK_PTR(prog, "bpf_object__find_program_by_name"))
53 link = bpf_program__attach(prog);
54 if (!ASSERT_OK_PTR(link, "bpf_program__attach"))
58 if (!ASSERT_GT(child_pid, -1, "child_pid"))
62 waitpid(child_pid, &status, 0);
63 ASSERT_OK(skel->bss->err, "post_wait_err");
66 bpf_link__destroy(link);
67 cpumask_success__destroy(skel);
70 void test_cpumask(void)
74 for (i = 0; i < ARRAY_SIZE(cpumask_success_testcases); i++) {
75 if (!test__start_subtest(cpumask_success_testcases[i]))
78 verify_success(cpumask_success_testcases[i]);
81 RUN_TESTS(cpumask_success);
82 RUN_TESTS(cpumask_failure);