diff options
author | Renato Golin <renato.golin@linaro.org> | 2017-03-24 14:21:59 +0000 |
---|---|---|
committer | Renato Golin <renato.golin@linaro.org> | 2017-03-24 14:21:59 +0000 |
commit | 6730292a5bfeaa882e1a189f7a39058d4f8defb4 (patch) | |
tree | b6540e0b520ac12ecac918caaf95fa8dd0360809 | |
parent | f08817d836dc81880a731dbcb6cf36ab085f5067 (diff) |
tcwg-llvm-testsuite.sh: Adding way to run LLVM test-suite
This checks out test-suite and run on a toolchain provided (mandatory).
This job will not build the toolchain for you, and it can work with any
toolchain (clang, gcc) provided.
Change-Id: I21d072de25a1d386379ae681ee8b7bfd1c85e576
-rwxr-xr-x | tcwg-llvm-testsuite.sh | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/tcwg-llvm-testsuite.sh b/tcwg-llvm-testsuite.sh new file mode 100755 index 00000000..3db70d34 --- /dev/null +++ b/tcwg-llvm-testsuite.sh @@ -0,0 +1,100 @@ +#!/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 + +# Syntax +SYN_TOOLCHAIN="--toolchain=http://url/for/tarball" +SYN_WORKSPACE="--workspace=/full/path/to/workspace" +SYNTAX="$0 $STN_TOOLCHAIN $SYN_WORKSPACE" + +# Environment Variables and default values +CPUS=$(nproc --all) +TOOLCHAIN="" +WORKSPACE="" + +# Command line parsing +while [ "$#" -gt 0 ]; do + ARG=$(echo "$1" | cut -d "=" -f 1) + VAL=$(echo "$1" | cut -d "=" -f 2) + 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) + if [ "$VAL" != "" ]; then + file=$(basename "$VAL") + dir=$(echo "$file" | sed 's/\.tar.*//g') + # Download the toolchain + if [ ! -d "$WORKSPACE/$dir" ]; then + echo "No dir '$WORKSPACE/$dir'..." + if [ ! -f "$WORKSPACE/$file" ]; then + echo "No file '$WORKSPACE/$file'..." + echo "Downloading from '$VAL'" + wget -q "$VAL" -O "$WORKSPACE/$file" + fi + echo "Unpacking '$WORKSPACE/$file'" + tar xf "$WORKSPACE/$file" -C "$WORKSPACE" + fi + # Clang or GCC? + if [ -f "$WORKSPACE/$dir/bin/clang" ]; then + export CC="$WORKSPACE/$dir/bin/clang" + export CXX="$WORKSPACE/$dir/bin/clang++" + elif [ -f "$WORKSPACE/$dir/bin/gcc" ]; then + export CC="$WORKSPACE/$dir/bin/gcc" + export CXX="$WORKSPACE/$dir/bin/g++" + else + echo "ERROR: Toolchain '$VAL' has no known compiler in $dir/bin" + echo "Syntax: $SYN_TOOLCHAIN" + exit 1 + fi + else + echo "ERROR: Toolchain '$VAL' not valid" + echo "Syntax: $SYN_TOOLCHAIN",xit 1 + fi + shift ;; + *) + echo "ERROR: Invalid argument '$1'" + echo "Syntax: $SYNTAX" + exit 1 + ;; + esac +done + +# Dump +echo "WORKSPACE = $WORKSPACE" +echo "TOOLCHAIN = $TOOLCHAIN" +echo "CC = $CC" +echo "CXX = $CXX" + +# Logs +LOGBASE="$WORKSPACE/tcwg-llvm" +LOGEXT="txt" + +# Checkout +git clone http://llvm.org/git/test-suite.git "$WORKSPACE/test-suite" |& tee "$LOGBASE-clone.$LOGEXT" +git clone http://llvm.org/git/lnt.git "$WORKSPACE/lnt" |& tee -a "$LOGBASE-clone.$LOGEXT" + +# Prepare +python=$(which python2) +cd "$WORKSPACE" && virtualenv --python=$python sandbox |& tee "$LOGBASE-setup.$LOGEXT" +cd "$WORKSPACE" && "$WORKSPACE/sandbox/bin/python" "$WORKSPACE/lnt/setup.py" develop |& tee "$LOGBASE-setup.$LOGEXT" + +# Run the test-suite +cd "$WROKSPACE" && 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" |& tee "$LOGBASE-test.$LOGEXT" |