From 8f9f5acc969237571789acd7ef6af89bee79c88b Mon Sep 17 00:00:00 2001 From: Milos Prchlik Date: Tue, 16 Nov 2021 12:31:23 +0100 Subject: [PATCH] tests: convert to TMT --- .fmf/version | 1 + tests/basic/main.fmf | 5 +++ tests/basic/test.sh | 3 ++ tests/build-gating-alternatives.fmf | 21 +++++++++++ tests/build-gating.fmf | 26 ++++++++++++++ tests/gcc-compat-basic/main.fmf | 5 +++ tests/gcc-compat-basic/test.sh | 3 ++ tests/integration-test-suite/runtest.sh | 38 -------------------- tests/ld-alternative/main.fmf | 8 +++++ tests/ld-alternative/{runtest.sh => test.sh} | 4 +-- tests/lit-tests/main.fmf | 6 ++++ tests/lit-tests/{runtest.sh => test.sh} | 3 +- tests/tests-ld-alternative.yml | 14 -------- tests/tests.yml | 36 ------------------- 14 files changed, 80 insertions(+), 93 deletions(-) create mode 100644 .fmf/version create mode 100644 tests/basic/main.fmf create mode 100755 tests/basic/test.sh create mode 100644 tests/build-gating-alternatives.fmf create mode 100644 tests/build-gating.fmf create mode 100644 tests/gcc-compat-basic/main.fmf create mode 100755 tests/gcc-compat-basic/test.sh delete mode 100755 tests/integration-test-suite/runtest.sh create mode 100644 tests/ld-alternative/main.fmf rename tests/ld-alternative/{runtest.sh => test.sh} (96%) create mode 100644 tests/lit-tests/main.fmf rename tests/lit-tests/{runtest.sh => test.sh} (92%) mode change 100644 => 100755 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/basic/main.fmf b/tests/basic/main.fmf new file mode 100644 index 0000000..e75cd73 --- /dev/null +++ b/tests/basic/main.fmf @@ -0,0 +1,5 @@ +summary: Test lld with clang +test: ./test.sh +require: + - lld + - clang diff --git a/tests/basic/test.sh b/tests/basic/test.sh new file mode 100755 index 0000000..2c6d046 --- /dev/null +++ b/tests/basic/test.sh @@ -0,0 +1,3 @@ +#!/bin/sh -eux + +echo "int main(){ return 0; }" | clang -x c -fuse-ld=lld - diff --git a/tests/build-gating-alternatives.fmf b/tests/build-gating-alternatives.fmf new file mode 100644 index 0000000..aff18ea --- /dev/null +++ b/tests/build-gating-alternatives.fmf @@ -0,0 +1,21 @@ +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-tests + how: fmf + test: ld-alternative +execute: + how: tmt +prepare: + - name: packages + how: install + package: lld +provision: + hardware: + memory: ">= 4 GiB" diff --git a/tests/build-gating.fmf b/tests/build-gating.fmf new file mode 100644 index 0000000..dfc0ea7 --- /dev/null +++ b/tests/build-gating.fmf @@ -0,0 +1,26 @@ +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 +discover: + - name: lld-tests + how: fmf + filter: "tag:-spoils-installation" + - name: upstream-llvm-integration-testsuite + how: fmf + url: https://src.fedoraproject.org/rpms/llvm.git + ref: rawhide + test: integration-test-suite +execute: + how: tmt +prepare: + - name: packages + how: install + package: lld +provision: + hardware: + memory: ">= 4 GiB" diff --git a/tests/gcc-compat-basic/main.fmf b/tests/gcc-compat-basic/main.fmf new file mode 100644 index 0000000..e2c19c6 --- /dev/null +++ b/tests/gcc-compat-basic/main.fmf @@ -0,0 +1,5 @@ +summary: Test lld with gcc +test: ./test.sh +require: + - lld + - gcc diff --git a/tests/gcc-compat-basic/test.sh b/tests/gcc-compat-basic/test.sh new file mode 100755 index 0000000..0cf9c51 --- /dev/null +++ b/tests/gcc-compat-basic/test.sh @@ -0,0 +1,3 @@ +#!/bin/sh -eux + +echo "int main(){ return 0; }" | gcc -x c -fuse-ld=lld - 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/main.fmf b/tests/ld-alternative/main.fmf new file mode 100644 index 0000000..af040ae --- /dev/null +++ b/tests/ld-alternative/main.fmf @@ -0,0 +1,8 @@ +summary: Test linker switching with alternatives +test: ./test.sh +# This test spoils the installation by removing lld, therefore it should be marked as such. +tag: + - spoils-installation +require: + - lld + - binutils diff --git a/tests/ld-alternative/runtest.sh b/tests/ld-alternative/test.sh similarity index 96% rename from tests/ld-alternative/runtest.sh rename to tests/ld-alternative/test.sh index b10cd94..3f646bd 100755 --- a/tests/ld-alternative/runtest.sh +++ b/tests/ld-alternative/test.sh @@ -1,9 +1,7 @@ -#!/bin/bash +#!/bin/sh -eux # This test assumes lld is already installed. -set -ex - function verify_ld_bfd { # Verify that /usr/bin/ld points to ld.bfd. diff --git a/tests/lit-tests/main.fmf b/tests/lit-tests/main.fmf new file mode 100644 index 0000000..599dee4 --- /dev/null +++ b/tests/lit-tests/main.fmf @@ -0,0 +1,6 @@ +summary: Run lld testsuite +test: ./test.sh +duration: 30m +require: + - lld + - lld-test diff --git a/tests/lit-tests/runtest.sh b/tests/lit-tests/test.sh old mode 100644 new mode 100755 similarity index 92% rename from tests/lit-tests/runtest.sh rename to tests/lit-tests/test.sh index 87d1d66..6b68588 --- a/tests/lit-tests/runtest.sh +++ b/tests/lit-tests/test.sh @@ -1,5 +1,4 @@ -set -ex - +set -eux if ! id -u lld; then useradd lld 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