summary refs log tree commit diff
path: root/nixos/tests/bpf.nix
blob: 233c7dab1ee22fff601f2f08154213b1140a3cf4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import ./make-test-python.nix ({ pkgs, ... }: {
  name = "bpf";
  meta.maintainers = with pkgs.lib.maintainers; [ martinetd ];

  machine = { pkgs, ... }: {
    programs.bcc.enable = true;
    environment.systemPackages = with pkgs; [ bpftrace ];
  };

  testScript = ''
    ## bcc
    # syscount -d 1 stops 1s after probe started so is good for that
    print(machine.succeed("syscount -d 1"))

    ## bpftrace
    # list probes
    machine.succeed("bpftrace -l")
    # simple BEGIN probe (user probe on bpftrace itself)
    print(machine.succeed("bpftrace -e 'BEGIN { print(\"ok\"); exit(); }'"))
    # tracepoint
    print(machine.succeed("bpftrace -e 'tracepoint:syscalls:sys_enter_* { print(probe); exit(); }'"))
    # kprobe
    print(machine.succeed("bpftrace -e 'kprobe:schedule { print(probe); exit() }'"))
  '';
})