Renato Golin | 94cc104 | 2016-04-26 11:02:23 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # This script helps you run one or all tests in the LLVM test-suite |
| 4 | # It automatically detects the CPU, the number of cores and uses |
| 5 | # command line options to set up debug or special builds. |
| 6 | # |
| 7 | # The script assumes the install directory is at ../install. It's handy to |
| 8 | # have a symlink to whatever directory you're building to, either a build |
| 9 | # directory or a release/rc1/Phase3/.../*.install |
| 10 | |
| 11 | 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)]" |
| 12 | CORE=`grep "CPU part" /proc/cpuinfo | awk '{print $4}'` |
| 13 | if [[ $CORE = '0xc08' ]]; then |
| 14 | CORE="-mcpu=cortex-a8" |
| 15 | else if [[ $CORE = '0xc09' ]]; then |
| 16 | CORE="-mcpu=cortex-a9" |
| 17 | else if [[ $CORE = '0xc0f' ]]; then |
| 18 | CORE="-mcpu=cortex-a15" |
| 19 | else if [[ $CORE = '0xd03' ]]; then |
| 20 | CORE="-mcpu=cortex-a53" |
| 21 | else if [[ $CORE = '0xd07' ]]; then |
| 22 | CORE="-mcpu=cortex-a57" |
| 23 | else |
| 24 | CORE='' |
| 25 | fi fi fi fi fi |
| 26 | ROOT=`pwd` |
| 27 | CPUS=`grep -c processor /proc/cpuinfo` |
| 28 | CC=$ROOT/../install/bin/clang |
| 29 | CXX=$ROOT/../install/bin/clang++ |
| 30 | CFLAGS="$CFLAGS $CORE" |
| 31 | CXXFLAGS="$CXXFLAGS $CORE" |
| 32 | LDFLAGS="$LDFLAGS" |
| 33 | TEST= |
| 34 | SMALL= |
| 35 | BENCH= |
| 36 | PERF=false |
| 37 | |
| 38 | while getopts "gldt:j:sbp" opt; do |
| 39 | case $opt in |
| 40 | l) |
| 41 | CFLAGS="$CFLAGS --rtlib=compiler-rt -lc++ -funwind-tables" |
| 42 | CXXFLAGS="$CXXFLAGS --rtlib=compiler-rt -stdlib=libc++ -funwind-tables" |
| 43 | LDFLAGS="$LDFLAGS -L/usr/local/lib -stdlib=libc++ -lc++abi" |
| 44 | ;; |
| 45 | d) |
| 46 | DEBUG="--build-mode Debug --optimize-option -O1" |
| 47 | ;; |
| 48 | t) |
| 49 | TEST="--only-test $OPTARG" |
| 50 | ;; |
| 51 | j) |
| 52 | CPUS="$OPTARG" |
| 53 | ;; |
| 54 | g) |
| 55 | CC=gcc |
| 56 | CXX=g++ |
| 57 | ;; |
| 58 | s) |
| 59 | SMALL="--small" |
| 60 | ;; |
| 61 | b) |
| 62 | BENCH="--benchmarking-only --build-threads=$CPUS" |
| 63 | BENCH="$BENCH --threads=1" |
| 64 | ;; |
| 65 | p) |
| 66 | PERF=true |
| 67 | ;; |
| 68 | *) |
| 69 | echo -e $syntax |
| 70 | exit 1 |
| 71 | ;; |
| 72 | esac |
| 73 | done |
| 74 | |
| 75 | if [ ! -z "$BENCH" ]; then |
| 76 | if $PERF && perf --help > /dev/null; then |
| 77 | # Only use perf is we have it installed and it works |
| 78 | BENCH="$BENCH --use-perf --multisample=4" |
| 79 | else |
| 80 | # Non-perf runs are a lot noisier |
| 81 | BENCH="$BENCH --multisample=8" |
| 82 | fi |
| 83 | # Either way, we want reproducible results |
| 84 | CPUS=1 |
| 85 | fi |
| 86 | |
| 87 | rm -rf sandbox/build |
| 88 | |
| 89 | # CC and CXX need to be duplicated because the --cc only affects the tests |
| 90 | # themselves, not the extra tools, and CFLAGS apply to both, which may break |
| 91 | # if you chose Clang-specific ones |
| 92 | LD_LIBRARY_PATH=$LD_LIBRARY_PATH \ |
| 93 | CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS \ |
| 94 | CC=$CC CXX=$CXX \ |
| 95 | ./sandbox/bin/python sandbox/bin/lnt runtest \ |
| 96 | nt \ |
| 97 | $TEST \ |
| 98 | $DEBUG \ |
| 99 | $SMALL \ |
| 100 | $BENCH \ |
| 101 | -j$CPUS \ |
| 102 | --no-timestamp \ |
| 103 | --sandbox sandbox \ |
| 104 | --test-suite $ROOT/test-suite \ |
| 105 | --cc $CC \ |
| 106 | --cxx $CXX |
| 107 | |
| 108 | ./failures.sh $ROOT/sandbox/build/test.log |
| 109 | if [ $? != 0 ]; then |
| 110 | exit 1 |
| 111 | fi |