2024-06-10 15:04:08 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
# created by Tobias Powalowski <tpowa@archlinux.org>
|
|
|
|
. /usr/lib/archboot/common.sh
|
2024-06-10 15:37:27 +02:00
|
|
|
_LOG=testsuite.log
|
2024-06-10 15:04:08 +02:00
|
|
|
_APPNAME=${0##*/}
|
|
|
|
_usage () {
|
2024-06-12 22:39:54 +02:00
|
|
|
echo -e "\e[1mTestsuite for Archboot Environment\e[m"
|
|
|
|
echo -e "\e[1m---------------------------------------------\e[m"
|
|
|
|
echo "Run automatic tests to detect errors/changes."
|
|
|
|
echo ""
|
|
|
|
echo -e "usage: \e[1m${_APPNAME} run\e[m"
|
2024-06-10 15:04:08 +02:00
|
|
|
exit 0
|
|
|
|
}
|
2024-06-10 16:37:22 +02:00
|
|
|
_run_test () {
|
2024-06-13 07:32:04 +02:00
|
|
|
echo -e "\e[1mTestsuite checking ${1}...\e[m"
|
2024-06-10 16:37:22 +02:00
|
|
|
}
|
2024-06-10 16:27:05 +02:00
|
|
|
_result() {
|
|
|
|
if [[ -s ${1} ]]; then
|
2024-06-10 16:49:46 +02:00
|
|
|
echo -e "\e[1;94m=> \e[1;91mFAILED\e[m"
|
2024-06-10 16:52:13 +02:00
|
|
|
cat "${1}"
|
2024-06-10 16:27:05 +02:00
|
|
|
else
|
2024-06-10 16:49:46 +02:00
|
|
|
echo -e "\e[1;94m=> \e[1;92mOK\e[m"
|
2024-06-10 16:27:05 +02:00
|
|
|
fi
|
|
|
|
}
|
2024-06-10 15:04:08 +02:00
|
|
|
[[ -z "${1}" || "${1}" != "run" ]] && _usage
|
2024-06-11 12:01:01 +02:00
|
|
|
_archboot_check
|
2024-06-11 09:10:49 +02:00
|
|
|
echo "Waiting for pacman keyring..."
|
2024-06-11 12:31:10 +02:00
|
|
|
_pacman_keyring
|
2024-06-13 07:22:22 +02:00
|
|
|
_run_test "journal"
|
2024-06-25 21:00:29 +02:00
|
|
|
if ! journalctl -p3 -xb | rg -q 'No entries'; then
|
2024-06-13 07:22:22 +02:00
|
|
|
journalctl -p3 -xb >>journal-error.txt
|
2024-06-10 15:04:08 +02:00
|
|
|
_TEST_FAIL=1
|
|
|
|
fi
|
2024-06-13 07:22:22 +02:00
|
|
|
_result journal-error.txt
|
2024-06-11 22:40:17 +02:00
|
|
|
_run_test "ldd on /usr/bin"
|
2024-06-10 15:04:08 +02:00
|
|
|
for i in /usr/bin/*; do
|
2024-06-25 21:00:29 +02:00
|
|
|
if ldd "${i}" 2>"${_NO_LOG}" | rg -q 'not found'; then
|
2024-06-11 10:27:13 +02:00
|
|
|
echo "${i}" >>bin-binary-error.txt
|
2024-06-25 21:00:29 +02:00
|
|
|
ldd "${i}" | rg 'not found' >>bin-binary-error.txt
|
2024-06-10 15:04:08 +02:00
|
|
|
_TEST_FAIL=1
|
|
|
|
fi
|
|
|
|
done
|
2024-06-11 10:27:13 +02:00
|
|
|
_result bin-binary-error.txt
|
2024-06-13 21:58:58 +02:00
|
|
|
_run_test "ldd on executables in /usr/lib"
|
2024-07-05 08:02:01 +02:00
|
|
|
for i in $(fd -u -t x -E '*.so.*' -E '*.so' -E 'ssh-sk-helper' . /usr/lib); do
|
2024-06-25 21:00:29 +02:00
|
|
|
if ldd "${i}" 2>"${_NO_LOG}" | rg -q 'not found'; then
|
2024-06-13 21:58:58 +02:00
|
|
|
echo "${i}" >>lib-binary-error.txt
|
2024-06-25 21:00:29 +02:00
|
|
|
ldd "${i}" | rg 'not found' >>lib-binary-error.txt
|
2024-06-11 10:27:13 +02:00
|
|
|
_TEST_FAIL=1
|
|
|
|
fi
|
|
|
|
done
|
2024-06-13 21:58:58 +02:00
|
|
|
_result lib-binary-error.txt
|
2024-06-11 22:40:17 +02:00
|
|
|
_run_test "ldd on /usr/lib"
|
2024-06-11 10:27:13 +02:00
|
|
|
# ignore wrong reported libsystemd-shared by libsystemd-core
|
2024-06-18 17:51:06 +02:00
|
|
|
for i in $(fd -u '.so' /usr/lib); do
|
2024-06-25 21:00:29 +02:00
|
|
|
if ldd "${i}" 2>"${_NO_LOG}" | rg -v 'tree_sitter|libsystemd-shared' | rg -q 'not found'; then
|
2024-06-11 10:27:13 +02:00
|
|
|
echo "${i}" >>lib-error.txt
|
2024-06-25 21:00:29 +02:00
|
|
|
ldd "${i}" | rg 'not found' >>lib-error.txt
|
2024-06-11 10:27:13 +02:00
|
|
|
_TEST_FAIL=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
_result lib-error.txt
|
2024-06-11 22:40:17 +02:00
|
|
|
_run_test "on missing base binaries"
|
2024-06-10 16:37:22 +02:00
|
|
|
# not needed binaries, that are tolerated
|
2024-06-10 15:37:27 +02:00
|
|
|
_BASE_BLACKLIST="arpd backup bashbug enosys exch fsck.cramfs fsck.minix gawk-5.3.0 \
|
2024-06-11 08:20:12 +02:00
|
|
|
gawkbug gencat getconf iconv iconvconfig importctl lastlog2 ld.so locale lsclocks makedb \
|
|
|
|
makepkg-template memusage memusagestat mkfs.bfs mkfs.cramfs mkfs.minix mtrace newgidmap \
|
|
|
|
newuidmap pcprofiledump pldd pstree.x11 restore routel run0 setpgid sln sotruss sprof \
|
|
|
|
systemd-confext systemd-cryptsetup systemd-delta systemd-home-fallback-shell systemd-repart \
|
|
|
|
systemd-run systemd-vmspawn systemd-vpick varlinkctl xtrace"
|
2024-06-10 15:14:27 +02:00
|
|
|
archboot-binary-check.sh base &>>"${_LOG}"
|
2024-06-10 16:08:07 +02:00
|
|
|
#shellcheck disable=SC2013
|
2024-06-25 21:00:29 +02:00
|
|
|
for i in $(rg '/usr/bin/(.*)' -r '$1' binary.txt); do
|
|
|
|
if ! echo "${_BASE_BLACKLIST}" | rg -qw "${i}"; then
|
2024-06-10 15:14:27 +02:00
|
|
|
echo "${i}" >> base-binary-error.txt
|
2024-06-10 15:04:08 +02:00
|
|
|
_TEST_FAIL=1
|
|
|
|
fi
|
|
|
|
done
|
2024-06-10 16:27:05 +02:00
|
|
|
_result base-binary-error.txt
|
2024-06-11 22:40:17 +02:00
|
|
|
_run_test "modules included /usr/lib/firmware"
|
2024-06-11 22:07:06 +02:00
|
|
|
if ! archboot-fw-check.sh run; then
|
2024-06-11 21:30:51 +02:00
|
|
|
TEST_FAIL=1
|
|
|
|
fi
|
|
|
|
_result fw-error.txt
|
2024-06-10 16:01:52 +02:00
|
|
|
# uninstall base again!
|
2024-06-13 07:37:01 +02:00
|
|
|
pacman --noconfirm -Rdd base gettext &>>"${_LOG}"
|
2024-06-18 08:21:43 +02:00
|
|
|
_run_test "licenses"
|
2024-06-25 22:22:08 +02:00
|
|
|
for i in $(pacman -Ql $(pacman -Q | sd ' .*' '') | rg -o '/usr/share/licenses/.*'); do
|
2024-06-25 21:00:29 +02:00
|
|
|
[[ -e "${i}" ]] || echo "${i}" | rg -v '/xz/' >>license-error.txt
|
2024-06-18 08:21:43 +02:00
|
|
|
done
|
|
|
|
_result license-error.txt
|
2024-07-11 20:20:05 +02:00
|
|
|
_run_test "filesystems"
|
2024-07-11 19:34:39 +02:00
|
|
|
for i in bcachefs btrfs ext4 swap vfat xfs; do
|
2024-07-11 19:27:19 +02:00
|
|
|
dd if=/dev/zero of=/test.img bs=1M count=1000 &>"${_NO_LOG}"
|
2024-07-11 20:20:05 +02:00
|
|
|
sync
|
2024-07-11 18:41:50 +02:00
|
|
|
if [[ "${i}" == "swap" ]]; then
|
2024-07-11 19:31:01 +02:00
|
|
|
mkswap /test.img &>"${_NO_LOG}" || echo "Creation error: ${i}" >> filesystems-error.log
|
2024-07-11 20:20:05 +02:00
|
|
|
sync
|
2024-07-11 18:41:50 +02:00
|
|
|
else
|
2024-07-11 19:31:01 +02:00
|
|
|
mkfs.${i} /test.img &>"${_NO_LOG}" || echo "Creation error: ${i}" >> filesystems-error.log
|
2024-07-11 20:20:05 +02:00
|
|
|
sync
|
2024-07-11 22:08:17 +02:00
|
|
|
mount -o loop -t "${i}" /test.img /mnt &>"${_NO_LOG}" || echo "Mount error: ${i}" >> filesystems-error.log
|
2024-07-11 21:54:02 +02:00
|
|
|
umount /mnt || echo "Unmount error: ${i}" >> filesystems-error.log
|
2024-07-11 18:41:50 +02:00
|
|
|
fi
|
2024-07-11 18:34:46 +02:00
|
|
|
done
|
2024-07-11 19:27:19 +02:00
|
|
|
_result filesytems-error.log
|
2024-07-11 21:41:35 +02:00
|
|
|
_run_test "blockdevices"
|
|
|
|
dd if=/dev/zero of=/test.img bs=1M count=1000 &>"${_NO_LOG}"
|
|
|
|
sync
|
2024-07-11 21:54:02 +02:00
|
|
|
losetup -f /test.img
|
2024-07-11 22:02:07 +02:00
|
|
|
mdadm --create /dev/md0 --run --level=1 --raid-devices=2 /dev/loop0 missing &>"${_NO_LOG}" || echo "Creation error: mdadm" >> blockdevices-error.log
|
2024-07-11 21:41:35 +02:00
|
|
|
wipefs -a -f /dev/md0 &>"${_NO_LOG}"
|
2024-07-11 21:44:15 +02:00
|
|
|
mdadm --manage --stop /dev/md0 &>"${_NO_LOG}" || echo "Stop error: mdadm" >> blockdevices-error.log
|
2024-07-11 21:41:35 +02:00
|
|
|
wipefs -a -f /dev/loop0 &>"${_NO_LOG}"
|
|
|
|
dd if=/dev/zero of=/test.img bs=1M count=10 &>"${_NO_LOG}"
|
|
|
|
sync
|
|
|
|
_result blockdevices-error.log
|
2024-07-11 20:20:05 +02:00
|
|
|
_run_test "Wi-Fi iwctl"
|
2024-07-11 20:06:53 +02:00
|
|
|
archboot-hwsim.sh test &>"${_NO_LOG}"
|
2024-07-11 20:02:27 +02:00
|
|
|
iwctl station wlan1 scan
|
|
|
|
sleep 5
|
2024-07-11 20:06:53 +02:00
|
|
|
iwctl station wlan1 get-networks | rg -q test || echo "Wi-Fi iwctl get-networks error" >> iwctl-error.log
|
|
|
|
iwctl --passphrase=12345678 station wlan1 connect test || echo "Wi-Fi iwctl connect error" >> iwctl-error.log
|
|
|
|
iwctl station wlan1 disconnect || echo "Wi-Fi iwctl disconnect error" >> iwctl-error.log
|
|
|
|
_result iwctl-error.log
|
2024-06-13 19:25:26 +02:00
|
|
|
echo -e "Starting none tracked files in \e[1m10\e[m seconds... \e[1;92mCTRL-C\e[m to stop now."
|
2024-06-28 18:39:59 +02:00
|
|
|
sleep 10
|
2024-06-13 19:25:26 +02:00
|
|
|
_run_test "none tracked files in /usr/lib... this takes a while"
|
2024-06-27 11:09:23 +02:00
|
|
|
for i in $(fd -u -E '/modules/' -E '/udev/' -E 'gconv-modules.cache' -E '/locale-archive' . /usr/lib); do
|
2024-07-10 21:40:20 +02:00
|
|
|
#shellcheck disable=SC2086
|
2024-06-13 19:20:04 +02:00
|
|
|
pacman -Qo ${i} &>${_NO_LOG} || echo ${i} >> pacman-error.log
|
|
|
|
done
|
|
|
|
_result pacman-error.log
|
2024-06-13 07:46:22 +02:00
|
|
|
echo -e "Starting pacman database check in \e[1m10\e[m seconds... \e[1;92mCTRL-C\e[m to stop now."
|
2024-06-28 18:39:59 +02:00
|
|
|
sleep 10
|
2024-06-13 19:25:26 +02:00
|
|
|
_run_test "pacman database... this takes a while"
|
2024-06-10 15:48:59 +02:00
|
|
|
archboot-not-installed.sh &>>"${_LOG}"
|
2024-06-10 16:27:05 +02:00
|
|
|
_result not-installed.txt
|
2024-06-10 15:04:08 +02:00
|
|
|
[[ -n "${_TEST_FAIL}" ]] && exit 1
|
|
|
|
# vim: set ft=sh ts=4 sw=4 et:
|