test/setup: Add initital tests for setup.sh

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>
This commit is contained in:
Michal Berger 2020-11-27 09:22:54 +01:00 committed by Tomasz Zawadzki
parent cd94246487
commit ec94874c1e
4 changed files with 70 additions and 2 deletions

View File

@ -60,8 +60,6 @@ src=$(readlink -f $(dirname $0))
out=$output_dir
cd $src
./scripts/setup.sh status
freebsd_update_contigmem_mod
# lcov takes considerable time to process clang coverage.
@ -127,8 +125,11 @@ if [ $(uname -s) = Linux ]; then
# Export our blocked list so it will take effect during next setup.sh
export PCI_BLOCKED
fi
run_test "setup.sh" "$rootdir/test/setup/test-setup.sh"
fi
./scripts/setup.sh status
if [[ $(uname -s) == Linux ]]; then
# Revert NVMe namespaces to default state
nvme_namespace_revert

50
test/setup/acl.sh Executable file
View File

@ -0,0 +1,50 @@
#!/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

9
test/setup/common.sh Normal file
View File

@ -0,0 +1,9 @@
source "$rootdir/test/common/autotest_common.sh"
setup() {
if [[ $1 == output ]]; then
"$rootdir/scripts/setup.sh" "${@:2}"
else
"$rootdir/scripts/setup.sh" "$@" &> /dev/null
fi
}

8
test/setup/test-setup.sh Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
testdir=$(readlink -f "$(dirname "$0")")
rootdir=$(readlink -f "$testdir/../../")
source "$testdir/common.sh"
[[ $(uname -s) == Linux ]] || exit 0
run_test "acl" "$testdir/acl.sh"