aboutsummaryrefslogtreecommitdiff
path: root/test-suite/run.sh
blob: a4313bbf27da7fcbbdb1410e34aaed60e22b1e68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/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