Migrate tests to tests/clang repo

This commit is contained in:
Jesus Checa Hidalgo 2022-09-12 11:53:59 +02:00 committed by jcheca
parent 431a66ade2
commit f15eec4d81
39 changed files with 12 additions and 649 deletions

6
tests/README.md Normal file
View File

@ -0,0 +1,6 @@
# Gating testplans for Clang
The tests for clang are in a separate repo: https://src.fedoraproject.org/tests/clang
This directory should contain only fmf plans (such as build-gating.fmf) which import
the tests from the tests repo. This can be done using the "url" parameter of the
plan's "discover" step. Reference: https://tmt.readthedocs.io/en/stable/spec/plans.html#fmf

View File

@ -1,37 +0,0 @@
summary: libomp clang tests for build/PR gating
adjust:
- because: "Plan to be ran when either executed locally, or executed by CI system to gate a build or PR."
when: >-
trigger is defined
and trigger != commit
and trigger != build
enabled: false
- 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: "libomp not supported in s390x"
when: arch == s390x
enabled: false
discover:
how: fmf
test: libomp
execute:
how: tmt
prepare:
# We want to make sure libomp is not already present on the system to ensure
# that clang pulls in the correct libomp dependencies when it is installed.
- name: Drop libomp
how: shell
script: |
yum erase -y libomp libomp-devel clang clang-libs
provision:
hardware:
memory: ">= 4 GiB"

View File

@ -16,6 +16,8 @@ adjust:
discover:
how: fmf
test: pocl
url: https://src.fedoraproject.org/tests/clang.git
ref: main
execute:
how: tmt
prepare:

View File

@ -50,11 +50,13 @@ adjust:
discover:
- name: clang-tests
how: fmf
url: https://src.fedoraproject.org/tests/clang.git
ref: main
filter: "tag:-not-in-default"
- name: upstream-llvm-integration-testsuite
how: fmf
url: https://src.fedoraproject.org/rpms/llvm.git
ref: rawhide
url: https://src.fedoraproject.org/tests/llvm.git
ref: main
test: integration-test-suite
execute:
how: tmt

View File

@ -1,15 +0,0 @@
summary: clang-format-diff
test: "$WITH_SCL ./test.sh"
adjust:
# Common requirements when LLVM is not SCL-ized
- require:
- clang-tools-extra
when: "collection is not defined"
# Requirements for SCL-ized LLVM
- require:
- llvm-toolset-13.0-clang-tools-extra
when: "collection == llvm-toolset-13.0"
- require:
- llvm-toolset-14.0-clang-tools-extra
when: "collection == llvm-toolset-14.0"

View File

@ -1,5 +0,0 @@
#!/bin/sh -eux
# Check that clang-format-diff is in PATH.
# rhbz#1939018
clang-format-diff -h

View File

@ -1,5 +0,0 @@
#include <stdio.h>
void hello() {
printf("Hello World\n");
}

View File

@ -1,5 +0,0 @@
#include <iostream>
void hello() {
std::cout << "Hello World\n";
}

View File

@ -1,6 +0,0 @@
void hello();
int main(int argc, char **argv) {
hello();
return 0;
}

View File

@ -1,6 +0,0 @@
void hello();
int main(int argc, char **argv) {
hello();
return 0;
}

View File

@ -1,30 +0,0 @@
summary: fedora-flags
test: "$WITH_SCL ./test.sh"
require:
- redhat-rpm-config
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"
- because: s390x does not have epel repo which is required to provide rpm macros
enabled: false
when: >-
distro == rhel-7
and arch == s390x
# Note: this needs epel-release repo to be available
- because: "To enable rpm macros not available by default (e.g. build_cflags), epel-rpm-macros is needed"
require+:
- epel-rpm-macros
when: distro == rhel-7

View File

