osbuild/tests/unit-tests/prep-host-environment.sh
Tomáš Hozza ca40d1fbe2
Test: rework execution of unit-tests
We have been running just a subset of osbuild unit tests and also not as
a root, so some of them would be skipped.

In addition, the downstream patches were never applied on sources which
were used for unit-testing. Thus if any issue with test was just
backported as a patch, this had no effect on the test result.

Rework how tests are executed by using a dedicated script which will
take care of the installation of test dependencies, preparation of
sources including application of downstream patches and execute all unit
tests.

Rework also the FMF test metadata and test discovery.

Related: rhbz#2174845

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
2023-05-30 13:03:53 +02:00

65 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/bash
# Prepare the host environment for running the osbuild unit tests.
# This includes installing missing dependencies and tools.
set -euxo pipefail
source /etc/os-release
case "${ID}" in
fedora)
PKG_MAINT_TOOL="fedpkg"
sudo dnf install -y "${PKG_MAINT_TOOL}"
;;
rhel)
PKG_MAINT_TOOL="rhpkg"
# rhpkg is not available in the default repos
sudo curl -L -o "/etc/yum.repos.d/rcm-tools-rhel-${VERSION_ID%.*}-baseos.repo" "http://download.devel.redhat.com/rel-eng/internal/rcm-tools-rhel-${VERSION_ID%.*}-baseos.repo"
# install the RH IT CA certificate used by the repo above
sudo curl -L -o /etc/pki/ca-trust/source/anchors/2015-IT-Root-CA.pem http://certs.corp.redhat.com/certs/2015-IT-Root-CA.pem
sudo curl -L -o /etc/pki/ca-trust/source/anchors/2022-IT-Root-CA.pem http://certs.corp.redhat.com/certs/2022-IT-Root-CA.pem
sudo update-ca-trust
;;
centos)
PKG_MAINT_TOOL="centpkg"
# centpkg is not available in the default repos
sudo dnf install -y epel-release
# CRB repos are available only for CentOS Stream 9
if [ "${VERSION_ID}" == "9" ]; then
dnf config-manager --set-enabled crb
fi
;;
*)
echo "Error: unsupported OS: ${ID}-${VERSION_ID}"
exit 1
;;
esac
# Move to the checked out git repo with the test plans
# this should be the root of the dist-git repo
cd "${TMT_TREE}"
# install all test dependencies
sudo dnf install -y \
"${PKG_MAINT_TOOL}" \
rpmdevtools \
python3-mako \
python3-pip \
rpm-ostree \
dosfstools \
gdisk
sudo dnf builddep -y osbuild.spec
# Install pytst from pip, because the version in some RHEL / CentOS releases is too old
sudo pip3 install pytest
# Make sure that /usr/lib/systemd/boot/efi/linuxx64.efi.stub is available to enable pe32p tests
case "${ID}-${VERSION_ID}" in
rhel-8.* | centos-8)
sudo dnf install -y systemd-udev
;;
*)
sudo dnf install -y systemd-boot-unsigned
;;
esac