Skip to content

Commit

Permalink
Added more sanitizers (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
levBagryansky authored Oct 28, 2023
1 parent d8c82bf commit 942e6fd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ jobs:
strategy:
matrix:
ctect_option:
- "-DCHAIVM_ADD_SANITIZERS=OFF"
- "-DCHAIVM_ADD_SANITIZERS=ON"
- "-DCHAIVM_ADD_MEM_SANITIZER=OFF -DCHAIVM_ADD_THREAD_SANITIZER=OFF"
- "-DCHAIVM_ADD_MEM_SANITIZER=OFF -DCHAIVM_ADD_THREAD_SANITIZER=ON"
- "-DCHAIVM_ADD_MEM_SANITIZER=ON -DCHAIVM_ADD_THREAD_SANITIZER=OFF"
steps:
- uses: actions/checkout@v3
with:
Expand Down
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,23 @@ build: init
cmake -S $(PWD) -B $(PWD)/$(BUILD_DIR) -DCHAIVM_ADD_SANITIZERS=OFF
cmake --build $(PWD)/$(BUILD_DIR) --parallel $(JOBS)

.PHONY: build-memcheck
build-memcheck: init
cmake -S $(PWD) -B $(PWD)/$(BUILD_DIR) -DCHAIVM_ADD_SANITIZERS=ON
cmake --build $(PWD)/$(BUILD_DIR) --parallel $(JOBS)

.PHONY: test
test: build
export GTEST_COLOR=1 && ctest --test-dir $(PWD)/$(BUILD_DIR)/test --parallel $(JOBS) --output-on-failure

.PHONY: test-memcheck
test-memcheck: build-memcheck
.PHONY: execute-tests-inside-make
execute-tests-inside-make:
cmake --build $(PWD)/$(BUILD_DIR) --parallel $(JOBS)
export GTEST_COLOR=1 && ctest --test-dir $(PWD)/$(BUILD_DIR)/test --parallel $(JOBS) --output-on-failure


.PHONY: test-extended
test-extended: init
cmake -S $(PWD) -B $(PWD)/$(BUILD_DIR) -DCHAIVM_ADD_MEM_SANITIZER=OFF -DCHAIVM_ADD_THREAD_SANITIZER=ON
$(MAKE) execute-tests-inside-make
cmake -S $(PWD) -B $(PWD)/$(BUILD_DIR) -DCHAIVM_ADD_MEM_SANITIZER=ON -DCHAIVM_ADD_THREAD_SANITIZER=OFF
$(MAKE) execute-tests-inside-make

.PHONY: bench
bench: init
cmake -S $(PWD) -B $(PWD)/$(BUILD_DIR) -DCHAI_BENCH=1
Expand Down
14 changes: 9 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ function(chai_test SOURCE_NAME)
add_executable(${TARGET_NAME})
target_sources(${TARGET_NAME} PRIVATE ${SOURCE_NAME})
target_link_libraries(${TARGET_NAME} PRIVATE chai_testif)
if (CHAIVM_ADD_SANITIZERS)
# @todo #37:60min Make address sanitizer work on MacOS with ARM
target_compile_options(${TARGET_NAME} PRIVATE -fsanitize=address)
target_link_options(${TARGET_NAME} PRIVATE -fsanitize=address)
endif ()
if (CHAIVM_ADD_MEM_SANITIZER AND NOT CHAIVM_ADD_THREAD_SANITIZER)
# @todo #37:60min Make address and leak and undefined sanitizer work on MacOS with ARM
target_compile_options(${TARGET_NAME} PRIVATE -fsanitize=address -g -fsanitize=leak -fsanitize=undefined)
target_link_options(${TARGET_NAME} PRIVATE -fsanitize=address -fsanitize=leak -fsanitize=undefined)
elseif(CHAIVM_ADD_THREAD_SANITIZER AND NOT CHAIVM_ADD_MEM_SANITIZER)
# @todo #37:60min Make thread sanitizer work on MacOS with ARM
target_compile_options(${TARGET_NAME} PRIVATE -fsanitize=thread -g)
target_link_options(${TARGET_NAME} PRIVATE -fsanitize=thread)
endif()
add_test(NAME ${TARGET_NAME} COMMAND ./${TARGET_NAME})
endfunction(chai_test)

Expand Down

3 comments on commit 942e6fd

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 942e6fd Oct 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 37-0019e1f7 disappeared from test/CMakeLists.txt), that's why I closed #39. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 942e6fd Oct 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 37-d4e9ebc7 discovered in test/CMakeLists.txt) and submitted as #45. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 942e6fd Oct 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 37-082f295d discovered in test/CMakeLists.txt) and submitted as #46. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.