tests: cleanup the basic structure of integration tests.

This commit is contained in:
Alexandre Pujol 2024-11-19 21:27:04 +00:00
parent 206bc3473d
commit 5c70c50c26
Failed to generate hash of commit
45 changed files with 49 additions and 501 deletions

View file

@ -10,26 +10,18 @@ setup_file() {
skip
}
# bats test_tags=aa-enforce
@test "aa-enforce: Disable profile" {
sudo aa-disable pass
aa_check
}
# bats test_tags=aa-enforce
@test "aa-enforce: Enforce a profile" {
sudo aa-enforce pass
aa_check
}
# bats test_tags=aa-enforce
@test "aa-enforce: Complain a profile" {
sudo aa-complain pass
aa_check
}
# bats test_tags=aa-enforce
@test "aa-enforce: Audit a profile" {
sudo aa-audit pass
aa_check
}

View file

@ -5,36 +5,22 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=aa-status
@test "aa-status: Check status" {
sudo aa-status
aa_check
}
# bats test_tags=aa-status
@test "aa-status: Display the number of loaded policies" {
sudo aa-status --profiled
aa_check
}
# bats test_tags=aa-status
@test "aa-status: Display the number of loaded enforicing policies" {
sudo aa-status --enforced
aa_check
}
# bats test_tags=aa-status
@test "aa-status: Display the number of loaded non-enforcing policies" {
sudo aa-status --complaining
aa_check
}
# bats test_tags=aa-status
@test "aa-status: Display the number of loaded enforcing policies that kill tasks" {
sudo aa-status --kill
aa_check
}

View file

@ -5,18 +5,10 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=blkid
@test "blkid: List all partitions" {
sudo blkid
aa_check
}
# bats test_tags=blkid
@test "blkid: List all partitions in a table, including current mountpoints" {
sudo blkid -o list
aa_check
}

View file

@ -5,24 +5,15 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=chsh
@test "chsh: [l]ist available shells" {
chsh --list-shells || true
aa_check
}
# bats test_tags=chsh
@test "chsh: Set a specific login [s]hell for the current user" {
echo "$PASSWORD" | chsh --shell /usr/bin/bash
aa_check
}
# bats test_tags=chsh
@test "chsh: Set a login [s]hell for a specific user" {
sudo chsh --shell /usr/bin/sh root
aa_check
}

View file

@ -105,8 +105,18 @@ aa_check() {
now=$(date +%s)
duration=$((now - _START + 1))
logs=$(aa-log --raw --systemd --since "-${duration}s")
aa_start
if [[ -n "$logs" ]]; then
fail "profile $PROGRAM raised logs: $logs"
fi
aa_start
}
# Bats setup and teardown hooks
setup_file() {
aa_setup
}
teardown() {
aa_check
}

View file

@ -5,24 +5,14 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=cpuid
@test "cpuid: Display information for all CPUs" {
cpuid
aa_check
}
# bats test_tags=cpuid
@test "cpuid: Display information only for the current CPU" {
cpuid -1
aa_check
}
# bats test_tags=cpuid
@test "cpuid: Display raw hex information with no decoding" {
cpuid -r
aa_check
}

View file

@ -5,36 +5,22 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=df
@test "df: Display all filesystems and their disk usage" {
df
aa_check
}
# bats test_tags=df
@test "df: Display all filesystems and their disk usage in human-readable form" {
df -h
aa_check
}
# bats test_tags=df
@test "df: Display the filesystem and its disk usage containing the given file or directory" {
df apparmor.d/
aa_check
}
# bats test_tags=df
@test "df: Include statistics on the number of free inodes" {
df --inodes
aa_check
}
# bats test_tags=df
@test "df: Display filesystem types" {
df --print-type
aa_check
}

View file

@ -5,30 +5,18 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=dfc
@test "dfc: Display filesystems and their disk usage in human-readable form with colors and graphs" {
dfc
aa_check
}
# bats test_tags=dfc
@test "dfc: Display all filesystems including pseudo, duplicate and inaccessible filesystems" {
dfc -a
aa_check
}
# bats test_tags=dfc
@test "dfc: Display filesystems without color" {
dfc -c never
aa_check
}
# bats test_tags=dfc
@test "dfc: Display filesystems containing "ext" in the filesystem type" {
dfc -t ext
aa_check
}

View file

