Commit 9aeaafa1 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

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: default avatarMichal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3238


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 2ba684aa
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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##*/}"