From 133fe2e617e48ca0948983329f43877064ffda3e Mon Sep 17 00:00:00 2001 From: James Clark Date: Tue, 21 Sep 2021 14:10:09 +0100 Subject: [PATCH] perf tests: Improve temp file cleanup in test_arm_coresight.sh 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. Reviewed-by: Leo Yan Signed-off-by: James Clark Acked-by: Ian Rogers Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Link: https://lore.kernel.org/r/20210921131009.390810-3-james.clark@arm.com Signed-off-by: Arnaldo Carvalho de Melo --- 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 c9eef0b..6de53b7 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 $$ + 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.7.4