cd11d001fe86 ("Support skipping tests from test{,_device}()") breaks a
good handful of tests.
For example, block/005 uses _test_dev_is_rotational to check if the
device is rotational and uses the result to size up the fio run. As a
side-effect, _test_dev_is_rotational also sets SKIP_REASON, which (since
commit
cd11d001fe86) causes the test to print out a "[not run]" even
through the test actually ran successfully.
Fix this by renaming the existing helpers to _require_foo (e.g. a
_require_test_dev_is_rotational) and add the non-_require variant where
needed.
Fixes: cd11d001fe86 ("Support skipping tests from test{,_device}()")
Reviewed-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
[Omar: simplify new _test_dev helpers]
Signed-off-by: Omar Sandoval <osandov@fb.com>
}
_test_dev_is_zoned() {
- if [[ ! -f "${TEST_DEV_SYSFS}/queue/zoned" ]] ||
- grep -q none "${TEST_DEV_SYSFS}/queue/zoned"; then
- SKIP_REASON="${TEST_DEV} is not a zoned block device"
- return 1
- fi
- return 0
-}
-
-_test_dev_is_not_zoned() {
- if _test_dev_is_zoned; then
- SKIP_REASON="${TEST_DEV} is a zoned block device"
- return 1
- fi
- unset SKIP_REASON
- return 0
+ [[ -e "${TEST_DEV_SYSFS}/queue/zoned" &&
+ $(cat "${TEST_DEV_SYSFS}/queue/zoned") != none ]]
}
_run_test() {
local unset_skip_reason=0
if [[ ! -v SKIP_REASON ]]; then
unset_skip_reason=1
- if (( !CAN_BE_ZONED )) && ! _test_dev_is_not_zoned; then
+ if (( !CAN_BE_ZONED )) && _test_dev_is_zoned; then
SKIP_REASON="${TEST_DEV} is a zoned block device"
elif declare -fF device_requires >/dev/null; then
device_requires
return 0
}
-_test_dev_supports_io_poll() {
+_require_test_dev_supports_io_poll() {
local old_io_poll
if ! old_io_poll="$(cat "${TEST_DEV_SYSFS}/queue/io_poll" 2>/dev/null)"; then
SKIP_REASON="kernel does not support polling"
return 0
}
-_test_dev_supports_io_poll_delay() {
+_require_test_dev_supports_io_poll_delay() {
local old_io_poll_delay
if ! old_io_poll_delay="$(cat "${TEST_DEV_SYSFS}/queue/io_poll_delay" 2>/dev/null)"; then
SKIP_REASON="kernel does not support hybrid polling"
return 0
}
-_test_dev_can_discard() {
- if [[ $(cat "${TEST_DEV_SYSFS}/queue/discard_max_bytes") -eq 0 ]]; then
- SKIP_REASON="$TEST_DEV does not support discard"
+_test_dev_is_rotational() {
+ [[ $(cat "${TEST_DEV_SYSFS}/queue/rotational") -ne 0 ]]
+}
+
+_require_test_dev_is_rotational() {
+ if ! _test_dev_is_rotational; then
+ SKIP_REASON="$TEST_DEV is not rotational"
return 1
fi
return 0
}
-_test_dev_is_rotational() {
- if [[ $(cat "${TEST_DEV_SYSFS}/queue/rotational") -eq 0 ]]; then
- SKIP_REASON="$TEST_DEV is not rotational"
+_test_dev_can_discard() {
+ [[ $(cat "${TEST_DEV_SYSFS}/queue/discard_max_bytes") -gt 0 ]]
+}
+
+_require_test_dev_can_discard() {
+ if ! _test_dev_can_discard; then
+ SKIP_REASON="$TEST_DEV does not support discard"
return 1
fi
return 0
echo "$2" >"${TEST_DEV_SYSFS}/queue/$1"
}
-_test_dev_is_pci() {
+_require_test_dev_is_pci() {
if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q pci; then
# nvme needs some special casing
if readlink -f "$TEST_DEV_SYSFS/device" | grep -q nvme; then
tail -2 | head -1
}
-_test_dev_in_hotplug_slot() {
+_require_test_dev_in_hotplug_slot() {
local parent
parent="$(_get_pci_parent_from_blkdev)"
}
_test_dev_is_partition() {
- if [[ -z ${TEST_DEV_PART_SYSFS} ]]; then
+ [[ -n ${TEST_DEV_PART_SYSFS} ]]
+}
+
+_require_test_dev_is_partition() {
+ if ! _test_dev_is_partition; then
SKIP_REASON="${TEST_DEV} is not a partition device"
return 1
fi
#
# Usually, group_device_requires() just needs to check that the test device is
# the right type of hardware or supports any necessary features using the
-# _test_dev_foo helpers. If group_device_requires() sets \$SKIP_REASON, all
-# tests in this group will be skipped on that device.
+# _require_test_dev_foo helpers. If group_device_requires() sets \$SKIP_REASON,
+# all tests in this group will be skipped on that device.
# group_device_requires() {
-# _test_dev_is_foo && _test_dev_supports_bar
+# _require_test_dev_is_foo && _require_test_dev_supports_bar
# }
# TODO: define any helpers that are specific to this group.
#
# Usually, device_requires() just needs to check that the test device is the
# right type of hardware or supports any necessary features using the
-# _test_dev_foo helpers. If device_requires() sets \$SKIP_REASON, the test will
-# be skipped on that device.
+# _require_test_dev_foo helpers. If device_requires() sets \$SKIP_REASON, the
+# test will be skipped on that device.
# device_requires() {
-# _test_dev_is_foo && _test_dev_supports_bar
+# _require_test_dev_is_foo && _require_test_dev_supports_bar
# }
# TODO: define the test. The output of this function (stdout and stderr) will
}
device_requires() {
- _test_dev_can_discard
+ _require_test_dev_can_discard
}
test_device() {
}
device_requires() {
- _test_dev_supports_io_poll && _test_dev_supports_io_poll_delay
+ _require_test_dev_supports_io_poll &&
+ _require_test_dev_supports_io_poll_delay
}
run_fio_job() {
}
device_requires() {
- _test_dev_is_pci
+ _require_test_dev_is_pci
}
test_device() {
}
device_requires() {
- _test_dev_is_pci && _test_dev_in_hotplug_slot
+ _require_test_dev_is_pci && _require_test_dev_in_hotplug_slot
}
test_device() {
}
device_requires() {
- _test_dev_is_nvme
+ _require_test_dev_is_nvme
}
test_device() {
}
group_device_requires() {
- _test_dev_is_nvme
+ _require_test_dev_is_nvme
}
NVMET_CFS="/sys/kernel/config/nvmet/"
-_test_dev_is_nvme() {
+_require_test_dev_is_nvme() {
if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q nvme; then
SKIP_REASON="$TEST_DEV is not a NVMe device"
return 1
QUICK=1
device_requires() {
- _test_dev_is_scsi_disk
+ _require_test_dev_is_scsi_disk
}
test_device() {
}
group_device_requires() {
- _test_dev_is_scsi
+ _require_test_dev_is_scsi
}
_have_scsi_generic() {
_have_modules sg
}
-_test_dev_is_scsi() {
+_require_test_dev_is_scsi() {
if [[ ! -d ${TEST_DEV_SYSFS}/device/scsi_device ]]; then
SKIP_REASON="$TEST_DEV is not a SCSI device"
return 1
return 0
}
-_test_dev_is_scsi_disk() {
+_require_test_dev_is_scsi_disk() {
if [[ ! -d ${TEST_DEV_SYSFS}/device/scsi_disk ]]; then
SKIP_REASON="$TEST_DEV is not a SCSI disk"
return 1
}
device_requires() {
- _test_dev_is_logical
+ _require_test_dev_is_logical
}
# Select test target zones. Pick up the first sequential required zones. If
}
group_device_requires() {
- _test_dev_is_zoned
+ if ! _test_dev_is_zoned; then
+ SKIP_REASON="${TEST_DEV} is not a zoned block device"
+ return
+ fi
}
_fallback_null_blk_zoned() {
}
_test_dev_is_dm() {
- if [[ ! -r "${TEST_DEV_SYSFS}/dm/name" ]]; then
- SKIP_REASON="$TEST_DEV is not device-mapper"
- return 1
- fi
- return 0
+ [[ -r "${TEST_DEV_SYSFS}/dm/name" ]]
}
-_test_dev_is_logical() {
+_require_test_dev_is_logical() {
if ! _test_dev_is_partition && ! _test_dev_is_dm; then
SKIP_REASON="$TEST_DEV is not a logical device"
return 1
dm_name=$(<"${TEST_DEV_SYSFS}/dm/name")
if ! dmsetup status "${dm_name}" | grep -qe "${target_type}"; then
- SKIP_REASON="$TEST_DEV does not have ${target_type} map"
return 1
fi
if dmsetup status "${dm_name}" | grep -v "${target_type}"; then
- SKIP_REASON="$TEST_DEV has map other than ${target_type}"
return 1
fi
return 0