clang/tests/llvm-toolchain/test.sh
Milos Prchlik 5f6796def1 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.
2021-11-23 17:16:17 +01:00

36 lines
774 B
Bash
Executable File

#!/bin/sh -eux
# Tests for using a full LLVM toolchain: clang + compiler-rt + libcxx + lld
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 - && \
./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="$CXXLIB" - && \
./a.out | grep 'Hello World'
#include <iostream>
int main(int argc, char **argv) {
std::cout << "Hello World\n";
return 0;
}
EOF