Merge pull request #114 from msteinert/check-tree-fixes

Fix issues with check_tree test
This commit is contained in:
Yo-An Lin 2018-07-06 00:42:01 +08:00 committed by GitHub
commit 3b9bb5745a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 106 additions and 27 deletions

5
.travis-ci/after_success.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
if [ x$COVERALLS == xyes ]; then
coveralls --exclude php --exclude 3rdparty
fi

22
.travis-ci/install.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/sh
apt-get update -qq
apt-get install -qq \
autoconf \
automake \
build-essential \
check \
clang \
graphviz-dev \
libjemalloc-dev \
libpcre3-dev \
libtool \
pkg-config
if [ x$COVERALLS == xyes ]; then
pip install cpp-coveralls
fi
if [ x$VALGRIND == xyes ]; then
apt-get install valgrind
fi

18
.travis-ci/script.sh Executable file
View file

@ -0,0 +1,18 @@
#!/bin/sh
set -ev
./autogen.sh
./configure --enable-check $CONFIGURE_OPTION
make V=1
make install
if [ x$VALGRIND == xyes ]; then
make check
else
make check V=1
fi
# XXX: tracing memory leak, disabled for some mystery reason for automake...
#if [ x$VALGRIND == xyes && x$DEBUG == xyes ]; then
# valgrind ./tests/check_* -v --trace-children=yes --show-leak-kinds=full --leak-check=full
#fi

View file

@ -1,4 +1,8 @@
language: c
sudo: required
services:
- docker
git:
depth: 1
@ -6,35 +10,49 @@ git:
matrix:
include:
- compiler: gcc
env: CONFIGURE_OPTION='--enable-debug --enable-gcov --with-malloc=jemalloc' COVERALLS=yes VALGRIND=no DEBUG=yes
env:
- CONFIGURE_OPTION='--enable-debug --enable-gcov --with-malloc=jemalloc'
- COVERALLS=yes
- VALGRIND=no
- DEBUG=yes
- CC=gcc
- CXX=g++
- compiler: gcc
env: CONFIGURE_OPTION='--enable-debug --enable-gcov' COVERALLS=yes VALGRIND=yes DEBUG=yes LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
env:
- CONFIGURE_OPTION='--enable-debug --enable-gcov'
- COVERALLS=yes
- VALGRIND=yes
- DEBUG=yes
- CC=gcc
- CXX=g++
- compiler: clang
env: CONFIGURE_OPTION='--enable-debug --enable-gcov' COVERALLS=yes VALGRIND=yes DEBUG=yes LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/
allow_failures:
- compiler: clang
env: ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=/usr/local/clang-3.4/bin/llvm-symbolizer CFLAGS='-fsanitize=address -g -O1 -D_BSD_SOURCE=1' CXX=clang++ CXXFLAGS='-fsanitize=address -g -O1 -D_BSD_SOURCE=1'
install:
- sudo apt-get update -qq
- sudo apt-get install -qq automake pkg-config build-essential libtool automake autoconf m4 gnulib
- sudo apt-get install -qq check libpcre3 libpcre3-dev libjemalloc-dev libjemalloc1
- sudo apt-get install -qq graphviz-dev graphviz
- if [ "x$COVERALLS" == xyes ]; then sudo pip install cpp-coveralls; fi
- if [ "x$VALGRIND" == xyes ]; then sudo apt-get install valgrind; fi
env:
- CONFIGURE_OPTION='--enable-debug --enable-gcov'
- COVERALLS=yes
- VALGRIND=yes
- DEBUG=yes
- CC=clang
- CXX=clang++
before_install:
- docker run -d
--name build
-v $(pwd):/travis
-e "CONFIGURE_OPTION=$CONFIGURE_OPTION"
-e "COVERALLS=$COVERALLS"
-e "VALGRIND=$VALGRIND"
-e "DEBUG=$DEBUG"
-e "CC=$CC"
-e "CXX=$CXX"
ubuntu:16.04
tail -f /dev/null
- docker ps
install:
- docker exec -t build bash -c "cd /travis && .travis-ci/install.sh"
before_script:
- sudo ldconfig
script:
- ./autogen.sh
- ./configure --enable-check $CONFIGURE_OPTION
- make V=1
- sudo make install
- if [ "x$VALGRIND" == xyes ]; then make check ; else make check V=1; fi
# XXX: tracing memory leak, disabled for some mystery reason for automake...
# - if [ "x$VALGRIND" == xyes && "x$DEBUG" == xyes ]; then valgrind ./tests/check_* -v --trace-children=yes --show-leak-kinds=full --leak-check=full; fi
- docker exec -t build bash -c "cd /travis && .travis-ci/script.sh"
after_success:
- if [ x$COVERALLS == xyes ]; then coveralls --exclude php --exclude 3rdparty; fi
cache:
apt: true
- docker exec -t build bash -c "cd /travis && .travis-ci/after_success.sh"

