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
|
|
|
|
LANG=C
|
2024-06-10 15:37:27 +02:00
|
|
|
_LOG=testsuite.log
|
2024-06-10 15:04:08 +02:00
|
|
|
_APPNAME=${0##*/}
|
|
|
|
_usage () {
|
|
|
|
echo "Tests for Archboot Environment"
|
2024-06-10 16:27:05 +02:00
|
|
|
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 () {
|
|
|
|
echo -e "\e[1m${1} running...\e[m"
|
|
|
|
}
|
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-11 09:10:49 +02:00
|
|
|
_gpg_check() {
|
|
|
|
# pacman-key process itself
|
|
|
|
while pgrep -x pacman-key &>"${_NO_LOG}"; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
# gpg finished in background
|
|
|
|
while pgrep -x gpg &>"${_NO_LOG}"; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2024-06-10 15:04:08 +02:00
|
|
|
[[ -z "${1}" || "${1}" != "run" ]] && _usage
|
2024-06-11 09:10:49 +02:00
|
|
|
echo "Waiting for pacman keyring..."
|
|
|
|
_gpg_check
|
2024-06-10 16:37:22 +02:00
|
|
|
_run_test "Boot Test"
|
2024-06-10 15:04:08 +02:00
|
|
|
if dmesg | grep -q error; then
|
2024-06-10 15:14:27 +02:00
|
|
|
dmesg | grep 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-10 16:37:22 +02:00
|
|
|
_run_test "Binary Test"
|
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-10 15:14:27 +02:00
|
|
|
echo "${i}" >>binary-error.txt
|
2024-06-10 16:27:05 +02:00
|
|
|
echo ldd "${i}" | grep 'not found' >>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 binary-error.txt
|
2024-06-10 16:37:22 +02:00
|
|
|
_run_test "Base Binary Test"
|
|
|
|
# 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-10 16:01:52 +02:00
|
|
|
# uninstall base again!
|
2024-06-10 16:08:07 +02:00
|
|
|
pacman --noconfirm -Rdd base &>>"${_LOG}"
|
2024-06-10 16:37:22 +02:00
|
|
|
_run_test "Pacman Package Database Test"
|
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:
|