Skip to content

Commit

Permalink
ci: Enable AddressSanitizer in Linux clang CI test runs.
Browse files Browse the repository at this point in the history
To make sure no memory leaks or invalid accesses reported by
AddressSanitizer are missed, also skip rechecking tests if
AddressSanitizer reports are present in the test run directory.

Note: This increases the GitHub Actions CI time for the clang test run
      from ~9 minutes (before the change) to ~10 minutes (after the
      change).

Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Mark Michelson <mmichels@redhat.com>
Acked-by: Ilya Maximets <i.maximets@ovn.org>
  • Loading branch information
dceara authored and putnopvut committed Dec 16, 2020
1 parent 7d443d0 commit a429b24
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .ci/linux-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -o errexit
set -x

CFLAGS=""
OVN_CFLAGS=""
SPARSE_FLAGS=""
EXTRA_OPTS="--enable-Werror"

Expand All @@ -19,13 +20,23 @@ function configure_ovs()
function configure_ovn()
{
configure_ovs $*

export OVS_CFLAGS="${OVS_CFLAGS} ${OVN_CFLAGS}"
./boot.sh && ./configure --with-ovs-source=$PWD/ovs_src $* || \
{ cat config.log; exit 1; }
}

save_OPTS="${OPTS} $*"
OPTS="${EXTRA_OPTS} ${save_OPTS}"

# If AddressSanitizer is requested, enable it, but only for OVN, not for OVS.
# However, disable some optimizations for OVS, to make AddressSanitizer
# reports user friendly.
if [ "$ASAN" ]; then
CFLAGS="-fno-omit-frame-pointer -fno-common"
OVN_CFLAGS="-fsanitize=address"
fi

if [ "$CC" = "clang" ]; then
export OVS_CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument"
elif [ "$M32" ]; then
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
M32: ${{ matrix.m32 }}
OPTS: ${{ matrix.opts }}
TESTSUITE: ${{ matrix.testsuite }}
ASAN: ${{ matrix.asan }}

name: linux ${{ join(matrix.*, ' ') }}
runs-on: ubuntu-18.04
Expand All @@ -33,6 +34,7 @@ jobs:
testsuite: test
- compiler: clang
testsuite: test
asan: asan

- compiler: gcc
testsuite: test
Expand Down
5 changes: 4 additions & 1 deletion tests/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ check_SCRIPTS += tests/atlocal

TESTSUITE = $(srcdir)/tests/testsuite
TESTSUITE_PATCH = $(srcdir)/tests/testsuite.patch
TESTSUITE_DIR = $(abs_top_builddir)/tests/testsuite.dir
SYSTEM_KMOD_TESTSUITE = $(srcdir)/tests/system-kmod-testsuite
SYSTEM_USERSPACE_TESTSUITE = $(srcdir)/tests/system-userspace-testsuite
DISTCLEANFILES += tests/atconfig tests/atlocal
Expand All @@ -62,7 +63,9 @@ export ovs_srcdir

check-local:
set $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH); \
"$$@" $(TESTSUITEFLAGS) || (test X'$(RECHECK)' = Xyes && "$$@" --recheck)
"$$@" $(TESTSUITEFLAGS) || \
(test -z "$$(find $(TESTSUITE_DIR) -name 'asan.*')" && \
test X'$(RECHECK)' = Xyes && "$$@" --recheck)

# Python Coverage support.
# Requires coverage.py http://nedbatchelder.com/code/coverage/.
Expand Down

0 comments on commit a429b24

Please sign in to comment.