Import tests from tests/clang repository

It's not necessary to store the tests in a separate repository, since
other packages can just reference the tests in this repo.

Also update, the other tests to pull from git repos in the rpms namespace.
This commit is contained in:
Tom Stellard 2021-04-14 02:01:54 +00:00
parent 56c57e4695
commit 13c66032d5
17 changed files with 217 additions and 15 deletions

View File

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

View File

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

View File

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

View File

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

20
tests/fedora-flags/runtest.sh Executable file
View File

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

View File

@ -0,0 +1,8 @@
#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;
}

7
tests/libomp/runtest.sh Executable file
View File

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

29
tests/llvm-toolchain/runtest.sh Executable file
View File

@ -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<stdio.h>
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 <iostream>
int main(int argc, char **argv) {
std::cout << "Hello World\n";
return 0;
}
EOF

10
tests/rhbz_1647130/runtest.sh Executable file
View File

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

View File

@ -0,0 +1,15 @@
#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;
}

6
tests/rhbz_1657544/runtest.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
set -e
set -x
clang++ from_chars.cpp
./a.out 100 | grep 100

View File

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

View File

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

View File

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

5
tests/toolchains/hello.c Normal file
View File

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

View File

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

80
tests/toolchains/runtest.sh Executable file
View File

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