1 import ./make-test-python.nix ({ pkgs, ... }: {
3 meta.maintainers = with pkgs.lib.maintainers; [ martinetd ];
5 nodes.machine = { pkgs, ... }: {
6 programs.bcc.enable = true;
7 environment.systemPackages = with pkgs; [ bpftrace ];
12 # syscount -d 1 stops 1s after probe started so is good for that
13 print(machine.succeed("syscount -d 1"))
17 machine.succeed("bpftrace -l")
18 # simple BEGIN probe (user probe on bpftrace itself)
19 print(machine.succeed("bpftrace -e 'BEGIN { print(\"ok\\n\"); exit(); }'"))
21 print(machine.succeed("bpftrace -e 'tracepoint:syscalls:sys_enter_* { print(probe); exit() }'"))
23 print(machine.succeed("bpftrace -e 'kprobe:schedule { print(probe); exit() }'"))
25 print(machine.succeed("bpftrace -e 'kprobe:schedule { "
26 " printf(\"tgid: %d\\n\", ((struct task_struct*) curtask)->tgid); exit() "
28 # module BTF (bpftrace >= 0.17)
29 # test is currently disabled on aarch64 as kfunc does not work there yet
30 # https://github.com/iovisor/bpftrace/issues/2496
31 print(machine.succeed("uname -m | grep aarch64 || "
32 "bpftrace -e 'kfunc:nft_trans_alloc_gfp { "
33 " printf(\"portid: %d\\n\", args->ctx->portid); "
34 "} BEGIN { exit() }'"))
36 print(machine.succeed("bpftrace -e '#include <errno.h>\n"
37 "BEGIN { printf(\"ok %d\\n\", EINVAL); exit(); }'"))