diff --git a/tests/failing_tests/vmlinux/Makefile b/tests/failing_tests/vmlinux/Makefile new file mode 100644 index 0000000..6be0827 --- /dev/null +++ b/tests/failing_tests/vmlinux/Makefile @@ -0,0 +1,19 @@ +BPF_CLANG := clang +CFLAGS := -O2 -emit-llvm -target bpf -c + +SRC := $(wildcard *.bpf.c) +LL := $(SRC:.bpf.c=.bpf.ll) +OBJ := $(SRC:.bpf.c=.bpf.o) + +.PHONY: all clean + +all: $(LL) $(OBJ) + +%.bpf.o: %.bpf.c + $(BPF_CLANG) -O2 -g -target bpf -c $< -o $@ + +%.bpf.ll: %.bpf.c + $(BPF_CLANG) $(CFLAGS) -g -S $< -o $@ + +clean: + rm -f $(LL) $(OBJ) diff --git a/tests/failing_tests/vmlinux/struct_field_access.py b/tests/failing_tests/vmlinux/struct_field_access.py new file mode 100644 index 0000000..b20dd24 --- /dev/null +++ b/tests/failing_tests/vmlinux/struct_field_access.py @@ -0,0 +1,28 @@ +import logging + +from pythonbpf import bpf, section, bpfglobal, compile_to_ir +from pythonbpf import compile # noqa: F401 +from vmlinux import TASK_COMM_LEN # noqa: F401 +from vmlinux import struct_trace_event_raw_sys_enter # noqa: F401 +from ctypes import c_uint64, c_int32, c_int64 +from pythonbpf.maps import HashMap + +# from vmlinux import struct_uinput_device +# from vmlinux import struct_blk_integrity_iter + +@bpf +@section("tracepoint/syscalls/sys_enter_execve") +def hello_world(ctx: struct_trace_event_raw_sys_enter) -> c_int64: + a = 2 + TASK_COMM_LEN + TASK_COMM_LEN + print(f"Hello, World{TASK_COMM_LEN} and {a}") + return c_int64(TASK_COMM_LEN + 2) + + +@bpf +@bpfglobal +def LICENSE() -> str: + return "GPL" + + +compile_to_ir("struct_field_access.py", "struct_field_access.ll", loglevel=logging.INFO) +# compile() diff --git a/tests/failing_tests/vmlinux/struct_field_tests.bpf.c b/tests/failing_tests/vmlinux/struct_field_tests.bpf.c new file mode 100644 index 0000000..96ceb23 --- /dev/null +++ b/tests/failing_tests/vmlinux/struct_field_tests.bpf.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include "vmlinux.h" +#include +#include + +SEC("tp/syscalls/sys_enter_execve") +int handle_setuid_entry(struct trace_event_raw_sys_enter *ctx) { + bpf_printk("args: %u", (unsigned int)ctx->args[0]); + return 0; +} + +char LICENSE[] SEC("license") = "GPL";