aboutsummaryrefslogtreecommitdiff
path: root/scripts/testing/tests/test_packages.py
blob: e0387d6bab3e98fc4bc230173122b653663c7d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# SPDX-License-Identifier: GPL-3.0-or-later
"""Post-install checks: package managers and key packages.

Parity port of validate_yay_installed, validate_pacman_working,
validate_terminus_font, validate_emacs, validate_git_config, validate_dev_tools.
"""

import pytest


DEV_TOOLS = ["python", "node", "npm", "go", "rustc"]


@pytest.mark.smoke
@pytest.mark.attribution("archsetup")
def test_yay_installed(host):
    assert host.exists("yay"), "yay binary not on PATH"


@pytest.mark.attribution("archsetup")
def test_yay_functional(host, target_user):
    # yay must actually query the package DB as the user, not just exist.
    assert host.run("sudo -u %s yay -Qi yay" % target_user).rc == 0


@pytest.mark.smoke
@pytest.mark.attribution("unknown")
def test_pacman_functional(host):
    assert host.package("base").is_installed


@pytest.mark.attribution("archsetup")
def test_terminus_font_installed(host):
    assert host.package("terminus-font").is_installed


@pytest.mark.attribution("archsetup")
def test_emacs_installed(host):
    assert host.exists("emacs")


@pytest.mark.attribution("archsetup")
def test_emacs_config_readable_by_user(host, target_user, home):
    emacsd = host.file("%s/.emacs.d" % home)
    if not emacsd.exists:
        pytest.skip(".emacs.d not present (config dir optional on some profiles)")
    assert emacsd.is_directory
    assert host.run("sudo -u %s ls %s" % (target_user, emacsd.path)).rc == 0


@pytest.mark.smoke
@pytest.mark.attribution("archsetup")
def test_git_installed(host):
    assert host.exists("git")


@pytest.mark.attribution("archsetup")
@pytest.mark.parametrize("tool", DEV_TOOLS)
def test_dev_tool_present(host, tool):
    assert host.exists(tool), "dev tool %s missing from PATH" % tool


BLUETOOTH_STACK = ["bluez", "bluez-utils"]
VPN_STACK = ["wireguard-tools", "proton-vpn-cli", "tailscale"]


@pytest.mark.attribution("archsetup")
@pytest.mark.parametrize("pkg", BLUETOOTH_STACK)
def test_bluetooth_stack_installed(host, pkg):
    assert host.package(pkg).is_installed


# bt panel replaced blueman; zoom-web replaced zoom; the net panel's Tunnels
# view + proton-vpn-cli replaced the GTK app (they can't run concurrently).
RETIRED_PACKAGES = ["blueman", "zoom", "proton-vpn-gtk-app"]


@pytest.mark.attribution("archsetup")
@pytest.mark.parametrize("pkg", RETIRED_PACKAGES)
def test_retired_package_not_installed(host, pkg):
    # A reappearance means an install step regressed.
    assert not host.package(pkg).is_installed


@pytest.mark.attribution("archsetup")
@pytest.mark.parametrize("pkg", VPN_STACK)
def test_vpn_stack_installed(host, pkg):
    assert host.package(pkg).is_installed


@pytest.mark.attribution("archsetup")
def test_tailscale_operator_granted(host, target_user):
    # The installer grants operator so the net panel can toggle tailscale
    # without sudo. Prefs only answer when the daemon is up.
    if not host.service("tailscaled").is_running:
        pytest.skip("tailscaled not running")
    out = host.run("tailscale debug prefs")
    assert out.rc == 0, "tailscale debug prefs failed"
    assert '"OperatorUser": "%s"' % target_user in out.stdout


@pytest.mark.attribution("archsetup")
def test_eask_installed_user_local(host, home):
    # Installed via npm -g --prefix ~/.local as the user; chime and
    # linear-emacs shell out to it.
    f = host.file("%s/.local/bin/eask" % home)
    assert f.exists, "eask missing from ~/.local/bin"
    npmrc = host.file("%s/.npmrc" % home)
    assert npmrc.exists, ".npmrc (user npm prefix) not stowed"