From 6ec423923fcd1b9747d1dcd938d0e306a9fad905 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Thu, 20 Jan 2022 16:57:09 +0100 Subject: [PATCH] tests: re-use Fedora tests Related: rhbz#2001107 --- .fmf/version | 1 + tests/build-gating-alternatives.fmf | 31 ++++++++++++++++ tests/build-gating.fmf | 47 +++++++++++++++++++++++++ tests/integration-test-suite/runtest.sh | 38 -------------------- tests/ld-alternative/runtest.sh | 32 ----------------- tests/lit-tests/runtest.sh | 8 ----- tests/tests-ld-alternative.yml | 14 -------- tests/tests.yml | 36 ------------------- 8 files changed, 79 insertions(+), 128 deletions(-) create mode 100644 .fmf/version create mode 100644 tests/build-gating-alternatives.fmf create mode 100644 tests/build-gating.fmf delete mode 100755 tests/integration-test-suite/runtest.sh delete mode 100755 tests/ld-alternative/runtest.sh delete mode 100644 tests/lit-tests/runtest.sh delete mode 100644 tests/tests-ld-alternative.yml delete mode 100644 tests/tests.yml diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/tests/build-gating-alternatives.fmf b/tests/build-gating-alternatives.fmf new file mode 100644 index 0000000..8a798a4 --- /dev/null +++ b/tests/build-gating-alternatives.fmf @@ -0,0 +1,31 @@ +# +# Build/PR gating tests for *LLVM 13* +# +# Imports and runs tests provided by Fedora LLVM git for the matching LLVM version. +# +# NOTE: *always* keep this file in sync with upstream, i.e. Fedora. Since we cannot "discover" a plan, +# we must duplicate at least some part of upstream plan setup, like `adjust` or `provision`. Not necessarily +# all steps, but if we do need some of them here, let's focus on making changes in upstream first, to preserve +# one source of truth. Once TMT learns to include whole plans, we could drop the copied content from here. +# + +summary: LLD tests for build/PR gating, testing alternatives and spoiling the installation +adjust: + - because: "Plan to be ran when either executed locally, or executed by CI system to gate a build or PR." + when: >- + trigger is defined + and trigger != commit + and trigger != build + enabled: false + +discover: + - name: lld-upstream-tests + how: fmf + test: ld-alternative + url: https://src.fedoraproject.org/rpms/lld.git + ref: rawhide +execute: + how: tmt +provision: + hardware: + memory: ">= 4 GiB" diff --git a/tests/build-gating.fmf b/tests/build-gating.fmf new file mode 100644 index 0000000..03417e9 --- /dev/null +++ b/tests/build-gating.fmf @@ -0,0 +1,47 @@ +# +# Build/PR gating tests for *LLVM 13* +# +# Imports and runs tests provided by Fedora LLVM git for the matching LLVM version. +# +# NOTE: *always* keep this file in sync with upstream, i.e. Fedora. Since we cannot "discover" a plan, +# we must duplicate at least some part of upstream plan setup, like `adjust` or `provision`. Not necessarily +# all steps, but if we do need some of them here, let's focus on making changes in upstream first, to preserve +# one source of truth. Once TMT learns to include whole plans, we could drop the copied content from here. +# + +summary: LLD tests for build/PR gating +adjust: + - because: "Plan to be ran when either executed locally, or executed by CI system to gate a build or PR." + when: >- + trigger is defined + and trigger != commit + and trigger != build + enabled: false + + # Unfortunatelly, TMT does not support more declarative approach, we need to run commands on our own. + - because: "On RHEL, CRB must be enabled to provide rarer packages" + when: >- + distro == centos + or distro == rhel-9 + or distro == rhel-8 + prepare+: + - name: Enable CRB + how: shell + script: dnf config-manager --set-enabled rhel-CRB + +discover: + - name: lld-upstream-tests + how: fmf + filter: "tag:-spoils-installation" + url: https://src.fedoraproject.org/rpms/lld.git + ref: rawhide + - name: upstream-llvm-integration-testsuite + how: fmf + url: https://src.fedoraproject.org/rpms/llvm.git + ref: rawhide + test: integration-test-suite +execute: + how: tmt +provision: + hardware: + memory: ">= 4 GiB" diff --git a/tests/integration-test-suite/runtest.sh b/tests/integration-test-suite/runtest.sh deleted file mode 100755 index 1af4e4a..0000000 --- a/tests/integration-test-suite/runtest.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash - -usage() { - echo "usage `basename $0` [OPTIONS]" - echo " --threads NUM The number of threads to use for running tests." -} - -thread_args="" -repo_url=https://github.com/opencollab/llvm-toolchain-integration-test-suite - -while [ $# -gt 0 ]; do - case $1 in - --threads) - shift - threads="$1" - ;; - * ) - echo "unknown option: $1" - echo "" - usage - exit 1 - ;; - esac - shift -done - -if [ -n "$threads" ]; then - thread_args="-j$threads" -fi - -set -xe - -cd $(mktemp -d -p /var/tmp) -git clone $repo_url -cd llvm-toolchain-integration-test-suite -mkdir _build && cd _build -cmake .. -GNinja -ninja $thread_args check diff --git a/tests/ld-alternative/runtest.sh b/tests/ld-alternative/runtest.sh deleted file mode 100755 index b10cd94..0000000 --- a/tests/ld-alternative/runtest.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# This test assumes lld is already installed. - -set -ex - -function verify_ld_bfd { - - # Verify that /usr/bin/ld points to ld.bfd. - ls -l /etc/alternatives/ld | grep ld.bfd - - # Run ld and verify it invokes ld.bfd - /usr/bin/ld --version | grep 'GNU ld' -} - - -# Verify ld.bfd is still the system linker when lld is installed -verify_ld_bfd - -# Set lld as the system linker -update-alternatives --set ld /usr/bin/ld.lld - -# Verify that /usr/bin/ld points to lld -ls -l /etc/alternatives/ld | grep ld.lld - -# Run ld and verify it invokes lld -/usr/bin/ld --version | grep 'LLD' - -# Uninstall lld and make sure the /usr/bin/ld is reset to ld.bfd -dnf -y remove --noautoremove lld - -verify_ld_bfd diff --git a/tests/lit-tests/runtest.sh b/tests/lit-tests/runtest.sh deleted file mode 100644 index 87d1d66..0000000 --- a/tests/lit-tests/runtest.sh +++ /dev/null @@ -1,8 +0,0 @@ -set -ex - - -if ! id -u lld; then - useradd lld -fi - -su lld -c 'bash /usr/libexec/tests/lld/run-lit-tests --threads 1' diff --git a/tests/tests-ld-alternative.yml b/tests/tests-ld-alternative.yml deleted file mode 100644 index e1fe1a3..0000000 --- a/tests/tests-ld-alternative.yml +++ /dev/null @@ -1,14 +0,0 @@ -# The ld-alternative test uninstalls lld, so it needs to be run by -# itself in a separate .yml file so it doesn't modify the test -# environment for other tests. - -- hosts: localhost - roles: - - role: standard-test-basic - tags: - - classic - required_packages: - - binutils - - lld - tests: - - ld-alternative diff --git a/tests/tests.yml b/tests/tests.yml deleted file mode 100644 index c10d6f8..0000000 --- a/tests/tests.yml +++ /dev/null @@ -1,36 +0,0 @@ -- hosts: localhost - roles: - - role: standard-test-basic - tags: - - classic - required_packages: - - lld - - clang - - gcc - - lld-test - # the requirements below are for the integration suite - - cmake - - llvm-devel - - clang - - clang-analyzer - - clang-tools-extra - - compiler-rt - - ninja-build - - libcxx-devel - - libomp-devel - - python-lit - - lld - - lldb - - git - - make - - libstdc++-static - - clang-devel - tests: - - basic: - dir: ./ - run: echo "int main(){ return 0; }" | clang -x c -fuse-ld=lld - - - gcc-compat-basic: - dir: ./ - run: echo "int main(){ return 0; }" | gcc -x c -fuse-ld=lld - - - lit-tests - - integration-test-suite