From 144d9b0ab43279fc6d61f954fb4c38b7f6991fa2 Mon Sep 17 00:00:00 2001 From: varun-r-mallya Date: Thu, 20 Nov 2025 17:24:02 +0530 Subject: [PATCH] change c-file test structure --- tests/c-form/Makefile | 13 ++++++++----- tests/c-form/requests.bpf.c | 15 +++++++++++++++ .../vmlinux/requests2.py | 0 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 tests/c-form/requests.bpf.c rename tests/{failing_tests => passing_tests}/vmlinux/requests2.py (100%) diff --git a/tests/c-form/Makefile b/tests/c-form/Makefile index 64ff900..a34deba 100644 --- a/tests/c-form/Makefile +++ b/tests/c-form/Makefile @@ -1,19 +1,22 @@ BPF_CLANG := clang -CFLAGS := -O0 -emit-llvm -target bpf -c +CFLAGS := -emit-llvm -target bpf -c SRC := $(wildcard *.bpf.c) LL := $(SRC:.bpf.c=.bpf.ll) OBJ := $(SRC:.bpf.c=.bpf.o) - +LL0 := $(SRC:.bpf.c=.bpf.o0.ll) .PHONY: all clean -all: $(LL) $(OBJ) +all: $(LL) $(OBJ) $(LL0) %.bpf.o: %.bpf.c $(BPF_CLANG) -O2 -g -target bpf -c $< -o $@ %.bpf.ll: %.bpf.c - $(BPF_CLANG) $(CFLAGS) -g -S $< -o $@ + $(BPF_CLANG) $(CFLAGS) -O2 -g -S $< -o $@ + +%.bpf.o0.ll: %.bpf.c + $(BPF_CLANG) $(CFLAGS) -O0 -g -S $< -o $@ clean: - rm -f $(LL) $(OBJ) + rm -f $(LL) $(OBJ) $(LL0) diff --git a/tests/c-form/requests.bpf.c b/tests/c-form/requests.bpf.c new file mode 100644 index 0000000..0e14e98 --- /dev/null +++ b/tests/c-form/requests.bpf.c @@ -0,0 +1,15 @@ +#include "vmlinux.h" +#include +#include + +char LICENSE[] SEC("license") = "GPL"; + +SEC("kprobe/blk_mq_start_request") +int example(struct pt_regs *ctx) +{ + struct request *req = (struct request *)(ctx->di); + u32 data_len = req->__data_len; + bpf_printk("data length %u\n", data_len); + + return 0; +} diff --git a/tests/failing_tests/vmlinux/requests2.py b/tests/passing_tests/vmlinux/requests2.py similarity index 100% rename from tests/failing_tests/vmlinux/requests2.py rename to tests/passing_tests/vmlinux/requests2.py