Add a smoketest, run on CoreDesktop's with coredesktop-dev
check / lint-and-test (push) Successful in 1m37s
check / packages (push) Successful in 23s

`coredesktop-dev smoketest run --with HamPack` installs HamPack on a VM with
CoreDesktop and checks a fresh install, an update with nothing to do, a
one-app rebuild, a failing build and hampackremove, with smoketest/health
checking every package, Flatpak and app is in place.

HAMPACK_SKIP_WINDOWS_APPS skips the Windows installers, which the test VMs'
desktop would start with no one to click through them; smoketest/setup sets
it in each VM.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Young
2026-11-26 10:15:11 -07:00
co-authored by Claude Opus 5.5
parent bc536407c4
commit e8fbe256df
16 changed files with 417 additions and 2 deletions
+2 -1
View File
@@ -6,7 +6,8 @@
# make hooks - run `make lint test` before each commit
SCRIPTS := install.sh update.sh lib.sh install-binaries.sh install-compiled.sh \
install-flatpaks.sh install-windows-apps.sh patch-potacat.sh hampackcheck hampackremove
install-flatpaks.sh install-windows-apps.sh patch-potacat.sh hampackcheck hampackremove \
smoketest/setup smoketest/health smoketest/lib.sh $(wildcard smoketest/scenarios/*.sh)
.PHONY: check lint test check-packages hooks
+1
View File
@@ -79,6 +79,7 @@ HamPack is a set of Bash scripts. `install.sh` runs once, from `sibling add`; `u
- `make test` runs the bats tests in `tests/`, which stub out sudo, pacman, Flatpak and systemd, so they're safe to run. They also check the conf files for missing or misspelt fields
- `make check-packages` checks that every package in `packages.conf` is in the Arch repos or the AUR, and every Flatpak is on Flathub (run `sudo pacman -Sy` first). It catches packages that were renamed or dropped upstream, but not a typo that happens to be another package's name
- `make hooks` runs `make lint test` before each commit
- `coredesktop-dev smoketest run --with HamPack` installs, updates and removes HamPack on a virtual machine with CoreDesktop, for what the bats tests' fakes can't check. See `smoketest/README.md`
Gitea runs `make lint test` on every push and pull request, and `make check-packages` on those and once a week, since packages can disappear upstream without any change here (`.gitea/workflows/check.yml`).
+7
View File
@@ -127,6 +127,13 @@ done
[ ${#missing[@]} -eq 0 ] && exit 0
# HamPack's smoketest sets this: its test machines have a desktop, but no one
# to click through the installers
if [ -n "${HAMPACK_SKIP_WINDOWS_APPS:-}" ]; then
echo "Not installing Windows applications: HAMPACK_SKIP_WINDOWS_APPS is set."
exit 0
fi
# The installers are Windows GUI programs; without a desktop there's nothing to show them on
if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then
echo "Not installing Windows applications without a desktop session; they'll be installed on a later update."
+41
View File
@@ -0,0 +1,41 @@
# HamPack's smoketest
End-to-end tests of HamPack on a real Arch + GNOME virtual machine with
CoreDesktop installed: `sibling add`, `update` and `hampackremove`, with real
pacman, AUR, Flatpak and source builds. The bats tests in `tests/` check the
logic with fake commands; these check what fakes can't.
They run with CoreDesktop's smoketest, from the `coredesktop-dev` sibling
project, with HamPack's working copy beside CoreDesktop's (in `~/Projects`):
```
coredesktop-dev smoketest list --with HamPack
coredesktop-dev smoketest run --with HamPack # the quick (pr) scenarios, CoreDesktop's too
coredesktop-dev smoketest run --with HamPack HamPack/30 # just this one
coredesktop-dev smoketest run --with HamPack --tier all # everything, including fresh installs
```
Each working copy's `HEAD` is tested, so commit first. The first run builds
the `installed+HamPack` image, CoreDesktop's installed image after `sibling add
HamPack` at the commit this branch started from. That takes an hour or two,
building the source apps; later runs reuse it. See coredesktop-dev's README for
what the smoketest needs and how its images work.
## Files
| File | What it is |
|------|------------|
| `project.conf` | HamPack's name, parent (CoreDesktop) and URL, for the driver |
| `setup` | Runs in each VM first: sets `HAMPACK_SKIP_WINDOWS_APPS`, since no one is there to click through the Windows installers |
| `health` | Runs in the VM; checks every package, Flatpak and app HamPack installs, at its version, with its libraries and desktop file |
| `lib.sh` | Helpers for the scenarios, on top of CoreDesktop's `smoketest/lib/scenario.sh` |
| `scenarios/NN-name.sh` | One scenario each |
Scenarios are written like CoreDesktop's (see its `smoketest/README.md`), with
HamPack named where it matters: `upstream_commit HamPack MESSAGE SCRIPT`
releases a new HamPack commit, and `health HamPack` checks HamPack alone.
## Not covered
The Windows applications (VARA, Winlink Express), anything that needs a radio,
and whether the apps work beyond starting: check those by hand.
+83
View File
@@ -0,0 +1,83 @@
#!/bin/bash
#
# Purpose : HamPack's smoketest health checks. Run in a test VM with HamPack
# installed; prints what it checked, and exits 1 if anything's wrong.
# The Windows applications aren't checked: the smoketest skips them.
HAMPACK_DIR="${HAMPACK_DIR:-$HOME/.local/share/siblings/HamPack}"
APPLICATIONS_DIR="$HOME/.local/share/applications"
# shellcheck source=../lib.sh
source "$HAMPACK_DIR/lib.sh"
problems=()
problem() {
echo "PROBLEM: $*"
problems+=("$*")
}
# Arch packages (or the packages providing them) and groups
packages_installed() {
local p
while read -r p; do
pacman -T "$p" > /dev/null 2>&1 || pacman -Qg "$p" > /dev/null 2>&1 || problem "package $p isn't installed"
done < <(source "$HAMPACK_DIR/packages.conf"; printf '%s\n' "${UTILITIES[@]}" "${APPLICATIONS[@]}")
echo "checked packages.conf's packages"
}
flatpaks_installed() {
local id
while read -r id; do
flatpak info "$id" > /dev/null 2>&1 || problem "Flatpak $id isn't installed"
done < <(source "$HAMPACK_DIR/packages.conf"; printf '%s\n' "${FLATPAKS[@]}")
echo "checked packages.conf's Flatpaks"
}
# True if FILE is an ELF binary
is_elf() {
[ "$(head -c 4 "$1" 2> /dev/null | tail -c 3)" = ELF ]
}
# parse_conf callback for binaries.conf and compile.conf: the app is where it
# should be, at the version in the conf, with every library it links to, and
# with its desktop file
check_app() {
local app="${CONF[_name]}" path recorded missing desktop=""
path="$(expand_vars "${CONF[install]}")"
if [ ! -e "$path" ]; then
problem "$app isn't installed at $path"
return
fi
recorded="$(get_recorded_version "$app")"
[ "$recorded" = "${CONF[version]}" ] \
|| problem "$app is recorded at version ${recorded:-(none)}, not ${CONF[version]}"
if is_elf "$path"; then
missing="$(ldd "$path" 2> /dev/null | grep 'not found')"
[ -z "$missing" ] || problem "$app can't find libraries: $(echo "$missing" | awk '{print $1}' | tr '\n' ' ')"
fi
if [ -n "${CONF[desktop]}" ]; then
desktop="$APPLICATIONS_DIR/$(basename "$(expand_vars "${CONF[desktop]}")")"
elif [ "$1" = binary ] && [ "${CONF[gui]}" = true ]; then
desktop="$APPLICATIONS_DIR/$app.desktop"
fi
[ -z "$desktop" ] || [ -f "$desktop" ] || problem "$app has no desktop file at $desktop"
echo "checked $app"
}
check_binary() { check_app binary; }
check_compiled() { check_app compiled; }
packages_installed
flatpaks_installed
parse_conf "$HAMPACK_DIR/binaries.conf" check_binary
parse_conf "$HAMPACK_DIR/compile.conf" check_compiled
systemctl is-enabled --quiet graywolf 2> /dev/null || problem "graywolf's service isn't enabled"
uv tool list 2> /dev/null | grep -q '^not1mm ' || problem "not1mm isn't installed"
[ -f "$APPLICATIONS_DIR/k6gte-not1mm.desktop" ] || problem "not1mm has no desktop file"
[ -x "$HOME/.local/bin/hampackremove" ] || problem "hampackremove isn't installed"
echo "checked graywolf's service, not1mm and hampackremove"
if (( ${#problems[@]} > 0 )); then
echo "${#problems[@]} problem(s)"
exit 1
fi
echo "HamPack is healthy"
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
#
# Purpose : Helpers for HamPack's smoketest scenarios, on top of CoreDesktop's
# smoketest/lib/scenario.sh. Scenarios source this.
# hampack_file FILE: print HamPack's FILE at the commit under test
hampack_file() {
git -C "$(project_dir HamPack)" show "$(project_sha HamPack):$1"
}
# The apps in compile.conf at the commit under test, one per line
compiled_apps() {
hampack_file compile.conf | sed -n 's/^\[\(.*\)\]$/\1/p'
}
# compiled_version APP: APP's version= in compile.conf at the commit under test
compiled_version() {
hampack_file compile.conf | awk -v app="[$1]" '
$0 == app { found = 1; next }
/^\[/ { found = 0 }
found && /^version=/ { sub(/^version=/, ""); print; exit }'
}
+8
View File
@@ -0,0 +1,8 @@
# HamPack's smoketest, run with coredesktop-dev on top of CoreDesktop's:
# `coredesktop-dev smoketest run --with HamPack`. See README.md here.
# shellcheck disable=SC2034
NAME=HamPack
PARENT=CoreDesktop
# What `sibling add` is given; in the test VM, git sends it to a fake upstream
# holding the commit under test
URLS=(https://gitea.young.computer/david/HamPack.git)
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# shellcheck disable=SC2034
DESCRIPTION="a fresh install of CoreDesktop, then sibling add HamPack, as the READMEs say"
IMAGE=base
TIER="nightly"
scenario() {
install_chain
health
}
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# shellcheck disable=SC2034
DESCRIPTION="update with nothing new for HamPack builds and downloads nothing"
IMAGE=installed
TIER="pr"
source "$(dirname "${BASH_SOURCE[0]}")/../lib.sh"
# smoketest_prepare has already updated the machine to the commit under test
scenario() {
local app
cd_update
assert_status 0
while read -r app; do
assert_output " $app $(compiled_version "$app") is up to date."
done < <(compiled_apps)
refute_output " Building "
refute_output " Downloading "
refute_output " Installing:"
health
}
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# shellcheck disable=SC2034
DESCRIPTION="a new version of one app in compile.conf rebuilds that app and no other"
IMAGE=installed
TIER="pr"
source "$(dirname "${BASH_SOURCE[0]}")/../lib.sh"
# Dump1090 is pinned to a commit with ref=, so a new version= rebuilds the same
# source: the quickest build there is
scenario() {
local old
old="$(compiled_version Dump1090)"
upstream_commit HamPack "Rebuild Dump1090" \
'sed -i "/^\[Dump1090\]/,/^\$/ s/^version=.*/&-smoketest/" compile.conf'
cd_update
assert_status 0
assert_output "Updating Dump1090 from $old to $old-smoketest"
[ "$(grep -c ' Building ' <<< "$OUTPUT")" -eq 1 ] || fail "update built more than Dump1090 (see $LAST_LOG)"
health HamPack
}
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
# shellcheck disable=SC2034
DESCRIPTION="a build that fails is reported, keeps the installed app, and is retried on the next update"
IMAGE=installed
TIER="pr"
source "$(dirname "${BASH_SOURCE[0]}")/../lib.sh"
scenario() {
local old
old="$(compiled_version Dump1090)"
upstream_commit HamPack "Break Dump1090's build" \
'sed -i "/^\[Dump1090\]/,/^\$/ { s/^version=.*/&-smoketest/; s/^steps=/steps=false, /; }" compile.conf'
cd_update
assert_status 1
assert_output "Error: build of Dump1090 failed"
assert_output "HamPack's update.sh failed"
assert_vm "Dump1090 is still installed, at its old version" \
"test -x ~/.local/bin/dump1090 && grep -qx Dump1090=$(q "$old") ~/.local/state/HamPack/.installed_versions"
upstream_commit HamPack "Fix Dump1090's build" 'sed -i "s/^steps=false, /steps=/" compile.conf'
cd_update
assert_status 0
assert_output "Updating Dump1090 from $old to $old-smoketest"
health HamPack
}
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
# shellcheck disable=SC2034
DESCRIPTION="hampackremove removes what HamPack installed and leaves CoreDesktop working"
IMAGE=installed
TIER="pr"
scenario() {
local recorded kept pkg
recorded="$(vm_value 'cat ~/.local/state/HamPack/installed-packages 2> /dev/null || true')"
# It asks to confirm, then (with nothing more on stdin) says no to anything else
run_in_vm hampackremove 'printf "y\n" | TERM=dumb ~/.local/bin/hampackremove'
assert_status 0
assert_output "HamPack has been removed."
assert_vm "HamPack's clone, state and apps are gone" '
! test -e ~/.local/share/siblings/HamPack && ! test -e ~/.local/state/HamPack &&
! test -e ~/.local/bin/direwolf && ! test -e ~/.local/bin/dump1090 &&
! test -e ~/.local/bin/POTACAT.AppImage && ! test -e ~/.local/bin/hampackremove'
refute_vm "graywolf's service is gone" 'systemctl cat graywolf'
# Each package HamPack installed is gone, unless something else needs it
kept="$(sed -n 's/^Kept because other software needs them: //p' <<< "$OUTPUT")"
for pkg in $recorded; do
if vm_exec "pacman -Qq $(q "$pkg")" > /dev/null 2>&1; then
[[ " $kept " == *" $pkg "* ]] || fail "$pkg is still installed, and wasn't reported as kept"
fi
done
echo "ok: HamPack's packages are gone, but for those kept: ${kept:-none}"
health CoreDesktop
cd_update
assert_status 0
health CoreDesktop
}
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
#
# Purpose : Run in each smoketest VM before HamPack is installed or tested.
# The VMs have a desktop, but no one to click through the Windows
# installers, which would wait for clicks until the run timed out.
# Set for the GNOME session now and after reboots, so every
# install, update and sibling add in the VM sees it.
set -e
mkdir -p ~/.config/environment.d
echo HAMPACK_SKIP_WINDOWS_APPS=1 > ~/.config/environment.d/90-hampack-smoketest.conf
systemctl --user set-environment HAMPACK_SKIP_WINDOWS_APPS=1
+1 -1
View File
@@ -16,7 +16,7 @@ setup_fake_home() {
# "dep" means it was installed as a dependency
export FAKE_PACMAN_DB="$BATS_TEST_TMPDIR/pacman-db"
export FAKE_FLATPAKS="$BATS_TEST_TMPDIR/flatpaks"
unset DISPLAY WAYLAND_DISPLAY WINEPREFIX
unset DISPLAY WAYLAND_DISPLAY WINEPREFIX HAMPACK_SKIP_WINDOWS_APPS
mkdir -p "$HOME/.local/bin" "$TMPDIR" "$STUB_DIR" "$FAKE_PACMAN_DB" "$FAKE_FLATPAKS"
: > "$STUB_LOG"
PATH="$STUB_DIR:$PATH"
+8
View File
@@ -81,6 +81,14 @@ install_all_windows_apps() {
! grep -q '^curl ' "$STUB_LOG"
}
@test "windows apps: HAMPACK_SKIP_WINDOWS_APPS skips them, even at the desktop" {
export DISPLAY=:0 HAMPACK_SKIP_WINDOWS_APPS=1
run bash "$REPO/install-windows-apps.sh"
[ "$status" -eq 0 ]
[[ "$output" == *"HAMPACK_SKIP_WINDOWS_APPS is set"* ]]
! grep -qE '^(curl|winetricks|wine) ' "$STUB_LOG"
}
@test "windows apps: winetricks runs only once" {
export DISPLAY=:0
mkdir -p "$HOME/.wine"
+120
View File
@@ -0,0 +1,120 @@
#!/usr/bin/env bats
#
# The smoketest's own files: its scenarios run with coredesktop-dev on test
# VMs (see smoketest/README.md), but what can be checked without one is here
load helpers
setup() {
setup_fake_home
}
# A machine with everything HamPack installs in place, as its health checks
# expect: packages and Flatpaks (stubbed), each app at its conf version with
# its desktop file, graywolf's service, not1mm and hampackremove
fake_installed_machine() {
stub pacman 'case "$1" in -T|-Qg) exit 0 ;; esac; exit 1'
stub flatpak 'exit 0'
stub systemctl '[ "$*" = "is-enabled --quiet graywolf" ]'
stub uv '[ "$*" = "tool list" ] && echo "not1mm v1.0"'
(
source "$REPO/lib.sh"
put_app() {
local path
path="$(expand_vars "${CONF[install]}")"
mkdir -p "$(dirname "$path")"
echo app > "$path"
save_installed_version "${CONF[_name]}" "${CONF[version]}"
mkdir -p "$HOME/.local/share/applications"
if [ -n "${CONF[desktop]}" ]; then
touch "$HOME/.local/share/applications/$(basename "${CONF[desktop]}")"
else
touch "$HOME/.local/share/applications/${CONF[_name]}.desktop"
fi
}
parse_conf "$REPO/binaries.conf" put_app
parse_conf "$REPO/compile.conf" put_app
)
touch "$HOME/.local/share/applications/k6gte-not1mm.desktop" "$HOME/.local/bin/hampackremove"
chmod +x "$HOME/.local/bin/hampackremove"
}
@test "smoketest: health passes on a machine with everything installed" {
fake_installed_machine
run bash "$REPO/smoketest/health"
[ "$status" -eq 0 ]
[[ "$output" == *"checked direwolf"* ]]
[[ "$output" == *"checked paracon"* ]]
[[ "$output" == *"HamPack is healthy"* ]]
}
@test "smoketest: health names each thing that's wrong, and fails" {
fake_installed_machine
stub pacman '[ "$2" != fldigi ] && [ "$1" = -T ]'
stub flatpak '[ "$2" != io.github.foldynl.QLog ]'
rm "$HOME/.local/bin/dump1090" "$HOME/.local/share/applications/js8call.desktop"
sed -i 's/^paracon=.*/paracon=0.1/' "$HAMPACK_STATE/.installed_versions"
stub systemctl 'exit 1'
run bash "$REPO/smoketest/health"
[ "$status" -eq 1 ]
[[ "$output" == *"PROBLEM: package fldigi isn't installed"* ]]
[[ "$output" == *"PROBLEM: Flatpak io.github.foldynl.QLog isn't installed"* ]]
[[ "$output" == *"PROBLEM: Dump1090 isn't installed at $HOME/.local/bin/dump1090"* ]]
[[ "$output" == *"PROBLEM: js8call-improved has no desktop file"* ]]
[[ "$output" == *"PROBLEM: paracon is recorded at version 0.1, not 1.3.0"* ]]
[[ "$output" == *"PROBLEM: graywolf's service isn't enabled"* ]]
[[ "$output" == *"6 problem(s)"* ]]
}
@test "smoketest: health finds a binary missing a library" {
fake_installed_machine
printf '\177ELF' > "$HOME/.local/bin/direwolf"
stub ldd 'echo " libhamlib.so.4 => not found"'
run bash "$REPO/smoketest/health"
[ "$status" -eq 1 ]
[[ "$output" == *"PROBLEM: direwolf can't find libraries: libhamlib.so.4"* ]]
}
@test "smoketest: setup turns the Windows installers off for the session, now and after reboots" {
stub systemctl 'exit 0'
run bash "$REPO/smoketest/setup"
[ "$status" -eq 0 ]
grep -qx "systemctl --user set-environment HAMPACK_SKIP_WINDOWS_APPS=1" "$STUB_LOG"
grep -qx HAMPACK_SKIP_WINDOWS_APPS=1 "$HOME/.config/environment.d/90-hampack-smoketest.conf"
}
@test "smoketest: the scenarios' helpers read compile.conf at the commit under test" {
project_dir() { echo "$REPO"; }
project_sha() { git -C "$REPO" rev-parse HEAD; }
source "$REPO/smoketest/lib.sh"
run compiled_apps
[ "$output" = "$(git -C "$REPO" show HEAD:compile.conf | sed -n 's/^\[\(.*\)\]$/\1/p')" ]
[[ "$output" == *Dump1090* ]]
[ "$(compiled_version Dump1090)" = "$(git -C "$REPO" show HEAD:compile.conf |
sed -n '/^\[Dump1090\]/,/^$/s/^version=//p')" ]
[ -n "$(compiled_version direwolf)" ]
[ -z "$(compiled_version nosuchapp)" ]
}
@test "smoketest: every scenario sets a description, image and tier, and defines scenario" {
for file in "$REPO"/smoketest/scenarios/*.sh; do
(
unset DESCRIPTION IMAGE TIER
unset -f scenario
source "$file"
[ -n "$DESCRIPTION" ] || { echo "$file: no DESCRIPTION"; exit 1; }
[[ "$IMAGE" == base || "$IMAGE" == installed ]] || { echo "$file: IMAGE is '$IMAGE'"; exit 1; }
[[ "$TIER" == pr || "$TIER" == nightly ]] || { echo "$file: TIER is '$TIER'"; exit 1; }
declare -f scenario > /dev/null || { echo "$file: no scenario function"; exit 1; }
)
done
}
@test "smoketest: project.conf adds HamPack from the URL the README gives" {
(
source "$REPO/smoketest/project.conf"
[ "$NAME" = HamPack ]
[ "$PARENT" = CoreDesktop ]
grep -qF "sibling add ${URLS[0]}" "$REPO/README.md"
)
}