Skip to content

Commit 8d0c7d5

Browse files
committed
.travis.yml: run PHP 7.2 target under -fsanitize=memory
1 parent ee77e17 commit 8d0c7d5

File tree

6 files changed

+84
-23
lines changed

6 files changed

+84
-23
lines changed

.travis.yml

+24-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,30 @@ branches:
44

55
dist: trusty
66
language: php
7-
php:
8-
- 5.6
9-
- 7.0
10-
- 7.1
11-
- 7.2
12-
- 7.3
7+
8+
matrix:
9+
include:
10+
11+
- php: 5.6
12+
env:
13+
- BUILD_NAME=PHP_5.6
14+
15+
- php: 7.0
16+
env:
17+
- BUILD_NAME=PHP_7.0
18+
19+
- php: 7.1
20+
env:
21+
- BUILD_NAME=PHP_7.1
22+
23+
- php: 7.2
24+
env:
25+
- BUILD_NAME=PHP_7.2_WITH_ASAN
26+
27+
- php: 7.3
28+
env:
29+
- BUILD_NAME=PHP_7.3
30+
1331
cache:
1432
apt: true
1533
directories:

Makefile

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AUTOTEST_OPTS=-strict -q
1+
AUTOTEST_OPTS?=-strict -q
22
PHP_MAPSCRIPT=build/mapscript/php/php_mapscript.so
33
PYTHON_MAPSCRIPT_PATH=build/mapscript/python
44
JAVA_MAPSCRIPT_PATH=build/mapscript/java
@@ -7,11 +7,11 @@ PERL_MAPSCRIPT_PATH=build/mapscript/perl
77
BUILDPATH=../../build
88
FLEX=flex
99
YACC=yacc
10-
CMAKEFLAGS=-DCMAKE_C_FLAGS="--coverage" -DCMAKE_CXX_FLAGS="--coverage" \
10+
CMAKEFLAGS=-DCMAKE_C_FLAGS="--coverage ${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="--coverage ${CMAKE_CXX_FLAGS}" \
1111
-DCMAKE_SHARED_LINKER_FLAGS="-lgcov" -DWITH_CLIENT_WMS=1 \
1212
-DWITH_CLIENT_WFS=1 -DWITH_KML=1 -DWITH_SOS=1 -DWITH_CSHARP=1 -DWITH_PHP=1 -DWITH_PERL=1 \
1313
-DWITH_PYTHON=1 -DWITH_JAVA=1 -DWITH_THREAD_SAFETY=1 -DWITH_FRIBIDI=1 -DWITH_FCGI=0 -DWITH_EXEMPI=1 \
14-
-DCMAKE_BUILD_TYPE=Release -DWITH_RSVG=1 -DWITH_CURL=1 -DWITH_HARFBUZZ=1 -DWITH_POINT_Z_M=1
14+
-DCMAKE_BUILD_TYPE=Release -DWITH_RSVG=1 -DWITH_CURL=1 -DWITH_HARFBUZZ=1 -DWITH_POINT_Z_M=1 ${EXTRA_CMAKEFLAGS}
1515
all: cmakebuild
1616

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

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

7376
lexer: maplexer.c
7477
parser: mapparser.c

ci/travis/after_success.sh

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/bin/sh
22
set -eu
33

4-
# Only run coverage when it is safe to do so (not on pull requests), and only on master branch
5-
echo "$TRAVIS_SECURE_ENV_VARS"
6-
echo "$TRAVIS_BRANCH"
7-
sh -c 'if test "$TRAVIS_SECURE_ENV_VARS" = "true" -a "$TRAVIS_BRANCH" = "master"; then echo "run coverage"; ./run_code_coverage_upload.sh; fi'
8-
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
4+
if [ "$BUILD_NAME" != "PHP_7.2_WITH_ASAN" ]; then
5+
# Only run coverage when it is safe to do so (not on pull requests), and only on master branch
6+
echo "$TRAVIS_SECURE_ENV_VARS"
7+
echo "$TRAVIS_BRANCH"
8+
sh -c 'if test "$TRAVIS_SECURE_ENV_VARS" = "true" -a "$TRAVIS_BRANCH" = "master"; then echo "run coverage"; ./run_code_coverage_upload.sh; fi'
9+
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
10+
fi

ci/travis/script.sh

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
#!/bin/sh
22
set -eu
33

