From ae7300425b7c4d64e85c54a61a6532fe1397781d Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Wed, 15 Apr 2020 11:44:07 +0200 Subject: [PATCH] autobuild: Use mktemp() for spdk workspace With issues similar to https://github.com/spdk/spdk/issues/1293 it would be better to use temporary directories for spdk workspace instead of depending on the hardcoded path (/tmp/spdk). This will mitigate potential scenario where permissions of the target dir are suddenly changed in-between autobuild runs. Change-Id: If44a2dcce712a185287186f33e7361223dc6d451 Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1863 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- autobuild.sh | 20 ++++++++++---------- scripts/perf/nvmf/run_nvmf.py | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/autobuild.sh b/autobuild.sh index 8b69b6803..e2a50cdbb 100755 --- a/autobuild.sh +++ b/autobuild.sh @@ -17,8 +17,11 @@ out=$output_dir scanbuild="scan-build -o $output_dir/scan-build-tmp --status-bugs" config_params=$(get_config_params) -rm -rf /tmp/spdk -mkdir /tmp/spdk +trap '[[ -d $SPDK_WORKSPACE ]] && rm -rf "$SPDK_WORKSPACE"' 0 + +SPDK_WORKSPACE=$(mktemp -dt "spdk_$(date +%s).XXXXXX") +export SPDK_WORKSPACE + umask 022 cd $rootdir @@ -115,15 +118,12 @@ function header_dependency_check { function test_make_uninstall { # Create empty file to check if it is not deleted by target uninstall - touch /tmp/spdk/usr/lib/sample_xyz.a - $MAKE $MAKEFLAGS uninstall DESTDIR=/tmp/spdk prefix=/usr - if [[ $(find /tmp/spdk/usr -maxdepth 1 -mindepth 1 | wc -l) -ne 2 ]] || [[ $(find /tmp/spdk/usr/lib/ -maxdepth 1 -mindepth 1 | wc -l) -ne 1 ]]; then - ls -lR /tmp/spdk - rm -rf /tmp/spdk + touch "$SPDK_WORKSPACE/usr/lib/sample_xyz.a" + $MAKE $MAKEFLAGS uninstall DESTDIR="$SPDK_WORKSPACE" prefix=/usr + if [[ $(find "$SPDK_WORKSPACE/usr" -maxdepth 1 -mindepth 1 | wc -l) -ne 2 ]] || [[ $(find "$SPDK_WORKSPACE/usr/lib/" -maxdepth 1 -mindepth 1 | wc -l) -ne 1 ]]; then + ls -lR "$SPDK_WORKSPACE" echo "Make uninstall failed" exit 1 - else - rm -rf /tmp/spdk fi } @@ -159,7 +159,7 @@ function autobuild_test_suite { run_test "scanbuild_make" scanbuild_make run_test "autobuild_generated_files_check" porcelain_check run_test "autobuild_header_dependency_check" header_dependency_check - run_test "autobuild_make_install" $MAKE $MAKEFLAGS install DESTDIR=/tmp/spdk prefix=/usr + run_test "autobuild_make_install" $MAKE $MAKEFLAGS install DESTDIR="$SPDK_WORKSPACE" prefix=/usr run_test "autobuild_make_uninstall" test_make_uninstall run_test "autobuild_build_doc" build_doc } diff --git a/scripts/perf/nvmf/run_nvmf.py b/scripts/perf/nvmf/run_nvmf.py index 1cc567288..d5d714b12 100755 --- a/scripts/perf/nvmf/run_nvmf.py +++ b/scripts/perf/nvmf/run_nvmf.py @@ -226,6 +226,8 @@ class Initiator(Server): self.ip = ip self.spdk_dir = workspace + if os.getenv('SPDK_WORKSPACE'): + self.spdk_dir = os.getenv('SPDK_WORKSPACE') self.fio_bin = fio_bin self.cpus_allowed = cpus_allowed self.cpus_allowed_policy = cpus_allowed_policy