View file

@ -218,6 +218,7 @@ int r3_tree_compile_patterns(R3Node * n, char **errstr) {
}
info("COMPARE_TYPE: %d\n",n->compare_type);
zfree(n->combined_pattern);
n->combined_pattern = cpat;
const char *pcre_error;

View file

@ -286,26 +286,34 @@ START_TEST (test_compile)
entry = match_entry_createl( "foo" , strlen("/foo") );
m = r3_tree_matchl( n , "/foo", strlen("/foo"), entry);
ck_assert( m );
match_entry_free(entry);
entry = match_entry_createl( "/zoo" , strlen("/zoo") );
m = r3_tree_matchl( n , "/zoo", strlen("/zoo"), entry);
ck_assert( m );
match_entry_free(entry);
entry = match_entry_createl( "/bar" , strlen("/bar") );
m = r3_tree_matchl( n , "/bar", strlen("/bar"), entry);
ck_assert( m );
match_entry_free(entry);
entry = match_entry_createl( "/xxx" , strlen("/xxx") );
m = r3_tree_matchl( n , "/xxx", strlen("/xxx"), entry);
ck_assert( m );
match_entry_free(entry);
entry = match_entry_createl( "/foo/xxx" , strlen("/foo/xxx") );
m = r3_tree_matchl( n , "/foo/xxx", strlen("/foo/xxx"), entry);
ck_assert( m );
match_entry_free(entry);
entry = match_entry_createl( "/some_id" , strlen("/some_id") );
m = r3_tree_matchl( n , "/some_id", strlen("/some_id"), entry);
ck_assert( m );
match_entry_free(entry);
r3_tree_free(n);
}
END_TEST
@ -439,6 +447,8 @@ START_TEST (test_root_match)
ck_assert(matched);
ck_assert(matched->data == &c);
ck_assert(matched->endpoint > 0);
r3_tree_free(n);
}
END_TEST
@ -464,6 +474,8 @@ START_TEST (test_pcre_patterns_insert_2)
matched = r3_tree_match(n, "/post/11/22", NULL);
ck_assert(matched);
ck_assert(matched->endpoint > 0);
r3_tree_free(n);
}
END_TEST
@ -504,6 +516,8 @@ START_TEST (test_pcre_patterns_insert_3)
matched = r3_tree_match(n, "/post/113", NULL);
ck_assert(!matched);
*/
r3_tree_free(n);
}
END_TEST
@ -646,7 +660,6 @@ START_TEST(test_route_cmp)
m->request_method = METHOD_POST | METHOD_GET;
fail_if( r3_route_cmp(r1, m) == -1, "should match");
r3_route_free(r1);
match_entry_free(m);
r3_tree_free(n);
}
@ -667,6 +680,7 @@ START_TEST(test_pcre_pattern_simple)
ck_assert(matched);
ck_assert(entry->vars.tokens.size > 0);
ck_assert_str_eq(entry->vars.tokens.entries[0].base,"123");
match_entry_free(entry);
r3_tree_free(n);
}
END_TEST
@ -719,6 +733,7 @@ START_TEST(test_pcre_pattern_more)
info("matched %p\n", matched->data);
ck_assert_int_eq( *((int*)matched->data), var3);
match_entry_free(entry);
r3_tree_free(n);
}
END_TEST