This is a template repository for setting up a Docker container to test C++ code for memory leaks using Valgrind and Google Test. The repository provides a Dockerfile and necessary configuration to build and run the tests in an isolated environment.
- Docker must be installed on your system to use this template.
- Dockerfile: Defines the Docker image with necessary dependencies.
- Makefile: Contains commands to build and test the code within the Docker container.
- valgrind.suppressions: Optional Valgrind suppressions file for suppressing known issues.
- src/: Directory containing your C++ source code and test files.
- test/: Directory containing your Google Test files.
-
Clone this repository to your local machine:
git clone https://github.com/yourusername/your-repo.git cd your-repo
-
Add your C++ source code to the
src/
directory. -
Modify the Makefile to include the necessary compilation and linking commands for your code and tests.
-
Build the Docker image:
make docker_build
-
Run the Valgrind memory leak check:
make docker_start
-
The test output and Valgrind analysis will be displayed on the terminal. Memory leak information will be saved in
valgrind.txt
.
- Modify the commands in the Makefile according to your specific project's requirements.
- If you have known Valgrind issues that you want to suppress, you can add them to valgrind.suppressions.
- This template assumes that your project is structured in a certain way. You might need to adapt it to your project's layout and build system.