👷 added flags for Valgrind and Clang sanitizer
This commit is contained in:
		
							parent
							
								
									c87b080cc5
								
							
						
					
					
						commit
						05b97c473a
					
				
					 2 changed files with 29 additions and 10 deletions
				
			
		
							
								
								
									
										12
									
								
								.travis.yml
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								.travis.yml
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -29,34 +29,28 @@ matrix:
 | 
			
		|||
  include:
 | 
			
		||||
 | 
			
		||||
  # Valgrind
 | 
			
		||||
 | 
			
		||||
  - os: linux
 | 
			
		||||
    compiler: gcc
 | 
			
		||||
    env:
 | 
			
		||||
      - COMPILER=g++-4.9
 | 
			
		||||
      - SPECIAL=valgrind
 | 
			
		||||
      - CMAKE_OPTIONS=-DJSON_Valgrind=ON
 | 
			
		||||
    addons:
 | 
			
		||||
      apt:
 | 
			
		||||
        sources: ['ubuntu-toolchain-r-test']
 | 
			
		||||
        packages: [g++-4.9, valgrind]
 | 
			
		||||
    after_success:
 | 
			
		||||
      - make check TEST_PREFIX="valgrind --error-exitcode=1 --leak-check=full " TEST_PATTERN=""
 | 
			
		||||
 | 
			
		||||
  # clang sanitizer
 | 
			
		||||
  - os: linux
 | 
			
		||||
    compiler: clang
 | 
			
		||||
    env:
 | 
			
		||||
      - COMPILER=clang++-5.0
 | 
			
		||||
      - SPECIAL=sanitizer
 | 
			
		||||
      - CMAKE_OPTIONS=-DJSON_Sanitizer=ON
 | 
			
		||||
    addons:
 | 
			
		||||
      apt:
 | 
			
		||||
        sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
 | 
			
		||||
        packages: ['g++-6', 'clang-5.0']
 | 
			
		||||
    after_success:
 | 
			
		||||
      - make clang_sanitize -j4
 | 
			
		||||
 | 
			
		||||
  # cppcheck
 | 
			
		||||
 | 
			
		||||
  - os: linux
 | 
			
		||||
    compiler: gcc
 | 
			
		||||
    env:
 | 
			
		||||
| 
						 | 
				
			
			@ -289,7 +283,7 @@ script:
 | 
			
		|||
 | 
			
		||||
  # compile and execute unit tests
 | 
			
		||||
  - mkdir -p build && cd build
 | 
			
		||||
  - cmake .. && cmake --build . --config Release -- -j4
 | 
			
		||||
  - cmake .. ${CMAKE_OPTIONS} && cmake --build . --config Release -- -j4
 | 
			
		||||
  - ctest -C Release -V
 | 
			
		||||
  - cd ..
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,19 @@
 | 
			
		|||
option(JSON_Sanitizer "Build with Clang Sanitizer" OFF)
 | 
			
		||||
option(JSON_Valgrind "Execute tests with Valgrind" OFF)
 | 
			
		||||
 | 
			
		||||
if(JSON_Sanitizer)
 | 
			
		||||
    if(NOT MSVC)
 | 
			
		||||
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer")
 | 
			
		||||
    endif()
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
if(JSON_Valgrind)
 | 
			
		||||
    find_program(CMAKE_MEMORYCHECK_COMMAND valgrind)
 | 
			
		||||
    set(MEMORYCHECK_COMMAND_OPTIONS "--error-exitcode=1 --leak-check=full")
 | 
			
		||||
    set(memcheck_command "${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}")
 | 
			
		||||
    separate_arguments(memcheck_command)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
#############################################################################
 | 
			
		||||
# Catch library with the main function to speed up build
 | 
			
		||||
#############################################################################
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +51,7 @@ foreach(file ${files})
 | 
			
		|||
    target_link_libraries(${testcase} ${JSON_TARGET_NAME})
 | 
			
		||||
 | 
			
		||||
    if(NOT MSVC)
 | 
			
		||||
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-float-equal")
 | 
			
		||||
        set_target_properties(${testcase} PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wno-float-equal")
 | 
			
		||||
    endif()
 | 
			
		||||
 | 
			
		||||
    include(cotire OPTIONAL)
 | 
			
		||||
| 
						 | 
				
			
			@ -54,4 +70,13 @@ foreach(file ${files})
 | 
			
		|||
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 | 
			
		||||
    )
 | 
			
		||||
    set_tests_properties("${testcase}_all" PROPERTIES LABELS "all")
 | 
			
		||||
 | 
			
		||||
    if(JSON_Valgrind)
 | 
			
		||||
        add_test(NAME "${testcase}_valgrind"
 | 
			
		||||
          COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase}
 | 
			
		||||
          WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
 | 
			
		||||
        )
 | 
			
		||||
        set_tests_properties("${testcase}_valgrind" PROPERTIES LABELS "valgrind")
 | 
			
		||||
    endif()
 | 
			
		||||
 | 
			
		||||
endforeach()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue