forked from mirrors/nixpkgs
nixos/tests: add bpf test
test bcc and bpftrace briefly
This commit is contained in:
parent
2318433b73
commit
559fe43665
|
@ -44,6 +44,7 @@ in
|
||||||
boot-stage1 = handleTest ./boot-stage1.nix {};
|
boot-stage1 = handleTest ./boot-stage1.nix {};
|
||||||
borgbackup = handleTest ./borgbackup.nix {};
|
borgbackup = handleTest ./borgbackup.nix {};
|
||||||
botamusique = handleTest ./botamusique.nix {};
|
botamusique = handleTest ./botamusique.nix {};
|
||||||
|
bpf = handleTestOn ["x86_64-linux" "aarch64-linux"] ./bpf.nix {};
|
||||||
btrbk = handleTest ./btrbk.nix {};
|
btrbk = handleTest ./btrbk.nix {};
|
||||||
buildbot = handleTest ./buildbot.nix {};
|
buildbot = handleTest ./buildbot.nix {};
|
||||||
buildkite-agents = handleTest ./buildkite-agents.nix {};
|
buildkite-agents = handleTest ./buildkite-agents.nix {};
|
||||||
|
|
25
nixos/tests/bpf.nix
Normal file
25
nixos/tests/bpf.nix
Normal 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() }'"))
|
||||||
|
'';
|
||||||
|
})
|
|
@ -1,7 +1,7 @@
|
||||||
{ lib, stdenv, fetchFromGitHub
|
{ lib, stdenv, fetchFromGitHub
|
||||||
, makeWrapper, cmake, llvmPackages
|
, makeWrapper, cmake, llvmPackages
|
||||||
, flex, bison, elfutils, python, luajit, netperf, iperf, libelf
|
, flex, bison, elfutils, python, luajit, netperf, iperf, libelf
|
||||||
, bash, libbpf
|
, bash, libbpf, nixosTests
|
||||||
}:
|
}:
|
||||||
|
|
||||||
python.pkgs.buildPythonApplication rec {
|
python.pkgs.buildPythonApplication rec {
|
||||||
|
@ -69,6 +69,10 @@ python.pkgs.buildPythonApplication rec {
|
||||||
wrapPythonProgramsIn "$out/share/bcc/tools" "$out $pythonPath"
|
wrapPythonProgramsIn "$out/share/bcc/tools" "$out $pythonPath"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
passthru.tests = {
|
||||||
|
bpf = nixosTests.bpf;
|
||||||
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Dynamic Tracing Tools for Linux";
|
description = "Dynamic Tracing Tools for Linux";
|
||||||
homepage = "https://iovisor.github.io/bcc/";
|
homepage = "https://iovisor.github.io/bcc/";
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
, llvmPackages, elfutils
|
, llvmPackages, elfutils
|
||||||
, libelf, libbfd, libbpf, libopcodes, bcc
|
, libelf, libbfd, libbpf, libopcodes, bcc
|
||||||
, cereal, asciidoctor
|
, cereal, asciidoctor
|
||||||
|
, nixosTests
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
|
@ -43,6 +44,10 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
outputs = [ "out" "man" ];
|
outputs = [ "out" "man" ];
|
||||||
|
|
||||||
|
passthru.tests = {
|
||||||
|
bpf = nixosTests.bpf;
|
||||||
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "High-level tracing language for Linux eBPF";
|
description = "High-level tracing language for Linux eBPF";
|
||||||
homepage = "https://github.com/iovisor/bpftrace";
|
homepage = "https://github.com/iovisor/bpftrace";
|
||||||
|
|
Loading…
Reference in a new issue