Fix memory leak and enable valgrind on travis

This commit is contained in:
Thiago de Arruda 2014-03-06 22:04:07 -03:00
parent 1b5c3331dc
commit cab5c25c70
4 changed files with 10 additions and 6 deletions

View File

@ -1,7 +1,6 @@
language: c language: c
script: ./scripts/travis.sh script: ./scripts/travis.sh
before_install: before_install:
- sudo apt-get update
- sudo apt-get install valgrind - sudo apt-get install valgrind
compiler: compiler:
- clang - clang

View File

@ -1,11 +1,11 @@
#!/bin/sh -e #!/bin/sh -e
# export VALGRIND_CHECK=1 export VALGRIND_CHECK=1
make cmake CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$PWD/dist" make cmake CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$PWD/dist"
make make
make unittest make unittest
echo "Running tests with valgrind..." echo "Running tests with valgrind..."
if ! make test > /dev/null; then if ! make test; then
if ls src/testdir/valgrind.* > /dev/null 2>&1; then if ls src/testdir/valgrind.* > /dev/null 2>&1; then
echo "Memory leak detected" >&2 echo "Memory leak detected" >&2
cat src/testdir/valgrind.* cat src/testdir/valgrind.*

View File

@ -175,11 +175,16 @@ int mch_is_absolute_path(char_u *fname)
int mch_isdir(char_u *name) int mch_isdir(char_u *name)
{ {
uv_fs_t request; uv_fs_t request;
if (0 != uv_fs_stat(uv_default_loop(), &request, (const char*) name, NULL)) { int result = uv_fs_stat(uv_default_loop(), &request, (const char*) name, NULL);
uint64_t mode = request.statbuf.st_mode;
uv_fs_req_cleanup(&request);
if (0 != result) {
return FALSE; return FALSE;
} }
if (!S_ISDIR(request.statbuf.st_mode)) { if (!S_ISDIR(mode)) {
return FALSE; return FALSE;
} }

View File

@ -28,7 +28,7 @@ SCRIPTS := test1.out test2.out test3.out test4.out test5.out test6.out \
SCRIPTS_GUI := test16.out SCRIPTS_GUI := test16.out
ifdef VALGRIND_CHECK ifdef VALGRIND_CHECK
VALGRIND = valgrind --suppressions=../../.valgrind.supp --leak-check=full --error-exitcode=111 --log-file=valgrind.$* VALGRIND = valgrind --suppressions=../../.valgrind.supp --leak-check=full --error-exitcode=123 --log-file=valgrind.$*
endif endif
ifdef TESTNUM ifdef TESTNUM