depot/nixos/tests/systemtap.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

50 lines
1.4 KiB
Nix

{ 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);
};
}