From ca5c810d9a07a001d9d94252dea3ed4aecc3865a Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Fri, 2 Feb 2024 10:28:45 +0100 Subject: [PATCH 01/36] Use correct DWARF version Instead of checking for DWARF4 only we now check for DWARF5 if clang is greater or equal to version 18. Only if Fedora is less than 38 we fall back to require DWARF4. The grep in the output of `llvm-dwarfdump` could potentially match other hex numbers and now only matches the version. --- use-correct-dwarf-default/.gitignore | 2 ++ .../main.fmf | 4 +-- use-correct-dwarf-default/test.sh | 26 +++++++++++++++++++ use-dwarf4-by-default/test.sh | 7 ----- 4 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 use-correct-dwarf-default/.gitignore rename {use-dwarf4-by-default => use-correct-dwarf-default}/main.fmf (87%) create mode 100755 use-correct-dwarf-default/test.sh delete mode 100755 use-dwarf4-by-default/test.sh diff --git a/use-correct-dwarf-default/.gitignore b/use-correct-dwarf-default/.gitignore new file mode 100644 index 0000000..0acf80b --- /dev/null +++ b/use-correct-dwarf-default/.gitignore @@ -0,0 +1,2 @@ +a.out +build.log \ No newline at end of file diff --git a/use-dwarf4-by-default/main.fmf b/use-correct-dwarf-default/main.fmf similarity index 87% rename from use-dwarf4-by-default/main.fmf rename to use-correct-dwarf-default/main.fmf index 3e54df0..b20851d 100644 --- a/use-dwarf4-by-default/main.fmf +++ b/use-correct-dwarf-default/main.fmf @@ -7,8 +7,8 @@ tier: 1 component: - llvm-toolset - clang -extra-summary: /tools/clang/use-dwarf4-by-default -extra-task: /tools/clang/use-dwarf4-by-default +extra-summary: /tools/clang/use-correct-dwarf-default +extra-task: /tools/clang/use-correct-dwarf-default extra-nitrate: TC#0614134 adjust: diff --git a/use-correct-dwarf-default/test.sh b/use-correct-dwarf-default/test.sh new file mode 100755 index 0000000..ac9b23a --- /dev/null +++ b/use-correct-dwarf-default/test.sh @@ -0,0 +1,26 @@ +#!/bin/sh -eux + +# Determine correct DWARF version to use. If Clang is newer or equal to version +# 18, we want to use DWARF5 except for Fedora 38 where we still want DWARF4. + +required_dwarf_version=4 + +# Get clang version +clang_version=$(rpm -q --queryformat "%{version}" clang | grep -ioP "^[0-9]+") +if [ $clang_version -ge 18 ]; then + >&2 echo "clang is greater or equal version 18"; + required_dwarf_version=5 +fi + +if [ -e /etc/fedora-release ]; then + fedora_version=$(grep -ioP "Fedora release \K[0-9]+" /etc/fedora-release) + if [ $fedora_version -le 38 ]; then + required_dwarf_version=4 + fi +fi + +echo "int main(){ return 0; }" | clang -g -v -x c - 2> build.log +# Make sure that clang is using the expected flag to use the required DWARF version +grep -q "\-dwarf-version=$required_dwarf_version" build.log +# Inspect the binary to double check expected DWARF version +llvm-dwarfdump a.out | grep -ioP "version\s*=\s*0x000$required_dwarf_version" diff --git a/use-dwarf4-by-default/test.sh b/use-dwarf4-by-default/test.sh deleted file mode 100755 index 5da8196..0000000 --- a/use-dwarf4-by-default/test.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -eux - -echo "int main(){ return 0; }" | clang -g -v -x c - 2> build.log -# Make sure that clang is using the expected flag to use DWARF 4 -grep -q "\-dwarf-version=4" build.log -# Inspect the binary to double check expected DWARF version -llvm-dwarfdump a.out | grep -i version | grep 0x0004 From 9c62e92982e5ba23d429d8c5f2c8542cd91ee4be Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Tue, 27 Feb 2024 12:09:20 +0100 Subject: [PATCH 02/36] Move all tests to a sudbirectory --- {clang-format-diff => tests/clang-format-diff}/main.fmf | 0 {clang-format-diff => tests/clang-format-diff}/test.sh | 0 {fedora-flags => tests/fedora-flags}/hello.c | 0 {fedora-flags => tests/fedora-flags}/hello.cpp | 0 {fedora-flags => tests/fedora-flags}/main.c | 0 {fedora-flags => tests/fedora-flags}/main.cpp | 0 {fedora-flags => tests/fedora-flags}/main.fmf | 0 {fedora-flags => tests/fedora-flags}/runtest.sh | 0 .../gcc-clang-compatibility}/hello.cpp | 0 .../gcc-clang-compatibility}/main.fmf | 0 .../gcc-clang-compatibility}/test.sh | 0 {libomp => tests/libomp}/main.fmf | 0 {libomp => tests/libomp}/openmp-compile-link-test.c | 0 {libomp => tests/libomp}/runtest.sh | 0 {llvm-test-suite => tests/llvm-test-suite}/main.fmf | 0 {llvm-test-suite => tests/llvm-test-suite}/test.sh | 0 {long-double => tests/long-double}/main.fmf | 0 {long-double => tests/long-double}/runtest.sh | 0 {openmp-rpm => tests/openmp-rpm}/main.fmf | 0 {openmp-rpm => tests/openmp-rpm}/runtest.sh | 0 {openmp-rpm => tests/openmp-rpm}/test.c | 0 {openmp-rpm => tests/openmp-rpm}/test.spec | 0 {ppc64le-long-double => tests/ppc64le-long-double}/exp.c | 0 {ppc64le-long-double => tests/ppc64le-long-double}/main.fmf | 0 {ppc64le-long-double => tests/ppc64le-long-double}/parse.cpp | 0 .../ppc64le-long-double}/runtest-fedora.sh | 0 {ppc64le-long-double => tests/ppc64le-long-double}/runtest.sh | 0 {rhbz_1647130 => tests/rhbz_1647130}/main.fmf | 0 {rhbz_1647130 => tests/rhbz_1647130}/runtest.sh | 0 {rhbz_1657544 => tests/rhbz_1657544}/from_chars.cpp | 0 {rhbz_1657544 => tests/rhbz_1657544}/main.fmf | 0 {rhbz_1657544 => tests/rhbz_1657544}/runtest.sh | 0 {rhbz_2239619 => tests/rhbz_2239619}/main.fmf | 0 {rhbz_2239619 => tests/rhbz_2239619}/runtest.sh | 0 {rhbz_2239619 => tests/rhbz_2239619}/test.c | 0 {rhbz_482491 => tests/rhbz_482491}/main.fmf | 0 {rhbz_482491 => tests/rhbz_482491}/test.sh | 0 {rpmmacros => tests/rpmmacros}/main.fmf | 0 {rpmmacros => tests/rpmmacros}/runtest.sh | 0 {toolchains => tests/toolchains}/hello.c | 0 {toolchains => tests/toolchains}/hello.cpp | 0 {toolchains => tests/toolchains}/main.fmf | 0 {toolchains => tests/toolchains}/runtest.sh | 0 {ucrt64-toolchain => tests/ucrt64-toolchain}/main.fmf | 0 {ucrt64-toolchain => tests/ucrt64-toolchain}/runtest.sh | 0 {ucrt64-toolchain => tests/ucrt64-toolchain}/test.cpp | 0 .../use-correct-dwarf-default}/.gitignore | 0 .../use-correct-dwarf-default}/main.fmf | 0 .../use-correct-dwarf-default}/test.sh | 0 49 files changed, 0 insertions(+), 0 deletions(-) rename {clang-format-diff => tests/clang-format-diff}/main.fmf (100%) rename {clang-format-diff => tests/clang-format-diff}/test.sh (100%) rename {fedora-flags => tests/fedora-flags}/hello.c (100%) rename {fedora-flags => tests/fedora-flags}/hello.cpp (100%) rename {fedora-flags => tests/fedora-flags}/main.c (100%) rename {fedora-flags => tests/fedora-flags}/main.cpp (100%) rename {fedora-flags => tests/fedora-flags}/main.fmf (100%) rename {fedora-flags => tests/fedora-flags}/runtest.sh (100%) rename {gcc-clang-compatibility => tests/gcc-clang-compatibility}/hello.cpp (100%) rename {gcc-clang-compatibility => tests/gcc-clang-compatibility}/main.fmf (100%) rename {gcc-clang-compatibility => tests/gcc-clang-compatibility}/test.sh (100%) rename {libomp => tests/libomp}/main.fmf (100%) rename {libomp => tests/libomp}/openmp-compile-link-test.c (100%) rename {libomp => tests/libomp}/runtest.sh (100%) rename {llvm-test-suite => tests/llvm-test-suite}/main.fmf (100%) rename {llvm-test-suite => tests/llvm-test-suite}/test.sh (100%) rename {long-double => tests/long-double}/main.fmf (100%) rename {long-double => tests/long-double}/runtest.sh (100%) rename {openmp-rpm => tests/openmp-rpm}/main.fmf (100%) rename {openmp-rpm => tests/openmp-rpm}/runtest.sh (100%) rename {openmp-rpm => tests/openmp-rpm}/test.c (100%) rename {openmp-rpm => tests/openmp-rpm}/test.spec (100%) rename {ppc64le-long-double => tests/ppc64le-long-double}/exp.c (100%) rename {ppc64le-long-double => tests/ppc64le-long-double}/main.fmf (100%) rename {ppc64le-long-double => tests/ppc64le-long-double}/parse.cpp (100%) rename {ppc64le-long-double => tests/ppc64le-long-double}/runtest-fedora.sh (100%) rename {ppc64le-long-double => tests/ppc64le-long-double}/runtest.sh (100%) rename {rhbz_1647130 => tests/rhbz_1647130}/main.fmf (100%) rename {rhbz_1647130 => tests/rhbz_1647130}/runtest.sh (100%) rename {rhbz_1657544 => tests/rhbz_1657544}/from_chars.cpp (100%) rename {rhbz_1657544 => tests/rhbz_1657544}/main.fmf (100%) rename {rhbz_1657544 => tests/rhbz_1657544}/runtest.sh (100%) rename {rhbz_2239619 => tests/rhbz_2239619}/main.fmf (100%) rename {rhbz_2239619 => tests/rhbz_2239619}/runtest.sh (100%) rename {rhbz_2239619 => tests/rhbz_2239619}/test.c (100%) rename {rhbz_482491 => tests/rhbz_482491}/main.fmf (100%) rename {rhbz_482491 => tests/rhbz_482491}/test.sh (100%) rename {rpmmacros => tests/rpmmacros}/main.fmf (100%) rename {rpmmacros => tests/rpmmacros}/runtest.sh (100%) rename {toolchains => tests/toolchains}/hello.c (100%) rename {toolchains => tests/toolchains}/hello.cpp (100%) rename {toolchains => tests/toolchains}/main.fmf (100%) rename {toolchains => tests/toolchains}/runtest.sh (100%) rename {ucrt64-toolchain => tests/ucrt64-toolchain}/main.fmf (100%) rename {ucrt64-toolchain => tests/ucrt64-toolchain}/runtest.sh (100%) rename {ucrt64-toolchain => tests/ucrt64-toolchain}/test.cpp (100%) rename {use-correct-dwarf-default => tests/use-correct-dwarf-default}/.gitignore (100%) rename {use-correct-dwarf-default => tests/use-correct-dwarf-default}/main.fmf (100%) rename {use-correct-dwarf-default => tests/use-correct-dwarf-default}/test.sh (100%) diff --git a/clang-format-diff/main.fmf b/tests/clang-format-diff/main.fmf similarity index 100% rename from clang-format-diff/main.fmf rename to tests/clang-format-diff/main.fmf diff --git a/clang-format-diff/test.sh b/tests/clang-format-diff/test.sh similarity index 100% rename from clang-format-diff/test.sh rename to tests/clang-format-diff/test.sh diff --git a/fedora-flags/hello.c b/tests/fedora-flags/hello.c similarity index 100% rename from fedora-flags/hello.c rename to tests/fedora-flags/hello.c diff --git a/fedora-flags/hello.cpp b/tests/fedora-flags/hello.cpp similarity index 100% rename from fedora-flags/hello.cpp rename to tests/fedora-flags/hello.cpp diff --git a/fedora-flags/main.c b/tests/fedora-flags/main.c similarity index 100% rename from fedora-flags/main.c rename to tests/fedora-flags/main.c diff --git a/fedora-flags/main.cpp b/tests/fedora-flags/main.cpp similarity index 100% rename from fedora-flags/main.cpp rename to tests/fedora-flags/main.cpp diff --git a/fedora-flags/main.fmf b/tests/fedora-flags/main.fmf similarity index 100% rename from fedora-flags/main.fmf rename to tests/fedora-flags/main.fmf diff --git a/fedora-flags/runtest.sh b/tests/fedora-flags/runtest.sh similarity index 100% rename from fedora-flags/runtest.sh rename to tests/fedora-flags/runtest.sh diff --git a/gcc-clang-compatibility/hello.cpp b/tests/gcc-clang-compatibility/hello.cpp similarity index 100% rename from gcc-clang-compatibility/hello.cpp rename to tests/gcc-clang-compatibility/hello.cpp diff --git a/gcc-clang-compatibility/main.fmf b/tests/gcc-clang-compatibility/main.fmf similarity index 100% rename from gcc-clang-compatibility/main.fmf rename to tests/gcc-clang-compatibility/main.fmf diff --git a/gcc-clang-compatibility/test.sh b/tests/gcc-clang-compatibility/test.sh similarity index 100% rename from gcc-clang-compatibility/test.sh rename to tests/gcc-clang-compatibility/test.sh diff --git a/libomp/main.fmf b/tests/libomp/main.fmf similarity index 100% rename from libomp/main.fmf rename to tests/libomp/main.fmf diff --git a/libomp/openmp-compile-link-test.c b/tests/libomp/openmp-compile-link-test.c similarity index 100% rename from libomp/openmp-compile-link-test.c rename to tests/libomp/openmp-compile-link-test.c diff --git a/libomp/runtest.sh b/tests/libomp/runtest.sh similarity index 100% rename from libomp/runtest.sh rename to tests/libomp/runtest.sh diff --git a/llvm-test-suite/main.fmf b/tests/llvm-test-suite/main.fmf similarity index 100% rename from llvm-test-suite/main.fmf rename to tests/llvm-test-suite/main.fmf diff --git a/llvm-test-suite/test.sh b/tests/llvm-test-suite/test.sh similarity index 100% rename from llvm-test-suite/test.sh rename to tests/llvm-test-suite/test.sh diff --git a/long-double/main.fmf b/tests/long-double/main.fmf similarity index 100% rename from long-double/main.fmf rename to tests/long-double/main.fmf diff --git a/long-double/runtest.sh b/tests/long-double/runtest.sh similarity index 100% rename from long-double/runtest.sh rename to tests/long-double/runtest.sh diff --git a/openmp-rpm/main.fmf b/tests/openmp-rpm/main.fmf similarity index 100% rename from openmp-rpm/main.fmf rename to tests/openmp-rpm/main.fmf diff --git a/openmp-rpm/runtest.sh b/tests/openmp-rpm/runtest.sh similarity index 100% rename from openmp-rpm/runtest.sh rename to tests/openmp-rpm/runtest.sh diff --git a/openmp-rpm/test.c b/tests/openmp-rpm/test.c similarity index 100% rename from openmp-rpm/test.c rename to tests/openmp-rpm/test.c diff --git a/openmp-rpm/test.spec b/tests/openmp-rpm/test.spec similarity index 100% rename from openmp-rpm/test.spec rename to tests/openmp-rpm/test.spec diff --git a/ppc64le-long-double/exp.c b/tests/ppc64le-long-double/exp.c similarity index 100% rename from ppc64le-long-double/exp.c rename to tests/ppc64le-long-double/exp.c diff --git a/ppc64le-long-double/main.fmf b/tests/ppc64le-long-double/main.fmf similarity index 100% rename from ppc64le-long-double/main.fmf rename to tests/ppc64le-long-double/main.fmf diff --git a/ppc64le-long-double/parse.cpp b/tests/ppc64le-long-double/parse.cpp similarity index 100% rename from ppc64le-long-double/parse.cpp rename to tests/ppc64le-long-double/parse.cpp diff --git a/ppc64le-long-double/runtest-fedora.sh b/tests/ppc64le-long-double/runtest-fedora.sh similarity index 100% rename from ppc64le-long-double/runtest-fedora.sh rename to tests/ppc64le-long-double/runtest-fedora.sh diff --git a/ppc64le-long-double/runtest.sh b/tests/ppc64le-long-double/runtest.sh similarity index 100% rename from ppc64le-long-double/runtest.sh rename to tests/ppc64le-long-double/runtest.sh diff --git a/rhbz_1647130/main.fmf b/tests/rhbz_1647130/main.fmf similarity index 100% rename from rhbz_1647130/main.fmf rename to tests/rhbz_1647130/main.fmf diff --git a/rhbz_1647130/runtest.sh b/tests/rhbz_1647130/runtest.sh similarity index 100% rename from rhbz_1647130/runtest.sh rename to tests/rhbz_1647130/runtest.sh diff --git a/rhbz_1657544/from_chars.cpp b/tests/rhbz_1657544/from_chars.cpp similarity index 100% rename from rhbz_1657544/from_chars.cpp rename to tests/rhbz_1657544/from_chars.cpp diff --git a/rhbz_1657544/main.fmf b/tests/rhbz_1657544/main.fmf similarity index 100% rename from rhbz_1657544/main.fmf rename to tests/rhbz_1657544/main.fmf diff --git a/rhbz_1657544/runtest.sh b/tests/rhbz_1657544/runtest.sh similarity index 100% rename from rhbz_1657544/runtest.sh rename to tests/rhbz_1657544/runtest.sh diff --git a/rhbz_2239619/main.fmf b/tests/rhbz_2239619/main.fmf similarity index 100% rename from rhbz_2239619/main.fmf rename to tests/rhbz_2239619/main.fmf diff --git a/rhbz_2239619/runtest.sh b/tests/rhbz_2239619/runtest.sh similarity index 100% rename from rhbz_2239619/runtest.sh rename to tests/rhbz_2239619/runtest.sh diff --git a/rhbz_2239619/test.c b/tests/rhbz_2239619/test.c similarity index 100% rename from rhbz_2239619/test.c rename to tests/rhbz_2239619/test.c diff --git a/rhbz_482491/main.fmf b/tests/rhbz_482491/main.fmf similarity index 100% rename from rhbz_482491/main.fmf rename to tests/rhbz_482491/main.fmf diff --git a/rhbz_482491/test.sh b/tests/rhbz_482491/test.sh similarity index 100% rename from rhbz_482491/test.sh rename to tests/rhbz_482491/test.sh diff --git a/rpmmacros/main.fmf b/tests/rpmmacros/main.fmf similarity index 100% rename from rpmmacros/main.fmf rename to tests/rpmmacros/main.fmf diff --git a/rpmmacros/runtest.sh b/tests/rpmmacros/runtest.sh similarity index 100% rename from rpmmacros/runtest.sh rename to tests/rpmmacros/runtest.sh diff --git a/toolchains/hello.c b/tests/toolchains/hello.c similarity index 100% rename from toolchains/hello.c rename to tests/toolchains/hello.c diff --git a/toolchains/hello.cpp b/tests/toolchains/hello.cpp similarity index 100% rename from toolchains/hello.cpp rename to tests/toolchains/hello.cpp diff --git a/toolchains/main.fmf b/tests/toolchains/main.fmf similarity index 100% rename from toolchains/main.fmf rename to tests/toolchains/main.fmf diff --git a/toolchains/runtest.sh b/tests/toolchains/runtest.sh similarity index 100% rename from toolchains/runtest.sh rename to tests/toolchains/runtest.sh diff --git a/ucrt64-toolchain/main.fmf b/tests/ucrt64-toolchain/main.fmf similarity index 100% rename from ucrt64-toolchain/main.fmf rename to tests/ucrt64-toolchain/main.fmf diff --git a/ucrt64-toolchain/runtest.sh b/tests/ucrt64-toolchain/runtest.sh similarity index 100% rename from ucrt64-toolchain/runtest.sh rename to tests/ucrt64-toolchain/runtest.sh diff --git a/ucrt64-toolchain/test.cpp b/tests/ucrt64-toolchain/test.cpp similarity index 100% rename from ucrt64-toolchain/test.cpp rename to tests/ucrt64-toolchain/test.cpp diff --git a/use-correct-dwarf-default/.gitignore b/tests/use-correct-dwarf-default/.gitignore similarity index 100% rename from use-correct-dwarf-default/.gitignore rename to tests/use-correct-dwarf-default/.gitignore diff --git a/use-correct-dwarf-default/main.fmf b/tests/use-correct-dwarf-default/main.fmf similarity index 100% rename from use-correct-dwarf-default/main.fmf rename to tests/use-correct-dwarf-default/main.fmf diff --git a/use-correct-dwarf-default/test.sh b/tests/use-correct-dwarf-default/test.sh similarity index 100% rename from use-correct-dwarf-default/test.sh rename to tests/use-correct-dwarf-default/test.sh From 598eead7e173bcb05a0905fc06d1444aa25f8e92 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Tue, 27 Feb 2024 13:47:37 +0100 Subject: [PATCH 03/36] Gather common metadata under a parent main.fmf Metadata common to all tests include component, contact, framework, test script and frequent required packages. Normalized script names to 'runtest.sh'. --- tests/clang-format-diff/main.fmf | 15 +++---- .../clang-format-diff/{test.sh => runtest.sh} | 0 tests/fedora-flags/main.fmf | 26 +---------- tests/gcc-clang-compatibility/main.fmf | 23 +--------- .../{test.sh => runtest.sh} | 0 tests/libomp/main.fmf | 10 +---- tests/llvm-test-suite/main.fmf | 6 +-- tests/llvm-test-suite/{test.sh => runtest.sh} | 0 tests/long-double/main.fmf | 26 +---------- tests/main.fmf | 45 +++++++++++++++++++ tests/openmp-rpm/main.fmf | 9 +--- tests/ppc64le-long-double/main.fmf | 28 ++---------- tests/rhbz_1647130/main.fmf | 12 +---- tests/rhbz_1657544/main.fmf | 23 ---------- tests/rhbz_2239619/main.fmf | 23 ---------- tests/rhbz_482491/main.fmf | 25 +---------- tests/rhbz_482491/{test.sh => runtest.sh} | 0 tests/rpmmacros/main.fmf | 6 +-- tests/toolchains/main.fmf | 12 ++--- tests/ucrt64-toolchain/main.fmf | 8 +--- tests/use-correct-dwarf-default/main.fmf | 9 +--- .../{test.sh => runtest.sh} | 0 22 files changed, 76 insertions(+), 230 deletions(-) rename tests/clang-format-diff/{test.sh => runtest.sh} (100%) rename tests/gcc-clang-compatibility/{test.sh => runtest.sh} (100%) rename tests/llvm-test-suite/{test.sh => runtest.sh} (100%) create mode 100644 tests/main.fmf rename tests/rhbz_482491/{test.sh => runtest.sh} (100%) rename tests/use-correct-dwarf-default/{test.sh => runtest.sh} (100%) diff --git a/tests/clang-format-diff/main.fmf b/tests/clang-format-diff/main.fmf index 15f4b9f..0fdeb7d 100644 --- a/tests/clang-format-diff/main.fmf +++ b/tests/clang-format-diff/main.fmf @@ -1,27 +1,22 @@ summary: clang-format-diff -test: "$WITH_SCL ./test.sh" -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/clang-format-diff extra-task: /tools/clang/clang-format-diff extra-nitrate: TC#0614126 -adjust: +adjust+: # Common requirements when LLVM is not SCL-ized - - require: + - require+: - clang-tools-extra when: "collection is not defined" # Requirements for SCL-ized LLVM - - require: + - require+: - llvm-toolset-13.0-clang-tools-extra when: "collection == llvm-toolset-13.0" - - require: + - require+: - llvm-toolset-14.0-clang-tools-extra when: "collection == llvm-toolset-14.0" - - require: + - require+: - llvm-toolset-15.0-clang-tools-extra when: "collection == llvm-toolset-15.0" diff --git a/tests/clang-format-diff/test.sh b/tests/clang-format-diff/runtest.sh similarity index 100% rename from tests/clang-format-diff/test.sh rename to tests/clang-format-diff/runtest.sh diff --git a/tests/fedora-flags/main.fmf b/tests/fedora-flags/main.fmf index f2ce847..5ee3879 100644 --- a/tests/fedora-flags/main.fmf +++ b/tests/fedora-flags/main.fmf @@ -1,34 +1,12 @@ summary: fedora-flags -test: "$WITH_SCL ./runtest.sh" -require: +require+: - redhat-rpm-config -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/fedora-flags extra-task: /tools/clang/fedora-flags extra-nitrate: TC#0614127 -adjust: - - # Common requirements when LLVM is not SCL-ized - - require+: - - clang - when: "collection is not defined" - - # Requirements for SCL-ized LLVM - - require+: - - llvm-toolset-13.0-clang - when: "collection == llvm-toolset-13.0" - - require+: - - llvm-toolset-14.0-clang - when: "collection == llvm-toolset-14.0" - - require+: - - llvm-toolset-15.0-clang - when: "collection == llvm-toolset-15.0" - +adjust+: - because: s390x does not have epel repo which is required to provide rpm macros enabled: false when: >- diff --git a/tests/gcc-clang-compatibility/main.fmf b/tests/gcc-clang-compatibility/main.fmf index b880df5..6a29a8a 100644 --- a/tests/gcc-clang-compatibility/main.fmf +++ b/tests/gcc-clang-compatibility/main.fmf @@ -2,30 +2,9 @@ summary: Test that both gcc/clang compile/link compatibility. description: Build an object file with g++, link it with clang++ and viceversa, to ensure that objects compiled with one can be linked with the other. -test: "$WITH_SCL ./test.sh" -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/gcc-clang-compatibility extra-task: /tools/clang/gcc-clang-compatibility -require: +require+: - gcc-c++ - -adjust: - - require+: - - clang - when: collection is not defined - - # Requirements for SCL-ized LLVM - - require+: - - llvm-toolset-13.0-clang - when: "collection == llvm-toolset-13.0" - - require+: - - llvm-toolset-14.0-clang - when: "collection == llvm-toolset-14.0" - - require+: - - llvm-toolset-15.0-clang - when: "collection == llvm-toolset-15.0" diff --git a/tests/gcc-clang-compatibility/test.sh b/tests/gcc-clang-compatibility/runtest.sh similarity index 100% rename from tests/gcc-clang-compatibility/test.sh rename to tests/gcc-clang-compatibility/runtest.sh diff --git a/tests/libomp/main.fmf b/tests/libomp/main.fmf index 62c7973..04d49f9 100644 --- a/tests/libomp/main.fmf +++ b/tests/libomp/main.fmf @@ -1,23 +1,17 @@ # The point of this test is to ensure that clang/clang-libs demand the correct # libomp packages, and is able to use openmp headers and libraries summary: test clang can find libomp header and libraries -test: "$WITH_SCL ./runtest.sh" -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/libomp extra-task: /tools/clang/libomp extra-nitrate: TC#0614137 -require: - - clang +require+: - clang-libs - libomp - libomp-devel -adjust: +adjust+: - because: "libomp is not supported in s390x" when: arch == s390x enabled: false diff --git a/tests/llvm-test-suite/main.fmf b/tests/llvm-test-suite/main.fmf index 7d61dfb..e084bd1 100644 --- a/tests/llvm-test-suite/main.fmf +++ b/tests/llvm-test-suite/main.fmf @@ -1,16 +1,14 @@ # TODO: once llvm-test-suite is converted to TMT, we can just link the test from plan. summary: Run tests from llvm-test-suite package -adjust: +adjust+: - because: "llvm-test-suite is available for Fedora, not RHEL/CentOS" when: >- distro == rhel or distro == centos enabled: false -test: "$WITH_SCL ./test.sh" - -require: +require+: - git - clang - ninja-build diff --git a/tests/llvm-test-suite/test.sh b/tests/llvm-test-suite/runtest.sh similarity index 100% rename from tests/llvm-test-suite/test.sh rename to tests/llvm-test-suite/runtest.sh diff --git a/tests/long-double/main.fmf b/tests/long-double/main.fmf index 71b2b42..21c9acb 100644 --- a/tests/long-double/main.fmf +++ b/tests/long-double/main.fmf @@ -1,33 +1,11 @@ summary: Test that gcc and clang use the same long double format -test: $WITH_SCL ./runtest.sh duration: 5m -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/long-double extra-task: /tools/clang/long-double extra-nitrate: TC#0614593 -adjust: - # Common requirements when LLVM is not SCL-ized - - require+: - - clang - when: "collection is not defined" +require+: + - gcc - - require+: - - gcc - when: distro != fedora - - # Requirements for SCL-ized LLVM - - require+: - - llvm-toolset-13.0-clang - when: "collection == llvm-toolset-13.0" - - require+: - - llvm-toolset-14.0-clang - when: "collection == llvm-toolset-14.0" - - require+: - - llvm-toolset-15.0-clang - when: "collection == llvm-toolset-15.0" id: 4096a1bb-d2a5-4aeb-b14d-fc465c293e32 diff --git a/tests/main.fmf b/tests/main.fmf new file mode 100644 index 0000000..9b52720 --- /dev/null +++ b/tests/main.fmf @@ -0,0 +1,45 @@ +# Common configuration for all the tests in this repo +# All the tmt tests under this directory inherit the settings from this file +component: + - llvm-toolset + - clang + +# Default QA contact. If more are relevant use 'contact+:' in each test metadata. +contact: + - Jesus Checa Hidalgo + +# All tests are shell by default. If a specific test uses another framework +# such as beakerlib, define "framework: beakerlib" in the test's main.fmf +framework: shell + +# Always define "test" key and override in adjust or in each specific test +# metadata if needed. +test: ./runtest.sh + +# Commonly used keys are initialized to empty. +require: [] +link: [] +tag: [] + +adjust+: + # Common requirements when LLVM is not SCL-ized + - require+: + - clang + when: collection is not defined + + # Requirements for SCL-ized LLVM + # We need to override the test key to do the proper scl call + - test: scl enable llvm-toolset-13.0 -- ./runtest.sh + require+: + - llvm-toolset-13.0-clang + when: collection == llvm-toolset-13.0 + + - test: scl enable llvm-toolset-14.0 -- ./runtest.sh + require+: + - llvm-toolset-14.0-clang + when: collection == llvm-toolset-14.0 + + - test: scl enable llvm-toolset-15.0 -- ./runtest.sh + require+: + - llvm-toolset-15.0-clang + when: collection == llvm-toolset-15.0 diff --git a/tests/openmp-rpm/main.fmf b/tests/openmp-rpm/main.fmf index e899916..3a41ad5 100644 --- a/tests/openmp-rpm/main.fmf +++ b/tests/openmp-rpm/main.fmf @@ -1,17 +1,12 @@ summary: Test build a simple RPM package to ensure that -fopenmp works -test: "$WITH_SCL ./runtest.sh" -require: +require+: - rpm-build -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/openmp-rpm extra-task: /tools/clang/openmp-rpm extra-nitrate: TC#0614128 -adjust: +adjust+: - because: "libomp not supported in s390x" when: arch == s390x enabled: false diff --git a/tests/ppc64le-long-double/main.fmf b/tests/ppc64le-long-double/main.fmf index cd4e68f..9cadea0 100644 --- a/tests/ppc64le-long-double/main.fmf +++ b/tests/ppc64le-long-double/main.fmf @@ -1,21 +1,11 @@ summary: Test binary compatibility of the long double format on ppc64le -test: $WITH_SCL ./runtest.sh duration: 1h -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/ppc64le-long-double extra-task: /tools/clang/ppc64le-long-double extra-nitrate: TC#0614129 -adjust: - # Common requirements when LLVM is not SCL-ized - - require+: - - clang - when: "collection is not defined" - +adjust+: - because: "Fedora CI runs in x86_64 only, emulate with qemu and mock" require+: - qemu-user-static @@ -29,19 +19,9 @@ adjust: - because: "glibc in RHEL older than 9 don't support IEEE 128bit doubles" enabled: false - when: distro < rhel-9 + when: distro < rhel-9 or distro < centos-stream-9 - - require+: + - because: "The test runs natively on RHEL so get gcc to build" + require+: - gcc when: distro != fedora - - # Requirements for SCL-ized LLVM - - require+: - - llvm-toolset-13.0-clang - when: "collection == llvm-toolset-13.0" - - require+: - - llvm-toolset-14.0-clang - when: "collection == llvm-toolset-14.0" - - require+: - - llvm-toolset-15.0-clang - when: "collection == llvm-toolset-15.0" diff --git a/tests/rhbz_1647130/main.fmf b/tests/rhbz_1647130/main.fmf index ea2d70d..c7252a0 100644 --- a/tests/rhbz_1647130/main.fmf +++ b/tests/rhbz_1647130/main.fmf @@ -1,32 +1,22 @@ summary: RHBZ1647130 -test: "$WITH_SCL ./runtest.sh" -require: [] -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/rhbz_167130 extra-task: /tools/clang/rhbz_167130 extra-nitrate: TC#0614130 -adjust: +adjust+: # Common requirements when LLVM is not SCL-ized - require+: - - clang - clang-analyzer when: "collection is not defined" # Requirements for SCL-ized LLVM - require+: - - llvm-toolset-13.0-clang - llvm-toolset-13.0-clang-analyzer when: "collection == llvm-toolset-13.0" - require+: - - llvm-toolset-14.0-clang - llvm-toolset-14.0-clang-analyzer when: "collection == llvm-toolset-14.0" - require+: - - llvm-toolset-15.0-clang - llvm-toolset-15.0-clang-analyzer when: "collection == llvm-toolset-15.0" diff --git a/tests/rhbz_1657544/main.fmf b/tests/rhbz_1657544/main.fmf index 0b6ab59..b947c0e 100644 --- a/tests/rhbz_1657544/main.fmf +++ b/tests/rhbz_1657544/main.fmf @@ -1,28 +1,5 @@ summary: RHBZ1657544 -test: "$WITH_SCL ./runtest.sh" -require: [] -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/rhbz_165744 extra-task: /tools/clang/rhbz_165744 extra-nitrate: TC#0614131 - -adjust: - # Common requirements when LLVM is not SCL-ized - - require+: - - clang - when: "collection is not defined" - - # Requirements for SCL-ized LLVM - - require+: - - llvm-toolset-13.0-clang - when: "collection == llvm-toolset-13.0" - - require+: - - llvm-toolset-14.0-clang - when: "collection == llvm-toolset-14.0" - - require+: - - llvm-toolset-15.0-clang - when: "collection == llvm-toolset-15.0" diff --git a/tests/rhbz_2239619/main.fmf b/tests/rhbz_2239619/main.fmf index e0c5e69..dd5c972 100644 --- a/tests/rhbz_2239619/main.fmf +++ b/tests/rhbz_2239619/main.fmf @@ -1,25 +1,2 @@ summary: Test if debug information is disabled by default -test: "$WITH_SCL ./runtest.sh" -require: [] -framework: shell tier: 1 -component: - - llvm-toolset - - clang - -adjust: - # Common requirements when LLVM is not SCL-ized - - require+: - - clang - when: "collection is not defined" - - # Requirements for SCL-ized LLVM - - require+: - - llvm-toolset-13.0-clang - when: "collection == llvm-toolset-13.0" - - require+: - - llvm-toolset-14.0-clang - when: "collection == llvm-toolset-14.0" - - require+: - - llvm-toolset-15.0-clang - when: "collection == llvm-toolset-15.0" diff --git a/tests/rhbz_482491/main.fmf b/tests/rhbz_482491/main.fmf index 6a3fa23..7f567a3 100644 --- a/tests/rhbz_482491/main.fmf +++ b/tests/rhbz_482491/main.fmf @@ -1,14 +1,9 @@ summary: rhbz-482491 description: | "Test that clang is able to find the right libgcc_s" -test: "$WITH_SCL ./test.sh" -require: +require+: - libgcc -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/rhbz_482194 extra-task: /tools/clang/rhbz_482194 extra-nitrate: TC#0614132 @@ -16,24 +11,8 @@ extra-nitrate: TC#0614132 link: - relates: https://bugzilla.redhat.com/show_bug.cgi?id=1482491 -adjust: +adjust+: # gcc-x86_64-linux-gnu is not available in RHEL - require+: - gcc-x86_64-linux-gnu when: "distro == fedora" - - # Common requirements when LLVM is not SCL-ized - - require+: - - clang - when: "collection is not defined" - - # Requirements for SCL-ized LLVM - - require+: - - llvm-toolset-13.0-clang - when: "collection == llvm-toolset-13.0" - - require+: - - llvm-toolset-14.0-clang - when: "collection == llvm-toolset-14.0" - - require+: - - llvm-toolset-15.0-clang - when: "collection == llvm-toolset-15.0" diff --git a/tests/rhbz_482491/test.sh b/tests/rhbz_482491/runtest.sh similarity index 100% rename from tests/rhbz_482491/test.sh rename to tests/rhbz_482491/runtest.sh diff --git a/tests/rpmmacros/main.fmf b/tests/rpmmacros/main.fmf index 265b158..7dc9d57 100644 --- a/tests/rpmmacros/main.fmf +++ b/tests/rpmmacros/main.fmf @@ -1,10 +1,6 @@ summary: Test if RPM macros are properly set -test: "./runtest.sh" -framework: shell tier: 1 -component: - - clang -require: +require+: - clang - clang-devel extra-summary: /tools/clang/rpmmacros diff --git a/tests/toolchains/main.fmf b/tests/toolchains/main.fmf index 5ce7fb6..ec80616 100644 --- a/tests/toolchains/main.fmf +++ b/tests/toolchains/main.fmf @@ -1,21 +1,15 @@ -# TODO REVIEW: better summary -summary: "" -test: "$WITH_SCL ./runtest.sh" -require: +summary: "Test integration between clang, compiler-rt and lld" +require+: - glibc-static - yum-utils # This require EPEL/CRB to be enabled on RHEL - libstdc++-static -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/toolchains extra-task: /tools/clang/toolchains extra-nitrate: TC#0614133 -adjust: +adjust+: # Common requirements when LLVM is not SCL-ized - require+: - clang diff --git a/tests/ucrt64-toolchain/main.fmf b/tests/ucrt64-toolchain/main.fmf index bd31699..18c9f22 100644 --- a/tests/ucrt64-toolchain/main.fmf +++ b/tests/ucrt64-toolchain/main.fmf @@ -1,12 +1,8 @@ summary: Test that ucrt64 toolchain is detected -test: ./runtest.sh -component: - - clang -require: - - clang +require+: - ucrt64-gcc-c++ -adjust: +adjust+: - enabled: false when: distro != fedora or distro < fedora-37 because: "The ucrt64 toolchain is only available since Fedora 37" diff --git a/tests/use-correct-dwarf-default/main.fmf b/tests/use-correct-dwarf-default/main.fmf index b20851d..da1ab93 100644 --- a/tests/use-correct-dwarf-default/main.fmf +++ b/tests/use-correct-dwarf-default/main.fmf @@ -1,17 +1,12 @@ summary: Test that clang uses DWARFv4 by default -test: "$WITH_SCL ./test.sh" -require: +require+: - libgcc -framework: shell tier: 1 -component: - - llvm-toolset - - clang extra-summary: /tools/clang/use-correct-dwarf-default extra-task: /tools/clang/use-correct-dwarf-default extra-nitrate: TC#0614134 -adjust: +adjust+: # Common requirements when LLVM is not SCL-ized - require+: - clang diff --git a/tests/use-correct-dwarf-default/test.sh b/tests/use-correct-dwarf-default/runtest.sh similarity index 100% rename from tests/use-correct-dwarf-default/test.sh rename to tests/use-correct-dwarf-default/runtest.sh From 77be13cc412ac07fc735302d64ca3d85fcc3fc55 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Thu, 29 Feb 2024 16:24:39 +0100 Subject: [PATCH 04/36] Update build-gating plan Collection adjustments no longer needed. Setup CRB in RHEL to take care of AWS/Beaker repo naming. Add discover setup for llvm-test-suite --- build-gating.fmf => plans/build-gating.fmf | 26 ++++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) rename build-gating.fmf => plans/build-gating.fmf (65%) diff --git a/build-gating.fmf b/plans/build-gating.fmf similarity index 65% rename from build-gating.fmf rename to plans/build-gating.fmf index 59192a1..419cced 100644 --- a/build-gating.fmf +++ b/plans/build-gating.fmf @@ -19,28 +19,14 @@ adjust: and trigger != build enabled: false - - because: "When testing SCL-ized LLVM, the collection must be enabled first" - environment+: - WITH_SCL: "scl enable llvm-toolset-13.0" - when: "collection == llvm-toolset-13.0" - - because: "When testing SCL-ized LLVM, the collection must be enabled first" - environment+: - WITH_SCL: "scl enable llvm-toolset-14.0" - when: "collection == llvm-toolset-14.0" - - because: "When testing SCL-ized LLVM, the collection must be enabled first" - environment+: - WITH_SCL: "scl enable llvm-toolset-15.0" - when: "collection == llvm-toolset-15.0" - # Unfortunately, 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" + - because: "On RHEL-8+, CRB must be enabled to provide rarer packages" prepare+: - name: Enable CRB how: shell - script: dnf config-manager --set-enabled rhel-CRB + script: dnf config-manager --set-enabled *-CRB when: >- - distro == rhel-9 - or distro == rhel-8 + distro == rhel and distro >= rhel-8 # Unfortunately, TMT does not support more declarative approach, we need to run commands on our own. - because: "On CentOS, CRB must be enabled to provide rarer packages" @@ -55,6 +41,12 @@ discover: - name: clang-tests how: fmf filter: "tag:-not-in-default" + # TODO uncomment when https://src.fedoraproject.org/tests/llvm-test-suite/pull-request/10 is merged + # - name: llvm-test-suite + # how: fmf + # url: https://src.fedoraproject.org/tests/llvm-test-suite.git + # ref: main + # test: test-suite - name: upstream-llvm-integration-testsuite how: fmf url: https://src.fedoraproject.org/tests/llvm.git From defae036115551f9119e02669c71418ed66a7e9f Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Thu, 7 Mar 2024 09:37:32 +0100 Subject: [PATCH 05/36] Update s390x adjustments for LLVM 18 Adjust tests to reflect libomp and lld support for s390x libomp and openmp-rpm tests need to be run in s390x for LLVM>=18 toolchains test needs to install lld package and run lld commands --- tests/libomp/main.fmf | 5 +++-- tests/openmp-rpm/main.fmf | 3 ++- tests/toolchains/main.fmf | 6 ++++-- tests/toolchains/runtest.sh | 11 +++++++++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/libomp/main.fmf b/tests/libomp/main.fmf index 04d49f9..499d11e 100644 --- a/tests/libomp/main.fmf +++ b/tests/libomp/main.fmf @@ -12,8 +12,9 @@ require+: - libomp-devel adjust+: - - because: "libomp is not supported in s390x" - when: arch == s390x + - because: "libomp is not supported in s390x in LLVM < 18" + when: > + arch == s390x and distro < rhel-9, rhel-9.5, fedora-40, centos-stream-9 enabled: false # Dependencies in rhel-7 are handled differently: there are no recommends, diff --git a/tests/openmp-rpm/main.fmf b/tests/openmp-rpm/main.fmf index 3a41ad5..44f93a9 100644 --- a/tests/openmp-rpm/main.fmf +++ b/tests/openmp-rpm/main.fmf @@ -8,7 +8,8 @@ extra-nitrate: TC#0614128 adjust+: - because: "libomp not supported in s390x" - when: arch == s390x + when: > + arch == s390x and distro < rhel-9, rhel-9.5, fedora-40, centos-stream-9 enabled: false continue: false diff --git a/tests/toolchains/main.fmf b/tests/toolchains/main.fmf index ec80616..c38a709 100644 --- a/tests/toolchains/main.fmf +++ b/tests/toolchains/main.fmf @@ -34,14 +34,16 @@ adjust+: - llvm-toolset-15.0-lld when: "collection == llvm-toolset-15.0" - # lld not supported in s390x or ppc64. If any lld package was added to + # lld not supported in s390x (LLVM<18) or ppc64. If any lld package was added to # requirements, remove it. - require-: - lld - llvm-toolset-13.0-lld - llvm-toolset-14.0-lld - llvm-toolset-15.0-lld - when: arch == s390x or arch == ppc64 + when: >- + arch == s390x and distro < rhel-9, rhel-9.5, fedora-40, centos-stream-9 + or arch == ppc64 - environment+: CXXLIBS: "libc++" diff --git a/tests/toolchains/runtest.sh b/tests/toolchains/runtest.sh index 65594e6..546d809 100755 --- a/tests/toolchains/runtest.sh +++ b/tests/toolchains/runtest.sh @@ -59,6 +59,7 @@ test_toolchain() { clang --version # Repoquery is needed instead yum info for compatibility with RHEL-7 repoquery -i --installed $(rpm -qf $(which clang)) | grep ^Source +clang_version=$(rpm -q --queryformat "%{version}" clang | grep -ioP "^[0-9]+") echo "" for compiler in clang clang++; do @@ -80,8 +81,14 @@ for compiler in clang clang++; do args="$args -pthread" fi - # lld is not supported in s390x and ppc64 - if [[ "$(uname -m)" = "s390x" || "$(uname -m)" = "ppc64" ]] \ + # lld is not supported in ppc64 + if [[ "$(uname -m)" = "ppc64" ]] && [[ "$linker" = "lld" ]]; + then + continue + fi + + # lld is supported in s390x only in LLVM >= 18 + if [[ "$(uname -m)" = "s390x" ]] && [[ $clang_version -lt 18 ]] \ && [[ "$linker" = "lld" ]]; then continue From 23bd2ee6b29eca8cb7a6dc6cebf6130b50a327b2 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Thu, 7 Mar 2024 13:29:07 +0100 Subject: [PATCH 06/36] Add libomp component metadata to relevant tests --- tests/libomp/main.fmf | 2 ++ tests/openmp-rpm/main.fmf | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/libomp/main.fmf b/tests/libomp/main.fmf index 499d11e..be7284f 100644 --- a/tests/libomp/main.fmf +++ b/tests/libomp/main.fmf @@ -5,6 +5,8 @@ tier: 1 extra-summary: /tools/clang/libomp extra-task: /tools/clang/libomp extra-nitrate: TC#0614137 +component+: + - libomp require+: - clang-libs diff --git a/tests/openmp-rpm/main.fmf b/tests/openmp-rpm/main.fmf index 44f93a9..d009f3c 100644 --- a/tests/openmp-rpm/main.fmf +++ b/tests/openmp-rpm/main.fmf @@ -5,6 +5,8 @@ tier: 1 extra-summary: /tools/clang/openmp-rpm extra-task: /tools/clang/openmp-rpm extra-nitrate: TC#0614128 +component+: + - libomp adjust+: - because: "libomp not supported in s390x" From acbe4aee52ba6e2ee89f150eff1c4fdbf2fa0226 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Thu, 7 Mar 2024 16:35:42 +0100 Subject: [PATCH 07/36] Add documentation to README.md --- README.md | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.rst | 0 2 files changed, 99 insertions(+) create mode 100644 README.md delete mode 100644 README.rst diff --git a/README.md b/README.md new file mode 100644 index 0000000..9dc5c60 --- /dev/null +++ b/README.md @@ -0,0 +1,99 @@ +# clang tests + +This repository contains tests for clang. + +## Usage +Tests are executed using TMT (Test Management Tool). The repository includes a +TMT plan that runs all the tests by default. All the tests support the following +context dimensions: +* `distro` +* `arch` +* `collection` (only applicable to RHEL 7) + +To run the tests: +```bash +# Run in the default virtual environment +tmt -c distro= -c arch= run -avv + +# Run on a scheduled system +tmt -c distro= -c arch= run -avv provision -h connect -g + +# Run specific tests +tmt -c distro= -c arch= run -avv provision -h connect -g test -n +``` + +## Adding New Tests +Please consider the following when adding new tests: +* Test scripts must be named `runtest.sh`. If a different test is needed, you need +to overwrite the `test:` key in the test `main.fmf`. +* Tests must be placed under `tests/`. Additionally they can be + placed into subdirectories if grouping make sense. E.g. + `tests/regression/`. +* This repository has a common configuration under `tests/main.fmf`, inherited + by all tests. When adding new ones, be careful not to overwrite existing keys + from the inherited `tests/main.fmf`. +* When setting FMF metadata keys, do merge values instead overwriting them. E.g. +use `require+:` instead `require:`. For advanced use and more examples check +[FMF documentation](https://fmf.readthedocs.io/en/stable/features.html#merging). + +After creating the new test, consider running `tmt tests show +` to review that the resulting metadata such as requires, enable or +test keys are as expected. For example: +``` +$ tmt -c distro=fedora-38 tests show ucrt64-toolchain +/tests/ucrt64-toolchain + summary Test that ucrt64 toolchain is detected + contact Jesus Checa Hidalgo + component 'llvm-toolset' and 'clang' + test ./runtest.sh + path /tests/ucrt64-toolchain + framework shell + manual false + tty false + require 'ucrt64-gcc-c++' and 'clang' + duration 5m + enabled true + result respect + +$ tmt -c distro=rhel-9.3 tests show ucrt64-toolchain +/tests/ucrt64-toolchain + summary Test that ucrt64 toolchain is detected + contact Jesus Checa Hidalgo + component 'llvm-toolset' and 'clang' + test ./runtest.sh + path /tests/ucrt64-toolchain + framework shell + manual false + tty false + require 'ucrt64-gcc-c++' and 'clang' + duration 5m + enabled false + result respect +``` + +### Templates +Use the following templates when creating new tests. + +FMF template. Uncomment needed fields, remove the rest. +```yaml +summary: Descriptive summary for the test +# Maximum duration for the test +duration: 2m +# Short tests should be tier <= 1 so they're used for gating. +tier: 1 +# Add an additional contact(s) if applicable +# contact+: +# - Somebody +# Additional requires +# require+: +# - rpm-build +# Adjustments based on context dimensions +# adjust+: +# - when: collection is defined +# enabled: false +# because: Test not supported in collections +# link+: +# - verifies: https://issues.redhat.com/browse/... +# tag+: +# - sometag +``` diff --git a/README.rst b/README.rst deleted file mode 100644 index e69de29..0000000 From 2b4086412b62d84d3dd985aa5355b0374208691d Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Tue, 2 Apr 2024 08:15:28 +0200 Subject: [PATCH 08/36] fix readme formatting --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9dc5c60..91a6458 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ This repository contains tests for clang. Tests are executed using TMT (Test Management Tool). The repository includes a TMT plan that runs all the tests by default. All the tests support the following context dimensions: + * `distro` * `arch` * `collection` (only applicable to RHEL 7) @@ -24,6 +25,7 @@ tmt -c distro= -c arch= run -avv provision -h connect -g `. Additionally they can be From 0d4c50b5e0ba3022cdcc928fbc9e8d56f0355a31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 26 Mar 2024 10:51:27 +0100 Subject: [PATCH 09/36] Add test to check -pie works. --- tests/pie-rpm/.gitignore | 5 +++++ tests/pie-rpm/main.fmf | 13 +++++++++++++ tests/pie-rpm/pie.c | 6 ++++++ tests/pie-rpm/pie.spec | 37 +++++++++++++++++++++++++++++++++++++ tests/pie-rpm/runtest.sh | 27 +++++++++++++++++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 tests/pie-rpm/.gitignore create mode 100644 tests/pie-rpm/main.fmf create mode 100644 tests/pie-rpm/pie.c create mode 100644 tests/pie-rpm/pie.spec create mode 100755 tests/pie-rpm/runtest.sh diff --git a/tests/pie-rpm/.gitignore b/tests/pie-rpm/.gitignore new file mode 100644 index 0000000..f9dfc4f --- /dev/null +++ b/tests/pie-rpm/.gitignore @@ -0,0 +1,5 @@ +pie +pie-static +pie-shared +pie-no-pie +pie.o diff --git a/tests/pie-rpm/main.fmf b/tests/pie-rpm/main.fmf new file mode 100644 index 0000000..c811cbb --- /dev/null +++ b/tests/pie-rpm/main.fmf @@ -0,0 +1,13 @@ +summary: Check that we build rpms with -pie +tier: 1 + +require+: + - clang + - clang-libs + - rpm-build + - glibc-static + +adjust: + - enabled: false + when: distro != fedora or distro < fedora-40 + because: "We only started doing this in Fedora 40" diff --git a/tests/pie-rpm/pie.c b/tests/pie-rpm/pie.c new file mode 100644 index 0000000..5423ce6 --- /dev/null +++ b/tests/pie-rpm/pie.c @@ -0,0 +1,6 @@ + + + +int main(int argc, char **argv) { + return 0; +} diff --git a/tests/pie-rpm/pie.spec b/tests/pie-rpm/pie.spec new file mode 100644 index 0000000..4d8b859 --- /dev/null +++ b/tests/pie-rpm/pie.spec @@ -0,0 +1,37 @@ +%global toolchain clang + +Name: pie +Version: 1 +Release: %autorelease +Summary: Check that -pie is passed. + +License: MIT +Source0: pie.c + +BuildRequires: clang + +%description +Make sure the standard configuration from redhat-rpm-config passes -pie when linking. + +%build + +LDFLAGS="${LDFLAGS} -Werror" + +clang ${CFLAGS} -c %{SOURCE0} -o %{NAME}.o + +# Regular +clang ${LDFLAGS} %{NAME}.o -o %{NAME} + +# With -shared +clang ${LDFLAGS} -shared %{NAME}.o -o %{NAME}-shared + +# With -static +clang ${LDFLAGS} -static %{NAME}.o -o %{NAME}-static + +# With -no-pie +clang ${LDFLAGS} -no-pie %{NAME}.o -o %{NAME}-no-pie + + + +%changelog +%autochangelog diff --git a/tests/pie-rpm/runtest.sh b/tests/pie-rpm/runtest.sh new file mode 100755 index 0000000..7758028 --- /dev/null +++ b/tests/pie-rpm/runtest.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -ex +set pipefail + +#${BUILDDEP_CMD} -y pie.spec + +rm -f pie{,.o} +QA_RPATHS=$(( 0x0001 )) rpmbuild -bb ./pie.spec --define '_sourcedir .' --define '_builddir .' + + if [[ "$(file ./pie)" != *"pie executable"* ]]; then + exit 1 + fi + +if [[ "$(file ./pie-shared)" == *"pie executable"* ]]; then + exit 1 +fi + +if [[ "$(file ./pie-static)" == *"pie executable"* ]]; then + exit 1 +fi + +if [[ "$(file ./pie-no-pie)" == *"pie executable"* ]]; then + exit 1 +fi + +exit 0 From f58e59b3942f6b7254f450d6ab5b934db2275d38 Mon Sep 17 00:00:00 2001 From: Tulio Magno Quites Machado Filho Date: Thu, 4 Apr 2024 09:20:18 -0300 Subject: [PATCH 10/36] Temporarily tag pie-rpm as not-in-default Filter out this test until redhat-rpm-config gets its side of the update. Otherwise, this will cause failures when building clang on Fedora and when running the daily snapshots. --- tests/pie-rpm/main.fmf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/pie-rpm/main.fmf b/tests/pie-rpm/main.fmf index c811cbb..9aa23e3 100644 --- a/tests/pie-rpm/main.fmf +++ b/tests/pie-rpm/main.fmf @@ -7,7 +7,11 @@ require+: - rpm-build - glibc-static -adjust: +# TODO: Untag this test when redhat-rpm-config is modified. +# See: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/291 +tag: not-in-default + +adjust+: - enabled: false when: distro != fedora or distro < fedora-40 because: "We only started doing this in Fedora 40" From 020d712305283a84c7a5ad66480396e1bc22ec46 Mon Sep 17 00:00:00 2001 From: Tulio Magno Quites Machado Filho Date: Mon, 15 Apr 2024 13:00:15 -0300 Subject: [PATCH 11/36] Run ppc64le-long-double natively on snapshot executions Snapshot builds are able to test natively on ppc64le despite using Fedora. This restriction only exists when running Bodhi tests. So, let ppc64le-long-double use the same test script as RHEL. --- tests/ppc64le-long-double/main.fmf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ppc64le-long-double/main.fmf b/tests/ppc64le-long-double/main.fmf index 9cadea0..c17e9b7 100644 --- a/tests/ppc64le-long-double/main.fmf +++ b/tests/ppc64le-long-double/main.fmf @@ -11,7 +11,7 @@ adjust+: - qemu-user-static - mock test: ./runtest-fedora.sh - when: distro == fedora and arch == x86_64 + when: distro == fedora and arch == x86_64 and snapshot is not defined continue: false - enabled: false @@ -24,4 +24,4 @@ adjust+: - because: "The test runs natively on RHEL so get gcc to build" require+: - gcc - when: distro != fedora + when: distro != fedora or snapshot is defined From 487364d65bb9ee06e52aa4d805055195fb42ed72 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Mon, 15 Apr 2024 16:26:20 +0200 Subject: [PATCH 12/36] Fix wrong relevancy for libomp tests libomp is supported in s390x only in Fedora, and if LLVM is 18 or newer For libomp installed from fedora repos this means Fedora >= 40, for LLVM snapshots it's enabled always. --- tests/libomp/main.fmf | 12 +++++++++--- tests/openmp-rpm/main.fmf | 11 ++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/libomp/main.fmf b/tests/libomp/main.fmf index be7284f..ccd2300 100644 --- a/tests/libomp/main.fmf +++ b/tests/libomp/main.fmf @@ -14,10 +14,16 @@ require+: - libomp-devel adjust+: - - because: "libomp is not supported in s390x in LLVM < 18" - when: > - arch == s390x and distro < rhel-9, rhel-9.5, fedora-40, centos-stream-9 + # Right now libomp in s390x is supported only in LLVM >= 18 in Fedora + # TODO until tmt allows to use custom adjusted contexts we need to do this + # indirect adjustment using the distro version. + - when: arch == s390x and distro < fedora-40 and snapshot is not defined enabled: false + continue: false + + - when: arch == s390x and distro != fedora + enabled: false + continue: false # Dependencies in rhel-7 are handled differently: there are no recommends, # only requires. diff --git a/tests/openmp-rpm/main.fmf b/tests/openmp-rpm/main.fmf index d009f3c..8443b21 100644 --- a/tests/openmp-rpm/main.fmf +++ b/tests/openmp-rpm/main.fmf @@ -9,9 +9,14 @@ component+: - libomp adjust+: - - because: "libomp not supported in s390x" - when: > - arch == s390x and distro < rhel-9, rhel-9.5, fedora-40, centos-stream-9 + # Right now libomp in s390x is supported only in LLVM >= 18 in Fedora + # TODO until tmt allows to use custom adjusted contexts we need to do this + # indirect adjustment using the distro version. + - when: arch == s390x and distro < fedora-40 and snapshot is not defined + enabled: false + continue: false + + - when: arch == s390x and distro != fedora enabled: false continue: false From 84b1265f72888efcb9683788f1c78455ac0cf005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 15 Apr 2024 10:23:08 +0200 Subject: [PATCH 13/36] Add more pie-rpm tests Make sure we also get the expected behavior when _pre_pending additional flags to $LDFLAGS --- tests/pie-rpm/pie.spec | 10 ++++++---- tests/pie-rpm/runtest.sh | 23 ++++++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/tests/pie-rpm/pie.spec b/tests/pie-rpm/pie.spec index 4d8b859..5d2913d 100644 --- a/tests/pie-rpm/pie.spec +++ b/tests/pie-rpm/pie.spec @@ -23,14 +23,16 @@ clang ${CFLAGS} -c %{SOURCE0} -o %{NAME}.o clang ${LDFLAGS} %{NAME}.o -o %{NAME} # With -shared -clang ${LDFLAGS} -shared %{NAME}.o -o %{NAME}-shared +clang ${LDFLAGS} -shared %{NAME}.o -o %{NAME}-shared-pre +clang -shared ${LDFLAGS} %{NAME}.o -o %{NAME}-shared-post # With -static -clang ${LDFLAGS} -static %{NAME}.o -o %{NAME}-static +clang ${LDFLAGS} -static %{NAME}.o -o %{NAME}-static-pre +clang -static ${LDFLAGS} %{NAME}.o -o %{NAME}-static-post # With -no-pie -clang ${LDFLAGS} -no-pie %{NAME}.o -o %{NAME}-no-pie - +clang ${LDFLAGS} -no-pie %{NAME}.o -o %{NAME}-no-pie-pre +clang -no-pie ${LDFLAGS} %{NAME}.o -o %{NAME}-no-pie-post %changelog diff --git a/tests/pie-rpm/runtest.sh b/tests/pie-rpm/runtest.sh index 7758028..3ce2f91 100755 --- a/tests/pie-rpm/runtest.sh +++ b/tests/pie-rpm/runtest.sh @@ -8,19 +8,28 @@ set pipefail rm -f pie{,.o} QA_RPATHS=$(( 0x0001 )) rpmbuild -bb ./pie.spec --define '_sourcedir .' --define '_builddir .' - if [[ "$(file ./pie)" != *"pie executable"* ]]; then - exit 1 - fi - -if [[ "$(file ./pie-shared)" == *"pie executable"* ]]; then +if [[ "$(file ./pie)" != *"pie executable"* ]]; then exit 1 fi -if [[ "$(file ./pie-static)" == *"pie executable"* ]]; then +if [[ "$(file ./pie-shared-pre)" == *"pie executable"* ]]; then + exit 1 +fi +if [[ "$(file ./pie-shared-post)" == *"pie executable"* ]]; then exit 1 fi -if [[ "$(file ./pie-no-pie)" == *"pie executable"* ]]; then +if [[ "$(file ./pie-static-pre)" == *"pie executable"* ]]; then + exit 1 +fi +if [[ "$(file ./pie-static-post)" == *"pie executable"* ]]; then + exit 1 +fi + +if [[ "$(file ./pie-no-pie-pre)" == *"pie executable"* ]]; then + exit 1 +fi +if [[ "$(file ./pie-no-pie-post)" == *"pie executable"* ]]; then exit 1 fi From b3c624504cefc4e5e66b635b50433b84d7972895 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Fri, 12 Apr 2024 12:46:39 +0200 Subject: [PATCH 14/36] libomp: remove hardcoded clang package Query the clang nvr checking which package provides the clang binary instead querying directly for "clang" package. Add also support for running the test with compat packages (clang17, clang16) --- tests/libomp/runtest.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/libomp/runtest.sh b/tests/libomp/runtest.sh index 2f3b9a5..dfe811f 100755 --- a/tests/libomp/runtest.sh +++ b/tests/libomp/runtest.sh @@ -2,17 +2,22 @@ set -exo pipefail -CLANG_VERSION=$(rpm --queryformat="%{version}" -q clang.$(uname -m)) -LIBOMP_DEPENDENCIES="libomp libomp-devel" +CLANG_PKG=$(rpm -qf --queryformat '%{name}' $(readlink -f $(type -p clang))) + +# For compat packages, we want to check if there's a package suffix: clang17 instead clang for example +PKG_SUFFIX=${CLANG_PKG#clang} +CLANG_NVR=$(rpm -q $CLANG_PKG) +CLANG_VERSION=$(rpm --queryformat="%{version}" -q $CLANG_NVR) +LIBOMP_DEPENDENCIES="libomp${PKG_SUFFIX} libomp${PKG_SUFFIX}-devel" # Ensure clang depends on the correct clang-libs version -rpm -q --requires clang | grep "clang-libs.* = ${CLANG_VERSION}" +rpm -q --requires ${CLANG_NVR} | grep "${CLANG_PKG}-libs.* = ${CLANG_VERSION}" # Check that weak dependencies are correct. The versions of these should be the same # as clang's to guarantee the ABI compatibility, and that version should be actually # installed as well. for lomp_dep in $LIBOMP_DEPENDENCIES; do - rpm -q --recommends clang-libs | grep "${lomp_dep}.* = ${CLANG_VERSION}" + rpm -q --recommends clang${PKG_SUFFIX}-libs | grep "${lomp_dep}.* = ${CLANG_VERSION}" [[ "$(rpm --queryformat="%{version}" -q ${lomp_dep}.$(uname -m))" == "${CLANG_VERSION}" ]] done From 0f16004a0a185e52ce3462def8cb38d75b0a7498 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Fri, 12 Apr 2024 16:47:38 +0200 Subject: [PATCH 15/36] openmp-rpm: Do not run dnf builddep tmt should take care of any dependencies required by the test. Letting the test call dnf and install packages can break the environment and cause invalid results in subsequent tests, specially when testing compat packages. --- tests/openmp-rpm/main.fmf | 27 ++++++--------------------- tests/openmp-rpm/runtest.sh | 4 +++- tests/openmp-rpm/test.spec | 6 ++++-- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/tests/openmp-rpm/main.fmf b/tests/openmp-rpm/main.fmf index 8443b21..0bd8f48 100644 --- a/tests/openmp-rpm/main.fmf +++ b/tests/openmp-rpm/main.fmf @@ -20,35 +20,20 @@ adjust+: enabled: false continue: false - - because: "Use yum in RHEL < 8" - require+: - - yum-utils - environment+: - BUILDDEP_CMD: "yum-builddep" - when: distro == rhel and distro < rhel-8 - - - because: "Use dnf5 in Fedora 39+" - require+: - - dnf5-plugins - environment+: - BUILDDEP_CMD: "dnf builddep" - continue: false - when: distro == fedora and distro >= fedora-39 - - - because: "Use dnf in RHEL >= 8, Fedora and CentOS" - require+: - - dnf-plugins-core - environment+: - BUILDDEP_CMD: "dnf builddep" - when: distro >= rhel-8 or distro != rhel + - require+: + - libomp + when: collection is not defined # Requirements for SCL-ized LLVM - require+: - llvm-toolset-13.0-build + - llvm-toolset-13.0-libomp when: "collection == llvm-toolset-13.0" - require+: - llvm-toolset-14.0-build + - llvm-toolset-14.0-libomp when: "collection == llvm-toolset-14.0" - require+: - llvm-toolset-15.0-build + - llvm-toolset-15.0-libomp when: "collection == llvm-toolset-15.0" diff --git a/tests/openmp-rpm/runtest.sh b/tests/openmp-rpm/runtest.sh index 86ec074..61eb313 100755 --- a/tests/openmp-rpm/runtest.sh +++ b/tests/openmp-rpm/runtest.sh @@ -2,5 +2,7 @@ set -ex -${BUILDDEP_CMD} -y test.spec +# Do not run dnf builddep here. TMT should take care of any packages needed to +# run the test. If the rpmbuild fails due to missing packages, then fmf metadata +# needs to be fixed. QA_RPATHS=$(( 0x0001 )) rpmbuild --define '_sourcedir .' --define '_builddir .' -bb test.spec diff --git a/tests/openmp-rpm/test.spec b/tests/openmp-rpm/test.spec index e317a6a..1fbb256 100644 --- a/tests/openmp-rpm/test.spec +++ b/tests/openmp-rpm/test.spec @@ -7,8 +7,10 @@ Release: 1 Summary: Test package for checking that RPM packages using -fopenmp build correctly License: MIT -BuildRequires: %{?scl_prefix}clang -BuildRequires: %{?scl_prefix}libomp +# Do not set buildrequires, tmt should cover any requirements to build. +# If not, tmt test metadata must be updated. +# BuildRequires: %{?scl_prefix}clang +# BuildRequires: %{?scl_prefix}libomp Source0: test.c From 0297643810d88c61e74dd65d567116a9e26cbe22 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Fri, 12 Apr 2024 16:50:33 +0200 Subject: [PATCH 16/36] remove hardcoded clang package when calling rpm command Use the clang command to locate the correct clang package name instead of hardcoding "clang" in the test. This is needed for the test to work with compat packages which are named differently. --- tests/rpmmacros/runtest.sh | 2 +- tests/toolchains/runtest.sh | 5 +++-- tests/use-correct-dwarf-default/runtest.sh | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/rpmmacros/runtest.sh b/tests/rpmmacros/runtest.sh index 658dc0d..99295c3 100755 --- a/tests/rpmmacros/runtest.sh +++ b/tests/rpmmacros/runtest.sh @@ -1,6 +1,6 @@ #!/bin/sh -eux -clang_pkg=${1:-"clang"} +clang_pkg=${1:-"$(rpm -qf --queryformat '%{name}' $(readlink -f $(type -p clang)))"} macros_path="/usr/lib/rpm/macros.d/macros.clang" set pipefail diff --git a/tests/toolchains/runtest.sh b/tests/toolchains/runtest.sh index 546d809..0d1a3e5 100755 --- a/tests/toolchains/runtest.sh +++ b/tests/toolchains/runtest.sh @@ -57,9 +57,10 @@ test_toolchain() { } clang --version +CLANG_PKG=$(rpm -qf --queryformat '%{name}' $(readlink -f $(type -p clang))) # Repoquery is needed instead yum info for compatibility with RHEL-7 -repoquery -i --installed $(rpm -qf $(which clang)) | grep ^Source -clang_version=$(rpm -q --queryformat "%{version}" clang | grep -ioP "^[0-9]+") +repoquery -i --installed $CLANG_PKG | grep ^Source +clang_version=$(rpm -q --queryformat "%{version}" $CLANG_PKG | grep -ioP "^[0-9]+") echo "" for compiler in clang clang++; do diff --git a/tests/use-correct-dwarf-default/runtest.sh b/tests/use-correct-dwarf-default/runtest.sh index ac9b23a..9918462 100755 --- a/tests/use-correct-dwarf-default/runtest.sh +++ b/tests/use-correct-dwarf-default/runtest.sh @@ -6,7 +6,8 @@ required_dwarf_version=4 # Get clang version -clang_version=$(rpm -q --queryformat "%{version}" clang | grep -ioP "^[0-9]+") +CLANG_PKG=$(rpm -qf --queryformat '%{name}' $(readlink -f $(type -p clang))) +clang_version=$(rpm -q --queryformat "%{version}" $CLANG_PKG | grep -ioP "^[0-9]+") if [ $clang_version -ge 18 ]; then >&2 echo "clang is greater or equal version 18"; required_dwarf_version=5 From 3449426c91126f2c09a0b298c4e88f5706916b80 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Fri, 12 Apr 2024 17:04:11 +0200 Subject: [PATCH 17/36] Remove redundant clang requires --- tests/pie-rpm/main.fmf | 1 - tests/rpmmacros/main.fmf | 1 - tests/toolchains/main.fmf | 1 - tests/use-correct-dwarf-default/main.fmf | 1 - 4 files changed, 4 deletions(-) diff --git a/tests/pie-rpm/main.fmf b/tests/pie-rpm/main.fmf index 9aa23e3..0a35fb6 100644 --- a/tests/pie-rpm/main.fmf +++ b/tests/pie-rpm/main.fmf @@ -2,7 +2,6 @@ summary: Check that we build rpms with -pie tier: 1 require+: - - clang - clang-libs - rpm-build - glibc-static diff --git a/tests/rpmmacros/main.fmf b/tests/rpmmacros/main.fmf index 7dc9d57..05c3245 100644 --- a/tests/rpmmacros/main.fmf +++ b/tests/rpmmacros/main.fmf @@ -1,7 +1,6 @@ summary: Test if RPM macros are properly set tier: 1 require+: - - clang - clang-devel extra-summary: /tools/clang/rpmmacros extra-task: /tools/clang/rpmmacros diff --git a/tests/toolchains/main.fmf b/tests/toolchains/main.fmf index c38a709..20bfdcb 100644 --- a/tests/toolchains/main.fmf +++ b/tests/toolchains/main.fmf @@ -12,7 +12,6 @@ extra-nitrate: TC#0614133 adjust+: # Common requirements when LLVM is not SCL-ized - require+: - - clang - compiler-rt - lld when: "collection is not defined" diff --git a/tests/use-correct-dwarf-default/main.fmf b/tests/use-correct-dwarf-default/main.fmf index da1ab93..3dcde07 100644 --- a/tests/use-correct-dwarf-default/main.fmf +++ b/tests/use-correct-dwarf-default/main.fmf @@ -9,7 +9,6 @@ extra-nitrate: TC#0614134 adjust+: # Common requirements when LLVM is not SCL-ized - require+: - - clang - llvm when: "collection is not defined" From 5e5ec124255d68af0905ce85ac32def45be3dae2 Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Fri, 3 May 2024 14:52:15 +0200 Subject: [PATCH 18/36] Add pre-commit config and update README See also https://src.fedoraproject.org/tests/llvm/pull-request/27 --- .pre-commit-config.yaml | 14 ++++++++++++++ README.md | 16 ++++++++++++++++ tests/rhbz_1647130/runtest.sh | 1 - tests/use-correct-dwarf-default/.gitignore | 2 +- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e5388a6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + +# See https://tmt.readthedocs.io/en/latest/guide.html#checking-data-validity +- repo: https://github.com/teemtee/tmt.git + rev: 1.32.2 + hooks: + - id: tmt-lint diff --git a/README.md b/README.md index 91a6458..af7c5f9 100644 --- a/README.md +++ b/README.md @@ -99,3 +99,19 @@ tier: 1 # tag+: # - sometag ``` + +### Avoid common errors using pre-commit + +This project uses [`pre-commit`](https://pre-commit.com/) + +* to [lint fmf files](https://tmt.readthedocs.io/en/latest/guide.html#lint) +* to check that you don't have [trailing + whitespaces](https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#trailing-whitespace) +* to check that [files end with a + newline](https://github.com/pre-commit/pre-commit-hooks?tab=readme-ov-file#end-of-file-fixer) + +Please install `pre-commit` using `pip install pre-commit` as described +[here](https://pre-commit.com/#install). Then navigate to your clone of this +project and install the git hook scripts using `pre-commit install`. This will +run pre-commit on every `git commit` that you make in this repository from now +on. diff --git a/tests/rhbz_1647130/runtest.sh b/tests/rhbz_1647130/runtest.sh index ab515c7..6898f78 100755 --- a/tests/rhbz_1647130/runtest.sh +++ b/tests/rhbz_1647130/runtest.sh @@ -7,4 +7,3 @@ tmp_dir=`mktemp -d` echo 'int main(int argc, char*argv[]) { while(argc--) new int(); return 0; }' > $tmp_cpp scan-build -o $tmp_dir clang++ -c $tmp_cpp -o /dev/null (scan-view --no-browser $tmp_dir/* & WPID=$! && sleep 10s && kill $WPID) - diff --git a/tests/use-correct-dwarf-default/.gitignore b/tests/use-correct-dwarf-default/.gitignore index 0acf80b..6a1fffa 100644 --- a/tests/use-correct-dwarf-default/.gitignore +++ b/tests/use-correct-dwarf-default/.gitignore @@ -1,2 +1,2 @@ a.out -build.log \ No newline at end of file +build.log From 3d9db8ae3585b4231c52c05e17d7be9de9adc661 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Wed, 20 Mar 2024 20:04:07 +0100 Subject: [PATCH 19/36] Create kernel-ark rebuild test This commit adds a new test that rebuilds kernel-ark with clang to ensure that we do not break the upstream builds. This is a squashed commit of the following: PoC for kernel-ark build test and plan kernel-ark: create virtual test and run all build configurations Created configurations for lto/non-lto and base/debug, adding proper relevancies. Test script parametrized with environment variables so it can be reused by all these configs. Fix relevancy for debug/non-lto build Fix dependency install logic Final cleanups Make kernel-ark-build plan to be run only if triggered manually Rename kernel-ark plan to avoid naming confusions with the test Add documentation for kernel-ark test --- README.md | 28 ++++++++++++ plans/kernel-ark-gating.fmf | 18 ++++++++ tests/kernel-ark-build/main.fmf | 52 ++++++++++++++++++++++ tests/kernel-ark-build/runtest.sh | 71 +++++++++++++++++++++++++++++++ 4 files changed, 169 insertions(+) create mode 100644 plans/kernel-ark-gating.fmf create mode 100644 tests/kernel-ark-build/main.fmf create mode 100755 tests/kernel-ark-build/runtest.sh diff --git a/README.md b/README.md index af7c5f9..ccf75d3 100644 --- a/README.md +++ b/README.md @@ -115,3 +115,31 @@ Please install `pre-commit` using `pip install pre-commit` as described project and install the git hook scripts using `pre-commit install`. This will run pre-commit on every `git commit` that you make in this repository from now on. + +## Test specific documentation + +### kernel-ark-rebuild +The `kernel-ark-rebuild` test is a special test that we use to ensure that clang, +llvm, and lld builds do not break [Always Ready Kernel]( +https://gitlab.com/cki-project/kernel-ark) builds, which are done in Fedora +Rawhide. This is a virtual test comprised of 4 tests corresponding to different +build configurations for the kernel: + +* base +* base/lto +* debug +* debug/lto + +Due to this, this test is not regularly run on PRs opened in tests/clang, as +running the 4 tests can take about 6 hours. Instead, if you modify the test +you are expected to run it on your own and provide the results in the Pull +Request. A specific tmt test plan named `kernel-ark-gating.fmf` is provided for +that. It can be run using Testing Farm with this command: +``` +testing-farm request -c initiator=human -c distro=fedora-rawhide -c arch= \ + --compose Fedora-Rawhide --git-url --git-ref \ + --plan kernel-ark-gating +``` +You need an [API key](https://docs.testing-farm.io/Testing%20Farm/0.1/onboarding.html) +to be able to use Testing Farm. If you don't have on, please ask for help running +the test when opening a Pull Request. diff --git a/plans/kernel-ark-gating.fmf b/plans/kernel-ark-gating.fmf new file mode 100644 index 0000000..9b4d6ea --- /dev/null +++ b/plans/kernel-ark-gating.fmf @@ -0,0 +1,18 @@ +summary: Build latest kernel-ark with clang using different build configurations +discover: + how: fmf + test: kernel-ark-build +execute: + how: tmt +provision: + hardware: + memory: ">=16 GiB" + cpu: + cores: ">=8" + +# We do not want to run this test on every pull request done to tests/clang. +# Only allow to run manually when the test is really modified to prevent +# using too much time and resources in non-related pull requests. +adjust: + - when: initiator is not defined or initiator != human + enabled: false diff --git a/tests/kernel-ark-build/main.fmf b/tests/kernel-ark-build/main.fmf new file mode 100644 index 0000000..ea036d8 --- /dev/null +++ b/tests/kernel-ark-build/main.fmf @@ -0,0 +1,52 @@ +summary: Build kernel-ark with clang +framework: beakerlib +component+: + - llvm + - lld +# CKI pipelines times out after 5h. 4h is safe for us. +duration: 4h +tier: 1 +require+: + - git + - make + - gcc + - flex + - bison + - bzip2 + - rpm-build +adjust+: + - when: distro is not defined or distro != fedora-rawhide + enabled: false + because: Only meaninful in Rawhide +link+: + - verifies: https://issues.redhat.com/browse/LLVM-72 +tag+: + - not-in-default + +/base: + summary+: " (base/non-LTO)" + +/debug: + summary+: " (debug/non-LTO)" + environment+: + ENABLE_DEBUG: 1 + adjust+: + - enabled: false + when: arch != x86_64 and arch != aarch64 + +/base-lto: + summary+: " (base/LTO)" + environment+: + ENABLE_LTO: 1 + adjust+: + - enabled: false + when: arch != x86_64 and arch != aarch64 + +/debug-lto: + summary+: " (debug/LTO)" + environment+: + ENABLE_LTO: 1 + ENABLE_DEBUG: 1 + adjust+: + - enabled: false + when: arch != x86_64 and arch != aarch64 diff --git a/tests/kernel-ark-build/runtest.sh b/tests/kernel-ark-build/runtest.sh new file mode 100755 index 0000000..48ef4eb --- /dev/null +++ b/tests/kernel-ark-build/runtest.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +## General configuration variables. Can be overriden via environment +# Kernel branch to build. Typically ark-latest or os-build. +KERNEL_BRANCH=${KERNEL_BRANCH:-"ark-latest"} +KERNEL_GIT_URL=${KERNEL_GIT_URL:-"https://gitlab.com/cki-project/kernel-ark.git"} + +# Environment variables to configure the kernel build: +# * ENABLE_LTO: If set, it will build kernel-ark with clang_lto. +# * ENABLE_DEBUG: If set, it will build kernel-ark in debug mode. +CLANG_MODE=${ENABLE_LTO:+"--with clang_lto"} +CLANG_MODE=${CLANG_MODE:-"--with clang"} +# Build mode, base or debug +BUILD_MODE=${ENABLE_DEBUG:+"--with debug --without base"} +BUILD_MODE=${BUILD_MODE:-"--with base --without debug"} + +rlJournalStart + rlPhaseStartSetup + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" + rlRun "pushd $tmp" + rlRun "set -o pipefail" + rlLog "Disable updates-testing" + rlRun "dnf config-manager --set-disabled updates-testing" + rlPhaseEnd + + rlPhaseStartTest + # TODO It would be fantastic to find out a way to shallow clone without + # breaking the dist-get-buildreqs and dist-srpm make targets, because + # a complete clone takes about 5GiB and a LOT of time... + rlLog "Cloning kernel" + rlRun "git clone --branch ${KERNEL_BRANCH} ${KERNEL_GIT_URL}" + rlRun 'cd kernel-ark' + + rlLog "Gathering and installing missing build requirements" + rlRun "make dist-get-buildreqs > make-buildreqs.log" + rlFileSubmit make-buildreqs.log + if grep 'Missing dependencies:' make-buildreqs.log; then + rlRun "KERNEL_BUILDREQS=\"$(sed -n 's/Missing dependencies://p' make-buildreqs.log)\"" + rlRun 'dnf install -y ${KERNEL_BUILDREQS} > install-buildreqs.log 2>&1' + rlFileSubmit install-buildreqs.log + elif grep 'PASS:' make-buildreqs.log; then + rlLog "All dependencies were already installed" + else + rlLogWarning "Error getting dependencies, the build might fail" + rlRun "cat make-buildreqs.log" + fi + + rlLog "Generating srpm" + rlRun 'make dist-srpm > dist-srpm.log 2>&1' + rlRun 'KERNEL_SRPM=$(find . -name kernel-*.src.rpm)' + rlFileSubmit dist-srpm.log + + # Prepare the flags to be passed to rpmbuild depending on the configuration + BUILD_FLAGS="--target $(uname -m) --with up --with toolchain_clang " + BUILD_FLAGS+="--without trace --without arm64_16k --without arm64_64k " + BUILD_FLAGS+="--without realtime --without zfcpdump " + BUILD_FLAGS+="${CLANG_MODE} ${BUILD_MODE}" + + rlLog "Building kernel (branch $KERNEL_BRANCH)" + rlRun "rpmbuild ${BUILD_FLAGS} --rebuild ${KERNEL_SRPM} > build.log 2>&1" + rlFileSubmit build.log + + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $tmp" 0 "Remove tmp directory" + rlPhaseEnd +rlJournalEnd From af1c69a51d2e6216475ebaaf8fe84b509048b8cd Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Thu, 23 May 2024 09:03:19 +0200 Subject: [PATCH 20/36] kernel-ark-build: Improve logging and fix disable updates-testing repo dnf5 is the default pkg manager in rawhide and config-manager command has different interface. Falling back to dnf-3. Added lld and llvm-devel as explicit requirements in test metadata Added extra logging of which packages (NVRs) where installed by tmt and the amount of cpus and memory the running system has. --- tests/kernel-ark-build/main.fmf | 2 ++ tests/kernel-ark-build/runtest.sh | 27 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/kernel-ark-build/main.fmf b/tests/kernel-ark-build/main.fmf index ea036d8..149eca2 100644 --- a/tests/kernel-ark-build/main.fmf +++ b/tests/kernel-ark-build/main.fmf @@ -7,6 +7,8 @@ component+: duration: 4h tier: 1 require+: + - llvm-devel + - lld - git - make - gcc diff --git a/tests/kernel-ark-build/runtest.sh b/tests/kernel-ark-build/runtest.sh index 48ef4eb..7342048 100755 --- a/tests/kernel-ark-build/runtest.sh +++ b/tests/kernel-ark-build/runtest.sh @@ -16,13 +16,36 @@ CLANG_MODE=${CLANG_MODE:-"--with clang"} BUILD_MODE=${ENABLE_DEBUG:+"--with debug --without base"} BUILD_MODE=${BUILD_MODE:-"--with base --without debug"} +function logTmtRequiredPackages(){ + # Get the expected packages from TMT metadata requires + if [[ ! -e $TMT_TEST_METADATA ]]; then + rlLogWarning "${FUNCNAME[0]}: No TMT_TEST_METADATA file found. Run the test from tmt" + return + fi + TMT_REQUIRES=$(rlGetYAMLdeps) + rlLog "# Installed packages:" + rlLog "#----------------------------#" + for pkg in $TMT_REQUIRES; do + rlAssertRpm $pkg + done; + rlLog "#----------------------------#" + +} + rlJournalStart rlPhaseStartSetup + # Log system mem/cpus and packages installed by tmt + rlRun "nproc" + rlRun "free -h" + logTmtRequiredPackages + rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" rlRun "pushd $tmp" rlRun "set -o pipefail" - rlLog "Disable updates-testing" - rlRun "dnf config-manager --set-disabled updates-testing" + if rlIsFedora; then + rlLog "Disable updates-testing" + rlRun "dnf-3 config-manager --set-disabled updates-testing" + fi rlPhaseEnd rlPhaseStartTest From f74147908610aad010b3da459e8970a13f4156f5 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Thu, 30 May 2024 12:03:40 +0200 Subject: [PATCH 21/36] openmp-rpm: make the test compatible with rpm 4.20+ --- tests/openmp-rpm/runtest.sh | 2 +- tests/openmp-rpm/test.spec | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/openmp-rpm/runtest.sh b/tests/openmp-rpm/runtest.sh index 61eb313..7f4606a 100755 --- a/tests/openmp-rpm/runtest.sh +++ b/tests/openmp-rpm/runtest.sh @@ -5,4 +5,4 @@ set -ex # Do not run dnf builddep here. TMT should take care of any packages needed to # run the test. If the rpmbuild fails due to missing packages, then fmf metadata # needs to be fixed. -QA_RPATHS=$(( 0x0001 )) rpmbuild --define '_sourcedir .' --define '_builddir .' -bb test.spec +QA_RPATHS=$(( 0x0001 )) rpmbuild --define "_sourcedir $PWD" -bb test.spec diff --git a/tests/openmp-rpm/test.spec b/tests/openmp-rpm/test.spec index 1fbb256..8a3ae3c 100644 --- a/tests/openmp-rpm/test.spec +++ b/tests/openmp-rpm/test.spec @@ -14,6 +14,8 @@ License: MIT Source0: test.c +%global debug_package %{nil} + %description clang was adding RUNPATH to binaries that use OpenMP, and since RUNPATH is prohibited in Fedora builds, this was causing packages using clang From ca2401025f3269d17bff9868bb4726bdab6b6d60 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 30 May 2024 10:16:15 +0300 Subject: [PATCH 22/36] Make the pie-rpm test spec self-contained and work with any rpm version Move the dummy source inline to %prep and checks from runtest.sh into %check, to take advantage of rpm facilities instead of fighting them, and now we can just run this anywhere at all without any cumbersome override defines and any rpm version. --- tests/pie-rpm/pie.c | 6 ------ tests/pie-rpm/pie.spec | 36 ++++++++++++++++++++++++++++++++++-- tests/pie-rpm/runtest.sh | 29 +---------------------------- 3 files changed, 35 insertions(+), 36 deletions(-) delete mode 100644 tests/pie-rpm/pie.c diff --git a/tests/pie-rpm/pie.c b/tests/pie-rpm/pie.c deleted file mode 100644 index 5423ce6..0000000 --- a/tests/pie-rpm/pie.c +++ /dev/null @@ -1,6 +0,0 @@ - - - -int main(int argc, char **argv) { - return 0; -} diff --git a/tests/pie-rpm/pie.spec b/tests/pie-rpm/pie.spec index 5d2913d..abb473e 100644 --- a/tests/pie-rpm/pie.spec +++ b/tests/pie-rpm/pie.spec @@ -6,18 +6,25 @@ Release: %autorelease Summary: Check that -pie is passed. License: MIT -Source0: pie.c BuildRequires: clang %description Make sure the standard configuration from redhat-rpm-config passes -pie when linking. +%prep +%setup -c -T +cat << EOF > pie.c +int main(int argc, char **argv) { + return 0; +} +EOF + %build LDFLAGS="${LDFLAGS} -Werror" -clang ${CFLAGS} -c %{SOURCE0} -o %{NAME}.o +clang ${CFLAGS} -c pie.c -o %{NAME}.o # Regular clang ${LDFLAGS} %{NAME}.o -o %{NAME} @@ -34,6 +41,31 @@ clang -static ${LDFLAGS} %{NAME}.o -o %{NAME}-static-post clang ${LDFLAGS} -no-pie %{NAME}.o -o %{NAME}-no-pie-pre clang -no-pie ${LDFLAGS} %{NAME}.o -o %{NAME}-no-pie-post +%check +if [[ "$(file ./pie)" != *"pie executable"* ]]; then + exit 1 +fi + +if [[ "$(file ./pie-shared-pre)" == *"pie executable"* ]]; then + exit 1 +fi +if [[ "$(file ./pie-shared-post)" == *"pie executable"* ]]; then + exit 1 +fi + +if [[ "$(file ./pie-static-pre)" == *"pie executable"* ]]; then + exit 1 +fi +if [[ "$(file ./pie-static-post)" == *"pie executable"* ]]; then + exit 1 +fi + +if [[ "$(file ./pie-no-pie-pre)" == *"pie executable"* ]]; then + exit 1 +fi +if [[ "$(file ./pie-no-pie-post)" == *"pie executable"* ]]; then + exit 1 +fi %changelog %autochangelog diff --git a/tests/pie-rpm/runtest.sh b/tests/pie-rpm/runtest.sh index 3ce2f91..a8bdafc 100755 --- a/tests/pie-rpm/runtest.sh +++ b/tests/pie-rpm/runtest.sh @@ -5,32 +5,5 @@ set pipefail #${BUILDDEP_CMD} -y pie.spec -rm -f pie{,.o} -QA_RPATHS=$(( 0x0001 )) rpmbuild -bb ./pie.spec --define '_sourcedir .' --define '_builddir .' +QA_RPATHS=$(( 0x0001 )) rpmbuild -bb ./pie.spec -if [[ "$(file ./pie)" != *"pie executable"* ]]; then - exit 1 -fi - -if [[ "$(file ./pie-shared-pre)" == *"pie executable"* ]]; then - exit 1 -fi -if [[ "$(file ./pie-shared-post)" == *"pie executable"* ]]; then - exit 1 -fi - -if [[ "$(file ./pie-static-pre)" == *"pie executable"* ]]; then - exit 1 -fi -if [[ "$(file ./pie-static-post)" == *"pie executable"* ]]; then - exit 1 -fi - -if [[ "$(file ./pie-no-pie-pre)" == *"pie executable"* ]]; then - exit 1 -fi -if [[ "$(file ./pie-no-pie-post)" == *"pie executable"* ]]; then - exit 1 -fi - -exit 0 From e5e8b03b9f98df12adce3f3a49a34d37706c3919 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 30 May 2024 11:21:04 +0300 Subject: [PATCH 23/36] Add missing glibc-static build dependency to pie-rpm test --- tests/pie-rpm/pie.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pie-rpm/pie.spec b/tests/pie-rpm/pie.spec index abb473e..3ed6aaa 100644 --- a/tests/pie-rpm/pie.spec +++ b/tests/pie-rpm/pie.spec @@ -7,7 +7,7 @@ Summary: Check that -pie is passed. License: MIT -BuildRequires: clang +BuildRequires: clang glibc-static %description Make sure the standard configuration from redhat-rpm-config passes -pie when linking. From 7ab65858ab6258b9fbbdc248134d1fc1f39f6fcf Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Thu, 30 May 2024 07:50:49 +0200 Subject: [PATCH 24/36] toolchains: Set lld package for rhel 8.10 modules llvm-toolset module is being updated to 18 in rhel 8.10 and we need to test newly added lld there. Set it as recommend for now as we still have LLVM 17 in default rhel8 stream --- tests/toolchains/main.fmf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/toolchains/main.fmf b/tests/toolchains/main.fmf index 20bfdcb..a0ed9f0 100644 --- a/tests/toolchains/main.fmf +++ b/tests/toolchains/main.fmf @@ -44,6 +44,14 @@ adjust+: arch == s390x and distro < rhel-9, rhel-9.5, fedora-40, centos-stream-9 or arch == ppc64 + # LLVM is getting updated to 18 in rhel 8.10 which adds lld for s390x, but we + # still have LLVM 17 in AppStream. Install lld if it's available, leave it out + # if not. The test will (correctly) fail if we lld is missing in LLVM 18. + # TODO once LLVM 18 is in the default module stream we can set this a require: + - recommend+: + - lld + when: arch == s390x and distro == rhel-8.10 + - environment+: CXXLIBS: "libc++" require+: From 33597822114caf1a24ec1b7dba012769280d8ecb Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Thu, 6 Jun 2024 08:30:12 +0200 Subject: [PATCH 25/36] toolchains: ensure that tmt requires lld when testing snapshots --- tests/toolchains/main.fmf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/toolchains/main.fmf b/tests/toolchains/main.fmf index a0ed9f0..8715c60 100644 --- a/tests/toolchains/main.fmf +++ b/tests/toolchains/main.fmf @@ -81,6 +81,8 @@ adjust+: - libcxx-static require+: - libstdc++ + # All archs support lld in snapshots, ensure it's required + - lld when: distro == fedora and snapshot is defined because: llvm-snapshots adjustments From 5100dc7cf029c3862567f2ce08f1a5c590c4761b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 7 Jun 2024 09:08:12 +0200 Subject: [PATCH 26/36] Perform llvm-snapshot adjustment for rhel as well We need to install lld for snapshots on rhel as well. --- tests/toolchains/main.fmf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/toolchains/main.fmf b/tests/toolchains/main.fmf index 8715c60..ad049dc 100644 --- a/tests/toolchains/main.fmf +++ b/tests/toolchains/main.fmf @@ -83,7 +83,7 @@ adjust+: - libstdc++ # All archs support lld in snapshots, ensure it's required - lld - when: distro == fedora and snapshot is defined + when: snapshot is defined because: llvm-snapshots adjustments From dade06cfdd09e14ebd04b8ffc61909228ec8fc9d Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Mon, 10 Jun 2024 11:39:04 +0200 Subject: [PATCH 27/36] use-correct-dwarf-default: Update test * The default version is now 5. If clang version is older than 18 then fall back to version 4. * Added optional env var to overwrite required dwarf version. * Updated fmf metadata to use dwarf4 in distros that don't support v5 * Fedora 38 is EOL, removed dead code. --- tests/use-correct-dwarf-default/main.fmf | 4 ++++ tests/use-correct-dwarf-default/runtest.sh | 21 +++++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/use-correct-dwarf-default/main.fmf b/tests/use-correct-dwarf-default/main.fmf index 3dcde07..ed39bd9 100644 --- a/tests/use-correct-dwarf-default/main.fmf +++ b/tests/use-correct-dwarf-default/main.fmf @@ -25,3 +25,7 @@ adjust+: - llvm-toolset-15.0-clang - llvm-toolset-15.0-llvm when: "collection == llvm-toolset-15.0" + + - environment+: + DWARF_VERSION: 4 + when: distro < rhel-10 or distro < centos-stream-10 diff --git a/tests/use-correct-dwarf-default/runtest.sh b/tests/use-correct-dwarf-default/runtest.sh index 9918462..926658e 100755 --- a/tests/use-correct-dwarf-default/runtest.sh +++ b/tests/use-correct-dwarf-default/runtest.sh @@ -1,23 +1,16 @@ #!/bin/sh -eux -# Determine correct DWARF version to use. If Clang is newer or equal to version -# 18, we want to use DWARF5 except for Fedora 38 where we still want DWARF4. - -required_dwarf_version=4 +# Determine correct DWARF version to use. Defaults to version 5, but older +# distros might need to use version 4, which can be configured using the +# DWARF_VERSION env var +required_dwarf_version=${DWARF_VERSION:-5} # Get clang version CLANG_PKG=$(rpm -qf --queryformat '%{name}' $(readlink -f $(type -p clang))) clang_version=$(rpm -q --queryformat "%{version}" $CLANG_PKG | grep -ioP "^[0-9]+") -if [ $clang_version -ge 18 ]; then - >&2 echo "clang is greater or equal version 18"; - required_dwarf_version=5 -fi - -if [ -e /etc/fedora-release ]; then - fedora_version=$(grep -ioP "Fedora release \K[0-9]+" /etc/fedora-release) - if [ $fedora_version -le 38 ]; then - required_dwarf_version=4 - fi +if [ $clang_version -lt 18 ]; then + >&2 echo "clang is older than version 18"; + required_dwarf_version=4 fi echo "int main(){ return 0; }" | clang -g -v -x c - 2> build.log From 06436d11ba96e85aae188ddce1ffa16b29ddcf22 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Mon, 10 Jun 2024 11:44:30 +0200 Subject: [PATCH 28/36] Revert "use-correct-dwarf-default: Update test" This reverts commit dade06cfdd09e14ebd04b8ffc61909228ec8fc9d. --- tests/use-correct-dwarf-default/main.fmf | 4 ---- tests/use-correct-dwarf-default/runtest.sh | 21 ++++++++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/use-correct-dwarf-default/main.fmf b/tests/use-correct-dwarf-default/main.fmf index ed39bd9..3dcde07 100644 --- a/tests/use-correct-dwarf-default/main.fmf +++ b/tests/use-correct-dwarf-default/main.fmf @@ -25,7 +25,3 @@ adjust+: - llvm-toolset-15.0-clang - llvm-toolset-15.0-llvm when: "collection == llvm-toolset-15.0" - - - environment+: - DWARF_VERSION: 4 - when: distro < rhel-10 or distro < centos-stream-10 diff --git a/tests/use-correct-dwarf-default/runtest.sh b/tests/use-correct-dwarf-default/runtest.sh index 926658e..9918462 100755 --- a/tests/use-correct-dwarf-default/runtest.sh +++ b/tests/use-correct-dwarf-default/runtest.sh @@ -1,16 +1,23 @@ #!/bin/sh -eux -# Determine correct DWARF version to use. Defaults to version 5, but older -# distros might need to use version 4, which can be configured using the -# DWARF_VERSION env var -required_dwarf_version=${DWARF_VERSION:-5} +# Determine correct DWARF version to use. If Clang is newer or equal to version +# 18, we want to use DWARF5 except for Fedora 38 where we still want DWARF4. + +required_dwarf_version=4 # Get clang version CLANG_PKG=$(rpm -qf --queryformat '%{name}' $(readlink -f $(type -p clang))) clang_version=$(rpm -q --queryformat "%{version}" $CLANG_PKG | grep -ioP "^[0-9]+") -if [ $clang_version -lt 18 ]; then - >&2 echo "clang is older than version 18"; - required_dwarf_version=4 +if [ $clang_version -ge 18 ]; then + >&2 echo "clang is greater or equal version 18"; + required_dwarf_version=5 +fi + +if [ -e /etc/fedora-release ]; then + fedora_version=$(grep -ioP "Fedora release \K[0-9]+" /etc/fedora-release) + if [ $fedora_version -le 38 ]; then + required_dwarf_version=4 + fi fi echo "int main(){ return 0; }" | clang -g -v -x c - 2> build.log From 2b2e06a7e1b25528c3a6a200a7d99f99312dc1a9 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Mon, 10 Jun 2024 11:39:04 +0200 Subject: [PATCH 29/36] use-correct-dwarf-default: Update test * The default version is now 5. If clang version is older than 18 then fall back to version 4. * Added optional env var to overwrite required dwarf version. * Updated fmf metadata to use dwarf4 in distros that don't support v5 * Fedora 38 is EOL, removed dead code. --- tests/use-correct-dwarf-default/main.fmf | 4 ++++ tests/use-correct-dwarf-default/runtest.sh | 21 +++++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/use-correct-dwarf-default/main.fmf b/tests/use-correct-dwarf-default/main.fmf index 3dcde07..ed39bd9 100644 --- a/tests/use-correct-dwarf-default/main.fmf +++ b/tests/use-correct-dwarf-default/main.fmf @@ -25,3 +25,7 @@ adjust+: - llvm-toolset-15.0-clang - llvm-toolset-15.0-llvm when: "collection == llvm-toolset-15.0" + + - environment+: + DWARF_VERSION: 4 + when: distro < rhel-10 or distro < centos-stream-10 diff --git a/tests/use-correct-dwarf-default/runtest.sh b/tests/use-correct-dwarf-default/runtest.sh index 9918462..926658e 100755 --- a/tests/use-correct-dwarf-default/runtest.sh +++ b/tests/use-correct-dwarf-default/runtest.sh @@ -1,23 +1,16 @@ #!/bin/sh -eux -# Determine correct DWARF version to use. If Clang is newer or equal to version -# 18, we want to use DWARF5 except for Fedora 38 where we still want DWARF4. - -required_dwarf_version=4 +# Determine correct DWARF version to use. Defaults to version 5, but older +# distros might need to use version 4, which can be configured using the +# DWARF_VERSION env var +required_dwarf_version=${DWARF_VERSION:-5} # Get clang version CLANG_PKG=$(rpm -qf --queryformat '%{name}' $(readlink -f $(type -p clang))) clang_version=$(rpm -q --queryformat "%{version}" $CLANG_PKG | grep -ioP "^[0-9]+") -if [ $clang_version -ge 18 ]; then - >&2 echo "clang is greater or equal version 18"; - required_dwarf_version=5 -fi - -if [ -e /etc/fedora-release ]; then - fedora_version=$(grep -ioP "Fedora release \K[0-9]+" /etc/fedora-release) - if [ $fedora_version -le 38 ]; then - required_dwarf_version=4 - fi +if [ $clang_version -lt 18 ]; then + >&2 echo "clang is older than version 18"; + required_dwarf_version=4 fi echo "int main(){ return 0; }" | clang -g -v -x c - 2> build.log From 07526ca7fa11d89daa1f710dfd167ea965aec151 Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Wed, 3 Jul 2024 15:36:11 +0200 Subject: [PATCH 30/36] For snapshots on RHEL we want to check for DWARF5 --- tests/use-correct-dwarf-default/main.fmf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/use-correct-dwarf-default/main.fmf b/tests/use-correct-dwarf-default/main.fmf index ed39bd9..bdd5ce1 100644 --- a/tests/use-correct-dwarf-default/main.fmf +++ b/tests/use-correct-dwarf-default/main.fmf @@ -28,4 +28,4 @@ adjust+: - environment+: DWARF_VERSION: 4 - when: distro < rhel-10 or distro < centos-stream-10 + when: distro < rhel-10,centos-stream-10 and snapshot is not defined From 9080b2716a6da5641db5150f5641c2e94f26e844 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Wed, 17 Jul 2024 12:55:17 +0200 Subject: [PATCH 31/36] Update test relevancy for compat packages llvm-test-suite and rpmmacros tests disabled for compat packages --- tests/llvm-test-suite/main.fmf | 4 ++++ tests/rpmmacros/main.fmf | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/tests/llvm-test-suite/main.fmf b/tests/llvm-test-suite/main.fmf index e084bd1..9deb601 100644 --- a/tests/llvm-test-suite/main.fmf +++ b/tests/llvm-test-suite/main.fmf @@ -8,6 +8,10 @@ adjust+: or distro == centos enabled: false + - because: "llvm test suite not built for compat packages" + enabled: false + when: compat is defined + require+: - git - clang diff --git a/tests/rpmmacros/main.fmf b/tests/rpmmacros/main.fmf index 05c3245..45e3ded 100644 --- a/tests/rpmmacros/main.fmf +++ b/tests/rpmmacros/main.fmf @@ -4,3 +4,12 @@ require+: - clang-devel extra-summary: /tools/clang/rpmmacros extra-task: /tools/clang/rpmmacros + +adjust+: + # From spec file: + # File in the macros file for other packages to use. We are not doing this + # in the compat package, because the version macros would conflict with + # eachother if both clang and the clang compat package were installed together. + - because: "macros.clang is not added to compat packages" + enabled: false + when: compat is defined From bf7e2faa36dfe6e15e5e0bbdb3ebbc92eed2d6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 22 May 2024 12:05:09 +0200 Subject: [PATCH 32/36] Enable pie-rpm test by default --- tests/pie-rpm/main.fmf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/pie-rpm/main.fmf b/tests/pie-rpm/main.fmf index 0a35fb6..1b276b9 100644 --- a/tests/pie-rpm/main.fmf +++ b/tests/pie-rpm/main.fmf @@ -6,10 +6,6 @@ require+: - rpm-build - glibc-static -# TODO: Untag this test when redhat-rpm-config is modified. -# See: https://src.fedoraproject.org/rpms/redhat-rpm-config/pull-request/291 -tag: not-in-default - adjust+: - enabled: false when: distro != fedora or distro < fedora-40 From 71a2b1c3bfc0b1908f057783c2c0f98849be6f37 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Tue, 16 Jul 2024 08:36:56 +0200 Subject: [PATCH 33/36] Refactor kernel-ark build test for caching and git clone retry This commit mitigates test failures due to git unreliability and improves test time over test reruns using cached SRPMs. - Added CACHE_DIR_BASE, KERNEL_SRPM_PATTERN and KERNEL SRPM variables. - Implemented checkCache() to look for an existing SRPM in the cache and install its build dependencies. - Implemented cloneKernelTree() for cloning the kernel-ark repo with retries. - Implemented generateSRPM() to handle all operations required to generate an SRPM and cache it. - Updated main test phase to utilize caching and SRPM generation functions. --- tests/kernel-ark-build/runtest.sh | 162 +++++++++++++++++++++++------- 1 file changed, 124 insertions(+), 38 deletions(-) diff --git a/tests/kernel-ark-build/runtest.sh b/tests/kernel-ark-build/runtest.sh index 7342048..f9b217f 100755 --- a/tests/kernel-ark-build/runtest.sh +++ b/tests/kernel-ark-build/runtest.sh @@ -2,11 +2,17 @@ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k . /usr/share/beakerlib/beakerlib.sh || exit 1 -## General configuration variables. Can be overriden via environment +## General configuration variables. Can be overridden via environment # Kernel branch to build. Typically ark-latest or os-build. KERNEL_BRANCH=${KERNEL_BRANCH:-"ark-latest"} KERNEL_GIT_URL=${KERNEL_GIT_URL:-"https://gitlab.com/cki-project/kernel-ark.git"} +## Helper variables to handle cached/generated SRPM +CACHE_DIR_BASE="/var/tmp/kernel-" +KERNEL_SRPM_PATTERN="kernel-*.src.rpm" +# Path to the kernel SRPM to build. +KERNEL_SRPM="" + # Environment variables to configure the kernel build: # * ENABLE_LTO: If set, it will build kernel-ark with clang_lto. # * ENABLE_DEBUG: If set, it will build kernel-ark in debug mode. @@ -16,8 +22,8 @@ CLANG_MODE=${CLANG_MODE:-"--with clang"} BUILD_MODE=${ENABLE_DEBUG:+"--with debug --without base"} BUILD_MODE=${BUILD_MODE:-"--with base --without debug"} -function logTmtRequiredPackages(){ - # Get the expected packages from TMT metadata requires +# Log installed packages required by TMT +logTmtRequiredPackages() { if [[ ! -e $TMT_TEST_METADATA ]]; then rlLogWarning "${FUNCNAME[0]}: No TMT_TEST_METADATA file found. Run the test from tmt" return @@ -26,15 +32,109 @@ function logTmtRequiredPackages(){ rlLog "# Installed packages:" rlLog "#----------------------------#" for pkg in $TMT_REQUIRES; do - rlAssertRpm $pkg - done; + rlAssertRpm "$pkg" + done rlLog "#----------------------------#" +} +# Check if a previous test run created a kernel SRPM for the latest commit +# If found, the abspath is stored in KERNEL_SRPM global variable +# Returns 0 if srpm found, 1 otherwise. +checkCache() { + local commit_hash + local cache_dir + local cached_srpm + + commit_hash=$(git ls-remote "${KERNEL_GIT_URL}" "${KERNEL_BRANCH}" | awk '{print $1}') + rlLog "Latest commit for ${KERNEL_BRANCH} branch: $commit_hash" + + cache_dir="${CACHE_DIR_BASE}${commit_hash}/" + if [[ -d "$cache_dir" ]]; then + cached_srpm=$(find "$cache_dir" -name "${KERNEL_SRPM_PATTERN}") + if [[ -n "$cached_srpm" ]]; then + rlLog "Found cached SRPM: $cached_srpm" + rlRun "dnf builddep -y $cached_srpm > install-buildreqs.log 2>&1" + rlFileSubmit install-buildreqs.log + KERNEL_SRPM="$cached_srpm" + return 0 + fi + fi + rlLog "Cached kernel SRPM not found" + return 1 +} + +# Attempts to clone the kernel-ark tree in the CWD, at most 3 times. +# Returns 0 on success, 1 otherwise +cloneKernelTree() { + local retries=3 + local delay=10 + + rlLog "Cloning kernel" + while [[ $retries -gt 0 ]]; do + rlRun "git clone -q --branch ${KERNEL_BRANCH} ${KERNEL_GIT_URL}" 0-255 + retcode=$? + if [[ $retcode -eq 0 ]]; then + return 0 + else + retries=$((retries - 1)) + rlLog "Clone failed, wait ${delay}s and retry ($retries retries left)" + sleep $delay + fi + done + return $retcode +} + +# In a kernel-ark repository, do all the operations needed to generate an SRPM +# If the kernel is generated return the abspath in KERNEL_SRPM global variable +# Returns 0 on success, 1 otherwise +generateSRPM() { + local generated_srpm + local commit_hash + local cache_dir + + if ! cloneKernelTree; then + rlFail "Failed to clone kernel tree" + return 1 + fi + + rlRun "pushd kernel-ark" + rlLog "Gathering and installing missing build requirements" + rlRun "make dist-get-buildreqs > make-buildreqs.log 2>&1" + rlFileSubmit make-buildreqs.log + if grep -q 'Missing dependencies:' make-buildreqs.log; then + rlRun "KERNEL_BUILDREQS=\"$(sed -n 's/Missing dependencies://p' make-buildreqs.log)\"" + rlRun 'dnf install -y ${KERNEL_BUILDREQS} > install-buildreqs.log 2>&1' + rlFileSubmit install-buildreqs.log + elif grep 'PASS:' make-buildreqs.log; then + rlLog "All dependencies were already installed" + else + rlLogWarning "Error getting dependencies, the build might fail" + rlRun "cat make-buildreqs.log" + fi + + rlLog "Generating SRPM" + rlRun "make dist-srpm > dist-srpm.log 2>&1" + rlFileSubmit dist-srpm.log + + generated_srpm=$(find "$(pwd)" -name "$KERNEL_SRPM_PATTERN") + if [[ -e "$generated_srpm" ]]; then + rlLog "Caching generated SRPM" + commit_hash=$(git rev-parse HEAD) + cache_dir="${CACHE_DIR_BASE}${commit_hash}/" + rlRun "mkdir -p $cache_dir" + rlRun "cp $generated_srpm $cache_dir" + KERNEL_SRPM="$generated_srpm" + rlRun "popd" + return 0 + else + rlLogWarning "Failed to generate SRPM" + rlRun "popd" + return 1 + fi } rlJournalStart rlPhaseStartSetup - # Log system mem/cpus and packages installed by tmt rlRun "nproc" rlRun "free -h" logTmtRequiredPackages @@ -49,42 +149,28 @@ rlJournalStart rlPhaseEnd rlPhaseStartTest - # TODO It would be fantastic to find out a way to shallow clone without - # breaking the dist-get-buildreqs and dist-srpm make targets, because - # a complete clone takes about 5GiB and a LOT of time... - rlLog "Cloning kernel" - rlRun "git clone --branch ${KERNEL_BRANCH} ${KERNEL_GIT_URL}" - rlRun 'cd kernel-ark' - - rlLog "Gathering and installing missing build requirements" - rlRun "make dist-get-buildreqs > make-buildreqs.log" - rlFileSubmit make-buildreqs.log - if grep 'Missing dependencies:' make-buildreqs.log; then - rlRun "KERNEL_BUILDREQS=\"$(sed -n 's/Missing dependencies://p' make-buildreqs.log)\"" - rlRun 'dnf install -y ${KERNEL_BUILDREQS} > install-buildreqs.log 2>&1' - rlFileSubmit install-buildreqs.log - elif grep 'PASS:' make-buildreqs.log; then - rlLog "All dependencies were already installed" + # Check if kernel package was generated by a previous test run + # and generate a new one if it wasn't + checkCache + if [[ -e "$KERNEL_SRPM" ]]; then + rlLog "Using cached kernel SRPM: $KERNEL_SRPM" else - rlLogWarning "Error getting dependencies, the build might fail" - rlRun "cat make-buildreqs.log" + rlLog "No kernel SRPM found, generating new SRPM" + generateSRPM fi - rlLog "Generating srpm" - rlRun 'make dist-srpm > dist-srpm.log 2>&1' - rlRun 'KERNEL_SRPM=$(find . -name kernel-*.src.rpm)' - rlFileSubmit dist-srpm.log - - # Prepare the flags to be passed to rpmbuild depending on the configuration - BUILD_FLAGS="--target $(uname -m) --with up --with toolchain_clang " - BUILD_FLAGS+="--without trace --without arm64_16k --without arm64_64k " - BUILD_FLAGS+="--without realtime --without zfcpdump " - BUILD_FLAGS+="${CLANG_MODE} ${BUILD_MODE}" - - rlLog "Building kernel (branch $KERNEL_BRANCH)" - rlRun "rpmbuild ${BUILD_FLAGS} --rebuild ${KERNEL_SRPM} > build.log 2>&1" - rlFileSubmit build.log + if [[ -e "$KERNEL_SRPM" ]]; then + BUILD_FLAGS="--target $(uname -m) --with up --with toolchain_clang " + BUILD_FLAGS+="--without trace --without arm64_16k --without arm64_64k " + BUILD_FLAGS+="--without realtime --without zfcpdump " + BUILD_FLAGS+="${CLANG_MODE} ${BUILD_MODE}" + rlLog "Building kernel (branch $KERNEL_BRANCH)" + rlRun "rpmbuild ${BUILD_FLAGS} --rebuild ${KERNEL_SRPM} > build.log 2>&1" + rlFileSubmit build.log + else + rlFail "Kernel SRPM not found, finishing test" + fi rlPhaseEnd rlPhaseStartCleanup From cda9761d2e9853bf34aa566dfb028e31fc2d0226 Mon Sep 17 00:00:00 2001 From: Jesus Checa Hidalgo Date: Mon, 5 Aug 2024 09:15:19 +0200 Subject: [PATCH 34/36] Shell static analysis Add pre-commit hook for static analysis on shell scripts (shellcheck) Fixed lots of issues flagged by shellcheck. --- .pre-commit-config.yaml | 7 +++++ tests/fedora-flags/runtest.sh | 7 +++-- tests/gcc-clang-compatibility/runtest.sh | 20 ++++++------ tests/kernel-ark-build/runtest.sh | 16 ++++++++-- tests/libomp/runtest.sh | 12 +++---- tests/long-double/runtest.sh | 2 +- tests/ppc64le-long-double/runtest-fedora.sh | 9 +++--- tests/ppc64le-long-double/runtest.sh | 9 ++---- tests/rhbz_1647130/runtest.sh | 14 ++++----- tests/rpmmacros/runtest.sh | 8 ++--- tests/toolchains/runtest.sh | 35 ++++++++++----------- tests/ucrt64-toolchain/runtest.sh | 2 +- tests/use-correct-dwarf-default/runtest.sh | 8 ++--- 13 files changed, 80 insertions(+), 69 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e5388a6..2e27e78 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,3 +12,10 @@ repos: rev: 1.32.2 hooks: - id: tmt-lint + +- repo: https://github.com/koalaman/shellcheck-precommit + rev: v0.10.0 + hooks: + - id: shellcheck + require_serial: true # Podman has trouble running concurrently + args: ["--exclude=SC1091"] # Ignore "Not following" sourced scripts diff --git a/tests/fedora-flags/runtest.sh b/tests/fedora-flags/runtest.sh index 96d1cc8..04698e7 100755 --- a/tests/fedora-flags/runtest.sh +++ b/tests/fedora-flags/runtest.sh @@ -1,10 +1,11 @@ #!/bin/bash +# shellcheck disable=SC2086 set -ex pipefail -cflags=`rpm -D '%toolchain clang' -E %{build_cflags}` -cxxflags=`rpm -D '%toolchain clang' -E %{build_cxxflags}` -ldflags=`rpm -D '%toolchain clang' -E %{build_ldflags}` +cflags=$(rpm -D '%toolchain clang' -E '%{build_cflags}') +cxxflags=$(rpm -D '%toolchain clang' -E '%{build_cxxflags}') +ldflags=$(rpm -D '%toolchain clang' -E '%{build_ldflags}') # Test a c program diff --git a/tests/gcc-clang-compatibility/runtest.sh b/tests/gcc-clang-compatibility/runtest.sh index 3480309..504713d 100755 --- a/tests/gcc-clang-compatibility/runtest.sh +++ b/tests/gcc-clang-compatibility/runtest.sh @@ -1,4 +1,4 @@ -#!/bin/sh -eux +#!/bin/bash -eux tmp=$(mktemp -d) @@ -6,7 +6,7 @@ tmp=$(mktemp -d) # gcc-toolset-XX, in such case we need to test the compatibility with that one. # We can get that from `clang -v` output. TOOLSET=$(clang -v |& grep "Selected GCC installation" | grep -P -o '(dev|gcc-)toolset-[0-9]*') ||: -if [[ "x" = "x${TOOLSET}" ]]; then +if [[ "" = "${TOOLSET}" ]]; then GCC="g++" else GCC="scl enable ${TOOLSET} -- g++" @@ -14,13 +14,13 @@ else fi # Build the source with GCC, link it with clang -${GCC} -c hello.cpp -o ${tmp}/hello.o -clang++ -o ${tmp}/hello ${tmp}/hello.o -${tmp}/hello | grep "Hello world" -rm -rf ${tmp}/* +${GCC} -c hello.cpp -o "${tmp}/hello.o" +clang++ -o "${tmp}"/hello "${tmp}/hello.o" +"${tmp}/hello" | grep "Hello world" +rm -rf "${tmp:?}"/* # Build the source with clang, link it with GCC -clang++ -c hello.cpp -o ${tmp}/hello.o -${GCC} -o ${tmp}/hello ${tmp}/hello.o -${tmp}/hello | grep "Hello world" -rm -rf ${tmp}/* +clang++ -c hello.cpp -o "${tmp}/hello.o" +${GCC} -o "${tmp}"/hello "${tmp}/hello.o" +"${tmp}/hello" | grep "Hello world" +rm -rf "${tmp:?}"/* diff --git a/tests/kernel-ark-build/runtest.sh b/tests/kernel-ark-build/runtest.sh index f9b217f..db04d4a 100755 --- a/tests/kernel-ark-build/runtest.sh +++ b/tests/kernel-ark-build/runtest.sh @@ -81,7 +81,7 @@ cloneKernelTree() { sleep $delay fi done - return $retcode + return "$retcode" } # In a kernel-ark repository, do all the operations needed to generate an SRPM @@ -102,8 +102,17 @@ generateSRPM() { rlRun "make dist-get-buildreqs > make-buildreqs.log 2>&1" rlFileSubmit make-buildreqs.log if grep -q 'Missing dependencies:' make-buildreqs.log; then - rlRun "KERNEL_BUILDREQS=\"$(sed -n 's/Missing dependencies://p' make-buildreqs.log)\"" - rlRun 'dnf install -y ${KERNEL_BUILDREQS} > install-buildreqs.log 2>&1' + # Getting the build requirements is quite tricky as it might contain + # not only package names but also "provides" perl(ExtUtils::Embed) which + # can break the dnf command if not escaped properly. The safest way is + # to create an array which contains each req as argument, then pass the + # array to dnf. Bash will later pass each element properly quoted. + # rlRun can also easily break the command due to special characters + # so we don't use it here. + read -ra KERNEL_BUILDREQS <<< "$(sed -n 's/Missing dependencies://p' make-buildreqs.log)" + rlLog "Installing dependencies: ${KERNEL_BUILDREQS[*]}" + dnf install -y "${KERNEL_BUILDREQS[@]}" > install-buildreqs.log 2>&1 || \ + rlFail "$(cat install-buildreqs.log)" rlFileSubmit install-buildreqs.log elif grep 'PASS:' make-buildreqs.log; then rlLog "All dependencies were already installed" @@ -139,6 +148,7 @@ rlJournalStart rlRun "free -h" logTmtRequiredPackages + declare tmp rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory" rlRun "pushd $tmp" rlRun "set -o pipefail" diff --git a/tests/libomp/runtest.sh b/tests/libomp/runtest.sh index dfe811f..934b96b 100755 --- a/tests/libomp/runtest.sh +++ b/tests/libomp/runtest.sh @@ -2,23 +2,23 @@ set -exo pipefail -CLANG_PKG=$(rpm -qf --queryformat '%{name}' $(readlink -f $(type -p clang))) +CLANG_PKG=$(rpm -qf --queryformat '%{name}' "$(readlink -f "$(type -p clang)")") # For compat packages, we want to check if there's a package suffix: clang17 instead clang for example PKG_SUFFIX=${CLANG_PKG#clang} -CLANG_NVR=$(rpm -q $CLANG_PKG) -CLANG_VERSION=$(rpm --queryformat="%{version}" -q $CLANG_NVR) +CLANG_NVR=$(rpm -q "$CLANG_PKG") +CLANG_VERSION=$(rpm --queryformat="%{version}" -q "$CLANG_NVR") LIBOMP_DEPENDENCIES="libomp${PKG_SUFFIX} libomp${PKG_SUFFIX}-devel" # Ensure clang depends on the correct clang-libs version -rpm -q --requires ${CLANG_NVR} | grep "${CLANG_PKG}-libs.* = ${CLANG_VERSION}" +rpm -q --requires "$CLANG_NVR" | grep "${CLANG_PKG}-libs.* = ${CLANG_VERSION}" # Check that weak dependencies are correct. The versions of these should be the same # as clang's to guarantee the ABI compatibility, and that version should be actually # installed as well. for lomp_dep in $LIBOMP_DEPENDENCIES; do - rpm -q --recommends clang${PKG_SUFFIX}-libs | grep "${lomp_dep}.* = ${CLANG_VERSION}" - [[ "$(rpm --queryformat="%{version}" -q ${lomp_dep}.$(uname -m))" == "${CLANG_VERSION}" ]] + rpm -q --recommends "clang${PKG_SUFFIX}-libs" | grep "${lomp_dep}.* = ${CLANG_VERSION}" + [[ "$(rpm --queryformat="%{version}" -q "${lomp_dep}"."$(uname -m)")" == "${CLANG_VERSION}" ]] done # Perform a sanity test to ensure everything works as expected diff --git a/tests/long-double/runtest.sh b/tests/long-double/runtest.sh index d69e2c3..68b6aaa 100755 --- a/tests/long-double/runtest.sh +++ b/tests/long-double/runtest.sh @@ -1,4 +1,4 @@ -set -e +#!/bin/bash -e # Use __LDBL_MANT_DIG__ as a way to distinguish between long double formats. # While this is not guaranteed to change for all formats, it provides a diff --git a/tests/ppc64le-long-double/runtest-fedora.sh b/tests/ppc64le-long-double/runtest-fedora.sh index 3cfb081..84dbee7 100755 --- a/tests/ppc64le-long-double/runtest-fedora.sh +++ b/tests/ppc64le-long-double/runtest-fedora.sh @@ -1,8 +1,7 @@ -set -e +#!/bin/bash -e -fedora_release=`rpm -E %{fedora}` +fedora_release=$(rpm -E "%{fedora}") mock_root=fedora-$fedora_release-ppc64le -triple=ppc64le-redhat-linux mock_cmd="mock -r $mock_root --isolation=simple" @@ -12,10 +11,10 @@ run_test () { echo "Running $test_name" echo "Expected output: $expected" - actual=$($mock_cmd -q --shell ./$test_name) + actual=$($mock_cmd -q --shell "./$test_name") echo "Actual output: $actual" - if [[ x$expected == x$actual ]]; then + if [[ "$expected" == "$actual" ]]; then return 0; else return 1; diff --git a/tests/ppc64le-long-double/runtest.sh b/tests/ppc64le-long-double/runtest.sh index be357d5..ec3a1c6 100755 --- a/tests/ppc64le-long-double/runtest.sh +++ b/tests/ppc64le-long-double/runtest.sh @@ -1,7 +1,4 @@ -set -e - -triple=ppc64le-redhat-linux - +#!/bin/bash -e run_test () { test_name=$1 @@ -9,10 +6,10 @@ run_test () { echo "Running $test_name" echo "Expected output: $expected" - actual=$(./$test_name) + actual=$("./$test_name") echo "Actual output: $actual" - if [[ x$expected == x$actual ]]; then + if [[ "$expected" == "$actual" ]]; then return 0; else return 1; diff --git a/tests/rhbz_1647130/runtest.sh b/tests/rhbz_1647130/runtest.sh index 6898f78..1b8b6db 100755 --- a/tests/rhbz_1647130/runtest.sh +++ b/tests/rhbz_1647130/runtest.sh @@ -1,9 +1,7 @@ -#!/bin/sh -set -e -set -x +#!/bin/bash -ex -tmp_cpp=`mktemp -t XXXXX.cpp` -tmp_dir=`mktemp -d` -echo 'int main(int argc, char*argv[]) { while(argc--) new int(); return 0; }' > $tmp_cpp -scan-build -o $tmp_dir clang++ -c $tmp_cpp -o /dev/null -(scan-view --no-browser $tmp_dir/* & WPID=$! && sleep 10s && kill $WPID) +tmp_cpp=$(mktemp -t XXXXX.cpp) +tmp_dir=$(mktemp -d) +echo 'int main(int argc, char*argv[]) { while(argc--) new int(); return 0; }' > "$tmp_cpp" +scan-build -o "$tmp_dir" clang++ -c "$tmp_cpp" -o /dev/null +(scan-view --no-browser "$tmp_dir"/* & WPID=$! && sleep 10s && kill $WPID) diff --git a/tests/rpmmacros/runtest.sh b/tests/rpmmacros/runtest.sh index 99295c3..02cd4a5 100755 --- a/tests/rpmmacros/runtest.sh +++ b/tests/rpmmacros/runtest.sh @@ -1,11 +1,11 @@ -#!/bin/sh -eux +#!/bin/bash -eux -clang_pkg=${1:-"$(rpm -qf --queryformat '%{name}' $(readlink -f $(type -p clang)))"} +clang_pkg=${1:-"$(rpm -qf --queryformat '%{name}' "$(readlink -f "$(type -p clang)")")"} macros_path="/usr/lib/rpm/macros.d/macros.clang" set pipefail -if ! rpm -q $clang_pkg > /dev/null; then +if ! rpm -q "$clang_pkg" > /dev/null; then echo "Could not find package $clang_pkg" exit 1 fi @@ -23,7 +23,7 @@ echo # suffix ~rcN. Meanwhile, the macro won't include it in order to allow packages # built with an RC package to be fully supported later. # In that case, we need to remove that prefix. -rpm_version=$(rpm -q $clang_pkg --qf "%{version}" | sed 's/~.*//') +rpm_version=$(rpm -q "$clang_pkg" --qf "%{version}" | sed 's/~.*//') macro_version=$(rpm --eval "%{clang_version}") if [[ "$rpm_version" != "$macro_version" ]]; then diff --git a/tests/toolchains/runtest.sh b/tests/toolchains/runtest.sh index 0d1a3e5..d1d9298 100755 --- a/tests/toolchains/runtest.sh +++ b/tests/toolchains/runtest.sh @@ -1,4 +1,4 @@ -#!/bin/sh -eux +#!/bin/bash -eu set pipefail @@ -12,41 +12,40 @@ status=0 test_toolchain() { - toolchain=$@ + toolchain=("$@") args="" - while [ $# -gt 0 ]; do - case $1 in + for arg in "${toolchain[@]}"; do + case "$arg" in clang) - compiler=$1 + compiler=$arg src=hello.c ;; clang++) - compiler=$1 + compiler=$arg src=hello.cpp ;; compiler-rt) - args="$args -rtlib=$1" + args="$args -rtlib=$arg" ;; libc++) - args="$args -stdlib=$1" + args="$args -stdlib=$arg" ;; libstdc++) - args="$args -stdlib=$1" + args="$args -stdlib=$arg" ;; lld) - args="$args -fuse-ld=$1" + args="$args -fuse-ld=$arg" ;; *) - args="$args $1" + args="$args $arg" ;; esac - shift done cmd="$compiler $args $src" rm -f a.out - echo "* $toolchain" + echo "* ${toolchain[*]}" echo " command: $cmd" if $cmd && ./a.out | grep -q 'Hello World'; then echo " PASS" @@ -57,17 +56,17 @@ test_toolchain() { } clang --version -CLANG_PKG=$(rpm -qf --queryformat '%{name}' $(readlink -f $(type -p clang))) +CLANG_PKG=$(rpm -qf --queryformat '%{name}' "$(readlink -f "$(type -p clang)")") # Repoquery is needed instead yum info for compatibility with RHEL-7 -repoquery -i --installed $CLANG_PKG | grep ^Source -clang_version=$(rpm -q --queryformat "%{version}" $CLANG_PKG | grep -ioP "^[0-9]+") +repoquery -i --installed "$CLANG_PKG" | grep ^Source +clang_version=$(rpm -q --queryformat "%{version}" "$CLANG_PKG" | grep -ioP "^[0-9]+") echo "" for compiler in clang clang++; do for rtlib in "" compiler-rt; do for linker in "" lld; do for cxxlib in "" $CXXLIBS; do - if [ "$compiler" = "clang" -a -n "$cxxlib" ]; then + if [[ "$compiler" = "clang" && -n "$cxxlib" ]]; then continue fi for args in "" -static; do @@ -100,7 +99,7 @@ for compiler in clang clang++; do continue fi - test_toolchain $compiler $rtlib $linker $cxxlib $args + test_toolchain "$compiler" "$rtlib" "$linker" "$cxxlib" "$args" done done done diff --git a/tests/ucrt64-toolchain/runtest.sh b/tests/ucrt64-toolchain/runtest.sh index 2b3f166..9c8d5fe 100755 --- a/tests/ucrt64-toolchain/runtest.sh +++ b/tests/ucrt64-toolchain/runtest.sh @@ -1,4 +1,4 @@ -set -eux +#!/bin/bash -eux clang++ --target=x86_64-windows-gnu test.cpp file a.exe | grep "PE32+ executable (console) x86-64, for MS Windows" diff --git a/tests/use-correct-dwarf-default/runtest.sh b/tests/use-correct-dwarf-default/runtest.sh index 926658e..47e5a30 100755 --- a/tests/use-correct-dwarf-default/runtest.sh +++ b/tests/use-correct-dwarf-default/runtest.sh @@ -1,4 +1,4 @@ -#!/bin/sh -eux +#!/bin/bash -eux # Determine correct DWARF version to use. Defaults to version 5, but older # distros might need to use version 4, which can be configured using the @@ -6,9 +6,9 @@ required_dwarf_version=${DWARF_VERSION:-5} # Get clang version -CLANG_PKG=$(rpm -qf --queryformat '%{name}' $(readlink -f $(type -p clang))) -clang_version=$(rpm -q --queryformat "%{version}" $CLANG_PKG | grep -ioP "^[0-9]+") -if [ $clang_version -lt 18 ]; then +CLANG_PKG=$(rpm -qf --queryformat '%{name}' "$(readlink -f "$(type -p clang)")") +clang_version=$(rpm -q --queryformat "%{version}" "$CLANG_PKG" | grep -ioP "^[0-9]+") +if [ "$clang_version" -lt 18 ]; then >&2 echo "clang is older than version 18"; required_dwarf_version=4 fi From c140bdf103ff140adc3efca43d5a0fa19bf649b1 Mon Sep 17 00:00:00 2001 From: Tulio Magno Quites Machado Filho Date: Wed, 13 Nov 2024 16:30:58 -0300 Subject: [PATCH 35/36] rhbz_1647130: Remove tmp_dir at the end Guarantee the temporary directory is removed after the execution of this test. --- tests/rhbz_1647130/runtest.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/rhbz_1647130/runtest.sh b/tests/rhbz_1647130/runtest.sh index 1b8b6db..39f8a90 100755 --- a/tests/rhbz_1647130/runtest.sh +++ b/tests/rhbz_1647130/runtest.sh @@ -5,3 +5,4 @@ tmp_dir=$(mktemp -d) echo 'int main(int argc, char*argv[]) { while(argc--) new int(); return 0; }' > "$tmp_cpp" scan-build -o "$tmp_dir" clang++ -c "$tmp_cpp" -o /dev/null (scan-view --no-browser "$tmp_dir"/* & WPID=$! && sleep 10s && kill $WPID) +rm -rf "$tmp_cpp" "$tmp_dir" From 3de6a2aad533cdf90fcccc21ba1d8207c4568714 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 6 Feb 2025 10:09:24 +0100 Subject: [PATCH 36/36] Update ucrt test for new file output After a recent file update, the output is now: > a.exe: PE32+ executable for MS Windows 5.02 (console), x86-64, 18 sections Adjust the grep to match both the old and new output. I think the key parts are that it's a "PE32+ executable" for x86-64. --- tests/ucrt64-toolchain/runtest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ucrt64-toolchain/runtest.sh b/tests/ucrt64-toolchain/runtest.sh index 9c8d5fe..c9d0946 100755 --- a/tests/ucrt64-toolchain/runtest.sh +++ b/tests/ucrt64-toolchain/runtest.sh @@ -1,4 +1,4 @@ #!/bin/bash -eux clang++ --target=x86_64-windows-gnu test.cpp -file a.exe | grep "PE32+ executable (console) x86-64, for MS Windows" +file a.exe | grep "PE32+ executable.*x86-64"