From c8802892abad97af04db1d9bfb05b29005712ad2 Mon Sep 17 00:00:00 2001 From: Krzysztof Karas Date: Wed, 19 Jan 2022 09:31:52 +0000 Subject: [PATCH] hotplug: rename and refactor hotplug.sh Rename hotplug.sh to sw_hotplug.sh (software hotplug) and refactor its code in preparation for new software based hotplug test. Signed-off-by: Maciej Szwed Change-Id: I751fc60ee013de341e064c83f0be3a9b404008e7 Signed-off-by: Krzysztof Karas Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8834 Reviewed-by: Tomasz Zawadzki Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI --- autotest.sh | 4 ++-- test/nvme/{hotplug.sh => sw_hotplug.sh} | 28 +++++++++++++------------ 2 files changed, 17 insertions(+), 15 deletions(-) rename test/nvme/{hotplug.sh => sw_hotplug.sh} (84%) diff --git a/autotest.sh b/autotest.sh index e2851d81e..72adbce70 100755 --- a/autotest.sh +++ b/autotest.sh @@ -212,8 +212,8 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then # Only test hotplug without ASAN enabled. Since if it is # enabled, it catches SEGV earlier than our handler which # breaks the hotplug logic. - if [ $SPDK_RUN_ASAN -eq 0 ]; then - run_test "nvme_hotplug" test/nvme/hotplug.sh + if [ $SPDK_RUN_ASAN -eq 0 ] && [ $(uname -s) = Linux ]; then + run_test "sw_hotplug" test/nvme/sw_hotplug.sh fi fi diff --git a/test/nvme/hotplug.sh b/test/nvme/sw_hotplug.sh similarity index 84% rename from test/nvme/hotplug.sh rename to test/nvme/sw_hotplug.sh index 962668f52..7ac9e01c2 100755 --- a/test/nvme/hotplug.sh +++ b/test/nvme/sw_hotplug.sh @@ -2,10 +2,10 @@ testdir=$(readlink -f $(dirname $0)) rootdir=$(readlink -f $testdir/../..) +source $rootdir/scripts/common.sh source $rootdir/test/common/autotest_common.sh -[[ $(uname -s) == Linux ]] || exit 0 - +# Pci bus hotplug cleanup() { [[ -e /proc/$hotplug_pid/status ]] || return 0 kill "$hotplug_pid" @@ -41,9 +41,19 @@ remove_attach_helper() { done } -hotplug() { +run_hotplug() { + "$rootdir/scripts/setup.sh" + local hotplug_events=3 local hotplug_wait=6 # This should be enough for more stubborn nvmes in the CI + local nvmes=($(nvme_in_userspace)) + local nvme_count=${#nvmes[@]} + + xtrace_disable + cache_pci_bus_sysfs + xtrace_restore + + trap "cleanup" EXIT remove_attach_helper "$hotplug_events" "$hotplug_wait" & hotplug_pid=$! @@ -56,13 +66,5 @@ hotplug() { -l warning } -"$rootdir/scripts/setup.sh" -nvmes=($(nvme_in_userspace)) nvme_count=${#nvmes[@]} - -xtrace_disable -cache_pci_bus_sysfs -xtrace_restore - -trap "cleanup" EXIT - -hotplug +# Run pci bus hotplug test +run_hotplug