diff options
| -rw-r--r-- | .travis.yml | 24 | ||||
| -rw-r--r-- | Makefile | 7 | ||||
| -rw-r--r-- | src/config.m4 | 13 | ||||
| -rw-r--r-- | src/sp_utils.c | 7 |
4 files changed, 29 insertions, 22 deletions
diff --git a/.travis.yml b/.travis.yml index 057c080..0a14f8f 100644 --- a/.travis.yml +++ b/.travis.yml | |||
| @@ -3,21 +3,25 @@ language: php | |||
| 3 | php: | 3 | php: |
| 4 | - '7.0' | 4 | - '7.0' |
| 5 | - '7.1' | 5 | - '7.1' |
| 6 | 6 | - '7.2' | |
| 7 | env: | 7 | - nightly |
| 8 | - CC=gcc | ||
| 9 | - CC=clang | ||
| 10 | 8 | ||
| 11 | addons: | 9 | addons: |
| 12 | apt: | 10 | apt: |
| 13 | packages: | 11 | packages: |
| 14 | - gdb | ||
| 15 | - gcc | 12 | - gcc |
| 16 | - lcov | 13 | - lcov |
| 17 | - valgrind | ||
| 18 | - libpcre3 | ||
| 19 | - libpcre3-dev | ||
| 20 | 14 | ||
| 21 | script: | 15 | script: |
| 22 | - php-config --configure-options | 16 | - cd src |
| 23 | - make debug | 17 | - phpize |
| 18 | - ./configure --enable-snuffleupagus --enable-coverage | ||
| 19 | - make | ||
| 20 | - make test | ||
| 21 | |||
| 22 | after_success: | ||
| 23 | - git clone https://github.com/linux-test-project/lcov.git --depth 1 | ||
| 24 | - ./lcov/bin/lcov -c -o ./COV.info --rc lcov_branch_coverage=1 --base-directory . --directory . | ||
| 25 | - ./lcov/bin/lcov --remove ./COV.info '/usr/*' --remove ./COV.info '*tweetnacl.c' -o ./COV.info --rc lcov_branch_coverage=1 | ||
| 26 | - ./lcov/bin/genhtml -o ./COV.html ./COV.info --branch-coverage | ||
| 27 | - bash <(curl -s https://codecov.io/bash) | ||
| @@ -10,13 +10,12 @@ debug: | |||
| 10 | 10 | ||
| 11 | coverage: | 11 | coverage: |
| 12 | cd src; phpize | 12 | cd src; phpize |
| 13 | export CFLAGS="--coverage -fprofile-arcs -ftest-coverage -O0"; export LDFLAGS="--coverage"; cd src; ./configure --enable-snuffleupagus --enable-coverage | 13 | export CFLAGS="--coverage"; cd src; ./configure --enable-snuffleupagus --enable-coverage |
| 14 | make -C src | 14 | make -C src |
| 15 | lcov --base-directory src --directory ./src --zerocounters -q --rc lcov_branch_coverage=1 | ||
| 16 | rm -Rf src/COV.html | 15 | rm -Rf src/COV.html |
| 17 | TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C src test | 16 | TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C src test |
| 18 | lcov --base-directory ./src --directory src -c -o ./src/COV.info --rc lcov_branch_coverage=1 2>/dev/null 1>/dev/null | 17 | lcov --base-directory ./src --directory ./src -c -o ./src/COV.info --rc lcov_branch_coverage=1 |
| 19 | lcov --remove src/COV.info '/usr/*' --remove src/COV.info '*tweetnacl.c' -o src/COV.info --rc lcov_branch_coverage=1 2>/dev/null 1>/dev/null | 18 | lcov --remove src/COV.info '/usr/*' --remove src/COV.info '*tweetnacl.c' -o src/COV.info --rc lcov_branch_coverage=1 |
| 20 | genhtml -o src/COV.html ./src/COV.info --branch-coverage | 19 | genhtml -o src/COV.html ./src/COV.info --branch-coverage |
| 21 | 20 | ||
| 22 | tests: joomla | 21 | tests: joomla |
diff --git a/src/config.m4 b/src/config.m4 index 84ca2f4..4f70871 100644 --- a/src/config.m4 +++ b/src/config.m4 | |||
| @@ -19,8 +19,9 @@ PHP_ARG_ENABLE(debug, whether to enable debug messages, | |||
| 19 | CFLAGS="$CFLAGS -lpcre" | 19 | CFLAGS="$CFLAGS -lpcre" |
| 20 | CFLAGS="$CFLAGS -D_DEFAULT_SOURCE=1 -std=c99" | 20 | CFLAGS="$CFLAGS -D_DEFAULT_SOURCE=1 -std=c99" |
| 21 | CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter" | 21 | CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter" |
| 22 | CFLAGS="$CFLAGS --coverage" | ||
| 22 | 23 | ||
| 23 | LFLAGS="$LFLAGS -lpcre" | 24 | LDFLAGS="$LDFLAGS -lpcre --coverage" |
| 24 | 25 | ||
| 25 | if test "$PHP_DEBUG" = "yes"; then | 26 | if test "$PHP_DEBUG" = "yes"; then |
| 26 | AC_DEFINE(SP_DEBUG, 1, [Wether you want to enable debug messages]) | 27 | AC_DEFINE(SP_DEBUG, 1, [Wether you want to enable debug messages]) |
| @@ -28,12 +29,14 @@ fi | |||
| 28 | 29 | ||
| 29 | AC_CHECK_LIB(pcre, pcre_compile, AC_DEFINE(HAVE_PCRE, 1, [have pcre])) | 30 | AC_CHECK_LIB(pcre, pcre_compile, AC_DEFINE(HAVE_PCRE, 1, [have pcre])) |
| 30 | 31 | ||
| 31 | if test "$PHP_SNUFFLEUPAGUS" != "no"; then | 32 | if test "$PHP_SNUFFLEUPAGUS" = "yes"; then |
| 32 | if test "$PHP_COVERAGE" != "no"; then | 33 | if test "$PHP_COVERAGE" = "yes"; then |
| 33 | CFLAGS="$CFLAGS --coverage -fprofile-arcs -ftest-coverage" | 34 | CFLAGS="$CFLAGS --coverage" |
| 34 | LDFLAGS="$LDFLAGS --coverage" | 35 | LDFLAGS="$LDFLAGS --coverage" |
| 35 | PHP_NEW_EXTENSION(snuffleupagus, $sources, $ext_shared,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -g -fprofile-arcs -ftest-coverage -lgcov) | 36 | PHP_NEW_EXTENSION(snuffleupagus, $sources, $ext_shared,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -g --coverage -lgcov) |
| 36 | else | 37 | else |
| 38 | CFLAGS="$CFLAGS --coverage" | ||
| 39 | LDFLAGS="$LDFLAGS --coverage" | ||
| 37 | PHP_NEW_EXTENSION(snuffleupagus, $sources, $ext_shared,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) | 40 | PHP_NEW_EXTENSION(snuffleupagus, $sources, $ext_shared,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) |
| 38 | fi | 41 | fi |
| 39 | fi | 42 | fi |
diff --git a/src/sp_utils.c b/src/sp_utils.c index 56512df..2370a6d 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c | |||
| @@ -39,7 +39,7 @@ int compute_hash(const char* const filename, char* file_hash) { | |||
| 39 | php_stream_open_wrapper(filename, "rb", REPORT_ERRORS, NULL); | 39 | php_stream_open_wrapper(filename, "rb", REPORT_ERRORS, NULL); |
| 40 | if (!stream) { | 40 | if (!stream) { |
| 41 | sp_log_err("hash_computation", "Can not open the file %s to compute its hash.\n", filename); | 41 | sp_log_err("hash_computation", "Can not open the file %s to compute its hash.\n", filename); |
| 42 | return -1; | 42 | return FAILURE; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | PHP_SHA256Init(&context); | 45 | PHP_SHA256Init(&context); |
| @@ -49,7 +49,7 @@ int compute_hash(const char* const filename, char* file_hash) { | |||
| 49 | PHP_SHA256Final(digest, &context); | 49 | PHP_SHA256Final(digest, &context); |
| 50 | php_stream_close(stream); | 50 | php_stream_close(stream); |
| 51 | make_digest_ex(file_hash, digest, SHA256_SIZE); | 51 | make_digest_ex(file_hash, digest, SHA256_SIZE); |
| 52 | return 0; | 52 | return SUCCESS; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | static void construct_filename(char* filename, const char* folder) { | 55 | static void construct_filename(char* filename, const char* folder) { |
| @@ -123,7 +123,7 @@ int sp_log_request(const char* folder) { | |||
| 123 | 123 | ||
| 124 | // Allocate and copy the data | 124 | // Allocate and copy the data |
| 125 | // FIXME Why are we even allocating? | 125 | // FIXME Why are we even allocating? |
| 126 | param = pecalloc(params_len, 1, 0); | 126 | param = ecalloc(params_len, 1); |
| 127 | NCAT_AND_DEC(param, zones[i].str, params_len); | 127 | NCAT_AND_DEC(param, zones[i].str, params_len); |
| 128 | NCAT_AND_DEC(param, ":", params_len); | 128 | NCAT_AND_DEC(param, ":", params_len); |
| 129 | ZEND_HASH_FOREACH_STR_KEY_VAL(ht, variable_key, variable_value) { | 129 | ZEND_HASH_FOREACH_STR_KEY_VAL(ht, variable_key, variable_value) { |
| @@ -138,6 +138,7 @@ int sp_log_request(const char* folder) { | |||
| 138 | 138 | ||
| 139 | fputs(param, file); | 139 | fputs(param, file); |
| 140 | fputs("\n", file); | 140 | fputs("\n", file); |
| 141 | efree(param); | ||
| 141 | } | 142 | } |
| 142 | fclose(file); | 143 | fclose(file); |
| 143 | 144 | ||
