Skip to content

Commit 0fb896c

Browse files
committed
Merge pull request #31 from gjtorikian/test-memory
Test memory leaks
2 parents 0a80392 + 17132d5 commit 0fb896c

File tree

5 files changed

+51
-1
lines changed

5 files changed

+51
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ cmake_install.cmake
1717
*.so
1818
GraphQLParser.py
1919
install_manifest.txt
20+
build/

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ compiler:
44
- clang
55
- gcc
66

7+
8+
addons:
9+
apt:
10+
packages:
11+
- valgrind
12+
713
before_install:
814
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
915
- sudo apt-get update -qq
@@ -19,4 +25,4 @@ before_install:
1925
&& cd ..
2026
&& rm gtest-1.7.0.zip
2127

22-
script: mkdir build && cd build && cmake .. -Dtest=ON && make && test/runTests
28+
script: mkdir build && cd build && cmake .. -Dtest=ON && make && test/runTests && make memcheck

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,12 @@ INSTALL(TARGETS graphqlparser
9999

100100
IF (test)
101101
ADD_SUBDIRECTORY(test)
102+
103+
if(UNIX)
104+
# setup valgrind
105+
ADD_CUSTOM_TARGET(memcheck
106+
valgrind --leak-check=full --suppressions=./test/valgrind.supp --dsymutil=yes --error-exitcode=1 ./test/runTests >/dev/null
107+
)
108+
endif()
109+
102110
ENDIF()

test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ ENABLE_TESTING()
44

55
INCLUDE_DIRECTORIES(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
66

7+
FILE(COPY valgrind.supp DESTINATION .)
8+
79
ADD_EXECUTABLE(runTests ParserTests.cpp)
810

911
TARGET_LINK_LIBRARIES(runTests gtest gtest_main)

test/valgrind.supp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
<osx_strdup_query_string>
3+
Memcheck:Cond
4+
fun:strlen
5+
fun:strdup
6+
fun:_ZN2yy17GraphQLParserImpl5parseEv
7+
fun:_ZN8facebook7graphqlL7doParseEPPKcPv
8+
fun:_ZN8facebook7graphql11parseStringEPKcPS2_
9+
fun:_ZL11expectErrorPKcS0_
10+
fun:_ZN44ParserTests_TracksLocationAcrossStrings_Test8TestBodyEv
11+
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
12+
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
13+
fun:_ZN7testing4Test3RunEv
14+
fun:_ZN7testing8TestInfo3RunEv
15+
fun:_ZN7testing8TestCase3RunEv
16+
}
17+
18+
{
19+
<unix_strdup_query_string>
20+
Memcheck:Cond
21+
fun:__GI_strlen
22+
fun:strdup
23+
fun:_ZN2yy17GraphQLParserImpl5parseEv
24+
fun:_ZN8facebook7graphqlL7doParseEPPKcPv
25+
fun:_ZN8facebook7graphql11parseStringEPKcPS2_
26+
fun:_ZL11expectErrorPKcS0_
27+
fun:_ZN44ParserTests_TracksLocationAcrossStrings_Test8TestBodyEv
28+
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
29+
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
30+
fun:_ZN7testing4Test3RunEv
31+
fun:_ZN7testing8TestInfo3RunEv
32+
fun:_ZN7testing8TestCase3RunEv
33+
}

0 commit comments

Comments
 (0)