diff --git a/tests/assert_llvm.sh b/tests/assert_llvm.sh new file mode 100755 index 0000000..25e4de4 --- /dev/null +++ b/tests/assert_llvm.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Script to assert that the llvm rpm installed during tmt prepare steps comes +# from the copr repo and matches exactly. +# Rely on dnf4 (/usr/bin/dnf-3) to avoid conflicts in newer Fedoras with dnf5. +# The script expects $COPR_PROJECT envvar to check the repo. +if [[ -z $COPR_PROJECT ]]; then + echo "*** Missing COPR_PROJECT required environment variable." + exit 1 +fi + +# Ensure the repo is available +if ! dnf-3 repolist | grep -q "$COPR_PROJECT"; then + echo "*** copr repo $COPR_PROJECT not enabled in dnf" +fi + +assert_package_match (){ + local pkg=$1 + local rpm_queryfmt="%{name}-%{version}-%{release}.%{arch}" + local installed_pkg pkg_from_copr + installed_pkg=$(rpm -q --qf "$rpm_queryfmt" "$pkg"."$(uname -m)") + pkg_from_copr=$(dnf-3 -q --disablerepo=* --enablerepo=*"$COPR_PROJECT"* \ + repoquery --queryformat "$rpm_queryfmt" "$pkg"."$(uname -m)") + + if [[ "$installed_pkg" != "$pkg_from_copr" ]]; then + echo "*** Unexpected $pkg package installed: $installed_pkg" + echo "*** Expected $pkg: $pkg_from_copr" + exit 1 + fi +} + +for pkg in llvm clang; do + assert_package_match "$pkg" +done diff --git a/tests/snapshot-gating.fmf b/tests/snapshot-gating.fmf index e3a3818..d91eebf 100644 --- a/tests/snapshot-gating.fmf +++ b/tests/snapshot-gating.fmf @@ -23,6 +23,11 @@ prepare: script: | dnf install -y dnf-plugins-core dnf config-manager --save --setopt="testing-farm-tag-repository.priority=999" || true + + - name: Assert correct llvm package is installed + how: shell + order: 99 + script: tests/assert_llvm.sh adjust: - discover+: - name: redhat-rpm-config-tests