Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
d-e-s-o committed Oct 8, 2024
1 parent f0b4c54 commit 431b040
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/blazesym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1400,5 +1400,5 @@ fn symbolize_bpf_program() {
};
let result = with_ringbuffer(&map, action);

assert_eq!(result, 1);
assert_eq!(result, 0);
}
13 changes: 11 additions & 2 deletions tests/bpf/src/getpid.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,27 @@ struct {
__uint(max_entries, 4096 /* one page */);
} ringbuf SEC(".maps");

u64 get_ip(void) {
u64 ip;
asm volatile(
"lea %0, [rip]"
: "=r"(ip)
);
return ip;
}

SEC("tracepoint/syscalls/sys_enter_getpid")
int handle__getpid(void *ctx)
{
u64 *value;

value = bpf_ringbuf_reserve(&ringbuf, sizeof(u64), 0);
value = bpf_ringbuf_reserve(&ringbuf, sizeof(*value), 0);
if (!value) {
bpf_printk("handle__getpid: failed to reserve ring buffer space");
return 1;
}

*value = 1;
*value = (u64)handle__getpid;
bpf_ringbuf_submit(value, 0);
bpf_printk("handle__getpid: submitted ringbuf value");
return 0;
Expand Down

0 comments on commit 431b040

Please sign in to comment.