From 28cd7e0bc2ce4034054dad2332cc89b9635cef06 Mon Sep 17 00:00:00 2001
From: Andrei Karas <akaras@inbox.ru>
Date: Wed, 30 Aug 2017 04:38:37 +0300
Subject: Add separate running unit tests with asan flags.

---
 .gitlab-ci.yml                             | 100 +++++++++++++++++++++++++++++
 tools/ci/scripts/lsansuppression_tests.txt |   3 +-
 2 files changed, 102 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ba85e0223..70776a01b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1642,6 +1642,106 @@ gcc-7_separate_doctest:
               libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev 
               python
 
+# disabled due kernel issue in shared runners.
+.gcc-7_separate_doctest_sanitize:
+  stage: prebuild
+  script:
+  - ./tools/ci/jobs/gcc7_silent.sh --enable-unittestsbin=doctest --without-manaplusgame --without-dyecmd
+  - ./tools/ci/scripts/separateunittests.sh
+  - ldd ./src/manaplustests | grep "libasan"
+  <<: *job-push
+  variables:
+    LSAN_OPTIONS: "suppressions=./tools/ci/scripts/lsansuppression_tests.txt"
+    POST_CXXFLAGS: "-fsanitize=address -fsanitize=undefined
+                    -fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable
+                    -fsanitize=vla-bound -fsanitize=null -fsanitize=return
+                    -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment
+                    -fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow
+                    -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool
+                    -fsanitize=enum -fsanitize=vptr -fsanitize=bounds-strict"
+    PACKAGES: gcc-7 g++-7 
+              make autoconf automake autopoint gettext 
+              libxml2-dev libcurl4-gnutls-dev libpng-dev 
+              libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev 
+              python
+  tags:
+    - docker
+
+# disabled due kernel issue in shared runners.
+.gcc-7_separate_doctest_sanitize_sdl2:
+  stage: prebuild
+  script:
+  - ./tools/ci/jobs/gcc7_silent.sh --enable-unittestsbin=doctest --without-manaplusgame --without-dyecmd --with-sdl2
+  - ./tools/ci/scripts/separateunittests.sh
+  - ldd ./src/manaplustests | grep "libasan"
+  <<: *job-push
+  variables:
+    LSAN_OPTIONS: "suppressions=./tools/ci/scripts/lsansuppression_tests.txt"
+    POST_CXXFLAGS: "-fsanitize=address -fsanitize=undefined
+                    -fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable
+                    -fsanitize=vla-bound -fsanitize=null -fsanitize=return
+                    -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment
+                    -fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow
+                    -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool
+                    -fsanitize=enum -fsanitize=vptr -fsanitize=bounds-strict"
+    PACKAGES: gcc-7 g++-7 
+              make autoconf automake autopoint gettext 
+              libxml2-dev libcurl4-gnutls-dev libpng-dev 
+              libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev
+              python
+  tags:
+    - docker
+
+gcc-7_separate_doctest_sanitize_i386:
+  stage: prebuild
+  script:
+  - ./tools/ci/jobs/gcc7_silent.sh --enable-unittestsbin=doctest --without-manaplusgame --without-dyecmd
+  - ./tools/ci/scripts/separateunittests.sh
+  - ldd ./src/manaplustests | grep "libasan"
+  <<: *job-push
+  image: vicamo/debian:sid-i386
+  variables:
+    LSAN_OPTIONS: "suppressions=./tools/ci/scripts/lsansuppression_tests.txt"
+    POST_CXXFLAGS: "-fsanitize=address -fsanitize=undefined
+                    -fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable
+                    -fsanitize=vla-bound -fsanitize=null -fsanitize=return
+                    -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment
+                    -fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow
+                    -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool
+                    -fsanitize=enum -fsanitize=vptr -fsanitize=bounds-strict"
+    PACKAGES: gcc-7 g++-7 
+              make autoconf automake autopoint gettext 
+              libxml2-dev libcurl4-gnutls-dev libpng-dev 
+              libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev 
+              python
+  tags:
+    - docker
+
+gcc-7_separate_doctest_sanitize_sdl2_i386:
+  stage: prebuild
+  script:
+  - ./tools/ci/jobs/gcc7_silent.sh --enable-unittestsbin=doctest --without-manaplusgame --without-dyecmd --with-sdl2
+  - ./tools/ci/scripts/separateunittests.sh
+  - ldd ./src/manaplustests | grep "libasan"
+  <<: *job-push
+  image: vicamo/debian:sid-i386
+  variables:
+    LSAN_OPTIONS: "suppressions=./tools/ci/scripts/lsansuppression_tests.txt"
+    POST_CXXFLAGS: "-fsanitize=address -fsanitize=undefined
+                    -fsanitize=shift -fsanitize=integer-divide-by-zero -fsanitize=unreachable
+                    -fsanitize=vla-bound -fsanitize=null -fsanitize=return
+                    -fsanitize=signed-integer-overflow -fsanitize=bounds -fsanitize=alignment
+                    -fsanitize=object-size -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow
+                    -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute -fsanitize=bool
+                    -fsanitize=enum -fsanitize=vptr -fsanitize=bounds-strict"
+    PACKAGES: gcc-7 g++-7 
+              make autoconf automake autopoint gettext 
+              libxml2-dev libcurl4-gnutls-dev libpng-dev 
+              libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev
+              python
+  tags:
+    - docker
+
 gcc-7_lto:
   stage: build
   script:
diff --git a/tools/ci/scripts/lsansuppression_tests.txt b/tools/ci/scripts/lsansuppression_tests.txt
index 2ce6c7a47..c8cd8da42 100644
--- a/tools/ci/scripts/lsansuppression_tests.txt
+++ b/tools/ci/scripts/lsansuppression_tests.txt
@@ -1,5 +1,6 @@
 leak:libcurl
 leak:testFailAlways1
 leak:testFailAlways2
-leak:checkutils_unittest.cc
+leak:checkutils.cc
+leak:throw.cc
 leak:SDL_CreateThreadWithStackSize
-- 
cgit v1.2.3-70-g09d2