Skip to content

Commit

Permalink
TOOLS: Add Valgrind
Browse files Browse the repository at this point in the history
Add Valgrind
  • Loading branch information
slali87 committed Oct 10, 2024
1 parent 9ece436 commit 4f4956f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,12 @@ jobs:
./build/Debug/src/app/CppSampleProject
./build/Debug/test/CppSampleProjectTest
ctest --test-dir ./build/Debug/test
# - name: Run Valgrind
# if: runner.os == 'Linux'
# run: |
# cd ${{ github.event.repository.name }}
# sudo apt install valgrind
# ./run.sh setDeb
# ./run.sh config
# ./run.sh build
# ./run.sh valgrind
# ./run.sh setRel
- name: Run Valgrind
if: runner.os == 'Linux'
run: |
cd ${{ github.event.repository.name }}
sudo apt install valgrind
cmake -P cmake/Valgrind.cmake
# - name: Test coverage
# if: runner.os == 'Linux'
# run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ The default mode is Release.

### **Command to run Valgrind:**
```
TODO: ./run.sh valgrind
cmake -P cmake/Valgrind.cmake
```
The **Valgrind** program has to be available on the machine.
The debug version of the executable has to be built.
Expand Down
3 changes: 0 additions & 3 deletions ToDo.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
- **Implement runValgrin**
.

- **Implement testCoverage**
.

Expand Down
11 changes: 11 additions & 0 deletions cmake/Valgrind.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.28)

get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME)
string(REPLACE " " "_" ProjectId ${ProjectId})

execute_process(COMMAND valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1 "${CMAKE_SOURCE_DIR}/build/Debug/src/app/${ProjectId}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND_ERROR_IS_FATAL ANY)
execute_process(COMMAND valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1 "${CMAKE_SOURCE_DIR}/build/Debug/test/${ProjectId}Test"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND_ERROR_IS_FATAL ANY)

0 comments on commit 4f4956f

Please sign in to comment.