shellcheck / shellcheck (push) Successful in 48s
install.sh failed whenever its upgrade replaced the kernel (Arch installed a few days earlier): pacman deletes the running kernel's modules, so Docker and then the firewall couldn't load theirs. The smoketest found it. kernel-modules-hook keeps them until the next reboot, and its cleanup service removes them after. install.sh installs it with archlinux-keyring, in a transaction of its own so its hooks run for the upgrade; packages.conf lists it and the service, so update adds them to existing machines. With the modules kept, a missing modules folder no longer means a newer kernel was installed, so newer_kernel_installed (utils.sh) also counts a folder no package owns, and the reboot check, version and finish-install use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
137 lines
4.3 KiB
Bash
137 lines
4.3 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
# system/finish-install.sh with a fake uname and configure. The kernel is up to
|
|
# date unless a test says otherwise: uname reports a kernel whose modules exist.
|
|
|
|
setup() {
|
|
common_setup
|
|
KERNEL="$(ls /usr/lib/modules 2> /dev/null | head -n 1)"
|
|
export KERNEL
|
|
stub uname 'echo "$KERNEL"'
|
|
# configure --list prints $ITEMS; configure itself logs that it ran
|
|
export ITEMS="done core Federated Core"
|
|
mkdir -p "$HOME/.local/bin"
|
|
cat > "$HOME/.local/bin/configure" << 'STUB'
|
|
#!/bin/bash
|
|
echo "configure${*:+ $*}" >> "$STUB_LOG"
|
|
[ "$1" = --list ] && printf '%s\n' "$ITEMS"
|
|
exit 0
|
|
STUB
|
|
chmod +x "$HOME/.local/bin/configure"
|
|
# No terminal unless a test gives answers
|
|
export COREDESKTOP_TTY="$BATS_TEST_TMPDIR/no-tty/tty"
|
|
}
|
|
|
|
needs_modules() {
|
|
[ -n "$KERNEL" ] || skip "needs a kernel in /usr/lib/modules"
|
|
}
|
|
|
|
answer() {
|
|
export COREDESKTOP_TTY="$BATS_TEST_TMPDIR/answer"
|
|
echo "$1" > "$COREDESKTOP_TTY"
|
|
}
|
|
|
|
@test "finish-install says the install worked when nothing is left to do" {
|
|
needs_modules
|
|
run bash "$REPO/system/finish-install.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"CoreDesktop is installed."* ]]
|
|
[[ "$output" == *"no reboot needed"* ]]
|
|
[[ "$output" != *"configure connects"* ]]
|
|
uncalled configure
|
|
}
|
|
|
|
@test "finish-install says the install worked, then asks for a reboot after a new kernel" {
|
|
KERNEL=0.0.0-not-installed
|
|
run bash "$REPO/system/finish-install.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"CoreDesktop is installed."*"Reboot, then run: configure"* ]]
|
|
not_called configure
|
|
}
|
|
|
|
@test "finish-install asks for a reboot when the running kernel's modules are only kernel-modules-hook's copy" {
|
|
export COREDESKTOP_MODULES_DIR="$BATS_TEST_TMPDIR/modules"
|
|
KERNEL=0.0.0-kept-by-hook
|
|
mkdir -p "$COREDESKTOP_MODULES_DIR/$KERNEL"
|
|
run bash "$REPO/system/finish-install.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"A newer kernel has been installed. Reboot, then run: configure"* ]]
|
|
not_called configure
|
|
}
|
|
|
|
@test "finish-install says the install worked before offering configure" {
|
|
needs_modules
|
|
ITEMS="to do core Federated Core"
|
|
run bash "$REPO/system/finish-install.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"CoreDesktop is installed."*"configure connects"*"To do it later, run: configure"* ]]
|
|
uncalled configure
|
|
}
|
|
|
|
@test "finish-install runs configure when asked" {
|
|
needs_modules
|
|
ITEMS="to do core Federated Core"
|
|
answer y
|
|
run bash "$REPO/system/finish-install.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"CoreDesktop is installed."* ]]
|
|
called configure
|
|
}
|
|
|
|
@test "finish-install reboots after a new kernel when told yes" {
|
|
KERNEL=0.0.0-not-installed
|
|
stub systemctl
|
|
answer y
|
|
run bash "$REPO/system/finish-install.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"Reboot, then run: configure"*"Rebooting..."* ]]
|
|
called systemctl reboot
|
|
}
|
|
|
|
@test "finish-install doesn't reboot unless told yes" {
|
|
KERNEL=0.0.0-not-installed
|
|
stub systemctl
|
|
answer ""
|
|
run bash "$REPO/system/finish-install.sh"
|
|
[ "$status" -eq 0 ]
|
|
not_called systemctl
|
|
}
|
|
|
|
@test "finish-install doesn't ask about a reboot when the kernel is up to date" {
|
|
needs_modules
|
|
stub systemctl
|
|
answer y
|
|
run bash "$REPO/system/finish-install.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" != *"Reboot now?"* ]]
|
|
not_called systemctl
|
|
}
|
|
|
|
@test "finish-install doesn't offer a reboot while the initramfs doesn't build" {
|
|
KERNEL=0.0.0-not-installed
|
|
mkdir -p "$HOME/.local/state/coredesktop"
|
|
printf '%s\n' "(3/4) Updating linux initcpios..." "==> ERROR: module not found: 'nvidia'" \
|
|
> "$HOME/.local/state/coredesktop/pacman-update.log"
|
|
stub systemctl
|
|
answer y
|
|
run bash "$REPO/system/finish-install.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"CoreDesktop is installed."*"Don't reboot yet"*"Once it builds"* ]]
|
|
[[ "$output" != *"Reboot now?"* ]]
|
|
not_called systemctl
|
|
}
|
|
|
|
@test "finish-install still offers configure while the initramfs doesn't build, if the kernel is current" {
|
|
needs_modules
|
|
ITEMS="to do core Federated Core"
|
|
mkdir -p "$HOME/.local/state/coredesktop"
|
|
printf '%s\n' "(3/4) Updating linux initcpios..." "==> ERROR: module not found: 'nvidia'" \
|
|
> "$HOME/.local/state/coredesktop/pacman-update.log"
|
|
run bash "$REPO/system/finish-install.sh"
|
|
[ "$status" -eq 0 ]
|
|
[[ "$output" == *"Don't reboot yet"*"configure connects"* ]]
|
|
[[ "$output" != *"no reboot needed"* ]]
|
|
}
|