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.
This commit is contained in:
Milos Prchlik 2021-11-11 12:56:36 +01:00
parent 90e30031a9
commit 5f6796def1
4 changed files with 60 additions and 13 deletions

View File

@ -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: []

View File

@ -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 <iostream>

View File

@ -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: []

View File

@ -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