diff --git a/autotest.sh b/autotest.sh index cf638833d..f60f9c766 100755 --- a/autotest.sh +++ b/autotest.sh @@ -78,9 +78,12 @@ if [ $(uname -s) = Linux ]; then bdf="$(basename $(readlink -e /sys/class/nvme/${dev#/dev/}/device))" echo "INFO: blacklisting OCSSD device: $dev ($bdf)" PCI_BLACKLIST+=" $bdf" + OCSSD_PCI_DEVICES+=" $bdf" fi done + export OCSSD_PCI_DEVICES + # Now, bind blacklisted devices to pci-stub module. This will prevent # automatic grabbing these devices when we add device/vendor ID to # proper driver. diff --git a/test/ftl/ftl.sh b/test/ftl/ftl.sh index ea1f751a8..c7670fc87 100755 --- a/test/ftl/ftl.sh +++ b/test/ftl/ftl.sh @@ -7,20 +7,27 @@ rootdir=$(readlink -f $testdir/../..) source $rootdir/test/common/autotest_common.sh -function ftl_kill() { - rm -f $testdir/.testfile_* +function at_ftl_exit() { + # restore original driver + PCI_WHITELIST="$device" PCI_BLACKLIST="" DRIVER_OVERRIDE="$ocssd_original_dirver" ./scripts/setup.sh } -vendor_id='0x1d1d' -device_id='0x1f1f' -device=$(lspci -d ${vendor_id}:${device_id} | cut -d' ' -f 1) +read device _ <<< "$OCSSD_PCI_DEVICES" -if [ -z "$device" ]; then - echo "Could not find FTL device. Tests skipped." - exit 0 +if [[ -z "$device" ]]; then + echo "OCSSD device list is empty." + echo "This test require that OCSSD_PCI_DEVICES environment variable to be set" + echo "and point to OCSSD devices PCI BDF. You can specify multiple space" + echo "separated BDFs in this case first one will be used." + exit 1 fi -trap "ftl_kill; exit 1" SIGINT SIGTERM EXIT +ocssd_original_dirver="$(basename $(readlink /sys/bus/pci/devices/$device/driver))" + +trap "at_ftl_exit" SIGINT SIGTERM EXIT + +# OCSSD is blacklisted so bind it to vfio/uio driver before testing +PCI_WHITELIST="$device" PCI_BLACKLIST="" DRIVER_OVERRIDE="" ./scripts/setup.sh timing_enter ftl timing_enter fio