@ -5,25 +5,14 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=fc-cache
@test "fc-cache: Generate font cache files" {
fc-cache
aa_check
}
# bats test_tags=fc-cache
@test "fc-cache: Force a rebuild of all font cache files, without checking if cache is up-to-date" {
fc-cache -f
aa_check
}
# bats test_tags=fc-cache
@test "fc-cache: Erase font cache files, then generate new font cache files" {
fc-cache -r
aa_check
}

View file

@ -5,12 +5,6 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=fc-list
@test "fc-list: Return a list of installed fonts in your system" {
fc-list
aa_check
}

View file

@ -5,48 +5,30 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=flatpak
@test "flatpak: List installed applications, ignoring runtimes" {
flatpak list --app
aa_check
}
# bats test_tags=flatpak
@test "flatpak: Install an application from a remote source" {
flatpak install --noninteractive org.vim.Vim
aa_check
}
# bats test_tags=flatpak
@test "flatpak: Show information about an installed application" {
flatpak info org.vim.Vim
aa_check
}
# bats test_tags=flatpak
@test "flatpak: Run an installed application" {
flatpak run org.vim.Vim
aa_check
}
# bats test_tags=flatpak
@test "flatpak: Update all installed applications and runtimes" {
flatpak update --noninteractive
aa_check
}
# bats test_tags=flatpak
@test "flatpak: Remove an installed application" {
flatpak remove --noninteractive org.vim.Vim
aa_check
}
# bats test_tags=flatpak
@test "flatpak: Remove all unused applications" {
flatpak remove --unused
aa_check
}

View file

@ -5,44 +5,30 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=gpgconf
@test "gpgconf: List all components" {
gpgconf --list-components
aa_check
}
# bats test_tags=gpgconf
@test "gpgconf: List the directories used by gpgconf" {
gpgconf --list-dirs
aa_check
}
# bats test_tags=gpgconf
@test "gpgconf: List all options of a component" {
gpgconf --list-options gpg
gpgconf --list-options gpgsm
gpgconf --list-options gpg-agent
gpgconf --list-options scdaemon || true
gpgconf --list-options dirmngr
aa_check
}
# bats test_tags=gpgconf
@test "gpgconf: List programs and test whether they are runnable" {
gpgconf --check-programs || true
aa_check
}
# bats test_tags=gpgconf
@test "gpgconf: Reload a component" {
gpgconf --reload gpg
gpgconf --reload gpgsm
gpgconf --reload gpg-agent
gpgconf --reload scdaemon || true
gpgconf --reload dirmngr
aa_check
}

View file

@ -5,32 +5,20 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=groupadd
@test "groupadd: Create a new group" {
sudo groupadd user2
aa_check
}
# bats test_tags=groupadd
@test "groupadd: Create a new system group" {
sudo groupadd --system system2
aa_check
}
# bats test_tags=groupadd
@test "groupadd: Create a new group with the specific groupid" {
sudo groupadd --gid 3000 user3
aa_check
}
# bats test_tags=groupadd
@test "groupdel: Delete newly created group" {
sudo groupdel user2
sudo groupdel system2
sudo groupdel user3
aa_check
}

View file

@ -5,19 +5,11 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=groups
@test "groups: Print group memberships for the current user" {
groups
aa_check
}
# bats test_tags=groups
@test "groups: Print group memberships for a list of users" {
groups root
aa_check
}

View file

@ -10,50 +10,34 @@ setup_file() {
skip
}
# bats test_tags=homectl
@test "homectl: Display help" {
homectl --no-pager --help
aa_check
}
# bats test_tags=homectl
@test "homectl: Create a user account and their associated home directory" {
sudo homectl create user2
aa_check
}
# bats test_tags=homectl
@test "homectl: List user accounts and their associated home directories" {
homectl list
aa_check
}
# bats test_tags=homectl
@test "homectl: Change the password for a specific user" {
sudo homectl passwd user2
aa_check
}
# bats test_tags=homectl
@test "homectl: Run a shell or a command with access to a specific home directory" {
sudo homectl with user2 -- ls -al /home/user2
aa_check
}
# bats test_tags=homectl
@test "homectl: Lock or unlock a specific home directory" {
sudo homectl lock user2
aa_check
}
# bats test_tags=homectl
@test "homectl: Change the disk space assigned to a specific home directory to 100 GiB" {
sudo homectl resize user2 1G
aa_check
}
# bats test_tags=homectl
@test "homectl: Remove a specific user and the associated home directory" {
sudo homectl remove user2
aa_check
}

