From patchwork Mon Jul 11 11:06:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Zhukov X-Patchwork-Id: 1654823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yandex.ru header.i=@yandex.ru header.a=rsa-sha256 header.s=mail header.b=EthtbN63; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LhLkS4qxyz9s07 for ; Mon, 11 Jul 2022 21:09:35 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id BFE024061C; Mon, 11 Jul 2022 11:09:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org BFE024061C Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.a=rsa-sha256 header.s=mail header.b=EthtbN63 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FGUsSf42OiCl; Mon, 11 Jul 2022 11:09:31 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 919F240169; Mon, 11 Jul 2022 11:09:30 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 919F240169 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4A39BC0035; Mon, 11 Jul 2022 11:09:30 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id B5D16C002D for ; Mon, 11 Jul 2022 11:09:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 8937D8318C for ; Mon, 11 Jul 2022 11:09:29 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 8937D8318C Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.a=rsa-sha256 header.s=mail header.b=EthtbN63 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FWZGOPmsc813 for ; Mon, 11 Jul 2022 11:09:27 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 8628183180 Received: from forward107j.mail.yandex.net (forward107j.mail.yandex.net [5.45.198.252]) by smtp1.osuosl.org (Postfix) with ESMTPS id 8628183180 for ; Mon, 11 Jul 2022 11:09:26 +0000 (UTC) Received: from sas2-bcc9105f7ecc.qloud-c.yandex.net (sas2-bcc9105f7ecc.qloud-c.yandex.net [IPv6:2a02:6b8:c08:b7ac:0:640:bcc9:105f]) by forward107j.mail.yandex.net (Yandex) with ESMTP id 06A9F884A9B; Mon, 11 Jul 2022 14:09:22 +0300 (MSK) Received: from sas2-ffeb92823cb1.qloud-c.yandex.net (sas2-ffeb92823cb1.qloud-c.yandex.net [2a02:6b8:c08:6803:0:640:ffeb:9282]) by sas2-bcc9105f7ecc.qloud-c.yandex.net (mxback/Yandex) with ESMTP id wWDBmNs7G0-9Lfew7DP; Mon, 11 Jul 2022 14:09:21 +0300 X-Yandex-Fwd: 2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1657537761; bh=WXOUxI9BoynGxws37PU4iUp4Qieb0QfQ90ET8xmgwcw=; h=Date:Subject:Cc:To:From:Message-Id; b=EthtbN63/kOVDGBKkGsJtO2+jZ4htSDiOWbanIkd/QdlH1We7JXQLZQyLL6gByIMU +skpk2d/0cA09qmnsB/km3Y2V3t8+4RhLN2ZljLCnSeYf37xUaQQ9DdCvHLcUNbntx I0dc0goKRDJcFFhhnURWDs1EHhIZKHEuhe21z/RI= Authentication-Results: sas2-bcc9105f7ecc.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by sas2-ffeb92823cb1.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id kASLoujwzQ-9Kdq8xRj; Mon, 11 Jul 2022 14:09:21 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) From: Igor Zhukov To: dev@openvswitch.org Date: Mon, 11 Jul 2022 18:06:55 +0700 Message-Id: <20220711110655.28169-1-fsb4000@yandex.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Cc: Dumitru Ceara , Igor Zhukov Subject: [ovs-dev] [PATCH ovn] Build tests with asan and ubsan together to reduce CI time. 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" From: Igor Zhukov Also fix typo in comments Also fix memory leak in utilities/ovn-dbctl.c Also add "-g" to CFLAGS to forbid autotools from adding "-g -O2" (temporary solution) Signed-off-by: Igor Zhukov Acked-by: Dumitru Ceara Submitted-at: https://github.com/ovn-org/ovn/pull/139 Acked-by: Ales Musil --- .ci/linux-build.sh | 16 +++++----------- .github/workflows/test.yml | 10 ++++------ tests/atlocal.in | 4 ++-- tests/automake.mk | 3 +-- tests/ovs-macros.at | 11 +++-------- utilities/ovn-dbctl.c | 4 ++++ 6 files changed, 19 insertions(+), 29 deletions(-) diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh index 570ddbace..8c6d751dc 100755 --- a/.ci/linux-build.sh +++ b/.ci/linux-build.sh @@ -28,20 +28,14 @@ function configure_ovn() save_OPTS="${OPTS} $*" OPTS="${EXTRA_OPTS} ${save_OPTS}" -# If AddressSanitizer or UdefinedBehaviorSanitizer is requested, enable it, +# If AddressSanitizer and UndefinedBehaviorSanitizer are requested, enable them, # but only for OVN, not for OVS. However, disable some optimizations for # OVS, to make sanitizer reports user friendly. -if [ "$ASAN" ]; then - CFLAGS="-O1 -fno-omit-frame-pointer -fno-common" - CFLAGS_ASAN="-fsanitize=address" - OVN_CFLAGS="${OVN_CFLAGS} ${CFLAGS_ASAN}" -fi - -if [ "$UBSAN" ]; then +if [ "$SANITIZERS" ]; then # Use the default options configured in tests/atlocal.in, in UBSAN_OPTIONS. - CFLAGS="-O1 -fno-omit-frame-pointer -fno-common" - CFLAGS_UBSAN="-fsanitize=undefined" - OVN_CFLAGS="${OVN_CFLAGS} ${CFLAGS_UBSAN}" + CFLAGS="-O1 -fno-omit-frame-pointer -fno-common -g" + CFLAGS_SANITIZERS="-fsanitize=address,undefined" + OVN_CFLAGS="${OVN_CFLAGS} ${CFLAGS_SANITIZERS}" fi if [ "$CC" = "clang" ]; then diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b24bc7a3b..e0de7c60e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,8 +20,8 @@ jobs: M32: ${{ matrix.m32 }} OPTS: ${{ matrix.opts }} TESTSUITE: ${{ matrix.testsuite }} - ASAN: ${{ matrix.asan }} - UBSAN: ${{ matrix.ubsan }} + SANITIZERS: ${{ matrix.sanitizers }} + CFLAGS: ${{ matrix.cflags }} name: linux ${{ join(matrix.*, ' ') }} runs-on: ubuntu-20.04 @@ -41,10 +41,8 @@ jobs: testsuite: system-test - compiler: clang testsuite: test - asan: asan - - compiler: clang - testsuite: test - ubsan: ubsan + sanitizers: sanitizers + cflags: -g - compiler: gcc testsuite: test diff --git a/tests/atlocal.in b/tests/atlocal.in index b3a011f41..0b9a31276 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -211,10 +211,10 @@ export OVS_CTL_TIMEOUT # Add some default flags to make the tests run better under Address # Sanitizer, if it was used for the build. -ASAN_OPTIONS=detect_leaks=1:abort_on_error=true:log_path=asan:$ASAN_OPTIONS +ASAN_OPTIONS=detect_leaks=1:abort_on_error=true:log_path=sanitizers:$ASAN_OPTIONS export ASAN_OPTIONS # Add some default flags for UndefinedBehaviorSanitizer, if it was used # for the build. -UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=true:log_path=ubsan:$UBSAN_OPTIONS +UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=true:log_path=sanitizers:$UBSAN_OPTIONS export UBSAN_OPTIONS diff --git a/tests/automake.mk b/tests/automake.mk index 9733e8fa0..dce9c9108 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -80,8 +80,7 @@ export ovs_srcdir check-local: set $(SHELL) '$(TESTSUITE)' -C tests AUTOTEST_PATH=$(AUTOTEST_PATH); \ "$$@" $(TESTSUITEFLAGS) || \ - (test -z "$$(find $(TESTSUITE_DIR) -name 'asan.*')" && \ - test -z "$$(find $(TESTSUITE_DIR) -name 'ubsan.*')" && \ + (test -z "$$(find $(TESTSUITE_DIR) -name 'sanitizers.*')" && \ test X'$(RECHECK)' = Xyes && "$$@" --recheck) # Python Coverage support. diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index 1bb31f315..5a06fe956 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -224,14 +224,9 @@ m4_divert_pop([PREPARE_TESTS]) OVS_START_SHELL_HELPERS ovs_cleanup() { - if test "$(echo asan.*)" != 'asan.*'; then - echo "Address Sanitizer reported errors in:" asan.* - cat asan.* - AT_FAIL_IF([:]) - fi - if test "$(echo ubsan.*)" != 'ubsan.*'; then - echo "Undefined Behavior Sanitizer reported errors in:" ubsan.* - cat ubsan.* + if test "$(echo sanitizers.*)" != 'sanitizers.*'; then + echo "Undefined Behavior Sanitizer or Address Sanitizer reported errors in:" sanitizers.* + cat sanitizers.* AT_FAIL_IF([:]) fi } diff --git a/utilities/ovn-dbctl.c b/utilities/ovn-dbctl.c index c4cc8c9b2..7ee0b92b4 100644 --- a/utilities/ovn-dbctl.c +++ b/utilities/ovn-dbctl.c @@ -237,6 +237,10 @@ cleanup: } free(commands); if (error) { + for (int i = 0; i < argc; i++) { + free(argv_[i]); + } + free(argv_); ctl_fatal("%s", error); } }