@ -1,20 +0,0 @@
#!/bin/sh -eux
set 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}`
# Test a c program
clang $cflags -c hello.c -o hello.o
clang $cflags -c main.c -o main.o
clang $ldflags -o hello main.o hello.o
./hello | grep "Hello World"
# Test a cxx program
clang++ $cxxflags -c hello.cpp -o hello-cpp.o
clang++ $cxxflags -c main.cpp -o main-cpp.o
clang++ $ldflags -o hello-cpp main-cpp.o hello-cpp.o
./hello-cpp | grep "Hello World"

View File

@ -1,36 +0,0 @@
# TODO: get fitting summary - what's the purpose of this test? Comment from the STI version says:
#
# We want to make sure libomp is not already present on the system to ensure
# that clang pulls in the correct libomp dependencies when it is installed.
summary: libomp tests
# This test requires a special preparation, see `/tests/tests-libomp` plan. As such,
# it shouldn't be part of the `/tests/default` plan.
tag:
- not-in-default
test: "$WITH_SCL ./test.sh"
adjust:
- because: "libomp is not supported in s390x"
when: arch == s390x
enabled: false
# Common requirements when LLVM is not SCL-ized
- require:
- clang
- clang-libs
- libomp
- libomp-devel
when: "collection is not defined"
# Requirements for SCL-ized LLVM
- require:
- llvm-toolset-13.0-clang
- llvm-toolset-13.0-clang-libs
- llvm-toolset-13.0-libomp
- llvm-toolset-13.0-libomp-devel
when: "collection == llvm-toolset-13.0"
- require:
- llvm-toolset-14.0-clang
- llvm-toolset-14.0-clang-libs
- llvm-toolset-14.0-libomp
- llvm-toolset-14.0-libomp-devel
when: "collection == llvm-toolset-14.0"

View File

@ -1,8 +0,0 @@
#include <omp.h>
#include <stdio.h>
int main(int argc, char **argv) {
int nthreads = omp_get_num_threads();
printf("Num Threads: %d\n", nthreads);
return 0;
}

View File

@ -1,7 +0,0 @@
#!/bin/bash
set -exo pipefail
clang -fopenmp openmp-compile-link-test.c
./a.out | grep "Num Threads: 1"

View File

@ -1,18 +0,0 @@
# 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:
- 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:
- git
- clang
- ninja-build
- llvm-test-suite
duration: 1h

View File

@ -1,7 +0,0 @@
#!/bin/sh -eux
# TODO: tmt does not support a remote git repo as a requirement, one has to clone it "manually".
git clone --depth 1 https://src.fedoraproject.org/rpms/llvm-test-suite.git llvm-test-suite
cd llvm-test-suite/tests/test-suite
./runtest.sh

View File

@ -1,30 +0,0 @@
summary: Test build a simple RPM package to ensure that -fopenmp works
test: "$WITH_SCL ./runtest.sh"
require:
- rpm-build
adjust:
- because: "libomp not supported in s390x"
when: arch == s390x
enabled: false
- because: "Use yum in RHEL < 8"
require+:
- yum-utils
environment+:
BUILDDEP_CMD: "yum-builddep"
when: distro < rhel-8
- 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
# Requirements for SCL-ized LLVM
- require+:
- llvm-toolset-13.0-build
when: "collection == llvm-toolset-13.0"
- require+:
- llvm-toolset-14.0-build
when: "collection == llvm-toolset-14.0"

View File

@ -1,6 +0,0 @@
#!/bin/bash
set -ex
${BUILDDEP_CMD} -y test.spec
rpmbuild --define '_sourcedir .' --define '_builddir .' -bb test.spec

View File

@ -1,7 +0,0 @@
int main(int argc, char **argv) {
int res = 1;
#pragma omp parallel
#pragma omp single
res = 0;
return res;
}

View File

@ -1,36 +0,0 @@
%global toolchain clang
%{?scl:%global scl_prefix %{scl}-}
Name: test
Version: 1
Release: 1
Summary: Test package for checking that RPM packages using -fopenmp build correctly
License: MIT
BuildRequires: %{?scl_prefix}clang
BuildRequires: %{?scl_prefix}libomp
Source0: test.c
%description
clang was adding RUNPATH to binaries that use OpenMP, and since RUNPATH
is prohibited in Fedora builds, this was causing packages using clang
and OpenMP to fail to build.
References:
https://fedoraproject.org/wiki/Changes/Broken_RPATH_will_fail_rpmbuild
https://github.com/llvm/llvm-project/commit/9b9d08111b618d74574ba03e5cc3d752ecc56f55
%build
clang ${CFLAGS} -c %{SOURCE0} -o test.o
clang ${LDFLAGS} -fopenmp test.o -o main
%check
./main
%install
install -d %{buildroot}%{_bindir}
install main %{buildroot}%{_bindir}
%files
%{_bindir}/main

View File

@ -1,24 +0,0 @@
# TODO REVIEW: get fitting summary - what's the purpose of this test? Comment from the STI version says:
#
# This is separate from tests.yml because we want to run the tests without
# clang installed.
summary: pocl
adjust:
- because: "PoCL is shipped with Fedora, not RHEL/CentOS"
when: >-
distro == rhel
or distro == centos
enabled: false
# This test requires a special preparation, see `/tests/tests-pocl` plan. As such,
# it shouldn't be part of the `/tests/default` plan.
tag:
- not-in-default
# rhbz#1582884
test: "$WITH_SCL ./test.sh"
require:
- git
- ocl-icd-devel
- pocl
- gcc

View File

@ -1,7 +0,0 @@
#!/bin/sh -eux
# TODO: tmt does not support a remote git repo as a requirement, one has to clone it "manually".
git clone --depth 1 https://src.fedoraproject.org/rpms/pocl.git pocl
cd pocl/tests/simple-opencl-no-clang
./runtest.sh

View File

@ -1,33 +0,0 @@
summary: Test that gcc and clang use the same long double format on ppc64le
test: $WITH_SCL ./runtest.sh
duration: 1h
# see https://bugzilla.redhat.com/show_bug.cgi?id=2115752
enabled: false
adjust:
# Common requirements when LLVM is not SCL-ized
- require+:
- clang
when: "collection is not defined"
- because: "Fedora CI runs in x86_64 only, emulate with qemu and mock"
require+:
- qemu-user-static
- mock
test: ./runtest-fedora.sh
when: distro == fedora and arch == x86_64
continue: false
- enabled: false
when: arch != ppc64le
- 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"

View File

@ -1,14 +0,0 @@
set -e
fedora_release=`rpm -E %{fedora}`
mock_root=fedora-$fedora_release-ppc64le
triple=ppc64le-redhat-linux
mock -r $mock_root --isolation=simple --install gcc
gcc_output=$(mock -r $mock_root --isolation=simple -q --shell gcc -E -dM -x c /dev/null | grep -e __LONG_DOUBLE_IEEE128__ -e __LONG_DOUBLE_IBM128__)
clang_output=$(clang -target $triple -E -dM -x c /dev/null | grep -e __LONG_DOUBLE_IEEE128__ -e __LONG_DOUBLE_IBM128__)
echo "gcc: $gcc_output"
echo "clang: $clang_output"
test "$gcc_output" = "$clang_output"

View File

@ -1,9 +0,0 @@
set -e
gcc_output=$(gcc -E -dM -x c /dev/null | grep -e __LONG_DOUBLE_IEEE128__ -e __LONG_DOUBLE_IBM128__)
clang_output=$(clang -E -dM -x c /dev/null | grep -e __LONG_DOUBLE_IEEE128__ -e __LONG_DOUBLE_IBM128__)
echo "gcc: $gcc_output"
echo "clang: $clang_output"
test "$gcc_output" = "$clang_output"

View File

@ -1,19 +0,0 @@
summary: RHBZ1647130
test: "$WITH_SCL ./test.sh"
require: []
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"

View File

@ -1,8 +0,0 @@
#!/bin/sh -eux
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)

View File

@ -1,15 +0,0 @@
#include <charconv>
#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, char **argv)
{
size_t r=0;
const char *begin = argv[1];
const char *end = begin + strlen(begin);
from_chars(begin, end, r);
cout << r << '\n';
return 0;
}

View File

@ -1,16 +0,0 @@
summary: RHBZ1657544
test: "$WITH_SCL ./test.sh"
require: []
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"

View File

@ -1,4 +0,0 @@
#!/bin/sh -eux
clang++ from_chars.cpp
./a.out 100 | grep 100

View File

@ -1,17 +0,0 @@
summary: rhbz-482491
test: "$WITH_SCL ./test.sh"
require:
- libgcc
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"

View File

@ -1,3 +0,0 @@
#!/bin/sh -eux
find /usr -name 'libgcc_s.so*' && echo "int main(){}" | clang -v -x c -

View File

@ -1,5 +0,0 @@
#include<stdio.h>
int main(int argc, char **argv) {
printf("Hello World\n");
return 0;
}

View File

@ -1,5 +0,0 @@
#include <iostream>
int main(int argc, char **argv) {
std::cout << "Hello World\n";
return 0;
}

View File

@ -1,55 +0,0 @@
# TODO REVIEW: better summary
summary: ""
test: "$WITH_SCL ./test.sh"
require:
- glibc-static
- yum-utils
# This require EPEL/CRB to be enabled on RHEL
- libstdc++-static
adjust:
# Common requirements when LLVM is not SCL-ized
- require+:
- clang
- compiler-rt
- lld
when: "collection is not defined"
# Requirements for SCL-ized LLVM
- require+:
- llvm-toolset-13.0-clang
- llvm-toolset-13.0-compiler-rt
- llvm-toolset-13.0-lld
when: "collection == llvm-toolset-13.0"
- require+:
- llvm-toolset-14.0-clang
- llvm-toolset-14.0-compiler-rt
- llvm-toolset-14.0-lld
when: "collection == llvm-toolset-14.0"
# lld not supported in s390x or ppc64. If any lld package was added to
# requirements, remove it.
- require-:
- lld
- llvm-toolset-13.0-lld
- llvm-toolset-14.0-lld
when: arch == s390x or arch == ppc64
- environment+:
CXXLIBS: "libc++"
require+:
- libcxx-devel
- libcxx-static
when: "distro == fedora"
because: testing against libcxx package in Fedora
- environment+:
CXXLIBS: "libstdc++"
require+:
- libstdc++
when: >-
distro == rhel
or distro == centos
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.

View File

@ -1,102 +0,0 @@
#!/bin/sh -eux
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() {
toolchain=$@
args=""
while [ $# -gt 0 ]; do
case $1 in
clang)
compiler=$1
src=hello.c
;;
clang++)
compiler=$1
src=hello.cpp
;;
compiler-rt)
args="$args -rtlib=$1"
;;
libc++)
args="$args -stdlib=$1"
;;
libstdc++)
args="$args -stdlib=$1"
;;
lld)
args="$args -fuse-ld=$1"
;;
*)
args="$args $1"
;;
esac
shift
done
cmd="$compiler $args $src"
rm -f a.out
echo "* $toolchain"
echo " command: $cmd"
if $cmd && ./a.out | grep -q 'Hello World'; then
echo " PASS"
else
echo " FAIL"
status=1
fi
}
clang --version
# Repoquery is needed instead yum info for compatibility with RHEL-7
repoquery -i --installed $(rpm -qf $(which clang)) | grep ^Source
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
continue
fi
for args in "" -static; do
# Skip known failures
# TODO: Fix these
if [[ "$args" = "-static" && "$rtlib" = "compiler-rt" ]]; then
continue
fi
# Static libc++ needs -pthread
if [[ "$args" = "-static" && "$cxxlib" = "libc++" ]]; then
args="$args -pthread"
fi
# lld is not supported in s390x and ppc64
if [[ "$(uname -m)" = "s390x" || "$(uname -m)" = "ppc64" ]] \
&& [[ "$linker" = "lld" ]];
then
continue
fi
# compiler-rt does not provide builtins for s390x
if [[ "$(uname -m)" = "s390x" && "$rtlib" = "compiler-rt" ]]; then
continue
fi
test_toolchain $compiler $rtlib $linker $cxxlib $args
done
done
done
done
done
exit $status

View File

@ -1,20 +0,0 @@
summary: Test that clang uses DWARFv4 by default
test: "$WITH_SCL ./test.sh"
require:
- libgcc
adjust:
# Common requirements when LLVM is not SCL-ized
- require+:
- clang
- llvm
when: "collection is not defined"
# Requirements for SCL-ized LLVM
- require+:
- llvm-toolset-13.0-clang
- llvm-toolset-13.0-llvm
when: "collection == llvm-toolset-13.0"
- require+:
- llvm-toolset-14.0-clang
- llvm-toolset-14.0-llvm
when: "collection == llvm-toolset-14.0"

View File

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