View file

@ -5,21 +5,14 @@
load common
setup() {
aa_setup
}
# bats test_tags=hostnamectl
@test "hostnamectl: Get the hostname of the computer" {
hostnamectl
}
# bats test_tags=hostnamectl
@test "hostnamectl: Get the location of the computer" {
hostnamectl location
}
# bats test_tags=hostnamectl
@test "hostnamectl: Set the hostname of the computer" {
name=$(hostnamectl hostname)
sudo hostnamectl set-hostname "new"

View file

@ -5,41 +5,26 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=id
@test "id: Display current user's ID (UID), group ID (GID) and groups to which they belong" {
id
aa_check
}
# bats test_tags=id
@test "id: Display the current user identity" {
id -un
aa_check
}
# bats test_tags=id
@test "id: Display the current user identity as a number" {
id -u
aa_check
}
# bats test_tags=id
@test "id: Display the current primary group identity" {
id -gn
aa_check
}
# bats test_tags=id
@test "id: Display the current primary group identity as a number" {
id -g
aa_check
}
# bats test_tags=id
@test "id: Display an arbitrary user ID (UID), group ID (GID) and groups to which they belong" {
id root
}

View file

@ -5,41 +5,42 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=ip
@test "ip: List interfaces with detailed info" {
@test "ip-address: List network interfaces and their associated IP addresses" {
ip address
aa_check
}
# bats test_tags=ip
@test "ip: List interfaces with brief link layer info" {
ip link
aa_check
@test "ip-address: Filter to show only active network interfaces" {
ip address show up
}
# bats test_tags=ip
@test "ip: Display the routing table" {
@test "ip-route: Display the routing table" {
ip route
aa_check
}
# bats test_tags=ip
@test "ip: Show neighbors (ARP table)" {
@test "ip-route-get: Print route to a destination" {
ip route get 1.1.1.1
}
@test "ip link: Show information about all network interfaces" {
ip link
}
@test "ip neighbour: Display the neighbour/ARP table entries" {
ip neighbour
aa_check
}
# bats test_tags=ip
@test "ip rule: Display the routing policy" {
ip rule show
ip rule list
}
@test "ip rule: Flush all deleted rules" {
ip rule flush
}
@test "ip: Manage network namespace" {
sudo ip netns add foo
sudo ip netns list
sudo ip netns exec foo bash -c "pwd"
sudo ip netns delete foo
aa_check
}

View file

@ -5,54 +5,34 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=lsblk
@test "lsblk: List all storage devices in a tree-like format" {
lsblk
aa_check
}
# bats test_tags=lsblk
@test "lsblk: Also list empty devices" {
lsblk -a
aa_check
}
# bats test_tags=lsblk
@test "lsblk: Print the SIZE column in bytes rather than in a human-readable format" {
lsblk -b
aa_check
}
# bats test_tags=lsblk
@test "lsblk: Output info about filesystems" {
lsblk -f
aa_check
}
# bats test_tags=lsblk
@test "lsblk: Use ASCII characters for tree formatting" {
lsblk -i
aa_check
}
# bats test_tags=lsblk
@test "lsblk: Output info about block-device topology" {
lsblk -t
aa_check
}
# bats test_tags=lsblk
@test "lsblk: Exclude the devices specified by the comma-separated list of major device numbers" {
lsblk -e 1
aa_check
}
# bats test_tags=lsblk
@test "lsblk: Display a customized summary using a comma-separated list of columns" {
lsblk --output NAME,SERIAL,MODEL,TRAN,TYPE,SIZE,FSTYPE,MOUNTPOINT
aa_check
}

View file

@ -5,24 +5,14 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=lscpu
@test "lscpu: Display information about all CPUs" {
lscpu
aa_check
}
# bats test_tags=lscpu
@test "lscpu: Display information in a table" {
lscpu --extended
aa_check
}
# bats test_tags=lscpu
@test "lscpu: Display only information about offline CPUs in a table" {
lscpu --extended --offline
aa_check
}

View file

@ -5,36 +5,22 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=lspci
@test "lspci: Show a brief list of devices" {
lspci
aa_check
}
# bats test_tags=lspci
@test "lspci: Display additional info" {
lspci -v
aa_check
}
# bats test_tags=lspci
@test "lspci: Display drivers and modules handling each device" {
lspci -k
aa_check
}
# bats test_tags=lspci
@test "lspci: Show a specific device" {
lspci -s 00:00.0
aa_check
}
# bats test_tags=lspci
@test "lspci: Dump info in a readable form" {
lspci -vm
aa_check
}

View file

@ -5,24 +5,14 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=lsusb
@test "lsusb: List all the USB devices available" {
lsusb || true
aa_check
}
# bats test_tags=lsusb
@test "lsusb: List the USB hierarchy as a tree" {
lsusb -t || true
aa_check
}
# bats test_tags=lsusb
@test "lsusb: List verbose information about USB devices" {
lsusb --verbose || true
aa_check
}

View file

@ -5,42 +5,26 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=ps
@test "ps: List all running processes" {
ps aux
aa_check
}
# bats test_tags=ps
@test "ps: List all running processes including the full command string" {
ps auxww
aa_check
}
# bats test_tags=ps
@test "ps: List all processes of the current user in extra full format" {
ps --user "$(id -u)" -F
aa_check
}
# bats test_tags=ps
@test "ps: List all processes of the current user as a tree" {
ps --user "$(id -u)" -f
aa_check
}
# bats test_tags=ps
@test "ps: Get the parent PID of a process" {
ps -o ppid= -p 1
aa_check
}
# bats test_tags=ps
@test "ps: Sort processes by memory consumption" {
ps auxww --sort size
aa_check
}

View file

@ -5,25 +5,15 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=pstree
@test "pstree: Display a tree of processes" {
pstree
aa_check
}
# bats test_tags=pstree
@test "pstree: Display a tree of processes with PIDs" {
pstree -p
aa_check
}
# bats test_tags=pstree
@test "pstree: Display all process trees rooted at processes owned by specified user" {
pstree root
aa_check
}

View file

@ -5,48 +5,30 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=snap
@test "snap: Search for a package" {
snap find vim
aa_check
}
# bats test_tags=snap
@test "snap: Install a package" {
sudo snap install nano-strict
aa_check
}
# bats test_tags=snap
@test "snap: Update a package to another channel (track, risk, or branch)" {
sudo snap refresh nano-strict --channel=edge
aa_check
}
# bats test_tags=snap
@test "snap: Update all packages" {
sudo snap refresh
aa_check
}
# bats test_tags=snap
@test "snap: Display basic information about installed snap software" {
sudo snap list
aa_check
}
# bats test_tags=snap
@test "snap: Check for recent snap changes in the system" {
sudo snap changes
aa_check
}
# bats test_tags=snap
@test "snap: Uninstall a package" {
sudo snap remove nano-strict
aa_check
}

View file

@ -5,18 +5,10 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=sync
@test "sync: Flush all pending write operations on all disks" {
sync
aa_check
}
# bats test_tags=sync
@test "sync: Flush all pending write operations on a single file to disk" {
sudo sync /
aa_check
}

View file

@ -5,19 +5,11 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=systemd-ac-power
@test "systemd-ac-power: Report whether we are connected to an external power source." {
systemd-ac-power || true
aa_check
}
# bats test_tags=systemd-ac-power
@test "systemd-ac-power: Check if battery is discharging and low" {
systemd-ac-power --low || true
aa_check
}

View file

@ -5,25 +5,16 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=systemd-analyze
@test "systemd-analyze: List all running units, ordered by the time they took to initialize" {
systemd-analyze --no-pager blame
aa_check
}
# bats test_tags=systemd-analyze
@test "systemd-analyze: Print a tree of the time-critical chain of units" {
systemd-analyze --no-pager critical-chain
aa_check
}
# bats test_tags=systemd-analyze
@test "systemd-analyze: Show security scores of running units" {
systemd-analyze --no-pager security
aa_check
}

View file

@ -5,18 +5,10 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=systemd-cat
@test "systemd-cat: Write the output of the specified command to the journal (both output streams are captured)" {
systemd-cat pwd
aa_check
}
# bats test_tags=systemd-cat
@test "systemd-cat: Write the output of a pipeline to the journal (`stderr` stays connected to the terminal)" {
echo apparmor.d-test-suite | systemd-cat
aa_check
}

View file

@ -5,25 +5,15 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=systemd-cgls
@test "systemd-cgls: Display the whole control group hierarchy on your system" {
systemd-cgls --no-pager
aa_check
}
# bats test_tags=systemd-cgls
@test "systemd-cgls: Display a control group tree of a specific resource controller" {
systemd-cgls --no-pager io
aa_check
}
# bats test_tags=systemd-cgls
@test "systemd-cgls: Display the control group hierarchy of one or more systemd units" {
systemd-cgls --no-pager --unit systemd-logind
aa_check
}

View file

@ -3,23 +3,24 @@
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
# bats test_tags=systemd-detect-virt
load common
@test "systemd-detect-virt: List detectable virtualization technologies" {
systemd-detect-virt --list
}
# bats test_tags=systemd-detect-virt
@test "systemd-detect-virt: Detect virtualization, print the result and return a zero status code when running in a VM or a container, and a non-zero code otherwise" {
systemd-detect-virt
systemd-detect-virt || true
}
# bats test_tags=systemd-detect-virt
@test "systemd-detect-virt: Silently check without printing anything" {
systemd-detect-virt --quiet
systemd-detect-virt --quiet || true
}
# bats test_tags=systemd-detect-virt
@test "systemd-detect-virt: Only detect hardware virtualization" {
systemd-detect-virt --vm
systemd-detect-virt --vm || true
}

View file

@ -5,31 +5,19 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=systemd-id128
@test "systemd-id128: Generate a new random identifier" {
systemd-id128 new
aa_check
}
# bats test_tags=systemd-id128
@test "systemd-id128: Print the identifier of the current machine" {
systemd-id128 machine-id
aa_check
}
# bats test_tags=systemd-id128
@test "systemd-id128: Print the identifier of the current boot" {
systemd-id128 boot-id
aa_check
}
# bats test_tags=systemd-id128
@test "systemd-id128: Generate a new random identifier and print it as a UUID (five groups of digits separated by hyphens)" {
systemd-id128 new --uuid
aa_check
}

View file

@ -5,24 +5,14 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=systemd-sysusers
@test "systemd-sysusers: Print the contents of all configuration files (before each file, its name is printed as a comment)" {
systemd-sysusers --cat-config
aa_check
}
# bats test_tags=systemd-sysusers
@test "systemd-sysusers: Process configuration files and print what would be done without actually doing anything" {
systemd-sysusers --dry-run
aa_check
}
# bats test_tags=systemd-sysusers
@test "systemd-sysusers: Create users and groups from all configuration file" {
sudo systemd-sysusers
aa_check
}

View file

@ -5,55 +5,35 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=uname
@test "uname: Print all information" {
uname --all
aa_check
}
# bats test_tags=uname
@test "uname: Print the current kernel name" {
uname --kernel-name
aa_check
}
# bats test_tags=uname
@test "uname: Print the current network node host name" {
uname --nodename
aa_check
}
# bats test_tags=uname
@test "uname: Print the current kernel release" {
uname --kernel-release
aa_check
}
# bats test_tags=uname
@test "uname: Print the current kernel version" {
uname --kernel-version
aa_check
}
# bats test_tags=uname
@test "uname: Print the current machine hardware name" {
uname --machine
aa_check
}
# bats test_tags=uname
@test "uname: Print the current processor type" {
uname --processor
aa_check
}
# bats test_tags=uname
@test "uname: Print the current operating system name" {
uname --operating-system
aa_check
}

View file

@ -5,25 +5,15 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=upower
@test "upower: Display power and battery information" {
upower --dump
aa_check
}
# bats test_tags=upower
@test "upower: List all power devices" {
upower --enumerate
aa_check
}
# bats test_tags=upower
@test "upower: Display version" {
upower --version
aa_check
}

View file

@ -5,31 +5,19 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=uptime
@test "uptime: Print current time, uptime, number of logged-in users and other information" {
uptime
aa_check
}
# bats test_tags=uptime
@test "uptime: Show only the amount of time the system has been booted for" {
uptime --pretty
aa_check
}
# bats test_tags=uptime
@test "uptime: Print the date and time the system booted up at" {
uptime --since
aa_check
}
# bats test_tags=uptime
@test "uptime: Display version" {
uptime --version
aa_check
}

View file

@ -5,45 +5,28 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=useradd
@test "useradd: Create a new user with the specified shell" {
sudo useradd --shell /bin/bash --create-home user2
aa_check
}
# bats test_tags=useradd
@test "useradd: Create a new user with the specified user ID" {
sudo useradd --uid 3000 user3
aa_check
}
# bats test_tags=useradd
@test "useradd: Create a new user belonging to additional groups (mind the lack of whitespace)" {
sudo useradd --groups adm user4
aa_check
}
# bats test_tags=useradd
@test "useradd: Create a new system user without the home directory" {
sudo useradd --system sys2
aa_check
}
# bats test_tags=userdel
@test "userdel: Remove a user" {
sudo userdel user3
sudo userdel user4
sudo userdel sys2
aa_check
}
# bats test_tags=userdel
@test "userdel: Remove a user along with the home directory and mail spool" {
sudo userdel --remove user2
aa_check
}

View file

@ -5,37 +5,23 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=userdbctl
@test "userdbctl: List all known user records" {
userdbctl --no-pager user
aa_check
}
# bats test_tags=userdbctl
@test "userdbctl: Show details of a specific user" {
userdbctl --no-pager user "$USER"
aa_check
}
# bats test_tags=userdbctl
@test "userdbctl: List all known groups" {
userdbctl --no-pager group
aa_check
}
# bats test_tags=userdbctl
@test "userdbctl: Show details of a specific group" {
sudo userdbctl --no-pager group "$USER"
aa_check
}
# bats test_tags=userdbctl
@test "userdbctl: List all services currently providing user/group definitions to the system" {
userdbctl --no-pager services
aa_check
}

View file

@ -5,19 +5,11 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=users
@test "users: Print logged in usernames" {
users
aa_check
}
# bats test_tags=users
@test "users: Print logged in usernames according to a given file" {
users /var/log/wmtp
aa_check
}

View file

@ -5,25 +5,14 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=uuidd
@test "uuidd: Generate a random UUID" {
uuidd --random
aa_check
}
# bats test_tags=uuidd
@test "uuidd: Generate a bulk number of random UUIDs" {
uuidd --random --uuids 10
aa_check
}
# bats test_tags=uuidd
@test "uuidd: Generate a time-based UUID, based on the current time and MAC address of the system" {
uuidd --time
aa_check
}

View file

@ -5,19 +5,10 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=uuidgen
@test "uuidgen: Create a random UUIDv4" {
uuidgen --random
aa_check
}
# bats test_tags=uuidgen
@test "uuidgen: Create a UUIDv1 based on the current time" {
uuidgen --time
aa_check
}

View file

@ -5,18 +5,10 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=w
@test "w: Display information about all users who are currently logged in" {
w
aa_check
}
# bats test_tags=w
@test "w: Display information about a specific user" {
w root
aa_check
}

View file

@ -5,25 +5,15 @@
load common
setup_file() {
aa_setup
}
# bats test_tags=who
@test "who: Display the username, line, and time of all currently logged-in sessions" {
who
aa_check
}
# bats test_tags=who
@test "who: Display all available information" {
who -a
aa_check
}
# bats test_tags=who
@test "who: Display all available information with table headers" {
who -a -H
aa_check
}

View file

@ -68,7 +68,6 @@ func run() error {
if err != nil {
return err
}
tests = tests.Filter()
if err := cfg.BatsDir.RemoveAll(); err != nil {
return err
@ -76,6 +75,12 @@ func run() error {
if err := cfg.BatsDir.MkdirAll(); err != nil {
return err
}
if err := cfg.BatsDir.Join("profiled").MkdirAll(); err != nil {
return err
}
if err := cfg.BatsDir.Join("unprofiled").MkdirAll(); err != nil {
return err
}
for _, test := range tests {
if err := test.Write(cfg.BatsDir); err != nil {
return err

View file

@ -20,16 +20,10 @@ const tmplTest = `#!/usr/bin/env bats
# SPDX-License-Identifier: GPL-2.0-only
load common
setup_file() {
aa_setup
}
{{ $name := .Name -}}
{{ range .Commands }}
# bats test_tags={{ $name }}
@test "{{ $name }}: {{ .Description }}" {
{{ .Cmd }}
aa_check
}
{{ end }}
`
@ -77,13 +71,14 @@ func (t Test) IsInstalled() bool {
}
func (t Test) Write(dir *paths.Path) error {
dstDir := dir.Join("profiled")
if !t.HasProfile() {
return nil
dstDir = dir.Join("unprofiled")
}
path := dstDir.Join(t.Name + ".bats")
path := dir.Join(t.Name + ".bats")
if paths.New("tests/bats").Join(t.Name + ".bats").Exist() {
path = dir.Join("00." + t.Name + ".bats")
path = dstDir.Join("00." + t.Name + ".bats")
}
content := renderBatsFile(t)
if err := path.WriteFile([]byte(content)); err != nil {