From c47d59b53618250e2581e6a60c814c8f0fb2481e Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Wed, 11 Sep 2019 20:12:21 +0100 Subject: [PATCH] Switch from Valgrind to ASAN --- .travis.yml | 27 +++++---------------------- HACKING.org | 6 ------ bootstrap.conf | 3 +-- configure.ac | 3 +++ tests/Makefile.am | 5 +++-- tests/asan-suppressions.txt | 1 + 6 files changed, 13 insertions(+), 32 deletions(-) create mode 100644 tests/asan-suppressions.txt diff --git a/.travis.yml b/.travis.yml index 522b618..590acd0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,17 @@ language: c -dist: xenial +dist: bionic sudo: required addons: apt: - sources: - - ubuntu-toolchain-r-test packages: &default_deps - - python3-dbg + - python3 - cython3 - flex - help2man - autopoint - texinfo - - valgrind - - g++-5 # env: # global: @@ -23,12 +19,6 @@ addons: matrix: include: - - os: linux - env: - - COMPILER=gcc-5 - - PYTHON=/usr/bin/python3-dbg - - CYTHON=/usr/bin/cython3 - - DISTCHECK_CONFIGURE_FLAGS="PYTHON=/usr/bin/python3-dbg CYTHON=/usr/bin/cython3" - os: osx osx_image: xcode9.2 env: @@ -37,17 +27,10 @@ matrix: - PYTHON=/usr/local/bin/python3 - compiler: gcc env: - - COMPILER=gcc-6 - PYTHON=/usr/bin/python3-dbg - CYTHON=/usr/bin/cython3 - - DISTCHECK_CONFIGURE_FLAGS="PYTHON=/usr/bin/python3-dbg CYTHON=/usr/bin/cython3" - addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - *default_deps - - [g++-6] + - CONFIGURE_ARGS=(--enable-package-suffix "CFLAGS=\"-g3 -fsanitize=address -fsanitize=undefined\"" "LDFLAGS=\"-fsanitize=address -fsanitize=undefined\"" "PY_LOG_ENV=\"LD_PRELOAD=/usr/lib/gcc/x86_64-linux-gnu/7/libasan.so PYTHONMALLOC=malloc\"") + - DISTCHECK_CONFIGURE_FLAGS="PYTHON=/usr/bin/python3 CYTHON=/usr/bin/cython3" before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi @@ -58,5 +41,5 @@ before_install: script: - ./bootstrap - - ./configure --enable-silent-rules CC=$COMPILER $DISTCHECK_CONFIGURE_FLAGS + - ./configure --enable-silent-rules "${CONFIGURE_ARGS[@]}" $DISTCHECK_CONFIGURE_FLAGS - make && make distcheck diff --git a/HACKING.org b/HACKING.org index a68acd1..5a4c0ae 100644 --- a/HACKING.org +++ b/HACKING.org @@ -15,12 +15,6 @@ m4, GNU Make, libtool, Autoconf, automake, Gettext, Help2man, Perl, Flex, Python make install #+END_SRC -* Testing with Valgrind - -Currently, Valgrind does not play nice with CPython, even with a fairly extensive suppressions file. It works on Ubuntu with the debug build of Python, from the package ~python3-dbg~. Having installed this, configure with the option ~PYTHON=/usr/bin/python3-dbg~ (the full path is required). - -To ensure that Valgrind is used for testing releases too, the above setting can be added to ~DISTCHECK_CONFIGURE_FLAGS~. - * Making a release To make a release, you'll need [[https://github.com/rrthomas/woger][woger]] and [[https://github.com/aktau/github-release][github-release]], suitably configured. Having tested and pushed all the changes, update the version number in =configure.ac= and write the =NEWS= entry and push those too. diff --git a/bootstrap.conf b/bootstrap.conf index 69cdd75..a281ab1 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -1,4 +1,4 @@ -# bootstrap.conf (Recode) version 2019-05-20 +# bootstrap.conf (Recode) version 2019-09-11 # This file is part of Recode. # @@ -69,7 +69,6 @@ gnulib_modules=' sys_wait unistd utime - valgrind-tests vasprintf vprintf-posix xalloc diff --git a/configure.ac b/configure.ac index 313312a..81d2c41 100644 --- a/configure.ac +++ b/configure.ac @@ -101,6 +101,9 @@ else fi AC_SUBST([ISYSTEM]) +# Extra settings for running tests, e.g. LD_PRELOAD for ASAN +AC_SUBST([TESTS_ENVIRONMENT_EXTRA]) + AC_CONFIG_HEADERS([config.h]) AC_HEADER_STDC AM_ICONV diff --git a/tests/Makefile.am b/tests/Makefile.am index 68b8941..5890c37 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -33,12 +33,13 @@ DISTCLEANFILES = Recode.c clean-local: rm -f *@pyextext@ +# TESTS_ENVIRONMENT_EXTRA can be set at configure time check-local: Recode@pyextext@ - if test -n "$(VALGRIND)"; then export VALGRIND='$(VALGRIND) --suppressions=$(srcdir)/valgrind-python.supp'; fi; \ export LD_LIBRARY_PATH=$(top_builddir)/src/@objdir@; \ export DYLD_LIBRARY_PATH=$(top_builddir)/src/@objdir@; \ + export LSAN_OPTIONS=suppressions=$(srcdir)/asan-suppressions.txt; \ RECODE=$(top_builddir)/src/recode$(EXEEXT) PYTHONPATH=.:$(srcdir) \ - $$VALGRIND $(PYTHON) $(srcdir)/pytest $(LIMIT) $(srcdir)/t*.py + $(TESTS_ENVIRONMENT_EXTRA) $(PYTHON) $(srcdir)/pytest $(LIMIT) $(srcdir)/t*.py Recode@pyextext@: Recode.c setup.py rm -f *@pyextext@ diff --git a/tests/asan-suppressions.txt b/tests/asan-suppressions.txt new file mode 100644 index 0000000..fac41eb --- /dev/null +++ b/tests/asan-suppressions.txt @@ -0,0 +1 @@ +leak:/bin/bash -- 2.40.0