diff --git a/tests/integration/apt/apt.bats b/tests/integration/apt/apt.bats new file mode 100644 index 000000000..822a1279d --- /dev/null +++ b/tests/integration/apt/apt.bats @@ -0,0 +1,42 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load ../common + +@test "apt: Update the list of available packages and versions" { + sudo apt update +} + +@test "apt: Search for a given package" { + apt search apparmor +} + +@test "apt: Show information for a package" { + apt show apparmor +} + +@test "apt: Install a package, or update it to the latest available version" { + 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: Upgrade all installed packages to their newest available versions" { + sudo apt upgrade -y +} + +@test "apt: List all packages" { + apt list +} + +@test "apt: List installed packages" { + apt list --installed +} + +@test "apt-moo: Print a cow easter egg" { + apt moo +} diff --git a/tests/integration/apt/dpkg.bats b/tests/integration/apt/dpkg.bats new file mode 100644 index 000000000..6a0e735b4 --- /dev/null +++ b/tests/integration/apt/dpkg.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2025 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load ../common + +@test "dpkg: Remove a package" { + sudo apt install -y pass + sudo dpkg -r pass +} + +@test "dpkg: List installed packages" { + dpkg -l apparmor +} + +@test "dpkg: List a package's contents" { + dpkg -L apparmor.d +} + +@test "dpkg: Find out which package owns a file" { + dpkg -S /etc/apparmor/parser.conf +} + +@test "dpkg: Purge an installed or already removed package, including configuration" { + sudo dpkg -P pass +} diff --git a/tests/integration/flatpak.bats b/tests/integration/flatpak.bats index e549e01ad..e2a70c242 100644 --- a/tests/integration/flatpak.bats +++ b/tests/integration/flatpak.bats @@ -5,12 +5,25 @@ load common -@test "flatpak: List installed applications, ignoring runtimes" { - flatpak list --app +@test "flatpak: Add a new remote repository (by URL)" { + sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +} + +@test "flatpak: List all remote repositories" { + flatpak remotes +} + +@test "flatpak: Search for an application in a remote repository" { + sudo flatpak search vim + sudo flatpak search org.freedesktop.Platform } @test "flatpak: Install an application from a remote source" { - flatpak install --noninteractive org.vim.Vim + sudo flatpak install --noninteractive org.vim.Vim +} + +@test "flatpak: List installed applications, ignoring runtimes" { + flatpak list --app } @test "flatpak: Show information about an installed application" { @@ -18,17 +31,17 @@ load common } @test "flatpak: Run an installed application" { - flatpak run org.vim.Vim + _timeout flatpak run org.vim.Vim } @test "flatpak: Update all installed applications and runtimes" { - flatpak update --noninteractive + sudo flatpak update --noninteractive } @test "flatpak: Remove an installed application" { - flatpak remove --noninteractive org.vim.Vim + sudo flatpak remove --noninteractive org.vim.Vim } @test "flatpak: Remove all unused applications" { - flatpak remove --unused + sudo flatpak remove --noninteractive --unused } diff --git a/tests/integration/hostname.bats b/tests/integration/hostname.bats new file mode 100644 index 000000000..35008bd79 --- /dev/null +++ b/tests/integration/hostname.bats @@ -0,0 +1,29 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +@test "hostname: Show current host name" { + hostname +} + +@test "hostname: Show the network address of the host name" { + hostname -i +} + +@test "hostname: Show all network addresses of the host" { + hostname -I +} + +@test "hostname: Show the FQDN (Fully Qualified Domain Name)" { + hostname --fqdn +} + +@test "hostname: Set current host name" { + name=$(hostname) + sudo hostname "new-$(hostname)" + sudo hostname "$name" +} + diff --git a/tests/integration/tlp.bats b/tests/integration/tlp.bats new file mode 100644 index 000000000..b9a9530fc --- /dev/null +++ b/tests/integration/tlp.bats @@ -0,0 +1,22 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load common + +@test "tlp: Apply settings (according to the actual power source)" { + sudo tlp start +} + +@test "tlp: Apply battery settings (ignoring the actual power source)" { + sudo tlp bat +} + +@test "tlp: Apply AC settings (ignoring the actual power source)" { + sudo tlp ac +} + +@test "tlp: Apply Disk settings" { + sudo tlp diskid +} diff --git a/tests/integration/utils/df.bats b/tests/integration/utils/df.bats index b0f3430ea..c15a32d5f 100644 --- a/tests/integration/utils/df.bats +++ b/tests/integration/utils/df.bats @@ -14,7 +14,7 @@ load ../common } @test "df: Display the filesystem and its disk usage containing the given file or directory" { - df apparmor.d/ + df /etc/apparmor.d/ } @test "df: Include statistics on the number of free inodes" { diff --git a/tests/integration/utils/eject.bats b/tests/integration/utils/eject.bats new file mode 100644 index 000000000..c4c2a3e0d --- /dev/null +++ b/tests/integration/utils/eject.bats @@ -0,0 +1,14 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load ../common + +@test "eject: Display the default device" { + eject -d || true +} + +@test "eject: Eject the default device" { + eject || true +} diff --git a/tests/integration/utils/hwclock.bats b/tests/integration/utils/hwclock.bats new file mode 100644 index 000000000..88c981c31 --- /dev/null +++ b/tests/integration/utils/hwclock.bats @@ -0,0 +1,19 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load ../common + +@test "hwclock: Display the current time as reported by the hardware clock" { + hwclock +} + +@test "hwclock: Write the current software clock time to the hardware clock (sometimes used during system setup)" { + hwclock --systohc +} + +@test "hwclock: Write the current hardware clock time to the software clock" { + hwclock --hctosys +} + diff --git a/tests/integration/utils/zramctl.bats b/tests/integration/utils/zramctl.bats new file mode 100644 index 000000000..ab1197de6 --- /dev/null +++ b/tests/integration/utils/zramctl.bats @@ -0,0 +1,18 @@ +#!/usr/bin/env bats +# apparmor.d - Full set of apparmor profiles +# Copyright (C) 2024 Alexandre Pujol +# SPDX-License-Identifier: GPL-2.0-only + +load ../common + +@test "zramctl: Check if zram is enabled; enable it if needed" { + lsmod | grep -i zram || sudo modprobe zram +} + +@test "zramctl: Find and initialize the next free zram device to a 1 GB virtual drive using LZ4 compression" { + sudo zramctl --find --size 1GB --algorithm lz4 +} + +@test "zramctl: List currently initialized devices" { + sudo zramctl +}