at 23.11-pre 1.4 kB view raw
1import ./make-test-python.nix ({ pkgs, ... }: { 2 name = "bpf"; 3 meta.maintainers = with pkgs.lib.maintainers; [ martinetd ]; 4 5 nodes.machine = { pkgs, ... }: { 6 programs.bcc.enable = true; 7 environment.systemPackages = with pkgs; [ bpftrace ]; 8 }; 9 10 testScript = '' 11 ## bcc 12 # syscount -d 1 stops 1s after probe started so is good for that 13 print(machine.succeed("syscount -d 1")) 14 15 ## bpftrace 16 # list probes 17 machine.succeed("bpftrace -l") 18 # simple BEGIN probe (user probe on bpftrace itself) 19 print(machine.succeed("bpftrace -e 'BEGIN { print(\"ok\"); exit(); }'")) 20 # tracepoint 21 print(machine.succeed("bpftrace -e 'tracepoint:syscalls:sys_enter_* { print(probe); exit() }'")) 22 # kprobe 23 print(machine.succeed("bpftrace -e 'kprobe:schedule { print(probe); exit() }'")) 24 # BTF 25 print(machine.succeed("bpftrace -e 'kprobe:schedule { " 26 " printf(\"tgid: %d\", ((struct task_struct*) curtask)->tgid); exit() " 27 "}'")) 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() }'")) 35 ''; 36})