This is first commit from the series introducing funcrional tests for setup.sh. Issues like #1689, #1691 showed that major changes to setup.sh may result in quite unexpected behavior. thus to avoid any regression, we should make sure the core of its functionality is properly tested. For now, only Linux systems are supported tests-wise. The tests are explicitly run after all OCSSD are put into PCI_BLOCKED to make sure they won't be picked up by the tests. Change-Id: Iac036e693bdbaac476faea3d2128cf4d95434cb2 Signed-off-by: Michal Berger <michalx.berger@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5308 Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
51 lines
1.1 KiB
Bash
Executable File
51 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
testdir=$(readlink -f "$(dirname "$0")")
|
|
rootdir=$(readlink -f "$testdir/../../")
|
|
source "$testdir/common.sh"
|
|
|
|
declare -a devs=()
|
|
declare -A drivers=()
|
|
|
|
collect_setup_devs() {
|
|
local dev driver
|
|
|
|
while read -r _ dev _ _ _ driver _; do
|
|
[[ $dev == *:*:*.* ]] || continue
|
|
devs+=("$dev") drivers["$dev"]=$driver
|
|
done < <(setup output status)
|
|
((${#devs[@]} > 0))
|
|
}
|
|
|
|
verify() {
|
|
local dev driver
|
|
|
|
for dev; do
|
|
[[ -e /sys/bus/pci/devices/$dev ]]
|
|
driver=$(readlink -f "/sys/bus/pci/devices/$dev/driver")
|
|
[[ ${drivers["$dev"]} == "${driver##*/}" ]]
|
|
done
|
|
}
|
|
|
|
denied() {
|
|
# Include OCSSD devices in the PCI_BLOCKED to make sure we don't unbind
|
|
# them from the pci-stub (see autotest.sh for details).
|
|
PCI_BLOCKED="$OCSSD_PCI_DEVICES ${devs[0]}" setup output config \
|
|
| grep "Skipping denied controller at ${devs[0]}"
|
|
verify "${devs[0]}"
|
|
setup reset
|
|
}
|
|
|
|
allowed() {
|
|
PCI_ALLOWED="${devs[0]}" setup output config \
|
|
| grep "Skipping denied controller at " \
|
|
| grep -v "${devs[0]}"
|
|
verify "${devs[@]:1}"
|
|
setup reset
|
|
}
|
|
|
|
setup reset
|
|
collect_setup_devs
|
|
|
|
run_test "denied" denied
|
|
run_test "allowed" allowed
|