3
0
Fork 0
forked from mirrors/nixpkgs

nixos/tests: add bpf test

test bcc and bpftrace briefly
This commit is contained in:
Dominique Martinet 2021-12-04 10:20:26 +09:00
parent 2318433b73
commit 559fe43665
4 changed files with 36 additions and 1 deletions

View file

@ -44,6 +44,7 @@ in
boot-stage1 = handleTest ./boot-stage1.nix {};
borgbackup = handleTest ./borgbackup.nix {};
botamusique = handleTest ./botamusique.nix {};
bpf = handleTestOn ["x86_64-linux" "aarch64-linux"] ./bpf.nix {};
btrbk = handleTest ./btrbk.nix {};
buildbot = handleTest ./buildbot.nix {};
buildkite-agents = handleTest ./buildkite-agents.nix {};

25
nixos/tests/bpf.nix Normal file
View file

@ -0,0 +1,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() }'"))
'';
})

View file

@ -1,7 +1,7 @@
{ lib, stdenv, fetchFromGitHub
, makeWrapper, cmake, llvmPackages
, flex, bison, elfutils, python, luajit, netperf, iperf, libelf
, bash, libbpf
, bash, libbpf, nixosTests
}:
python.pkgs.buildPythonApplication rec {
@ -69,6 +69,10 @@ python.pkgs.buildPythonApplication rec {
wrapPythonProgramsIn "$out/share/bcc/tools" "$out $pythonPath"
'';
passthru.tests = {
bpf = nixosTests.bpf;
};
meta = with lib; {
description = "Dynamic Tracing Tools for Linux";
homepage = "https://iovisor.github.io/bcc/";

View file

@ -3,6 +3,7 @@
, llvmPackages, elfutils
, libelf, libbfd, libbpf, libopcodes, bcc
, cereal, asciidoctor
, nixosTests
}:
stdenv.mkDerivation rec {
@ -43,6 +44,10 @@ stdenv.mkDerivation rec {
outputs = [ "out" "man" ];
passthru.tests = {
bpf = nixosTests.bpf;
};
meta = with lib; {
description = "High-level tracing language for Linux eBPF";
homepage = "https://github.com/iovisor/bpftrace";