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 '';
29})