From 9aeaafa1bc080eeb1605e8fee376dbfe6d45cb31 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Tue, 7 Jul 2020 12:38:00 +0200 Subject: [PATCH] test/common: Use mktemp() to determine fallback test storage Using hardcoded path of /tmp/spdk was a bit problematic due to the way how CI mixes root permissions with non-root's during test execution. As an example, see: https://review.spdk.io/gerrit/c/spdk/spdk/+/2560 Instead of using /tmp/spdk as a fallback, always try to create tmp directory by generating its path via mktemp(). This way, as with "autobuild: Use mktemp() for spdk workspace (ae730042)", different permissions shouldn't be an issue anymore. Lingering tmp directories will be purge at each set_test_storage() run. Change-Id: I93bc60c97b68e66606e98fc83463074fc020e372 Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3238 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- test/common/autotest_common.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 2fb9e1862..0db53eb7c 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -258,8 +258,17 @@ function set_test_storage() { local source fs size avail mount use local storage_fallback storage_candidates + local storage_fallback_purge - storage_fallback=/tmp/spdk + storage_fallback_purge=("${TMPDIR:-/tmp}/spdk."??????) + + if ((${#storage_fallback_purge[@]} > 0)); then + printf '* Purging old temporary test storage (%s)\n' \ + "${storage_fallback_purge[*]}" >&2 + rm -rf "${storage_fallback_purge[@]}" + fi + + storage_fallback=$(mktemp -udt spdk.XXXXXX) storage_candidates=( "$testdir" "$storage_fallback/tests/${testdir##*/}"