Skip to content

Commit 499c772

Browse files
authored
Activates asan in tests/fuzzer for msvc (#36)
1 parent e15aa4c commit 499c772

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

.github/workflows/cmake.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
env:
1010
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11-
BUILD_TYPE: Release
11+
BUILD_TYPE: RelWithDebInfo
1212

1313

1414
jobs:
@@ -25,6 +25,13 @@ jobs:
2525
with:
2626
python-version: '3.13'
2727

28+
# setup toolchain for asan
29+
- name: Setup MSVC dev command prompt
30+
uses: TheMrMilchmann/setup-msvc-dev@v3
31+
with:
32+
arch: x64
33+
if: contains(matrix.os, 'windows' )
34+
2835
- name: Configure CMake
2936
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
3037
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
@@ -45,7 +52,7 @@ jobs:
4552
- name: Test
4653
working-directory: ${{github.workspace}}/build
4754
env:
48-
RC_PARAMS: "max_success=1000"
55+
RC_PARAMS: "max_success=300"
4956
# Execute tests defined by the CMake configuration.
5057
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
5158
run: ctest --output-on-failure -C ${{env.BUILD_TYPE}}

fuzzing/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ set(FUZZ_RUNTIME
44

55
set (CMAKE_CXX_STANDARD 17)
66
add_executable(fuzzing main.cpp)
7-
target_link_libraries(fuzzing PRIVATE -coverage -fsanitize=fuzzer)
87
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
9-
target_compile_options(fuzzing PRIVATE -fsanitize=fuzzer)
8+
target_compile_options(fuzzing PRIVATE -coverage -fsanitize=fuzzer)
109
target_link_libraries(fuzzing PUBLIC -fsanitize=address,undefined)
11-
target_compile_definitions(fuzzing PRIVATE "-D_LIBCPP_DISABLE_DEPRECATION_WARNINGS")
1210
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
13-
target_compile_options(fuzzing PRIVATE /fsanitize=fuzzer)
14-
target_compile_definitions(fuzzing PRIVATE "-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS")
11+
target_compile_options(fuzzing PRIVATE /fsanitize=fuzzer /fsanitize=address)
1512
endif()
1613

1714
target_link_libraries(fuzzing PRIVATE ValveFileVDF)

tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ target_compile_options(tests PRIVATE
1818

1919
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
2020
target_link_libraries(tests PUBLIC -fsanitize=address,undefined)
21+
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
22+
target_compile_options(tests PRIVATE /fsanitize=address)
2123
endif()
2224

2325

tests/proptests/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ target_compile_options(rapidcheck_tests PRIVATE
2424

2525
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
2626
target_link_libraries(rapidcheck_tests PUBLIC -fsanitize=address,undefined)
27+
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
28+
# disable annotations or possible annotation mismatch with librapidcheck. It is not really required by the vdf parser
29+
target_compile_definitions(rapidcheck_tests PRIVATE "_DISABLE_VECTOR_ANNOTATION" "_DISABLE_STRING_ANNOTATION")
30+
target_compile_options(rapidcheck_tests PRIVATE /fsanitize=address)
2731
endif()
2832

2933

0 commit comments

Comments
 (0)