blob: a4313bbf27da7fcbbdb1410e34aaed60e22b1e68 [file] [log] [blame]
Renato Golin94cc1042016-04-26 11:02:23 +01001#!/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
11syntax="Syntax: $0 [-j cpus] [-g(cc)] [-l(ibc++/compiler-rt)] [-d(ebug)] [-t(est) <full-test-name>] [-s(mall)] [-b(enchmark-only)] [-p(erf)]"
12CORE=`grep "CPU part" /proc/cpuinfo | awk '{print $4}'`
13if [[ $CORE = '0xc08' ]]; then
14 CORE="-mcpu=cortex-a8"
15else if [[ $CORE = '0xc09' ]]; then
16 CORE="-mcpu=cortex-a9"
17else if [[ $CORE = '0xc0f' ]]; then
18 CORE="-mcpu=cortex-a15"
19else if [[ $CORE = '0xd03' ]]; then
20 CORE="-mcpu=cortex-a53"
21else if [[ $CORE = '0xd07' ]]; then
22 CORE="-mcpu=cortex-a57"
23else
24 CORE=''
25fi fi fi fi fi
26ROOT=`pwd`
27CPUS=`grep -c processor /proc/cpuinfo`
28CC=$ROOT/../install/bin/clang
29CXX=$ROOT/../install/bin/clang++
30CFLAGS="$CFLAGS $CORE"
31CXXFLAGS="$CXXFLAGS $CORE"
32LDFLAGS="$LDFLAGS"
33TEST=
34SMALL=
35BENCH=
36PERF=false
37
38while 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
73done
74
75if [ ! -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
85fi
86
87rm -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
92LD_LIBRARY_PATH=$LD_LIBRARY_PATH \
93CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS \
94CC=$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
109if [ $? != 0 ]; then
110 exit 1
111fi