Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp359885pxb; Wed, 22 Sep 2021 04:01:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwP6f7UZY52rvF6V8812jTtbAnpMAuYl4/CFbSiL3StXzTG2/OrHfPD9uHwN/AKN+2nyem X-Received: by 2002:a5d:9ad2:: with SMTP id x18mr3896051ion.182.1632308486297; Wed, 22 Sep 2021 04:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632308486; cv=none; d=google.com; s=arc-20160816; b=YN4usorWUoE+T5JUwJlXFzd7JHIOySM9hsj5IqOfYKxVCcjeukhMwIU1Jw0FiLm/mX 5B3e27mNeMjgExCC5cqCWVjakD1t1aKzMHvA8RAN05MJfeY1RxRtC99XLwNerDomIYN1 SmuHfVcBuMweQ4Oi1W0m9q4qOKn7TvakUxm90o/tiV8ljNYxpGwhcodpSy2Lc5CvGigF lFUCMNikIRtna4mkl35IXSjPwe5kG9xnn5LvBurzxuGB4mt3HRBQPOpAEzo+IN6hH381 zeIt+OdaLigEYxy/xUzo916mgUotSR1lijvhqGXYAJsuURfyVwCUKwzof5E0BkXDPjXq w3vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Hwl3MVKuLK+CwZQofEVoUFGs27PPnfkfJHGmENBFAts=; b=pVthYcP5StjnZxUny5c1VaVRyTxXNt9IrTGlhjgvXPX/kq5g9gzHp4SMgLK59ljFCa trgGcSLLWyqCAikTe4pWzvjEu0klpFD4CKXBmvHOraa6Xw7kkBwo2bnKBDWaaDLjZH8v vUuAZzTsIlSheJFC9bl/3BI3avr3voCKbnlq3jPGNU7hKuwuw1MAYPgxxt4ZN9YNlSR4 5wqCwGXXlRj91Ad3sVLdQZZ0BHt0xmDDCklzcMYJjr1uAV6LMqa244AY+GVP/UXDdV3V JrZXf2L3YRbW0tbfcm1dOnRtKmN96d+8P/b25NZwlQLsSZRLUKM2ZXWwBEiti+kWTw2i +VDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hjLHBpmu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r1si2129424ilg.125.2021.09.22.04.01.10; Wed, 22 Sep 2021 04:01:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hjLHBpmu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235047AbhIVLBr (ORCPT + 99 others); Wed, 22 Sep 2021 07:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235153AbhIVLBr (ORCPT ); Wed, 22 Sep 2021 07:01:47 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81AD7C061756 for ; Wed, 22 Sep 2021 04:00:17 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id w6so1512930pll.3 for ; Wed, 22 Sep 2021 04:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Hwl3MVKuLK+CwZQofEVoUFGs27PPnfkfJHGmENBFAts=; b=hjLHBpmuAPymArjlyDDR/L6wa5rSjTRJswtwPE1xPI6UPAl8bAIeYySoyLmCJXlrGq 6DyG9PKxc/HH/KRFqwnbLjTXdXSo/u23wFNK1l425tkZjDBipaGE2f5TYRfs6HUdo4In xg9TjAHhTybSVQyE4zwUBgLHJAsivfkWQCqNQbrITK7u5Gk4lSC0Bk4LY5X29gZMRFFQ SsiJL0skX75tSXdvquluepwkNt0kl7Eqh7e/k0ljYsx2zoS8BNckVNi20dkqosN5QqYj 0g/xgmXAPus3mkTbzuIgxCuK0Xzwb6u4L+wWAiwuTZ/nV8hqcNwc5V+5XtUF0p958QiK 90TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Hwl3MVKuLK+CwZQofEVoUFGs27PPnfkfJHGmENBFAts=; b=mhdUgLRD6hwQH1h6Q6djCYe29UW/T+Im7Xgjq0zfKK412bzZQRo56xJCOJIWBfnGJK PWZvRfFY+e7Uca0exmdBhHa/PWo4TfkuFZkp2ns9cZviJ5lbcgiP2PIxnDMactIbs33n osmlzHygjJxn9weurTuNuo8Hv/tfmv/UPfCpbN2eVeNLFHiPXtbE1yXTpIQFaPLrsSUO VYjbM/l/xAEjiLr7IebdjY9zh5IKeDD87II6hLXp/LmOKH0WKv5xeVbn5Tbf+/VN6ISc 22vDIURPLVZQw6PDnMLrG7HPa7fNcqSRDX4oFF0Tfbfer/cz0O0h1uaUOfoWW8690Z14 Jq0g== X-Gm-Message-State: AOAM533/Li3ovI9Jt1ocuOAazWJg3YUAQFBgtAcLVXwvNbRIngBs8iXQ caHOsPnMw0CRwX4Yw6JyycpZcg== X-Received: by 2002:a17:90b:1a90:: with SMTP id ng16mr10659892pjb.130.1632308416907; Wed, 22 Sep 2021 04:00:16 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([213.173.35.225]) by smtp.gmail.com with ESMTPSA id u12sm3518046pjr.2.2021.09.22.04.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 04:00:16 -0700 (PDT) Date: Wed, 22 Sep 2021 19:00:12 +0800 From: Leo Yan To: James Clark Cc: acme@kernel.org, leo.yan@linaro.com, linux-perf-users@vger.kernel.org, Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] perf tests: Improve temp file cleanup in test_arm_coresight.sh Message-ID: <20210922110012.GA400258@leoy-ThinkPad-X240s> References: <20210921131009.390810-1-james.clark@arm.com> <20210921131009.390810-3-james.clark@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210921131009.390810-3-james.clark@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 21, 2021 at 02:10:09PM +0100, James Clark wrote: > Cleanup perf.data.old files which are also dropped by perf, handle > sigint and propagate it to the parent in case the test is run in a bash > while loop and don't create the temp files if the test will be skipped. > > Signed-off-by: James Clark > --- > tools/perf/tests/shell/test_arm_coresight.sh | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/tools/perf/tests/shell/test_arm_coresight.sh b/tools/perf/tests/shell/test_arm_coresight.sh > index c9eef0bba6f1..6de53b7ef5ff 100755 > --- a/tools/perf/tests/shell/test_arm_coresight.sh > +++ b/tools/perf/tests/shell/test_arm_coresight.sh > @@ -9,8 +9,6 @@ > # SPDX-License-Identifier: GPL-2.0 > # Leo Yan , 2020 > > -perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) > -file=$(mktemp /tmp/temporary_file.XXXXX) > glb_err=0 > > skip_if_no_cs_etm_event() { > @@ -22,13 +20,20 @@ skip_if_no_cs_etm_event() { > > skip_if_no_cs_etm_event || exit 2 > > +perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) > +file=$(mktemp /tmp/temporary_file.XXXXX) > + > cleanup_files() > { > rm -f ${perfdata} > rm -f ${file} > + rm -f "${perfdata}.old" > + trap - exit term int > + kill -2 $$ Here it always sends signal SIGINT to current PID with $$, another choice is to send signal based on the incoming signal type, like below: [[ "$1" = "int" ]] || kill -SIGINT $$ [[ "$1" = "term" ]] || kill -SIGTERM $$ If you think the current change is sufficient to meet the testing requirement, then this patch would be fine for me either: Reviewed-by: Leo Yan > + exit $glb_err > } > > -trap cleanup_files exit > +trap cleanup_files exit term int > > record_touch_file() { > echo "Recording trace (only user mode) with path: CPU$2 => $1" > -- > 2.28.0 >