Skip to content
Permalink
Browse files
.travis.yml: run PHP 7.2 target under -fsanitize=memory
  • Loading branch information
rouault committed Sep 11, 2019
1 parent ee77e17 commit 8d0c7d5efc80d04ee86d8979aecb512d18fd9909
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 23 deletions.
@@ -4,12 +4,30 @@ branches:

dist: trusty
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3

matrix:
include:

- php: 5.6
env:
- BUILD_NAME=PHP_5.6

- php: 7.0
env:
- BUILD_NAME=PHP_7.0

- php: 7.1
env:
- BUILD_NAME=PHP_7.1

- php: 7.2
env:
- BUILD_NAME=PHP_7.2_WITH_ASAN

- php: 7.3
env:
- BUILD_NAME=PHP_7.3

cache:
apt: true
directories:
@@ -1,4 +1,4 @@
AUTOTEST_OPTS=-strict -q
AUTOTEST_OPTS?=-strict -q
PHP_MAPSCRIPT=build/mapscript/php/php_mapscript.so
PYTHON_MAPSCRIPT_PATH=build/mapscript/python
JAVA_MAPSCRIPT_PATH=build/mapscript/java
@@ -7,11 +7,11 @@ PERL_MAPSCRIPT_PATH=build/mapscript/perl
BUILDPATH=../../build
FLEX=flex
YACC=yacc
CMAKEFLAGS=-DCMAKE_C_FLAGS="--coverage" -DCMAKE_CXX_FLAGS="--coverage" \
CMAKEFLAGS=-DCMAKE_C_FLAGS="--coverage ${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="--coverage ${CMAKE_CXX_FLAGS}" \
-DCMAKE_SHARED_LINKER_FLAGS="-lgcov" -DWITH_CLIENT_WMS=1 \
-DWITH_CLIENT_WFS=1 -DWITH_KML=1 -DWITH_SOS=1 -DWITH_CSHARP=1 -DWITH_PHP=1 -DWITH_PERL=1 \
-DWITH_PYTHON=1 -DWITH_JAVA=1 -DWITH_THREAD_SAFETY=1 -DWITH_FRIBIDI=1 -DWITH_FCGI=0 -DWITH_EXEMPI=1 \
-DCMAKE_BUILD_TYPE=Release -DWITH_RSVG=1 -DWITH_CURL=1 -DWITH_HARFBUZZ=1 -DWITH_POINT_Z_M=1
-DCMAKE_BUILD_TYPE=Release -DWITH_RSVG=1 -DWITH_CURL=1 -DWITH_HARFBUZZ=1 -DWITH_POINT_Z_M=1 ${EXTRA_CMAKEFLAGS}
all: cmakebuild

cmakebuild: lexer parser
@@ -69,6 +69,9 @@ test: cmakebuild
@$(MAKE) $(MFLAGS) csharp-testcase
@$(MAKE) $(MFLAGS) perl-testcase

asan_compatible_tests: cmakebuild
@$(MAKE) $(MFLAGS) wxs-testcase renderers-testcase misc-testcase gdal-testcase query-testcase
@./print-test-results.sh

lexer: maplexer.c
parser: mapparser.c
@@ -1,8 +1,10 @@
#!/bin/sh
set -eu

# Only run coverage when it is safe to do so (not on pull requests), and only on master branch
echo "$TRAVIS_SECURE_ENV_VARS"
echo "$TRAVIS_BRANCH"
sh -c 'if test "$TRAVIS_SECURE_ENV_VARS" = "true" -a "$TRAVIS_BRANCH" = "master"; then echo "run coverage"; ./run_code_coverage_upload.sh; fi'
coveralls --exclude renderers --exclude mapscript --exclude apache --exclude build/mapscript/mapscriptJAVA_wrap.c --exclude build/mapscript/mapscriptPYTHON_wrap.c --exclude shp2img.c --exclude legend.c --exclude scalebar.c --exclude msencrypt.c --exclude sortshp.c --exclude shptreevis.c --exclude shptree.c --exclude testexpr.c --exclude sym2img.c --exclude testcopy.c --exclude shptreetst.c --exclude tile4ms.c --extension .c --extension .cpp
if [ "$BUILD_NAME" != "PHP_7.2_WITH_ASAN" ]; then
# Only run coverage when it is safe to do so (not on pull requests), and only on master branch
echo "$TRAVIS_SECURE_ENV_VARS"
echo "$TRAVIS_BRANCH"
sh -c 'if test "$TRAVIS_SECURE_ENV_VARS" = "true" -a "$TRAVIS_BRANCH" = "master"; then echo "run coverage"; ./run_code_coverage_upload.sh; fi'
coveralls --exclude renderers --exclude mapscript --exclude apache --exclude build/mapscript/mapscriptJAVA_wrap.c --exclude build/mapscript/mapscriptPYTHON_wrap.c --exclude shp2img.c --exclude legend.c --exclude scalebar.c --exclude msencrypt.c --exclude sortshp.c --exclude shptreevis.c --exclude shptree.c --exclude testexpr.c --exclude sym2img.c --exclude testcopy.c --exclude shptreetst.c --exclude tile4ms.c --extension .c --extension .cpp
fi
@@ -1,8 +1,18 @@
#!/bin/sh
set -eu

