archboot/usr/bin/archboot-testsuite.sh

95 lines
3.2 KiB
Bash
Raw Normal View History

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
_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-13 07:27:14 +02:00
if ! journalctl -p3 -xb | grep -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-10 16:37:22 +02:00
if ldd "${i}" 2>"${_NO_LOG}" | grep -q 'not found'; then
2024-06-11 10:27:13 +02:00
echo "${i}" >>bin-binary-error.txt
2024-06-11 10:39:13 +02:00
ldd "${i}" | grep '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-11 22:40:17 +02:00
_run_test "ldd on /usr/lib/systemd"
2024-06-11 10:27:13 +02:00
for i in /usr/lib/systemd*; do
if ldd "${i}" 2>"${_NO_LOG}" | grep -q 'not found'; then
echo "${i}" >>systemd-binary-error.txt
2024-06-11 10:39:13 +02:00
ldd "${i}" | grep 'not found' >>systemd-binary-error.txt
2024-06-11 10:27:13 +02:00
_TEST_FAIL=1
fi
done
_result systemd-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
for i in $(find /usr/lib | grep '.so$'); do
2024-06-11 10:33:25 +02:00
if ldd "${i}" 2>"${_NO_LOG}" | grep -v -E 'tree_sitter|libsystemd-shared' | grep -q 'not found'; then
2024-06-11 10:27:13 +02:00
echo "${i}" >>lib-error.txt
2024-06-11 10:39:13 +02:00
ldd "${i}" | grep '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-10 15:07:56 +02:00
for i in $(grep '/usr/bin/' binary.txt | sed -e 's#^/usr/bin/##g'); do
2024-06-10 15:04:08 +02:00
if ! echo "${_BASE_BLACKLIST}" | grep -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-13 07:42:01 +02:00
echo -e "Starting pacman database check in [1m5\e[m seconds... [1;92mCTRL-C\e[m to stop now."
read -t 5
2024-06-11 22:49:34 +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: