From d576350e1edd359875b87cb84e9b46eea09d7e65 Mon Sep 17 00:00:00 2001 From: Pedro Flemming Date: Wed, 8 Feb 2017 11:21:04 +0100 Subject: [PATCH] add auto memory leak check with valgrind to test script --- .travis.yml | 15 ++++++++++++++- src/parser/Makefile | 2 ++ test/test.sh | 25 +++++++++++++++++++------ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9e0929..1ccd703 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,17 +4,30 @@ language: cpp install: - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - 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 flex valgrind - 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 + + # 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++ - g++ -v + - bison --version + - flex --version + - valgrind --version compiler: - gcc - clang script: + - make cleanall - make - make test diff --git a/src/parser/Makefile b/src/parser/Makefile index 4bd46f1..a0102f4 100644 --- a/src/parser/Makefile +++ b/src/parser/Makefile @@ -2,9 +2,11 @@ all: bison_parser.cpp flex_lexer.cpp bison_parser.cpp: bison_parser.y + @bison --version | head -n 1 bison bison_parser.y -v flex_lexer.cpp: flex_lexer.l + @flex --version flex flex_lexer.l clean: diff --git a/test/test.sh b/test/test.sh index 3df2e42..690465c 100755 --- a/test/test.sh +++ b/test/test.sh @@ -1,15 +1,28 @@ #!/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:./ +RET=0 + +# Running the tests. bin/sql_grammar_test -f "test/lib/valid_queries.sql" -RET1=$? +RET=$(($RET + $?)) bin/sql_tests -RET2=$? +RET=$(($RET + $?)) -if [[ $RET1 != 0 ]]; then exit $RET1; fi -if [[ $RET2 != 0 ]]; then exit $RET2; fi +# Running memory leak checks. +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