diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index a0aa4d4f6a0a..eed43d7a080e 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -861,6 +861,7 @@ in { systemd-misc = handleTest ./systemd-misc.nix {}; systemd-userdbd = handleTest ./systemd-userdbd.nix {}; systemd-homed = handleTest ./systemd-homed.nix {}; + systemtap = handleTest ./systemtap.nix {}; tandoor-recipes = handleTest ./tandoor-recipes.nix {}; tang = handleTest ./tang.nix {}; taskserver = handleTest ./taskserver.nix {}; diff --git a/nixos/tests/systemtap.nix b/nixos/tests/systemtap.nix new file mode 100644 index 000000000000..5cd79d66e872 --- /dev/null +++ b/nixos/tests/systemtap.nix @@ -0,0 +1,50 @@ +{ system ? builtins.currentSystem +, config ? { } +, pkgs ? import ../.. { inherit system config; } +}@args: + +with pkgs.lib; + +let + stapScript = pkgs.writeText "test.stp" '' + probe kernel.function("do_sys_poll") { + println("kernel function probe & println work") + exit() + } + ''; + + ## TODO shared infra with ../kernel-generic.nix + testsForLinuxPackages = linuxPackages: (import ./make-test-python.nix ({ pkgs, ... }: { + name = "kernel-${linuxPackages.kernel.version}"; + meta = with pkgs.lib.maintainers; { + maintainers = [ bendlas ]; + }; + + nodes.machine = { ... }: + { + boot.kernelPackages = linuxPackages; + programs.systemtap.enable = true; + }; + + testScript = + '' + with subtest("Capture stap ouput"): + output = machine.succeed("stap ${stapScript} 2>&1") + + with subtest("Ensure that expected output from stap script is there"): + assert "kernel function probe & println work\n" == output, "kernel function probe & println work\n != " + output + ''; + }) args); + + ## TODO shared infra with ../kernel-generic.nix + kernels = { + inherit (pkgs.linuxKernel.packageAliases) linux_default linux_latest; + }; + +in mapAttrs (_: lP: testsForLinuxPackages lP) kernels // { + passthru = { + inherit testsForLinuxPackages; + + testsForKernel = kernel: testsForLinuxPackages (pkgs.linuxPackagesFor kernel); + }; +} diff --git a/pkgs/development/tools/profiling/systemtap/default.nix b/pkgs/development/tools/profiling/systemtap/default.nix index 11f5b5d49aad..25bdd45e03b8 100644 --- a/pkgs/development/tools/profiling/systemtap/default.nix +++ b/pkgs/development/tools/profiling/systemtap/default.nix @@ -6,8 +6,8 @@ let ## fetchgit info url = "git://sourceware.org/git/systemtap.git"; rev = "release-${version}"; - sha256 = "sha256-UiUMoqdfkk6mzaPGctpQW3dvOWKhNBNuScJ5BpCykVg="; - version = "4.8"; + sha256 = "sha256-2L7+k/tgI6trkstDTY4xxfFzmNDlxbCHDRKAFaERQeM="; + version = "5.0a"; inherit (kernel) stdenv; @@ -22,6 +22,14 @@ let env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=deprecated-declarations" ]; # Needed with GCC 12 }; + ## symlink farm for --sysroot flag + sysroot = runCommand "systemtap-sysroot-${kernel.version}" { } '' + mkdir -p $out/boot $out/usr/lib/debug + ln -s ${kernel.dev}/vmlinux ${kernel.dev}/lib $out + ln -s ${kernel.dev}/vmlinux $out/usr/lib/debug + ln -s ${kernel}/System.map $out/boot/System.map-${kernel.version} + ''; + pypkgs = with python3.pkgs; makePythonPath [ pyparsing ]; in runCommand "systemtap-${kernel.version}-${version}" { @@ -40,7 +48,7 @@ in runCommand "systemtap-${kernel.version}-${version}" { done rm $out/bin/stap $out/bin/dtrace makeWrapper $stapBuild/bin/stap $out/bin/stap \ - --add-flags "-r ${kernel.dev}" \ + --add-flags "--sysroot ${sysroot}" \ --prefix PATH : ${lib.makeBinPath [ stdenv.cc.cc stdenv.cc.bintools elfutils gnumake ]} makeWrapper $stapBuild/bin/dtrace $out/bin/dtrace \ --prefix PYTHONPATH : ${pypkgs}