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 <maciej.szwed@intel.com>
Change-Id: I751fc60ee013de341e064c83f0be3a9b404008e7
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8834
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
This commit is contained in:
Krzysztof Karas 2022-01-19 09:31:52 +00:00 committed by Tomasz Zawadzki
parent d66bb2d185
commit c8802892ab
2 changed files with 17 additions and 15 deletions

View File

@ -212,8 +212,8 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then
# Only test hotplug without ASAN enabled. Since if it is # Only test hotplug without ASAN enabled. Since if it is
# enabled, it catches SEGV earlier than our handler which # enabled, it catches SEGV earlier than our handler which
# breaks the hotplug logic. # breaks the hotplug logic.
if [ $SPDK_RUN_ASAN -eq 0 ]; then if [ $SPDK_RUN_ASAN -eq 0 ] && [ $(uname -s) = Linux ]; then
run_test "nvme_hotplug" test/nvme/hotplug.sh run_test "sw_hotplug" test/nvme/sw_hotplug.sh
fi fi
fi fi

View File

@ -2,10 +2,10 @@
testdir=$(readlink -f $(dirname $0)) testdir=$(readlink -f $(dirname $0))
rootdir=$(readlink -f $testdir/../..) rootdir=$(readlink -f $testdir/../..)
source $rootdir/scripts/common.sh
source $rootdir/test/common/autotest_common.sh source $rootdir/test/common/autotest_common.sh
[[ $(uname -s) == Linux ]] || exit 0 # Pci bus hotplug
cleanup() { cleanup() {
[[ -e /proc/$hotplug_pid/status ]] || return 0 [[ -e /proc/$hotplug_pid/status ]] || return 0
kill "$hotplug_pid" kill "$hotplug_pid"
@ -41,9 +41,19 @@ remove_attach_helper() {
done done
} }
hotplug() { run_hotplug() {
"$rootdir/scripts/setup.sh"
local hotplug_events=3 local hotplug_events=3
local hotplug_wait=6 # This should be enough for more stubborn nvmes in the CI 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" & remove_attach_helper "$hotplug_events" "$hotplug_wait" &
hotplug_pid=$! hotplug_pid=$!
@ -56,13 +66,5 @@ hotplug() {
-l warning -l warning
} }
"$rootdir/scripts/setup.sh" # Run pci bus hotplug test
nvmes=($(nvme_in_userspace)) nvme_count=${#nvmes[@]} run_hotplug
xtrace_disable
cache_pci_bus_sysfs
xtrace_restore
trap "cleanup" EXIT
hotplug