From 5f6796def10452d31aa7b2615fddfa9dcf36eda5 Mon Sep 17 00:00:00 2001 From: Milos Prchlik Date: Nov 23 2021 16:16:17 +0000 Subject: tests: parametrize "libc++" in tests Downstream has no `libc++`, but it can run clang tests with `libstdc++`. Parametrize the tests, leaving the actual library to use on their respective `main.fmf` files that are easier to overturn in downstream repos. --- diff --git a/tests/llvm-toolchain/main.fmf b/tests/llvm-toolchain/main.fmf index ff88230..96d4d56 100644 --- a/tests/llvm-toolchain/main.fmf +++ b/tests/llvm-toolchain/main.fmf @@ -1,12 +1,30 @@ # TODO REVIEW: better summary summary: "" test: ./test.sh -require: - - clang - - lld - - compiler-rt - - libcxx-devel - - libcxx-static - - glibc-devel - - glibc-static - - gcc +adjust: + - environment+: + CXXLIB: "libc++" + require: + - clang + - lld + - compiler-rt + - libcxx-devel + - libcxx-static + - glibc-devel + - glibc-static + - gcc + when: "distro == fedora" + because: testing against libcxx package in Fedora + - environment+: + CXXLIB: "libstdc++" + require: + - clang + - lld + - compiler-rt + - glibc-devel + - glibc-static + - gcc + - libstdc++ + when: "distro == rhel" + because: testing against libstdc++ package in RHEL as libcxx is not shipped with RHEL +require: [] diff --git a/tests/llvm-toolchain/test.sh b/tests/llvm-toolchain/test.sh index 4dde26c..2b2ef02 100755 --- a/tests/llvm-toolchain/test.sh +++ b/tests/llvm-toolchain/test.sh @@ -4,6 +4,12 @@ set pipefail +if [ -z "${CXXLIB:-}" ]; then + echo "CXXLIB variable is a required input but it's not specified!" + echo "Test metadata should have picked a proper value, depending on distro." + exit 1 +fi + # Test compile a C program. cat << EOF | \ clang -fuse-ld=lld -rtlib=compiler-rt -x c - && \ @@ -18,7 +24,7 @@ EOF # Test compile a C++ program. cat << EOF | \ - clang++ -x c++ -fuse-ld=lld -rtlib=compiler-rt -stdlib=libc++ - && \ + clang++ -x c++ -fuse-ld=lld -rtlib=compiler-rt -stdlib="$CXXLIB" - && \ ./a.out | grep 'Hello World' #include diff --git a/tests/toolchains/main.fmf b/tests/toolchains/main.fmf index 86705f4..7a3b0f4 100644 --- a/tests/toolchains/main.fmf +++ b/tests/toolchains/main.fmf @@ -1,7 +1,21 @@ # TODO REVIEW: better summary summary: "" test: ./test.sh +adjust: + - environment+: + CXXLIBS: "libc++" + require: + - clang + - libcxx-devel + when: "distro == fedora" + because: testing against libcxx package in Fedora + - environment+: + CXXLIBS: "libstdc++" + require: + - clang + - libstdc++ + when: "distro == rhel" + because: testing against libstdc++ package in RHEL as libcxx is not shipped with RHEL # TODO REVIEW: are these all requirements? test.sh seems to run quite a lot of stuff, looks like we # need more packages from LLVM family. -require: - - clang +require: [] diff --git a/tests/toolchains/test.sh b/tests/toolchains/test.sh index f6d77fb..bed2e3d 100755 --- a/tests/toolchains/test.sh +++ b/tests/toolchains/test.sh @@ -2,6 +2,12 @@ set pipefail +if [ -z "${CXXLIBS:-}" ]; then + echo "CXXLIBS variable is a required input but it's not specified!" + echo "Test metadata should have picked a proper value, depending on distro." + exit 1 +fi + status=0 test_toolchain() { @@ -25,6 +31,9 @@ test_toolchain() { libc++) args="$args -stdlib=$1" ;; + libstdc++) + args="$args -stdlib=$1" + ;; lld) args="$args -fuse-ld=$1" ;; @@ -54,7 +63,7 @@ echo "" for compiler in clang clang++; do for rtlib in "" compiler-rt; do for linker in "" lld; do - for cxxlib in "" libc++; do + for cxxlib in "" $CXXLIBS; do if [ "$compiler" = "clang" -a -n "$cxxlib" ]; then continue fi