summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2022-09-12 11:34:02 +0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2022-10-04 14:55:23 +0300
commit19af23df66b412106ce90f2e2258fefe6a256acd (patch)
tree4370845ac4aedef8142d0b267b18ac57c4756631
parent4627a000dced43ae9e81a9c174e75773794ce905 (diff)
downloadlinux-19af23df66b412106ce90f2e2258fefe6a256acd.tar.xz
perf test: test_intel_pt.sh: Add cleanup function
Add a cleanup function that will still clean up if the script is terminated prematurely. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20220912083412.7058-2-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-xtools/perf/tests/shell/test_intel_pt.sh18
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/perf/tests/shell/test_intel_pt.sh b/tools/perf/tests/shell/test_intel_pt.sh
index a3298643884d..17338e6a6f99 100755
--- a/tools/perf/tests/shell/test_intel_pt.sh
+++ b/tools/perf/tests/shell/test_intel_pt.sh
@@ -14,6 +14,21 @@ err_cnt=0
tmpfile=`mktemp`
perfdatafile=`mktemp`
+cleanup()
+{
+ trap - EXIT TERM INT
+ rm -f ${tmpfile}
+ rm -f ${perfdatafile}
+}
+
+trap_cleanup()
+{
+ cleanup
+ exit 1
+}
+
+trap trap_cleanup EXIT TERM INT
+
can_cpu_wide()
{
perf record -o ${tmpfile} -B -N --no-bpf-event -e dummy:u -C $1 true 2>&1 >/dev/null || return 2
@@ -57,8 +72,7 @@ test_system_wide_side_band
count_result $?
-rm -f ${tmpfile}
-rm -f ${perfdatafile}
+cleanup
if [ ${err_cnt} -gt 0 ] ; then
exit 1