Skip to content

Commit 627170b

Browse files
seehearfeelintel-lab-lkp
authored andcommitted
selftests/bpf: Copy insn_is_pseudo_func() into testing_helpers
insn_is_pseudo_func() will be used in test_verifier, the original idea is to move it from libbpf.c to libbpf_internal.h and then include the header to reuse this function, this just adds more internal code of libbpf used by selftests. While we have allowed it in some cases to avoid duplication of more complex logic, it is not justified in this case. Since insn_is_pseudo_func() and its helper is_ldimm64_insn() are trivial enough, just copy into testing_helpers. Suggested-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
1 parent 51bc7c7 commit 627170b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/testing/selftests/bpf/testing_helpers.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,14 @@ int get_xlated_program(int fd_prog, struct bpf_insn **buf, __u32 *cnt);
5454
int testing_prog_flags(void);
5555
bool is_jit_enabled(void);
5656

57+
static inline bool is_ldimm64_insn(struct bpf_insn *insn)
58+
{
59+
return insn->code == (BPF_LD | BPF_IMM | BPF_DW);
60+
}
61+
62+
static inline bool insn_is_pseudo_func(struct bpf_insn *insn)
63+
{
64+
return is_ldimm64_insn(insn) && insn->src_reg == BPF_PSEUDO_FUNC;
65+
}
66+
5767
#endif /* __TESTING_HELPERS_H */

0 commit comments

Comments
 (0)