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

Commitdaf9931

Browse files
committed
add valgrind memory leak tests; add a memory leak
1 parent82b5a6e commitdaf9931

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

‎docs/build.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#Overview of the build system
22
`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.
33

4+
You`valgrind` installed to run memory checks:`sudo apt install valgrind`
5+
6+
To run all regression tests:
7+
```
8+
cd tests
9+
./run_tests.sh
10+
```
11+
412
#Building with Makefiles
513
From the command line inside a git clone, run the following:
614
```

‎src/CMakeLists.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ project("datalog-cpp")
2121
# specify the C++ standard
2222
set(CMAKE_CXX_STANDARD 17)
2323

24+
# cpp memory checker
25+
include (CTest)
26+
2427
# unit-test library
2528
add_library(tests_mainSTATIC ../tests/tests_main.cpp)
2629

@@ -29,15 +32,18 @@ add_executable(types_test ../tests/types_test.cpp)
2932
target_include_directories(types_testPUBLIC${CMAKE_CURRENT_SOURCE_DIR})
3033
target_link_libraries(types_test tests_main)
3134
target_compile_definitions(types_testPUBLICUNIX)
35+
add_test(types_test_memory types_test)
3236

3337
# variable_test target
3438
add_executable(variable_test ../tests/variable_test.cpp)
3539
target_include_directories(variable_testPUBLIC${CMAKE_CURRENT_SOURCE_DIR})
3640
target_link_libraries(variable_test tests_main)
3741
target_compile_definitions(variable_testPUBLICUNIX)
42+
add_test(variable_test_memory variable_test)
3843

3944
# tuple_binding_test target
4045
add_executable(tuple_binding_test ../tests/tuple_binding_test.cpp)
4146
target_include_directories(tuple_binding_testPUBLIC${CMAKE_CURRENT_SOURCE_DIR})
4247
target_link_libraries(tuple_binding_test tests_main)
4348
target_compile_definitions(tuple_binding_testPUBLICUNIX)
49+
add_test(tuple_binding_test_memory tuple_binding_test)

‎tests/run_tests.sh‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22
set -e
3+
echo"Running tests"
34
../build/types_test
45
../build/variable_test
5-
../build/tuple_binding_test
6+
../build/tuple_binding_test
7+
echo"Checking for memory leaks"
8+
cd ../build; ctest --overwrite MemoryCheckCommandOptions="--leak-check=full --error-exitcode=1" -T memcheck

‎tests/tuple_binding_test.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ bool unbindTest()
1515
return returnVal;
1616
}
1717

18+
boolleakTest() {
19+
double* leak =newdouble[10];
20+
std::cout <<"Hello!" << std::endl;
21+
returntrue;
22+
}
23+
1824
TEST_CASE("tuple binding test","[tuple-binding]")
1925
{
2026
REQUIRE(unbindTest());
27+
REQUIRE(leakTest());
2128
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp