archboot/usr/bin/archboot-testsuite.sh

91 lines
3 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-11 21:30:51 +02:00
echo "Testsuite for Archboot Environment"
echo "----------------------------------"
2024-06-10 15:04:08 +02:00
echo "usage: ${_APPNAME} run"
exit 0
}
2024-06-10 16:37:22 +02:00
_run_test () {
2024-06-11 22:11:07 +02:00
echo -e "\e[1m${1} Check running...\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-11 22:11:07 +02:00
_run_test "Dmesg Error"
2024-06-11 18:06:54 +02:00
if dmesg | grep -q -w -E 'error'; then
dmesg | grep -w -E 'error' >>dmesg-error.txt
2024-06-10 15:04:08 +02:00
_TEST_FAIL=1
fi
2024-06-10 16:27:05 +02:00
_result dmesg-error.txt
2024-06-11 22:11:07 +02:00
_run_test "Binary Linking /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:11:07 +02:00
_run_test "Binary Linking /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:11:07 +02:00
_run_test "Library Linking /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:11:07 +02:00
_run_test "Base Binary"
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:11:07 +02:00
_run_test "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-10 16:08:07 +02:00
pacman --noconfirm -Rdd base &>>"${_LOG}"
2024-06-11 22:11:07 +02:00
_run_test "Pacman Package Database"
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: