Skip to content

Commit

Permalink
added enable_asan option
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Aug 22, 2024
1 parent 1cce1a1 commit e0b3ccf
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/WORKFLOW-PARAMETERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ Setting this parameter will cause the test program to be run with `valgrind`.
```shell
git commit -m "commit message --filter=[core][unit] --valgrind"
```

## --asan
Setting this parameter will cause the test program to be run with `ASAN`.
5 changes: 5 additions & 0 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jobs:
sudo apt install -y valgrind
cd core-tests && SWOOLE_VALGRIND=1 ./run.sh
- name: make test with asan
if: "contains(github.event.head_commit.message, '--asan')"
run: |
cd core-tests && SWOOLE_ENABLE_ASAN=1 ./run.sh
- name: make test
run:
cd core-tests && ./run.sh
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ if (DEFINED enable_trace_log)
add_definitions(-DSW_LOG_TRACE_OPEN)
endif()

if (DEFINED enable_asan)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif()

execute_process(COMMAND php-config --includes OUTPUT_VARIABLE PHP_INCLUDES OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND php-config --extension-dir OUTPUT_VARIABLE PHP_EXTENSION_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PHP_INCLUDES}")
Expand Down
4 changes: 4 additions & 0 deletions core-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ if (DEFINED enable_asan)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif()

if (DEFINED enable_thread)
add_definitions(-DSW_THREAD)
endif()

# should execute before the add_executable command
link_directories(${core_tests_link_directories})

Expand Down
6 changes: 5 additions & 1 deletion core-tests/run.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash
cmake . -DSW_THREAD=1
if [ "${SWOOLE_ENABLE_ASAN}" = 1 ]; then
cmake . -D enable_thread=1 -D enable_asan=1
else
cmake . -D enable_thread=1
fi
make -j8
ipcs -q

Expand Down

0 comments on commit e0b3ccf

Please sign in to comment.