bpftime can allow you override the execution of a function in userspace, and return a value you specify, or error injection in the system call.
It's useful for testing the error handling of your program.
server
LD_PRELOAD=~/.bpftime/libbpftime-syscall-server.so ./error_inject
client
LD_PRELOAD=~/.bpftime/libbpftime-agent.so ./victim