[ci] Small improvements for run-jenkins and collect-coverage. (#5669)
[mono.git] / scripts / ci / run-jenkins.sh
index fc913009f2a31a9c8cb2cc22590eabd87c97deb2..ca0cca115eb2ac8fd889b4583b32d02727074133 100755 (executable)
@@ -5,11 +5,34 @@ export TESTCMD=${MONO_REPO_ROOT}/scripts/ci/run-step.sh
 
 export TEST_HARNESS_VERBOSE=1
 
+make_timeout=300m
+
+if [[ $CI_TAGS == *'collect-coverage'* ]]; then
+    # Collect coverage for further use by lcov and similar tools.
+    # Coverage must be collected with -O0 and debug information.
+    export CFLAGS="$CFLAGS -ggdb3 --coverage -O0"
+fi
+
+if [[ ${CI_TAGS} == *'clang-sanitizer'* ]]; then
+       export CC="clang"
+       export CXX="clang++"
+       export CFLAGS="$CFLAGS -g -O1 -fsanitize=thread -fsanitize-blacklist=${MONO_REPO_ROOT}/scripts/ci/clang-thread-sanitizer-blacklist -mllvm -tsan-instrument-atomics=false"
+       export LDFLAGS="-fsanitize=thread"
+       # TSAN_OPTIONS are used by programs that were compiled with Clang's ThreadSanitizer
+       # see https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags for more details
+       export TSAN_OPTIONS="history_size=7:exitcode=0:force_seq_cst_atomics=1"
+       make_timeout=30m
+fi
+
 if [[ ${label} == w* ]]; then
     # Passing -ggdb3 on Cygwin breaks linking against libmonosgen-x.y.dll
-    export CFLAGS="-g -O2"
+    export CFLAGS="$CFLAGS -g -O2"
 else
-    export CFLAGS="-ggdb3 -O2"
+    export CFLAGS="$CFLAGS -ggdb3 -O2"
+fi
+
+if [[ $CI_TAGS == *'retry-flaky-tests'* ]]; then
+    export MONO_FLAKY_TEST_RETRIES=5
 fi
 
 if [[ ${label} == 'osx-i386' ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-libgdiplus=/Library/Frameworks/Mono.framework/Versions/Current/lib/libgdiplus.dylib --build=i386-apple-darwin11.2.0"; fi
@@ -19,10 +42,11 @@ if [[ ${label} == 'w64' ]]; then PLATFORM=x64; EXTRA_CONF_FLAGS="${EXTRA_CONF_FL
 
 if [[ ${CI_TAGS} == *'coop-gc'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-cooperative-gc=yes"; fi
 
-if [[ ${CI_TAGS} == *'checked-coop'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-checked-build=gc,thread"; export MONO_CHECK_MODE=gc,thread; fi
-if [[ ${CI_TAGS} == *'checked-all'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-checked-build=all"; export MONO_CHECK_MODE=all; fi
+if [[ ${CI_TAGS} == *'checked-coop'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-checked-build=gc,thread"; fi
+if [[ ${CI_TAGS} == *'checked-all'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-checked-build=all"; fi
 
 if [[ ${CI_TAGS} == *'mcs-compiler'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-csc=mcs"; fi
+if [[ ${CI_TAGS} == *'disable-mcs-build'* ]]; then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --disable-mcs-build"; fi
 
 if   [[ ${CI_TAGS} == *'fullaot_llvm'* ]];       then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime_preset=fullaot ";
 elif [[ ${CI_TAGS} == *'hybridaot_llvm'* ]];     then EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --enable-llvm=yes --with-runtime_preset=hybridaot";
@@ -42,6 +66,10 @@ elif [[ ${label} != w* ]] && [[ ${label} != 'debian-8-ppc64el' ]] && [[ ${label}
     if [[ ${label} == 'ubuntu-1404-amd64' ]]; then
         # only enable build of the additional profiles on one architecture to save time
         EXTRA_CONF_FLAGS="${EXTRA_CONF_FLAGS} --with-runtime_preset=all"
+        # when building profiles like monotouch/monodroid which don't build System.Drawing.dll in the Mono repo we need
+        # to build the facades against _something_ to satisfy the typeforwards. In CI we can cheat a little and pass
+        # them System.Drawing.dll from the 'build' profile since we don't test those profiles here (we just ensure they compile).
+        export EXTERNAL_FACADE_DRAWING_REFERENCE=${MONO_REPO_ROOT}/mcs/class/lib/build/System.Drawing.dll
     fi
 fi
 
@@ -77,14 +105,22 @@ if [[ ${CI_TAGS} == *'monolite'* ]]; then make get-monolite-latest; fi
 make_parallelism=-j4
 if [[ ${label} == 'debian-8-ppc64el' ]]; then make_parallelism=-j1; fi
 
-${TESTCMD} --label=make --timeout=300m --fatal make ${make_parallelism} -w V=1
+${TESTCMD} --label=make --timeout=${make_timeout} --fatal make ${make_parallelism} -w V=1
+
+if [[ ${CI_TAGS} == *'checked-coop'* ]]; then export MONO_CHECK_MODE=gc,thread; fi
+if [[ ${CI_TAGS} == *'checked-all'* ]]; then export MONO_CHECK_MODE=all; fi
+
+export MONO_ENV_OPTIONS="$MONO_ENV_OPTIONS $MONO_TEST_ENV_OPTIONS"
 
 if [[ ${CI_TAGS} == *'acceptance-tests'* ]];
     then
        $(dirname "${BASH_SOURCE[0]}")/run-test-acceptance-tests.sh
 elif [[ ${CI_TAGS} == *'profiler-stress-tests'* ]];
     then
-       $(dirname "${BASH_SOURCE[0]}")/run-test-profiler-stress-tests.sh
+    $(dirname "${BASH_SOURCE[0]}")/run-test-profiler-stress-tests.sh
+elif [[ ${CI_TAGS} == *'stress-tests'* ]];
+    then
+    $(dirname "${BASH_SOURCE[0]}")/run-test-stress-tests.sh
 elif [[ ${CI_TAGS} == *'interpreter'* ]];
     then
     $(dirname "${BASH_SOURCE[0]}")/run-test-interpreter.sh