Skip to content

Commit

Permalink
Automate checks for t-san and a-san on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
James Stone committed Aug 3, 2017
1 parent aff61d5 commit f8a650d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,20 @@ option(REALM_ENABLE_ASSERTIONS "Enable assertions in release mode." OFF)
option(REALM_ENABLE_ALLOC_SET_ZERO "Zero all allocations." OFF)
option(REALM_ENABLE_ENCRYPTION "Enable encryption." ON)
option(REALM_ENABLE_MEMDEBUG "Add additional memory checks" OFF)
option(REALM_SANITIZE_ADDRESS "Enable the GCC/Clang address sanitizer." OFF)
option(REALM_SANITIZE_THREAD "Enable the GCC/Clang thread sanitizer." OFF)
set(REALM_MAX_BPNODE_SIZE "1000" CACHE STRING "Max B+ tree node size.")

if (CMAKE_SYSTEM_NAME MATCHES "^Windows")
set(REALM_ENABLE_ENCRYPTION OFF)
endif()

if(REALM_SANITIZE_THREAD)
set(CMAKE_CXX_FLAGS "-fsanitize=thread")
elseif(REALM_SANITIZE_ADDRESS)
set(CMAKE_CXX_FLAGS "-fsanitize=address")
endif()

check_include_files(malloc.h HAVE_MALLOC_H)

# Store configuration in header file
Expand Down
20 changes: 13 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ timeout(time: 5, unit: 'HOURS') {
}

stage('check') {
parallelExecutors = [checkLinuxRelease : doBuildInDocker('Release'),
checkLinuxDebug : doBuildInDocker('Debug'),
parallelExecutors = [checkLinuxRelease : doBuildInDocker('Release', ''),
checkLinuxDebug : doBuildInDocker('Debug', ''),
buildMacOsDebug : doBuildMacOs('Debug'),
buildMacOsRelease : doBuildMacOs('Release'),
buildWin32Debug : doBuildWindows('Debug', false, 'Win32'),
Expand All @@ -60,8 +60,9 @@ timeout(time: 5, unit: 'HOURS') {
packageGeneric : doBuildPackage('generic', 'tgz'),
packageCentos7 : doBuildPackage('centos-7', 'rpm'),
packageCentos6 : doBuildPackage('centos-6', 'rpm'),
packageUbuntu1604 : doBuildPackage('ubuntu-1604', 'deb')
//threadSanitizer: doBuildInDocker('jenkins-pipeline-thread-sanitizer')
packageUbuntu1604 : doBuildPackage('ubuntu-1604', 'deb'),
threadSanitizer : doBuildInDocker('Debug', 'thread'),
addressSanitizer : doBuildInDocker('Debug', 'address')
]

androidAbis = ['armeabi-v7a', 'x86', 'mips', 'x86_64', 'arm64-v8a']
Expand Down Expand Up @@ -151,24 +152,29 @@ def buildDockerEnv(name) {
return docker.image(name)
}

def doBuildInDocker(String buildType) {
def doBuildInDocker(String buildType, String sanitizeMode) {
return {
node('docker') {
getArchive()

def buildEnv = docker.build 'realm-core:snapshot'
def environment = environment()
def sanitizeFlags = ''
environment << 'UNITTEST_PROGRESS=1'
if (buildType.contains('sanitizer')) {
if (sanitizeMode.contains('thread')) {
environment << 'UNITTEST_THREADS=1'
sanitizeFlags = '-D REALM_SANITIZE_THREAD=ON'
} else if (sanitizeMode.contains('address') {
environment << 'UNITTEST_THREADS=1'
sanitizeFlags = '-D REALM_SANITIZE_ADDRESS=ON'
}
withEnv(environment) {
buildEnv.inside {
try {
sh """
mkdir build-dir
cd build-dir
cmake -D CMAKE_BUILD_TYPE=${buildType} -G Ninja ..
cmake -D CMAKE_BUILD_TYPE=${buildType} ${sanitizeFlags} -G Ninja ..
"""
runAndCollectWarnings(script: "cd build-dir && ninja")
sh """
Expand Down

0 comments on commit f8a650d

Please sign in to comment.