summaryrefslogtreecommitdiff
path: root/tcwg-llvm-testsuite.sh
blob: 5bd51e816a66306685f5982fa6e6433a0a888964 (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
#!/usr/bin/env bash

# This script is an experiment on how to run the LLVM test-suite in Jenkins.
# The steps here are based on the scripts currently in:
# https://git.linaro.org/toolchain/llvm/linaro-scripts.git

set -e
set -o pipefail
set -u

BASEDIR=$(dirname "$(readlink -f "$0")")
# shellcheck disable=SC1090
. "$BASEDIR/tcwg-llvm-common.sh"

# Syntax
SYN_TOOLCHAIN="--toolchain=http://url/for/tarball"
SYN_WORKSPACE="--workspace=/full/path/to/workspace"
SYNTAX="$0 $SYN_TOOLCHAIN $SYN_WORKSPACE"

# Environment Variables and default values
CPUS=$(nproc --all)
TOOLCHAIN=""
WORKSPACE=""
NT_FLAGS=""

# Command line parsing
while [ "$#" -gt 0 ]; do
    # shellcheck disable=SC2162
    IFS="=" read ARG VAL <<< "$1"
    case "$ARG" in
      --workspace)
        if [ -d "$VAL" ]; then
          WORKSPACE=$VAL
        else
          echo "ERROR: Workspace '$VAL' not valid"
          echo "Syntax: $SYN_WORKSPACE"
          exit 1
        fi
        shift ;;
      --toolchain)
        download_toolchain "$WORKSPACE" "$VAL"
        shift ;;
      --nt-flags)
        NT_FLAGS=$VAL
        shift ;;
      *)
        echo "ERROR: Invalid argument '$1'"
        echo "Syntax: $SYNTAX"
        exit 1
        ;;
    esac
done

# Dump
echo "WORKSPACE = $WORKSPACE"
echo "REFDIR = $REFDIR"
echo "TOOLCHAIN = $TOOLCHAIN"
echo "CC = $CC"
echo "CXX = $CXX"
echo "NT_FLAGS = $NT_FLAGS"

# Logs
LOGBASE="$WORKSPACE/tcwg-llvm"
LOGEXT="txt"

# Checkout
git clone https://github.com/llvm/llvm-test-suite.git \
    "$WORKSPACE/test-suite" |& tee "$LOGBASE-clone.$LOGEXT"
git clone https://github.com/llvm/llvm-lnt.git \
    "$WORKSPACE/lnt" |& tee -a "$LOGBASE-clone.$LOGEXT"

# Prepare
python=$(which python2)
cd "$WORKSPACE" && LC_ALL=C virtualenv --python=$python sandbox |& tee "$LOGBASE-setup.$LOGEXT"
cd "$WORKSPACE" && LC_ALL=C "$WORKSPACE/sandbox/bin/python" "$WORKSPACE/lnt/setup.py" develop |& tee "$LOGBASE-setup.$LOGEXT"

# Run the test-suite
# shellcheck disable=SC2097,SC2098
cd "$WORKSPACE" && LC_ALL=C CC="$CC" CXX="$CXX" "$WORKSPACE/sandbox/bin/python" \
                   "$WORKSPACE/sandbox/bin/lnt" runtest nt \
                      "-j$CPUS" \
                      --no-timestamp \
                      --sandbox "$WORKSPACE/sandbox" \
                      --test-suite "$WORKSPACE/test-suite" \
                      --cc "$CC" --cxx "$CXX" $NT_FLAGS |& tee "$LOGBASE-test.$LOGEXT"