| #!/usr/bin/env bash |
| |
| # This script helps you run one or all tests in the LLVM test-suite |
| # It automatically detects the CPU, the number of cores and uses |
| # command line options to set up debug or special builds. |
| # |
| # The script assumes the install directory is at ../install. It's handy to |
| # have a symlink to whatever directory you're building to, either a build |
| # directory or a release/rc1/Phase3/.../*.install |
| |
| syntax="Syntax: $0 [-j cpus] [-g(cc)] [-l(ibc++/compiler-rt)] [-d(ebug)] [-t(est) <full-test-name>] [-s(mall)] [-b(enchmark-only)] [-p(erf)]" |
| CORE=`grep "CPU part" /proc/cpuinfo | awk '{print $4}'` |
| if [[ $CORE = '0xc08' ]]; then |
| CORE="-mcpu=cortex-a8" |
| else if [[ $CORE = '0xc09' ]]; then |
| CORE="-mcpu=cortex-a9" |
| else if [[ $CORE = '0xc0f' ]]; then |
| CORE="-mcpu=cortex-a15" |
| else if [[ $CORE = '0xd03' ]]; then |
| CORE="-mcpu=cortex-a53" |
| else if [[ $CORE = '0xd07' ]]; then |
| CORE="-mcpu=cortex-a57" |
| else |
| CORE='' |
| fi fi fi fi fi |
| ROOT=`pwd` |
| CPUS=`grep -c processor /proc/cpuinfo` |
| CC=$ROOT/../install/bin/clang |
| CXX=$ROOT/../install/bin/clang++ |
| CFLAGS="$CFLAGS $CORE" |
| CXXFLAGS="$CXXFLAGS $CORE" |
| LDFLAGS="$LDFLAGS" |
| TEST= |
| SMALL= |
| BENCH= |
| PERF=false |
| |
| while getopts "gldt:j:sbp" opt; do |
| case $opt in |
| l) |
| CFLAGS="$CFLAGS --rtlib=compiler-rt -lc++ -funwind-tables" |
| CXXFLAGS="$CXXFLAGS --rtlib=compiler-rt -stdlib=libc++ -funwind-tables" |
| LDFLAGS="$LDFLAGS -L/usr/local/lib -stdlib=libc++ -lc++abi" |
| ;; |
| d) |
| DEBUG="--build-mode Debug --optimize-option -O1" |
| ;; |
| t) |
| TEST="--only-test $OPTARG" |
| ;; |
| j) |
| CPUS="$OPTARG" |
| ;; |
| g) |
| CC=gcc |
| CXX=g++ |
| ;; |
| s) |
| SMALL="--small" |
| ;; |
| b) |
| BENCH="--benchmarking-only --build-threads=$CPUS" |
| BENCH="$BENCH --threads=1" |
| ;; |
| p) |
| PERF=true |
| ;; |
| *) |
| echo -e $syntax |
| exit 1 |
| ;; |
| esac |
| done |
| |
| if [ ! -z "$BENCH" ]; then |
| if $PERF && perf --help > /dev/null; then |
| # Only use perf is we have it installed and it works |
| BENCH="$BENCH --use-perf --multisample=4" |
| else |
| # Non-perf runs are a lot noisier |
| BENCH="$BENCH --multisample=8" |
| fi |
| # Either way, we want reproducible results |
| CPUS=1 |
| fi |
| |
| rm -rf sandbox/build |
| |
| # CC and CXX need to be duplicated because the --cc only affects the tests |
| # themselves, not the extra tools, and CFLAGS apply to both, which may break |
| # if you chose Clang-specific ones |
| LD_LIBRARY_PATH=$LD_LIBRARY_PATH \ |
| CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS \ |
| CC=$CC CXX=$CXX \ |
| ./sandbox/bin/python sandbox/bin/lnt runtest \ |
| nt \ |
| $TEST \ |
| $DEBUG \ |
| $SMALL \ |
| $BENCH \ |
| -j$CPUS \ |
| --no-timestamp \ |
| --sandbox sandbox \ |
| --test-suite $ROOT/test-suite \ |
| --cc $CC \ |
| --cxx $CXX |
| |
| ./failures.sh $ROOT/sandbox/build/test.log |
| if [ $? != 0 ]; then |
| exit 1 |
| fi |