Commit 3bc35c63 authored by Alexei Starovoitov's avatar Alexei Starovoitov Committed by Daniel Borkmann

selftests/bpf: add bpf_call test

strip always_inline from test_l4lb.c and compile it with -fno-inline
to let verifier go through 11 function with various function arguments
and return values
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 48cca7e4
...@@ -17,7 +17,8 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test ...@@ -17,7 +17,8 @@ TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test
TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o test_obj_id.o \ TEST_GEN_FILES = test_pkt_access.o test_xdp.o test_l4lb.o test_tcp_estats.o test_obj_id.o \
test_pkt_md_access.o test_xdp_redirect.o test_xdp_meta.o sockmap_parse_prog.o \ test_pkt_md_access.o test_xdp_redirect.o test_xdp_meta.o sockmap_parse_prog.o \
sockmap_verdict_prog.o dev_cgroup.o sample_ret0.o test_tracepoint.o sockmap_verdict_prog.o dev_cgroup.o sample_ret0.o test_tracepoint.o \
test_l4lb_noinline.o
TEST_PROGS := test_kmod.sh test_xdp_redirect.sh test_xdp_meta.sh \ TEST_PROGS := test_kmod.sh test_xdp_redirect.sh test_xdp_meta.sh \
test_offload.py test_offload.py
...@@ -49,8 +50,12 @@ else ...@@ -49,8 +50,12 @@ else
CPU ?= generic CPU ?= generic
endif endif
CLANG_FLAGS = -I. -I./include/uapi -I../../../include/uapi \
-Wno-compare-distinct-pointer-types
$(OUTPUT)/test_l4lb_noinline.o: CLANG_FLAGS += -fno-inline
%.o: %.c %.o: %.c
$(CLANG) -I. -I./include/uapi -I../../../include/uapi \ $(CLANG) $(CLANG_FLAGS) \
-Wno-compare-distinct-pointer-types \
-O2 -target bpf -emit-llvm -c $< -o - | \ -O2 -target bpf -emit-llvm -c $< -o - | \
$(LLC) -march=bpf -mcpu=$(CPU) -filetype=obj -o $@ $(LLC) -march=bpf -mcpu=$(CPU) -filetype=obj -o $@
This diff is collapsed.
...@@ -169,10 +169,9 @@ static void test_xdp(void) ...@@ -169,10 +169,9 @@ static void test_xdp(void)
#define NUM_ITER 100000 #define NUM_ITER 100000
#define VIP_NUM 5 #define VIP_NUM 5
static void test_l4lb(void) static void test_l4lb(const char *file)
{ {
unsigned int nr_cpus = bpf_num_possible_cpus(); unsigned int nr_cpus = bpf_num_possible_cpus();
const char *file = "./test_l4lb.o";
struct vip key = {.protocol = 6}; struct vip key = {.protocol = 6};
struct vip_meta { struct vip_meta {
__u32 flags; __u32 flags;
...@@ -249,6 +248,15 @@ static void test_l4lb(void) ...@@ -249,6 +248,15 @@ static void test_l4lb(void)
bpf_object__close(obj); bpf_object__close(obj);
} }
static void test_l4lb_all(void)
{
const char *file1 = "./test_l4lb.o";
const char *file2 = "./test_l4lb_noinline.o";
test_l4lb(file1);
test_l4lb(file2);
}
static void test_tcp_estats(void) static void test_tcp_estats(void)
{ {
const char *file = "./test_tcp_estats.o"; const char *file = "./test_tcp_estats.o";
...@@ -757,7 +765,7 @@ int main(void) ...@@ -757,7 +765,7 @@ int main(void)
test_pkt_access(); test_pkt_access();
test_xdp(); test_xdp();
test_l4lb(); test_l4lb_all();
test_tcp_estats(); test_tcp_estats();
test_bpf_obj_id(); test_bpf_obj_id();
test_pkt_md_access(); test_pkt_md_access();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment