1import ./make-test-python.nix (
2 {
3 pkgs,
4 latestKernel ? false,
5 ...
6 }:
7
8 {
9 name = "systemd-analyze";
10 meta = with pkgs.lib.maintainers; {
11 maintainers = [ raskin ];
12 };
13
14 nodes.machine =
15 { pkgs, lib, ... }:
16 {
17 boot.kernelPackages = lib.mkIf latestKernel pkgs.linuxPackages_latest;
18 };
19
20 testScript = ''
21 machine.wait_for_unit("multi-user.target")
22
23 # We create a special output directory to copy it as a whole
24 with subtest("Prepare output dir"):
25 machine.succeed("mkdir systemd-analyze")
26
27
28 # Save the output into a file with given name inside the common
29 # output directory
30 def run_systemd_analyze(args, name):
31 tgt_dir = "systemd-analyze"
32 machine.succeed(
33 "systemd-analyze {} > {}/{} 2> {}/{}.err".format(
34 " ".join(args), tgt_dir, name, tgt_dir, name
35 )
36 )
37
38
39 with subtest("Print statistics"):
40 run_systemd_analyze(["blame"], "blame.txt")
41 run_systemd_analyze(["critical-chain"], "critical-chain.txt")
42 run_systemd_analyze(["dot"], "dependencies.dot")
43 run_systemd_analyze(["plot"], "systemd-analyze.svg")
44
45 # We copy the main graph into the $out (toplevel), and we also copy
46 # the entire output directory with additional data
47 with subtest("Copying the resulting data into $out"):
48 machine.copy_from_vm("systemd-analyze/", "")
49 machine.copy_from_vm("systemd-analyze/systemd-analyze.svg", "")
50 '';
51 }
52)