Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add valgrind memory leak tests#8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Z80coder merged 4 commits intomasterfromadd-memory-checks
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.github/workflows/linux_check.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@ jobs:
- uses: actions/checkout@v2
- name: build
run: |
sudo apt install -y valgrind
mkdir build && cd build
cmake ../src
make
Expand Down
8 changes: 8 additions & 0 deletionsdocs/build.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
# Overview of the build system
`datalog-cpp` uses the [CMake](www.cmake.org) build tool to generate build files for other build systems. Currently, building using clang and gcc with Makefiles are supported.

You `valgrind` installed to run memory checks: `sudo apt install valgrind`

To run all regression tests:
```
cd tests
./run_tests.sh
```

# Building with Makefiles
From the command line inside a git clone, run the following:
```
Expand Down
6 changes: 6 additions & 0 deletionssrc/CMakeLists.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,6 +21,9 @@ project("datalog-cpp")
# specify the C++ standard
set(CMAKE_CXX_STANDARD 17)

# cpp memory checker
include (CTest)

# unit-test library
add_library(tests_main STATIC ../tests/tests_main.cpp)

Expand All@@ -29,15 +32,18 @@ add_executable(types_test ../tests/types_test.cpp)
target_include_directories(types_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(types_test tests_main)
target_compile_definitions(types_test PUBLIC UNIX)
add_test(types_test_memory types_test)

# variable_test target
add_executable(variable_test ../tests/variable_test.cpp)
target_include_directories(variable_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(variable_test tests_main)
target_compile_definitions(variable_test PUBLIC UNIX)
add_test(variable_test_memory variable_test)

# tuple_binding_test target
add_executable(tuple_binding_test ../tests/tuple_binding_test.cpp)
target_include_directories(tuple_binding_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(tuple_binding_test tests_main)
target_compile_definitions(tuple_binding_test PUBLIC UNIX)
add_test(tuple_binding_test_memory tuple_binding_test)
5 changes: 4 additions & 1 deletiontests/run_tests.sh
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
#!/bin/bash
set -e
echo "Running tests"
../build/types_test
../build/variable_test
../build/tuple_binding_test
../build/tuple_binding_test
echo "Checking for memory leaks"
cd ../build; ctest --overwrite MemoryCheckCommandOptions="--leak-check=full --error-exitcode=1" -T memcheck
8 changes: 8 additions & 0 deletionstests/tuple_binding_test.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,15 @@ bool unbindTest()
return returnVal;
}

bool leakTest() {
double* leak = new double[10];
std::cout << "Hello!" << std::endl;
delete[] leak;
return true;
}

TEST_CASE("tuple binding test", "[tuple-binding]")
{
REQUIRE(unbindTest());
REQUIRE(leakTest());
}

[8]ページ先頭

©2009-2025 Movatter.jp