From patchwork Fri Jan 22 19:04:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 1430492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DMpb25pk7z9sRR for ; Sat, 23 Jan 2021 06:04:14 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 0E043868E6; Fri, 22 Jan 2021 19:04:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iI3WuXH_1sCn; Fri, 22 Jan 2021 19:04:12 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 63D2985766; Fri, 22 Jan 2021 19:04:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4896AC088B; Fri, 22 Jan 2021 19:04:12 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 49E02C013A for ; Fri, 22 Jan 2021 19:04:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 368EE85FDB for ; Fri, 22 Jan 2021 19:04:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LO5I55ld1urJ for ; Fri, 22 Jan 2021 19:04:10 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 8052D85766 for ; Fri, 22 Jan 2021 19:04:09 +0000 (UTC) X-Originating-IP: 78.45.89.65 Received: from im-t490s.redhat.com (ip-78-45-89-65.net.upcbroadband.cz [78.45.89.65]) (Authenticated sender: i.maximets@ovn.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id D43A0240006; Fri, 22 Jan 2021 19:04:04 +0000 (UTC) From: Ilya Maximets To: ovs-dev@openvswitch.org, Ian Stokes Date: Fri, 22 Jan 2021 20:04:02 +0100 Message-Id: <20210122190402.957407-1-i.maximets@ovn.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Cc: Ilya Maximets , Dumitru Ceara Subject: [ovs-dev] [PATCH] github: Run clang test with AddressSanitizer enabled. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This commit is based on a similar one from OVN by Dumitru Ceara: a429b24f7bf5 ("ci: Enable AddressSanitizer in Linux clang CI test runs.") It's useful to run testsuite with address sanitizer enabled to catch memory leaks and invalid memory accesses. Skipping re-check if AddressSanitizer reports are present in the test run directory to not lose them. Right now OVS has no memory leaks detected on a testsuite run with -O1. With -O2 there are few false-positive leak reports in test-ovsdb application, so not using this optimization level for now. For the same reason not enabling leak detection by default for everyone. Enabled only in CI. AddressSanitizer increases execution time for this job from ~12 to ~16 minutes, but it looks like a reasonable sacrifice. Signed-off-by: Ilya Maximets Acked-by: Dumitru Ceara --- .ci/linux-build.sh | 9 +++++++++ .github/workflows/build-and-test.yml | 2 ++ tests/automake.mk | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index 3e5136fd4..581a8888b 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -226,6 +226,15 @@ elif [ "$TRAVIS_ARCH" != "aarch64" ]; then CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} ${SPARSE_FLAGS}" fi +if [ "$ASAN" ]; then + # This will override default option configured in tests/atlocal.in. + export ASAN_OPTIONS='detect_leaks=1' + # -O2 generates few false-positive memory leak reports in test-ovsdb + # application, so lowering optimizations to -O1 here. + CLFAGS_ASAN="-O1 -fno-omit-frame-pointer -fno-common -fsanitize=address" + CFLAGS_FOR_OVS="${CFLAGS_FOR_OVS} ${CLFAGS_ASAN}" +fi + save_OPTS="${OPTS} $*" OPTS="${EXTRA_OPTS} ${save_OPTS}" diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index b29c300c5..e24970505 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -14,6 +14,7 @@ jobs: deb_dependencies: | linux-headers-$(uname -r) build-essential fakeroot devscripts equivs AFXDP: ${{ matrix.afxdp }} + ASAN: ${{ matrix.asan }} CC: ${{ matrix.compiler }} DEB_PACKAGE: ${{ matrix.deb_package }} DPDK: ${{ matrix.dpdk }} @@ -44,6 +45,7 @@ jobs: - compiler: clang testsuite: test kernel: 3.16 + asan: asan - compiler: gcc testsuite: test diff --git a/tests/automake.mk b/tests/automake.mk index 677b99a6b..dfec2ea10 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -189,6 +189,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 SYSTEM_TSO_TESTSUITE = $(srcdir)/tests/system-tso-testsuite @@ -202,7 +203,9 @@ AUTOTEST_PATH = utilities:vswitchd:ovsdb:vtep:tests:$(PTHREAD_WIN32_DIR_DLL):$(S 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/.