From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F281FECAAA1 for ; Mon, 12 Sep 2022 08:34:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230064AbiILIee (ORCPT ); Mon, 12 Sep 2022 04:34:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbiILIec (ORCPT ); Mon, 12 Sep 2022 04:34:32 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B50DB2A; Mon, 12 Sep 2022 01:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1662971671; x=1694507671; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NJc/hTioHCdfuSYNEzedGGrqLQLSzj9kvnpmuTm90lA=; b=kOynKcwDRBJDoD6tlICTLnbAySnvizvx9Htd+3aBVTAhi2hyNdw7vWx5 2XsA0iOLlS7QVXYEzZ/l8XWTkgM2d4x3wkuRuRJVcycaNSG1sa6pUgzVG WFfg2beHv9TbWKXAiaVSjOF7S7WzKRRec0JZ0srTC7nG7/re1aTisD+7B fbcrEYqYVZHj7hCvqNpwqe45w8clAWKLOrfudejLgqGyISWtqvB4qKEfN +7fzh1H6I2m1ZJgSmjkLK1p2q++S5itZK524UWAuxcFg9cxu873abVrcR sWkSaL70FyVcgg4Ic54J1vNFoIUzQZXrimHm9ZTnTMt0X58MFzM3dtTkm Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10467"; a="299153614" X-IronPort-AV: E=Sophos;i="5.93,308,1654585200"; d="scan'208";a="299153614" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 01:34:30 -0700 X-IronPort-AV: E=Sophos;i="5.93,308,1654585200"; d="scan'208";a="611688251" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.46.215]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2022 01:34:28 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Ian Rogers , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: [PATCH 02/11] perf test: test_intel_pt.sh: Use a temp directory Date: Mon, 12 Sep 2022 11:34:03 +0300 Message-Id: <20220912083412.7058-3-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220912083412.7058-1-adrian.hunter@intel.com> References: <20220912083412.7058-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-perf-users@vger.kernel.org Create a directory for temporary files so that mktemp needs to be used only once. It also enables more temp files to be added without having to add them also to the cleanup. Signed-off-by: Adrian Hunter --- tools/perf/tests/shell/test_intel_pt.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/shell/test_intel_pt.sh index 17338e6a6f99..872ee0d89d38 100755 --- a/tools/perf/tests/shell/test_intel_pt.sh +++ b/tools/perf/tests/shell/test_intel_pt.sh @@ -11,14 +11,20 @@ skip_cnt=0 ok_cnt=0 err_cnt=0 -tmpfile=`mktemp` -perfdatafile=`mktemp` +temp_dir=$(mktemp -d /tmp/perf-test-intel-pt-sh.XXXXXXXXXX) + +tmpfile="${temp_dir}/tmp-perf.data" +perfdatafile="${temp_dir}/test-perf.data" cleanup() { trap - EXIT TERM INT - rm -f ${tmpfile} - rm -f ${perfdatafile} + sane=$(echo "${temp_dir}" | cut -b 1-26) + if [ "${sane}" = "/tmp/perf-test-intel-pt-sh" ] ; then + echo "--- Cleaning up ---" + rm -f "${temp_dir}/"* + rmdir "${temp_dir}" + fi } trap_cleanup() -- 2.25.1