4-
export CC="ccache gcc"
5-
export CXX="ccache g++"
6-
make cmakebuild MFLAGS="-j2"
7-
make mspython-wheel
8-
make -j4 test
4+
if [ "$BUILD_NAME" = "PHP_7.2_WITH_ASAN" ]; then
5+
export CC="ccache clang"
6+
export CXX="ccache clang++"
7+
# -DNDEBUG to avoid issues with cairo cleanup
8+
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"
9+
export AUTOTEST_OPTS="-q -strict -run_under_asan"
10+
# Only run tests that only involve mapserv/shp2img binaries. mspython, etc would require LD_PREOLOAD'ing the asan shared object
11+
make -j4 asan_compatible_tests
12+
else
13+
export CC="ccache gcc"
14+
export CXX="ccache g++"
15+
make cmakebuild MFLAGS="-j2"
16+
make mspython-wheel
17+
make -j4 test
18+
fi

msautotest/pymod/mstestlib.py

+28-1
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,8 @@ def run_tests( argv ):
481481
keep_pass = 0
482482
valgrind = 0
483483
valgrind_log = ''
484+
run_under_asan = False
485+
asan_log = ''
484486
shp2img = 'shp2img'
485487
renderer = None
486488
verbose = 0
@@ -489,6 +491,7 @@ def run_tests( argv ):
489491
validate_xml = True
490492
skiparg = False
491493
valgrind_non_empty_count = 0
494+
asan_non_empty_count = 0
492495

493496
###########################################################################
494497
# Process arguments.
@@ -504,6 +507,8 @@ def run_tests( argv ):
504507
keep_pass = 1
505508
elif argv[i] == '-valgrind':
506509
valgrind = 1
510+
elif argv[i] == '-run_under_asan':
511+
run_under_asan = True
507512
elif argv[i] == '-strict':
508513
strict = 1
509514
elif argv[i] == '-renderer':
@@ -519,7 +524,7 @@ def run_tests( argv ):
519524
pass
520525
else:
521526
print( 'Unrecognised argument: %s' % argv[i] )
522-
print( 'Usage: run_test.py [-v] [-keep] [-valgrind] [-strict]\n' +
527+
print( 'Usage: run_test.py [-v] [-keep] [-valgrind|-run_under_asan] [-strict]\n' +
523528
' [-shp2img <file>] [-renderer <name>]\n' +
524529
' [mapfilename]*' )
525530
sys.exit( 1 )
@@ -673,6 +678,10 @@ def run_tests( argv ):
673678
command = 'valgrind --tool=memcheck -q --suppressions=../valgrind-suppressions.txt --leak-check=full --show-reachable=yes %s 2>%s'%(command, valgrind_log)
674679
else:
675680
command = 'echo "' + post + '" | valgrind --tool=memcheck -q --suppressions=../valgrind-suppressions.txt --leak-check=full --show-reachable=yes %s 2>%s'%(command, valgrind_log)
681+
elif run_under_asan:
682+
asan_log = 'result/' + out_file + ".asan.txt"
683+
command = command.strip()
684+
command += " 2>%s" % asan_log
676685

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

718+
elif run_under_asan:
719+
if os.path.getsize(asan_log) == 0:
720+
os.remove( asan_log )
721+
else:
722+
asan_log_content = open(asan_log, 'rt').read()
723+
# We get some unexplained crashes on Travis-CI
724+
if "Assertion `unscaled->face" in asan_log_content:
725+
os.remove( asan_log )
726+
elif 'AddressSanitizer' in asan_log_content or 'LeakSanitizer' in asan_log_content:
727+
asan_non_empty_count = asan_non_empty_count + 1
728+
if not quiet:
729+
print(' ASAN log non empty.')
730+
else:
731+
# some other standard error output
732+
os.remove( asan_log )
733+
709734
apply_strip_items_file( 'result/'+out_file, strip_items )
710735

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

790817
if noresult_count > 0:
791818
print('%d of failed tests produced *no* result! Serious Failure!' % noresult_count)

print-test-results.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ for testcase in "${tests[@]}"; do
3939
echo "######################################"
4040
echo "# $testcase => $failedtest"
4141
echo "######################################"
42+
if echo "$failedtest" | egrep -q "asan.txt"; then
43+
cat "$failedtest"
4244
#for txt, gml and xml files, print a diff
43-
if echo "$failedtest" | egrep -q "(txt|xml|gml|html|json)$"; then
45+
elif echo "$failedtest" | egrep -q "(txt|xml|gml|html|json)$"; then
4446
$DIFF -u "../expected/$failedtest" "$failedtest"
45-
fi
46-
if echo "$failedtest" | egrep -q "(png|gif|tif)$"; then
47+
elif echo "$failedtest" | egrep -q "(png|gif|tif)$"; then
4748
if echo "$failedtest" | egrep -v -q "\\.diff\\.png$"; then
4849
if [ -n "$COMPARE" ]; then
4950
$COMPARE ../expected/$failedtest $failedtest -compose Src $failedtest.diff.png

0 commit comments

Comments
 (0)