export CC="ccache gcc"
export CXX="ccache g++"
make cmakebuild MFLAGS="-j2"
make mspython-wheel
make -j4 test
if [ "$BUILD_NAME" = "PHP_7.2_WITH_ASAN" ]; then
export CC="ccache clang"
export CXX="ccache clang++"
# -DNDEBUG to avoid issues with cairo cleanup
make cmakebuild MFLAGS="-j2" CMAKE_C_FLAGS="-g -fsanitize=address -DNDEBUG" CMAKE_CXX_FLAGS="-g -fsanitize=address -DNDEBUG" EXTRA_CMAKEFLAGS="-DCMAKE_BUILD_TYPE=None -DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address"
export AUTOTEST_OPTS="-q -strict -run_under_asan"
# Only run tests that only involve mapserv/shp2img binaries. mspython, etc would require LD_PREOLOAD'ing the asan shared object
make -j4 asan_compatible_tests
else
export CC="ccache gcc"
export CXX="ccache g++"
make cmakebuild MFLAGS="-j2"
make mspython-wheel
make -j4 test
fi
@@ -481,6 +481,8 @@ def run_tests( argv ):
keep_pass = 0
valgrind = 0
valgrind_log = ''
run_under_asan = False
asan_log = ''
shp2img = 'shp2img'
renderer = None
verbose = 0
@@ -489,6 +491,7 @@ def run_tests( argv ):
validate_xml = True
skiparg = False
valgrind_non_empty_count = 0
asan_non_empty_count = 0

###########################################################################
# Process arguments.
@@ -504,6 +507,8 @@ def run_tests( argv ):
keep_pass = 1
elif argv[i] == '-valgrind':
valgrind = 1
elif argv[i] == '-run_under_asan':
run_under_asan = True
elif argv[i] == '-strict':
strict = 1
elif argv[i] == '-renderer':
@@ -519,7 +524,7 @@ def run_tests( argv ):
pass
else:
print( 'Unrecognised argument: %s' % argv[i] )
print( 'Usage: run_test.py [-v] [-keep] [-valgrind] [-strict]\n' +
print( 'Usage: run_test.py [-v] [-keep] [-valgrind|-run_under_asan] [-strict]\n' +
' [-shp2img <file>] [-renderer <name>]\n' +
' [mapfilename]*' )
sys.exit( 1 )
@@ -673,6 +678,10 @@ def run_tests( argv ):
command = 'valgrind --tool=memcheck -q --suppressions=../valgrind-suppressions.txt --leak-check=full --show-reachable=yes %s 2>%s'%(command, valgrind_log)
else:
command = 'echo "' + post + '" | valgrind --tool=memcheck -q --suppressions=../valgrind-suppressions.txt --leak-check=full --show-reachable=yes %s 2>%s'%(command, valgrind_log)
elif run_under_asan:
asan_log = 'result/' + out_file + ".asan.txt"
command = command.strip()
command += " 2>%s" % asan_log

if verbose:
print('')
@@ -706,6 +715,22 @@ def run_tests( argv ):
if not quiet:
print(' Valgrind log non empty.')

elif run_under_asan:
if os.path.getsize(asan_log) == 0:
os.remove( asan_log )
else:
asan_log_content = open(asan_log, 'rt').read()
# We get some unexplained crashes on Travis-CI
if "Assertion `unscaled->face" in asan_log_content:
os.remove( asan_log )
elif 'AddressSanitizer' in asan_log_content or 'LeakSanitizer' in asan_log_content:
asan_non_empty_count = asan_non_empty_count + 1
if not quiet:
print(' ASAN log non empty.')
else:
# some other standard error output
os.remove( asan_log )

apply_strip_items_file( 'result/'+out_file, strip_items )

crlf('result/'+out_file)
@@ -786,6 +811,8 @@ def run_tests( argv ):
print('%d test results initialized' % init_count)
if valgrind:
print('%d test have non-empty Valgrind log' % valgrind_non_empty_count)
elif run_under_asan:
print('%d test have non-empty ASAN log' % asan_non_empty_count)

if noresult_count > 0:
print('%d of failed tests produced *no* result! Serious Failure!' % noresult_count)
@@ -39,11 +39,12 @@ for testcase in "${tests[@]}"; do
echo "######################################"
echo "# $testcase => $failedtest"
echo "######################################"
if echo "$failedtest" | egrep -q "asan.txt"; then
cat "$failedtest"
#for txt, gml and xml files, print a diff
if echo "$failedtest" | egrep -q "(txt|xml|gml|html|json)$"; then
elif echo "$failedtest" | egrep -q "(txt|xml|gml|html|json)$"; then
$DIFF -u "../expected/$failedtest" "$failedtest"
fi
if echo "$failedtest" | egrep -q "(png|gif|tif)$"; then
elif echo "$failedtest" | egrep -q "(png|gif|tif)$"; then
if echo "$failedtest" | egrep -v -q "\\.diff\\.png$"; then
if [ -n "$COMPARE" ]; then
$COMPARE ../expected/$failedtest $failedtest -compose Src $failedtest.diff.png

0 comments on commit 8d0c7d5

Please sign in to comment.