1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2023. Huawei Technologies Co., Ltd */
8 #include <test_progs.h>
10 #include "test_bpf_ma.skel.h"
12 void test_test_bpf_ma(void)
14 struct test_bpf_ma *skel;
18 skel = test_bpf_ma__open();
19 if (!ASSERT_OK_PTR(skel, "open"))
22 btf = bpf_object__btf(skel->obj);
23 if (!ASSERT_OK_PTR(btf, "btf"))
26 for (i = 0; i < ARRAY_SIZE(skel->rodata->data_sizes); i++) {
30 snprintf(name, sizeof(name), "bin_data_%u", skel->rodata->data_sizes[i]);
31 id = btf__find_by_name_kind(btf, name, BTF_KIND_STRUCT);
32 if (!ASSERT_GT(id, 0, "bin_data"))
34 skel->rodata->data_btf_ids[i] = id;
37 err = test_bpf_ma__load(skel);
38 if (!ASSERT_OK(err, "load"))
41 err = test_bpf_ma__attach(skel);
42 if (!ASSERT_OK(err, "attach"))
45 skel->bss->pid = getpid();
47 ASSERT_OK(skel->bss->err, "test error");
49 test_bpf_ma__destroy(skel);