From patchwork Mon May 24 12:15:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= X-Patchwork-Id: 43555 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3714E3891C02; Mon, 24 May 2021 12:15:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3714E3891C02 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621858549; bh=htdAS2cAeKjTAasRQWkyx1upEHyMMVMdsRUBoXzUDNk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=QgGk4aN/jb07z0VcWXNjzR9CVUjA0KwOFZiApopLVeFwaxEVTq/Wt3XOD/1jg1IT9 wi+9axOcjlDfEsROlONkw3BwFSAohQB3nBsVL2ZyAtJkcuug19140gWS8ldrHkemmY ArUlReE7hdNTpXYCs2mGf3SRAaVjlASeu+BAaT8I= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with UTF8SMTPS id 74068386FC1D for ; Mon, 24 May 2021 12:15:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 74068386FC1D Received: by mail-wm1-x330.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso11305036wmh.4 for ; Mon, 24 May 2021 05:15:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=htdAS2cAeKjTAasRQWkyx1upEHyMMVMdsRUBoXzUDNk=; b=EJv3va7MUc3GAmNDFUza1LvYypSMdP5UuWpV1TNVG9Kz1wmhAJIBB/Y0ORFqBquA64 ypwx3IZ49cdWjvUVfjpxeMu1yW3kmn53kl83xSeg1gnBSZdzx2Cg/3pM11ynGHw87Xk4 oUtcsziujsuoeAsknQ/aqDOJYYdlDGYlAkB6E34c4Df9/9LzyZZ+96ja9vXAfACLtjL1 jZOKXOiCy2vcn9adKMfRCjNhrJ0rrD/Z8qj0pB7ga8v7BM5n94vGU7GerckcNDIChmZW HTjHe4a1uj/iRatLMFSMs0gjuK+cZG4LBGXy460ydenqj38LJ83O38bND6r0xjyNtvfQ TBSg== X-Gm-Message-State: AOAM530jlFPAV63vZwz/jJrAeKnzFcNkCxIJkIW4Glxb3tGHDOBQe7+p Cy124nlffDC7p88aW7SWRq4Np5xfgsWzLQ== X-Google-Smtp-Source: ABdhPJyKWXRyalaUWvCgJYTLu0gKVjNl3tT5ZFCpPGyFeMx3aE+GQUvYSCZ4TfoMKrY89wc7pdbIPw== X-Received: by 2002:a1c:9dc6:: with SMTP id g189mr6048219wme.59.1621858541716; Mon, 24 May 2021 05:15:41 -0700 (PDT) Received: from picard.redhat.com (ip-244-183.pel.cz. [213.226.244.183]) by smtp.gmail.com with ESMTPSA id m9sm12092480wrq.78.2021.05.24.05.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 05:15:41 -0700 (PDT) X-Google-Original-From: =?unknown-8bit?q?Alexandra_H=C3=A1jkov=C3=A1_ahajkov?= =?unknown-8bit?q?a=40redhat=2Ecom?= To: libc-alpha@sourceware.org Subject: [PATCH] Add valgrind smoke test Date: Mon, 24 May 2021 14:15:32 +0200 Message-Id: <20210524121532.1374966-1-ahajkova@redhat.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1_via_Libc-alpha?= From: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= Reply-To: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= Cc: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Alexandra Hájková Check if valgrind is present during the configure time and run smoke tests with valgrind to verify dynamic loader. --- Makefile | 4 +++ configure | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 1 + elf/Makefile | 8 +++++ 4 files changed, 106 insertions(+) diff --git a/Makefile b/Makefile index 50f99ca611..a9ae15d65e 100644 --- a/Makefile +++ b/Makefile @@ -146,6 +146,7 @@ GCONV_PATH="$${builddir}/iconvdata" usage () { echo "usage: $$0 [--tool=strace] PROGRAM [ARGUMENTS...]" 2>&1 echo " $$0 --tool=valgrind PROGRAM [ARGUMENTS...]" 2>&1 + echo " $$0 --tool=valgrind-test PROGRAM [ARGUMENTS...]" 2>&1 exit 1 } @@ -181,6 +182,9 @@ case "$$toolname" in valgrind) exec env $(run-program-env) valgrind $(test-via-rtld-prefix) $${1+"$$@"} ;; + valgrind-test) + exec env $(run-program-env) valgrind -q --error-exitcode=1 $(test-via-rtld-prefix) $${1+"$$@"} + ;; container) exec env $(run-program-env) $(test-via-rtld-prefix) \ $(common-objdir)/support/test-container \ diff --git a/configure b/configure index 5dde2ba355..769341ef05 100755 --- a/configure +++ b/configure @@ -690,6 +690,7 @@ sysheaders ac_ct_CXX CXXFLAGS CXX +VALGRIND READELF CPP cross_compiling @@ -2922,6 +2923,98 @@ else READELF="$ac_cv_prog_READELF" fi +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}valgrind", so it can be a program name with args. +set dummy ${ac_tool_prefix}valgrind; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_VALGRIND+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$VALGRIND"; then + ac_cv_prog_VALGRIND="$VALGRIND" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_VALGRIND="${ac_tool_prefix}valgrind" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +VALGRIND=$ac_cv_prog_VALGRIND +if test -n "$VALGRIND"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $VALGRIND" >&5 +$as_echo "$VALGRIND" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_VALGRIND"; then + ac_ct_VALGRIND=$VALGRIND + # Extract the first word of "valgrind", so it can be a program name with args. +set dummy valgrind; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_VALGRIND+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_VALGRIND"; then + ac_cv_prog_ac_ct_VALGRIND="$ac_ct_VALGRIND" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_VALGRIND="valgrind" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_VALGRIND=$ac_cv_prog_ac_ct_VALGRIND +if test -n "$ac_ct_VALGRIND"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_VALGRIND" >&5 +$as_echo "$ac_ct_VALGRIND" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_VALGRIND" = x; then + VALGRIND="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + VALGRIND=$ac_ct_VALGRIND + fi +else + VALGRIND="$ac_cv_prog_VALGRIND" +fi + # We need the C++ compiler only for testing. ac_ext=cpp diff --git a/configure.ac b/configure.ac index 19051b8ee0..fef797527b 100644 --- a/configure.ac +++ b/configure.ac @@ -52,6 +52,7 @@ fi AC_SUBST(cross_compiling) AC_PROG_CPP AC_CHECK_TOOL(READELF, readelf, false) +AC_CHECK_TOOL([VALGRIND], [valgrind], [false]) # We need the C++ compiler only for testing. AC_PROG_CXX diff --git a/elf/Makefile b/elf/Makefile index 834ec858a8..5b72cc76f9 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -49,6 +49,14 @@ ifeq (yesyes,$(build-shared)$(run-built-tests)) tests-special += $(objpfx)list-tunables.out endif +# Run smoke tests with valgrind to verify dynamic loader +ifneq ($(VALGRIND),false) +tests-special += $(objpfx)valgrind-smoke-test.out +$(objpfx)valgrind-smoke-test.out: $(objpfx)ld.so + $(common-objpfx)testrun.sh --tool=valgrind-test /usr/bin/true > $@ + $(common-objpfx)testrun.sh --tool=valgrind-test /usr/bin/true --help >> $@ +endif + # Make sure that the compiler does not insert any library calls in tunables # code paths. ifeq (yes,$(have-loop-to-function))