1import ./make-test-python.nix ({ pkgs, lib, ... }:
2
3with lib;
4
5{
6 name = "iftop";
7 meta.maintainers = with pkgs.lib.maintainers; [ ma27 ];
8
9 nodes = {
10 withIftop = {
11 imports = [ ./common/user-account.nix ];
12 programs.iftop.enable = true;
13 };
14 withoutIftop = {
15 imports = [ ./common/user-account.nix ];
16 environment.systemPackages = [ pkgs.iftop ];
17 };
18 };
19
20 testScript = ''
21 with subtest("machine with iftop enabled"):
22 withIftop.wait_for_unit("default.target")
23 # limit to eth1 (eth0 is the test driver's control interface)
24 # and don't try name lookups
25 withIftop.succeed("su -l alice -c 'iftop -t -s 1 -n -i eth1'")
26
27 with subtest("machine without iftop"):
28 withoutIftop.wait_for_unit("default.target")
29 # check that iftop is there but user alice lacks capabilitie
30 withoutIftop.succeed("iftop -t -s 1 -n -i eth1")
31 withoutIftop.fail("su -l alice -c 'iftop -t -s 1 -n -i eth1'")
32 '';
33})