add auto memory leak check with valgrind to test script

This commit is contained in:
Pedro Flemming 2017-02-08 11:21:04 +01:00
parent 1f183147ec
commit d576350e1e
3 changed files with 35 additions and 7 deletions

View File

@ -4,17 +4,30 @@ language: cpp
install: install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get -qq update - sudo apt-get -qq update
- sudo apt-get install -y bison flex
- sudo apt-get install -y g++-4.8 libstdc++-4.8-dev - sudo apt-get install -y g++-4.8 libstdc++-4.8-dev
- sudo apt-get install -y flex valgrind
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 90 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 90
# Install bison 3.0.4.
- wget http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.gz
- tar -xvzf bison-3.0.4.tar.gz
- cd bison-3.0.4
- ./configure && make && sudo make install
- cd ..
# Show installed versions.
- which g++ - which g++
- g++ -v - g++ -v
- bison --version
- flex --version
- valgrind --version
compiler: compiler:
- gcc - gcc
- clang - clang
script: script:
- make cleanall
- make - make
- make test - make test

View File

@ -2,9 +2,11 @@
all: bison_parser.cpp flex_lexer.cpp all: bison_parser.cpp flex_lexer.cpp
bison_parser.cpp: bison_parser.y bison_parser.cpp: bison_parser.y
@bison --version | head -n 1
bison bison_parser.y -v bison bison_parser.y -v
flex_lexer.cpp: flex_lexer.l flex_lexer.cpp: flex_lexer.l
@flex --version
flex flex_lexer.l flex flex_lexer.l
clean: clean:

View File

@ -1,15 +1,28 @@
#!/bin/bash #!/bin/bash
# has to be executed from the root of the repository # Has to be executed from the root of the repository.
# Usually invoked by `make test`.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./
RET=0
# Running the tests.
bin/sql_grammar_test -f "test/lib/valid_queries.sql" bin/sql_grammar_test -f "test/lib/valid_queries.sql"
RET1=$? RET=$(($RET + $?))
bin/sql_tests bin/sql_tests
RET2=$? RET=$(($RET + $?))
if [[ $RET1 != 0 ]]; then exit $RET1; fi # Running memory leak checks.
if [[ $RET2 != 0 ]]; then exit $RET2; fi echo ""
echo "Running memory leak checks..."
exit 0 valgrind --leak-check=full --error-exitcode=1 \
./bin/sql_grammar_test -f "test/lib/valid_queries.sql" >> /dev/null
RET=$(($RET + $?))
valgrind --leak-check=full --error-exitcode=1 \
./bin/sql_tests -f "test/lib/valid_queries.sql" >> /dev/null
RET=$(($RET + $?))
exit $RET