From patchwork Tue Jul 25 19:00:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 108664 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp912734qge; Tue, 25 Jul 2017 12:01:26 -0700 (PDT) X-Received: by 10.200.11.65 with SMTP id m1mr29699026qti.229.1501009286272; Tue, 25 Jul 2017 12:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501009286; cv=none; d=google.com; s=arc-20160816; b=O3N8kZ2Cl9VteP2MrvTLFuD1yDNn/oTf5/0f8REHzePkwCF3VzExfkU1StSgWU1M5I BIxd5TUZSXNJwGcoUi/SkxCN833RIQchNYp4o1r+6sK1KkuWX6Et8ciPO2bu5zOdayux QBl2X2Aeb1YinE3lSWpHUIPrl4fcmVULeznhZJ+tC7+1N+IHNeqtJ9ix/QedJVHz2LUs J4Wu4MkuWMSwxmENMfFFXzwUp6Qs2OjzN6vMr4hrEkQm99ZcaIPH3FbCVTVSvvcaz7T4 Lu0tc444F550fXbLWVCpsi2IGyg8tnqIyBauaPkGackAW2V3kQPDE1dqCSVAjF8p/TAt +aGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=IJ8BhG0LJFH9hsy5c2hcmRXswvh4FDqqd5K15mVJ19Y=; b=MpbP9snAAgICDKJH8yRyOgKhOq3XJa9o6ahpFO3i3ooVOiimKNPUiGYZ5pnYSlKSxU 6KcEjrHP4yhE7KejZehYmOjWKgKDfH+WW06LamvGJsCu7mk3Xqt+fhblEFRYl8M9HbsH EsYetaDvWOgwCoAu6d3BeN6+4PbdsdaC5hxMrLyCckcOXmFel8I4OdrFzRYTGxYc5Ht8 SWoBD+edQMmKjbsh4yKSo51QG1DVcCXhGRik4xRSvo09Q7Z4xlxUlWWgaeflkiRBkVns nj6UMj1gUcsWblCeJM/v4TLvXenlnWpfvwyBGjobxfJT4bURZAuH9dBsbbzB6Fk2wOQS EwUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f4si11621153qta.272.2017.07.25.12.01.25; Tue, 25 Jul 2017 12:01:26 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id D679960BE3; Tue, 25 Jul 2017 19:01:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 6C8DB60521; Tue, 25 Jul 2017 19:00:33 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 63A8161C9B; Tue, 25 Jul 2017 19:00:25 +0000 (UTC) Received: from forward3h.cmail.yandex.net (forward3h.cmail.yandex.net [87.250.230.18]) by lists.linaro.org (Postfix) with ESMTPS id 97D316092B for ; Tue, 25 Jul 2017 19:00:21 +0000 (UTC) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [IPv6:2a02:6b8:0:1619::15:6]) by forward3h.cmail.yandex.net (Yandex) with ESMTP id EE10521133 for ; Tue, 25 Jul 2017 22:00:19 +0300 (MSK) Received: from smtp4j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp4j.mail.yandex.net (Yandex) with ESMTP id 81BED32410B4 for ; Tue, 25 Jul 2017 22:00:18 +0300 (MSK) Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZZmVc0vwF2-0IQ8xIBk; Tue, 25 Jul 2017 22:00:18 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 25 Jul 2017 22:00:06 +0300 Message-Id: <1501009206-21235-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501009206-21235-1-git-send-email-odpbot@yandex.ru> References: <1501009206-21235-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 87 Subject: [lng-odp] [PATCH v1 2/2] m4: update valgrind check macro X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Update valgrind check file from aclocal-archive. Current one contains several non-POSIX-compliant constructs. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 87 (lumag:fix-m4) ** https://github.com/Linaro/odp/pull/87 ** Patch: https://github.com/Linaro/odp/pull/87.patch ** Base sha: f4f7679d16917d9a7c1b2220e351fd27733ee96b ** Merge commit sha: 39b4f10ed8c764ff67ddc651f9b82f5c3e015119 **/ m4/ax_valgrind_check.m4 | 145 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 101 insertions(+), 44 deletions(-) diff --git a/m4/ax_valgrind_check.m4 b/m4/ax_valgrind_check.m4 index ccee86b2..b18babe6 100644 --- a/m4/ax_valgrind_check.m4 +++ b/m4/ax_valgrind_check.m4 @@ -4,19 +4,24 @@ # # SYNOPSIS # +# AX_VALGRIND_DFLT(memcheck|helgrind|drd|sgcheck, on|off) # AX_VALGRIND_CHECK() # # DESCRIPTION # -# Checks whether Valgrind is present and, if so, allows running `make -# check` under a variety of Valgrind tools to check for memory and -# threading errors. +# AX_VALGRIND_CHECK checks whether Valgrind is present and, if so, allows +# running `make check` under a variety of Valgrind tools to check for +# memory and threading errors. # # Defines VALGRIND_CHECK_RULES which should be substituted in your # Makefile; and $enable_valgrind which can be used in subsequent configure # output. VALGRIND_ENABLED is defined and substituted, and corresponds to # the value of the --enable-valgrind option, which defaults to being -# enabled if Valgrind is installed and disabled otherwise. +# enabled if Valgrind is installed and disabled otherwise. Individual +# Valgrind tools can be disabled via --disable-valgrind-, the +# default is configurable via the AX_VALGRIND_DFLT command or is to use +# all commands not disabled via AX_VALGRIND_DFLT. All AX_VALGRIND_DFLT +# calls must be made before the call to AX_VALGRIND_CHECK. # # If unit tests are written using a shell script and automake's # LOG_COMPILER system, the $(VALGRIND) variable can be used within the @@ -28,6 +33,7 @@ # # configure.ac: # +# AX_VALGRIND_DFLT([sgcheck], [off]) # AX_VALGRIND_CHECK # # Makefile.am: @@ -40,22 +46,38 @@ # which includes "@VALGRIND_CHECK_RULES@" (assuming the module has been # configured with --enable-valgrind). Running `make check-valgrind` in # that directory will run the module's test suite (`make check`) once for -# each of the available Valgrind tools (out of memcheck, helgrind, drd and -# sgcheck), and will output results to test-suite-$toolname.log for each. -# The target will succeed if there are zero errors and fail otherwise. +# each of the available Valgrind tools (out of memcheck, helgrind and drd) +# while the sgcheck will be skipped unless enabled again on the +# commandline with --enable-valgrind-sgcheck. The results for each check +# will be output to test-suite-$toolname.log. The target will succeed if +# there are zero errors and fail otherwise. +# +# Alternatively, a "check-valgrind-$TOOL" rule will be added, for $TOOL in +# memcheck, helgrind, drd and sgcheck. These are useful because often only +# some of those tools can be ran cleanly on a codebase. # # The macro supports running with and without libtool. # # LICENSE # -# Copyright (c) 2014, 2015 Philip Withnall +# Copyright (c) 2014, 2015, 2016 Philip Withnall # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 3 +#serial 13 + +dnl Configured tools +m4_define([valgrind_tool_list], [[memcheck], [helgrind], [drd], [sgcheck]]) +m4_set_add_all([valgrind_exp_tool_set], [sgcheck]) +m4_foreach([vgtool], [valgrind_tool_list], + [m4_define([en_dflt_valgrind_]vgtool, [on])]) + +AC_DEFUN([AX_VALGRIND_DFLT],[ + m4_define([en_dflt_valgrind_$1], [$2]) +])dnl AC_DEFUN([AX_VALGRIND_CHECK],[ dnl Check for --enable-valgrind @@ -63,36 +85,65 @@ AC_DEFUN([AX_VALGRIND_CHECK],[ [AS_HELP_STRING([--enable-valgrind], [Whether to enable Valgrind on the unit tests])], [enable_valgrind=$enableval],[enable_valgrind=]) - # Check for Valgrind. - AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind]) - - AS_IF([test "$enable_valgrind" = "yes" -a "$VALGRIND" = ""],[ - AC_MSG_ERROR([Could not find valgrind; either install it or reconfigure with --disable-valgrind]) + AS_IF([test "$enable_valgrind" != "no"],[ + # Check for Valgrind. + AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind]) + AS_IF([test "$VALGRIND" = ""],[ + AS_IF([test "$enable_valgrind" = "yes"],[ + AC_MSG_ERROR([Could not find valgrind; either install it or reconfigure with --disable-valgrind]) + ],[ + enable_valgrind=no + ]) + ],[ + enable_valgrind=yes + ]) ]) - AS_IF([test "$enable_valgrind" != "no"],[enable_valgrind=yes]) AM_CONDITIONAL([VALGRIND_ENABLED],[test "$enable_valgrind" = "yes"]) AC_SUBST([VALGRIND_ENABLED],[$enable_valgrind]) # Check for Valgrind tools we care about. - m4_define([valgrind_tool_list],[[memcheck], [helgrind], [drd], [exp-sgcheck]]) - - AS_IF([test "$VALGRIND" != ""],[ - m4_foreach([vgtool],[valgrind_tool_list],[ - m4_define([vgtooln],AS_TR_SH(vgtool)) - m4_define([ax_cv_var],[ax_cv_valgrind_tool_]vgtooln) - AC_CACHE_CHECK([for Valgrind tool ]vgtool,ax_cv_var,[ - ax_cv_var= - AS_IF([`$VALGRIND --tool=vgtool --help 2&>/dev/null`],[ - ax_cv_var="vgtool" + [valgrind_enabled_tools=] + m4_foreach([vgtool],[valgrind_tool_list],[ + AC_ARG_ENABLE([valgrind-]vgtool, + m4_if(m4_defn([en_dflt_valgrind_]vgtool),[off],dnl +[AS_HELP_STRING([--enable-valgrind-]vgtool, [Whether to use ]vgtool[ during the Valgrind tests])],dnl +[AS_HELP_STRING([--disable-valgrind-]vgtool, [Whether to skip ]vgtool[ during the Valgrind tests])]), + [enable_valgrind_]vgtool[=$enableval], + [enable_valgrind_]vgtool[=]) + AS_IF([test "$enable_valgrind" = "no"],[ + enable_valgrind_]vgtool[=no], + [test "$enable_valgrind_]vgtool[" ]dnl +m4_if(m4_defn([en_dflt_valgrind_]vgtool), [off], [= "yes"], [!= "no"]),[ + AC_CACHE_CHECK([for Valgrind tool ]vgtool, + [ax_cv_valgrind_tool_]vgtool,[ + ax_cv_valgrind_tool_]vgtool[=no + m4_set_contains([valgrind_exp_tool_set],vgtool, + [m4_define([vgtoolx],[exp-]vgtool)], + [m4_define([vgtoolx],vgtool)]) + AS_IF([`$VALGRIND --tool=]vgtoolx[ --help >/dev/null 2>&1`],[ + ax_cv_valgrind_tool_]vgtool[=yes ]) ]) - - AC_SUBST([VALGRIND_HAVE_TOOL_]vgtooln,[$ax_cv_var]) + AS_IF([test "$ax_cv_valgrind_tool_]vgtool[" = "no"],[ + AS_IF([test "$enable_valgrind_]vgtool[" = "yes"],[ + AC_MSG_ERROR([Valgrind does not support ]vgtool[; reconfigure with --disable-valgrind-]vgtool) + ],[ + enable_valgrind_]vgtool[=no + ]) + ],[ + enable_valgrind_]vgtool[=yes + ]) ]) + AS_IF([test "$enable_valgrind_]vgtool[" = "yes"],[ + valgrind_enabled_tools="$valgrind_enabled_tools ]m4_bpatsubst(vgtool,[^exp-])[" + ]) + AC_SUBST([ENABLE_VALGRIND_]vgtool,[$enable_valgrind_]vgtool) ]) + AC_SUBST([valgrind_tools],["]m4_join([ ], valgrind_tool_list)["]) + AC_SUBST([valgrind_enabled_tools],[$valgrind_enabled_tools]) -VALGRIND_CHECK_RULES=' +[VALGRIND_CHECK_RULES=' # Valgrind check # # Optional: @@ -112,7 +163,6 @@ VALGRIND_drd_FLAGS ?= VALGRIND_sgcheck_FLAGS ?= # Internal use -valgrind_tools ?= memcheck helgrind drd sgcheck valgrind_log_files = $(addprefix test-suite-,$(addsuffix .log,$(valgrind_tools))) valgrind_memcheck_flags = --tool=memcheck $(VALGRIND_memcheck_FLAGS) @@ -123,6 +173,9 @@ valgrind_sgcheck_flags = --tool=exp-sgcheck $(VALGRIND_sgcheck_FLAGS) valgrind_quiet = $(valgrind_quiet_$(V)) valgrind_quiet_ = $(valgrind_quiet_$(AM_DEFAULT_VERBOSITY)) valgrind_quiet_0 = --quiet +valgrind_v_use = $(valgrind_v_use_$(V)) +valgrind_v_use_ = $(valgrind_v_use_$(AM_DEFAULT_VERBOSITY)) +valgrind_v_use_0 = @echo " USE " $(patsubst check-valgrind-%,%,$''@):; # Support running with and without libtool. ifneq ($(LIBTOOL),) @@ -134,10 +187,8 @@ endif # Use recursive makes in order to ignore errors during check check-valgrind: ifeq ($(VALGRIND_ENABLED),yes) - -$(foreach tool,$(valgrind_tools), \ - $(if $(VALGRIND_HAVE_TOOL_$(tool))$(VALGRIND_HAVE_TOOL_exp_$(tool)), \ - $(MAKE) $(AM_MAKEFLAGS) -k check-valgrind-tool VALGRIND_TOOL=$(tool); \ - ) \ + -$(A''M_V_at)$(foreach tool,$(valgrind_enabled_tools), \ + $(MAKE) $(AM_MAKEFLAGS) -k check-valgrind-$(tool); \ ) else @echo "Need to reconfigure with --enable-valgrind" @@ -154,25 +205,31 @@ VALGRIND_LOG_COMPILER = \ $(valgrind_lt) \ $(VALGRIND) $(VALGRIND_SUPPRESSIONS) --error-exitcode=1 $(VALGRIND_FLAGS) -check-valgrind-tool: -ifeq ($(VALGRIND_ENABLED),yes) - $(MAKE) check-TESTS \ - TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ - LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ - LOG_FLAGS="$(valgrind_$(VALGRIND_TOOL)_flags)" \ - TEST_SUITE_LOG=test-suite-$(VALGRIND_TOOL).log +define valgrind_tool_rule = +check-valgrind-$(1): +ifeq ($$(VALGRIND_ENABLED)-$$(ENABLE_VALGRIND_$(1)),yes-yes) + $$(valgrind_v_use)$$(MAKE) check-TESTS \ + TESTS_ENVIRONMENT="$$(VALGRIND_TESTS_ENVIRONMENT)" \ + LOG_COMPILER="$$(VALGRIND_LOG_COMPILER)" \ + LOG_FLAGS="$$(valgrind_$(1)_flags)" \ + TEST_SUITE_LOG=test-suite-$(1).log +else ifeq ($$(VALGRIND_ENABLED),yes) + @echo "Need to reconfigure with --enable-valgrind-$(1)" else @echo "Need to reconfigure with --enable-valgrind" endif +endef + +$(foreach tool,$(valgrind_tools),$(eval $(call valgrind_tool_rule,$(tool)))) -DISTCHECK_CONFIGURE_FLAGS ?= -DISTCHECK_CONFIGURE_FLAGS += --disable-valgrind +A''M_DISTCHECK_CONFIGURE_FLAGS ?= +A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-valgrind MOSTLYCLEANFILES ?= MOSTLYCLEANFILES += $(valgrind_log_files) -.PHONY: check-valgrind check-valgrind-tool -' +.PHONY: check-valgrind $(add-prefix check-valgrind-,$(valgrind_tools)) +'] AC_SUBST([VALGRIND_CHECK_RULES]) m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([VALGRIND_CHECK_RULES])])