aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorGravatar Adrian Hunter <adrian.hunter@intel.com> 2022-09-12 11:34:03 +0300
committerGravatar Arnaldo Carvalho de Melo <acme@redhat.com> 2022-10-04 08:55:23 -0300
commit170ac70f16e7993449ae20a5c5f23d965e3e171d (patch)
tree65d87b9f478cbdce905e66efb544d57ee0904eed /tools
parentperf test: test_intel_pt.sh: Add cleanup function (diff)
downloadlinux-170ac70f16e7993449ae20a5c5f23d965e3e171d.tar.gz
linux-170ac70f16e7993449ae20a5c5f23d965e3e171d.tar.bz2
linux-170ac70f16e7993449ae20a5c5f23d965e3e171d.zip
perf test: test_intel_pt.sh: Use a temp directory
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 <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-3-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/perf/tests/shell/test_intel_pt.sh14
1 files 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()