diff --git a/tests/fedora-flags/hello.c b/tests/fedora-flags/hello.c new file mode 100644 index 0000000..51b259b --- /dev/null +++ b/tests/fedora-flags/hello.c @@ -0,0 +1,5 @@ +#include + +void hello() { + printf("Hello World\n"); +} diff --git a/tests/fedora-flags/hello.cpp b/tests/fedora-flags/hello.cpp new file mode 100644 index 0000000..400612b --- /dev/null +++ b/tests/fedora-flags/hello.cpp @@ -0,0 +1,5 @@ +#include + +void hello() { + std::cout << "Hello World\n"; +} diff --git a/tests/fedora-flags/main.c b/tests/fedora-flags/main.c new file mode 100644 index 0000000..1a3455d --- /dev/null +++ b/tests/fedora-flags/main.c @@ -0,0 +1,6 @@ +void hello(); + +int main(int argc, char **argv) { + hello(); + return 0; +} diff --git a/tests/fedora-flags/main.cpp b/tests/fedora-flags/main.cpp new file mode 100644 index 0000000..1a3455d --- /dev/null +++ b/tests/fedora-flags/main.cpp @@ -0,0 +1,6 @@ +void hello(); + +int main(int argc, char **argv) { + hello(); + return 0; +} diff --git a/tests/fedora-flags/runtest.sh b/tests/fedora-flags/runtest.sh new file mode 100755 index 0000000..96d1cc8 --- /dev/null +++ b/tests/fedora-flags/runtest.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +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}` + + +# 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" diff --git a/tests/libomp/openmp-compile-link-test.c b/tests/libomp/openmp-compile-link-test.c new file mode 100644 index 0000000..a2b6004 --- /dev/null +++ b/tests/libomp/openmp-compile-link-test.c @@ -0,0 +1,8 @@ +#include +#include + +int main(int argc, char **argv) { + int nthreads = omp_get_num_threads(); + printf("Num Threads: %d\n", nthreads); + return 0; +} diff --git a/tests/libomp/runtest.sh b/tests/libomp/runtest.sh new file mode 100755 index 0000000..f07dbbc --- /dev/null +++ b/tests/libomp/runtest.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -exo pipefail + +clang -fopenmp openmp-compile-link-test.c + +./a.out | grep "Num Threads: 1" diff --git a/tests/llvm-toolchain/runtest.sh b/tests/llvm-toolchain/runtest.sh new file mode 100755 index 0000000..eeebda5 --- /dev/null +++ b/tests/llvm-toolchain/runtest.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# Tests for using a full LLVM toolchain: clang + compiler-rt + libcxx + lld + +set -ex pipefail + +# Test compile a C program. +cat << EOF | \ + clang -fuse-ld=lld -rtlib=compiler-rt -x c - && \ + ./a.out | grep 'Hello World' + +#include +int main(int argc, char **argv) { + printf("Hello World\n"); + return 0; +} +EOF + +# Test compile a C++ program. +cat << EOF | \ + clang++ -x c++ -fuse-ld=lld -rtlib=compiler-rt -stdlib=libc++ - && \ + ./a.out | grep 'Hello World' + +#include +int main(int argc, char **argv) { + std::cout << "Hello World\n"; + return 0; +} +EOF diff --git a/tests/rhbz_1647130/runtest.sh b/tests/rhbz_1647130/runtest.sh new file mode 100755 index 0000000..ab515c7 --- /dev/null +++ b/tests/rhbz_1647130/runtest.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e +set -x + +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/rhbz_1657544/from_chars.cpp b/tests/rhbz_1657544/from_chars.cpp new file mode 100644 index 0000000..b76be22 --- /dev/null +++ b/tests/rhbz_1657544/from_chars.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +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; +} diff --git a/tests/rhbz_1657544/runtest.sh b/tests/rhbz_1657544/runtest.sh new file mode 100755 index 0000000..758de0b --- /dev/null +++ b/tests/rhbz_1657544/runtest.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -e +set -x + +clang++ from_chars.cpp +./a.out 100 | grep 100 diff --git a/tests/tests-libomp.yml b/tests/tests-libomp.yml index b43e4be..a9db418 100644 --- a/tests/tests-libomp.yml +++ b/tests/tests-libomp.yml @@ -15,10 +15,7 @@ - role: standard-test-basic tags: - classic - repositories: - - repo: "https://src.fedoraproject.org/tests/clang.git" - dest: "clang" required_packages: - clang tests: - - clang/libomp + - libomp diff --git a/tests/tests.yml b/tests/tests.yml index 576e7a7..65426f8 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -26,19 +26,17 @@ - redhat-rpm-config repositories: - - repo: "https://src.fedoraproject.org/tests/llvm-test-suite.git" + - repo: "https://src.fedoraproject.org/rpms/llvm-test-suite.git" dest: "llvm-test-suite" - - repo: "https://src.fedoraproject.org/tests/clang.git" - dest: "clang" tests: - rhbz#482491: dir: ./ run: find /usr -name 'libgcc_s.so*' && echo "int main(){}" | clang -v -x c - - - llvm-test-suite/test-suite + - llvm-test-suite/tests/test-suite # ABI test suite is too greedy on the FS #- llvm-test-suite/abi-test-suite - - clang/rhbz_1657544 - - clang/rhbz_1647130 - - clang/llvm-toolchain - - clang/fedora-flags - - clang/toolchains + - rhbz_1657544 + - rhbz_1647130 + - llvm-toolchain + - fedora-flags + - toolchains diff --git a/tests/testspocl.yml b/tests/testspocl.yml index 01bcd5b..7189eac 100644 --- a/tests/testspocl.yml +++ b/tests/testspocl.yml @@ -17,7 +17,7 @@ tags: - classic repositories: - - repo: "https://src.fedoraproject.org/tests/pocl.git" + - repo: "https://src.fedoraproject.org/rpms/pocl.git" dest: "pocl" required_packages: - ocl-icd-devel @@ -25,4 +25,4 @@ - gcc tests: # rhbz#1582884 - - pocl/simple-opencl-no-clang: + - pocl/tests/simple-opencl-no-clang diff --git a/tests/toolchains/hello.c b/tests/toolchains/hello.c new file mode 100644 index 0000000..f5c80a9 --- /dev/null +++ b/tests/toolchains/hello.c @@ -0,0 +1,5 @@ +#include +int main(int argc, char **argv) { + printf("Hello World\n"); + return 0; +} diff --git a/tests/toolchains/hello.cpp b/tests/toolchains/hello.cpp new file mode 100644 index 0000000..bda4087 --- /dev/null +++ b/tests/toolchains/hello.cpp @@ -0,0 +1,5 @@ +#include +int main(int argc, char **argv) { + std::cout << "Hello World\n"; + return 0; +} diff --git a/tests/toolchains/runtest.sh b/tests/toolchains/runtest.sh new file mode 100755 index 0000000..c928ae4 --- /dev/null +++ b/tests/toolchains/runtest.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +set pipefail + +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" + ;; + 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 +dnf info installed clang | grep ^Source +echo "" + +for compiler in clang clang++; do + for rtlib in "" compiler-rt; do + for linker in "" lld; do + for cxxlib in "" libc++; 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 + + test_toolchain $compiler $rtlib $linker $cxxlib $args + done + done + done + done +done + +exit $status