From patchwork Tue Mar 26 20:49:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 87679 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 C2625385841B for ; Tue, 26 Mar 2024 20:50:07 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 75D413858CD1 for ; Tue, 26 Mar 2024 20:49:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75D413858CD1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 75D413858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.83.234.184 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711486197; cv=none; b=EpLXdPXYlbk+L7eTrY41ZNVBYno2eLrnykyPN7fiPHAs51nVHzBVXclVSENIZjAQhgUqWdzCXH8NjIgPN3pTmwTZO1NKr5SvSENx4F6yTEd7hKHDUcCJX8bEgOqOgc6+JK+CkoY8l+SNDnQMrfzTNkCw3f885tMhdIO+AYvFAuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711486197; c=relaxed/simple; bh=GXxvqDJczpafcrc/G4andankXCr3WwKpBxJwxRGiZxM=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=VulTW0fCkfnH7McGgrUaGkv36osSDN0/CzE1iTA/x7Y7mm1I0eNvxVU3jRcnBiVGznHK/7+FwNZ+upU2dWn+TmHbbj/j95M3vNbwGjxQoSdP9XTHlk97oEWiS2E1loHN69VtnV26oA+TaI9hQWAFa5FwgZZ0Hq/b3MfGbRvHBM8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from csb.redhat.com (deer0x03.wildebeest.org [172.31.17.133]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id BFC55300046F; Tue, 26 Mar 2024 21:49:53 +0100 (CET) Received: by csb.redhat.com (Postfix, from userid 10916) id 9FA40CB959; Tue, 26 Mar 2024 21:49:53 +0100 (CET) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] config: Make sure profile.sh succeeds with set -e and set -o pipefail Date: Tue, 26 Mar 2024 21:49:48 +0100 Message-Id: <20240326204948.794765-1-mark@klomp.org> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org profile.sh might fail with set -o pipefail because: cat /dev/null "${prefix}/etc/debuginfod"/*.urls 2>/dev/null | tr '\n' ' ' might fail when there isn't an *.urls file the first command in the pipe fails (the 2>/dev/null is there to hide that failure). This can be fixed by adding || echo -n "" at the end. This works because echo -n "" produces the empty string which is what the script expects when the command would fail. Also add a new testcase that runs profile.sh with bout set -e and set -o pipefail. * config/profile.sh.in: Add || echo -n "" at end of pipe. * tests/run-debuginfod-client-profile.sh: New test. * tests/Makefile.am (TESTS): Add run-debuginfod-client-profile.sh. (EXTRA_DIST): Likewise. https://sourceware.org/bugzilla/show_bug.cgi?id=31562 Signed-off-by: Mark Wielaard --- config/profile.sh.in | 2 +- tests/Makefile.am | 2 ++ tests/run-debuginfod-client-profile.sh | 27 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 tests/run-debuginfod-client-profile.sh diff --git a/config/profile.sh.in b/config/profile.sh.in index 3f4397dcb44d..4488c66511a4 100644 --- a/config/profile.sh.in +++ b/config/profile.sh.in @@ -6,7 +6,7 @@ if [ -z "$DEBUGINFOD_URLS" ]; then prefix="@prefix@" - DEBUGINFOD_URLS=$(cat /dev/null "@sysconfdir@/debuginfod"/*.urls 2>/dev/null | tr '\n' ' ') + DEBUGINFOD_URLS=$(cat /dev/null "@sysconfdir@/debuginfod"/*.urls 2>/dev/null | tr '\n' ' ' || echo -n "") [ -n "$DEBUGINFOD_URLS" ] && export DEBUGINFOD_URLS || unset DEBUGINFOD_URLS unset prefix fi diff --git a/tests/Makefile.am b/tests/Makefile.am index 9315ec3bbe4c..344d6706e16e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -209,6 +209,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ run-disasm-riscv64.sh \ run-pt_gnu_prop-tests.sh \ run-getphdrnum.sh run-test-includes.sh \ + run-debuginfod-client-profile.sh \ leb128 read_unaligned \ msg_tst system-elf-libelf-test system-elf-gelf-test \ $(asm_TESTS) run-disasm-bpf.sh run-low_high_pc-dw-form-indirect.sh \ @@ -636,6 +637,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ testfile_pt_gnu_prop.bz2 testfile_pt_gnu_prop32.bz2 \ run-getphdrnum.sh testfile-phdrs.elf.bz2 \ run-test-includes.sh run-low_high_pc-dw-form-indirect.sh \ + run-debuginfod-client-profile.sh \ run-readelf-dw-form-indirect.sh testfile-dw-form-indirect.bz2 \ run-nvidia-extended-linemap-libdw.sh run-nvidia-extended-linemap-readelf.sh \ testfile_nvidia_linemap.bz2 \ diff --git a/tests/run-debuginfod-client-profile.sh b/tests/run-debuginfod-client-profile.sh new file mode 100755 index 000000000000..7435ced83f15 --- /dev/null +++ b/tests/run-debuginfod-client-profile.sh @@ -0,0 +1,27 @@ +#! /bin/sh +# Copyright (C) 2024 Mark J. Wielaard +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. $srcdir/test-subr.sh + +# Make sure the profile.sh or profile.d/debuginfod.sh works even with +# set -e (any command error is an error) and set -o pipefail (any error +# in a pipe fails the whole pipe command). + +set -e +set -o pipefail + +source ${abs_top_builddir}/config/profile.sh