tests: add a few integration tests.

This commit is contained in:
Alexandre Pujol 2025-07-21 00:32:27 +02:00 committed by Alex
parent 0c2385fef9
commit d579b33011
16 changed files with 325 additions and 6 deletions

View file

@ -25,14 +25,26 @@ setup_file() {
sudo apt install -y pass
}
@test "apt: Remove a package (using 'purge' instead also removes its configuration files)" {
sudo apt remove -y pass
@test "apt: Remove a package and its configuration files" {
sudo apt purge -y pass
}
@test "apt: Upgrade all installed packages to their newest available versions" {
sudo apt upgrade -y
}
@test "apt: Upgrade installed packages, but remove obsolete packages and install additional packages to meet new dependencies" {
sudo apt dist-upgrade -y
}
@test "apt: Clean the local repository - removing package files (.deb) from interrupted downloads that can no longer be downloaded" {
sudo apt autoclean
}
@test "apt: Remove all packages that are no longer needed" {
sudo apt autoremove
}
@test "apt: List all packages" {
apt list
}
@ -41,6 +53,6 @@ setup_file() {
apt list --installed
}
@test "apt-moo: Print a cow easter egg" {
@test "apt: Print a cow easter egg" {
apt moo
}

View file

@ -0,0 +1,27 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "dpkg-query: List all installed packages" {
dpkg-query --list
}
@test "dpkg-query: List installed packages matching a pattern" {
dpkg-query --list 'libc6*'
}
@test "dpkg-query: List all files installed by a package" {
dpkg-query --listfiles libc6
}
@test "dpkg-query: Show information about a package" {
dpkg-query --status libc6
}
@test "dpkg-query: Search for packages that own files matching a pattern" {
dpkg-query --search /etc/ld.so.conf.d
}

View file

@ -0,0 +1,12 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "dpkg-reconfigure: Reconfigure one or more packages" {
sudo apt install -y pass
sudo dpkg-reconfigure pass
}

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "paccache: Perform a dry-run and show the number of candidate packages for deletion" {
sudo paccache -d
}
@test "paccache: Move candidate packages to a directory instead of deleting them" {
sudo paccache -m "$USER_BUILD_DIRS"
}
@test "paccache: Remove all but the 3 most recent package versions from the `pacman` cache" {
sudo paccache -r
}
@test "paccache: Set the number of package versions to keep" {
sudo paccache -rk 3
}

View file

@ -0,0 +1,34 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "pacman-key: Initialize the 'pacman' keyring" {
sudo pacman-key --init
}
@test "pacman-key: Add the default Arch Linux keys" {
sudo pacman-key --populate
}
@test "pacman-key: List keys from the public keyring" {
pacman-key --list-keys
}
@test "pacman-key: Receive a key from a key server" {
sudo pacman-key --recv-keys 06A26D531D56C42D66805049C5469996F0DF68EC
}
@test "pacman-key: Print the fingerprint of a specific key" {
pacman-key --finger 06A26D531D56C42D66805049C5469996F0DF68EC
}
@test "pacman-key: Sign an imported key locally" {
sudo pacman-key --lsign-key 06A26D531D56C42D66805049C5469996F0DF68EC
}
@test "pacman-key: Remove a specific key" {
sudo pacman-key --delete 06A26D531D56C42D66805049C5469996F0DF68EC
}

View file

@ -0,0 +1,34 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "pacman: Synchronize and update all packages" {
sudo pacman -Syu --noconfirm
}
@test "pacman: Install a new package" {
sudo pacman -S --noconfirm pass pass-otp
}
@test "pacman: Remove a package and its dependencies" {
sudo pacman -Rs --noconfirm pass-otp
}
@test "pacman: List installed packages and versions" {
pacman -Q
}
@test "pacman: List only the explicitly installed packages and versions" {
pacman -Qe
}
@test "pacman: List orphan packages (installed as dependencies but not actually required by any package)" {
pacman -Qtdq
}
@test "pacman: Empty the entire 'pacman' cache" {
sudo pacman -Scc --noconfirm
}

View file

@ -21,6 +21,6 @@ load ../common
sysctl fs.file-max
}
@test "sysctl: Apply changes from `/etc/sysctl.conf`" {
sysctl -p
@test "sysctl: Apply changes from '/etc/sysctl.conf'" {
sudo sysctl -p
}

View file

@ -0,0 +1,18 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "uptime: Print current time, uptime, number of logged-in users and other information" {
uptime
}
@test "uptime: Show only the amount of time the system has been booted for" {
uptime --pretty
}
@test "uptime: Print the date and time the system booted up at" {
uptime --since
}

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2025 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "bootctl: Show information about the system firmware and the bootloaders" {
sudo bootctl status
}
@test "bootctl: Show all available bootloader entries" {
sudo bootctl list
}
@test "bootctl: Install 'systemd-boot' into the EFI system partition" {
sudo bootctl install
}
@test "bootctl: Remove all installed versions of 'systemd-boot' from the EFI system partition" {
sudo bootctl remove
}

View file

@ -0,0 +1,27 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2025 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "busctl: Show all peers on the bus, by their service names" {
busctl list
}
@test "busctl: Show process information and credentials of a bus service, a process, or the owner of the bus (if no parameter is specified)" {
busctl status 1
busctl status org.freedesktop.DBus
}
@test "busctl: Show an object tree of one or more services (or all services if no service is specified)" {
busctl tree org.freedesktop.DBus
}
@test "busctl: Show interfaces, methods, properties and signals of the specified object on the specified service" {
busctl introspect org.freedesktop.login1 /org/freedesktop/login1
}
@test "busctl: Retrieve the current value of one or more object properties" {
busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager Docked
}

View file

@ -16,7 +16,7 @@ setup_file() {
}
@test "homectl: Create a user account and their associated home directory" {
sudo homectl create user2
printf "user2\nuser2" | sudo homectl create user2
}
@test "homectl: List user accounts and their associated home directories" {

View file

@ -0,0 +1,30 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2025 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "journalctl: Show all messages with priority level 3 (errors) from this boot" {
sudo journalctl -b --priority=3
}
@test "journalctl: Show only the last N lines of the journal" {
sudo journalctl --lines 100
}
@test "journalctl: Show all messages by a specific [u]nit" {
sudo journalctl --unit apparmor.service
}
@test "journalctl: Show all messages by a specific process" {
sudo journalctl _PID=1
}
@test "journalctl: Show all messages by a specific executable" {
sudo journalctl /usr/bin/bootctl
}
@test "journalctl: Delete journal logs which are older than 10 seconds" {
sudo journalctl --vacuum-time=10s
}

View file

@ -0,0 +1,23 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2025 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "localectl: Show the current settings of the system locale and keyboard mapping" {
localectl
}
@test "localectl: List available locales" {
localectl list-locales
}
@test "localectl: Set a system locale variable" {
sudo localectl set-locale LANG=en_US.UTF-8
}
@test "localectl: Set the system keyboard mapping for the console and X11" {
sudo localectl set-keymap uk
}

View file

@ -0,0 +1,26 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2025 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "importctl: Import an image as a machine" {
sudo importctl pull-tar --force --class=machine -N https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64-root.tar.xz noble
}
@test "machinectl: Display a list of available images" {
sudo machinectl list-images
}
@test "machinectl: Start a machine as a service using systemd-nspawn" {
sudo machinectl start noble
}
@test "machinectl: Display a list of running machines" {
sudo machinectl list
}
@test "machinectl: Stop a running machine" {
sudo machinectl stop noble
}

View file

@ -0,0 +1,18 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2025 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "networkctl: List existing links with their status" {
sudo networkctl list
}
@test "networkctl: Show an overall network status" {
sudo networkctl status
}
@test "networkctl: Reload configuration files (.netdev and .network)" {
sudo networkctl reload
}

View file

@ -0,0 +1,14 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "fstrim: Trim unused blocks on all mounted partitions that support it" {
sudo fstrim --all
}
@test "fstrim: Trim unused blocks on a specified partition" {
sudo fstrim --verbose /
}