# Running Tests
-The `./check` script executes tests. Without any arguments, it executes the
-default set of tests. `./check` exits with a zero exit status if all tests
-passed and non-zero otherwise.
+The `./check` script executes tests. `./check` exits with a zero exit status if
+all tests passed and non-zero otherwise.
## Test Organization
-Tests are split up into various categories, which are the subdirectories of the
+Tests are split up into various groups, which are the subdirectories of the
`tests` directory. For example, `tests/loop` contains tests for loop devices,
and `tests/block` contains generic block layer tests.
-Tests also belong to one or more groups. Each test category is also a group.
-Additionally, there is a group for common functionality like "discard".
-Finally, there are a couple of basic groups:
+`./check` can execute individual tests or test groups. For example,
-- The `auto` group is the default set of tests. These tests are expected to
- pass reliably.
-- The `quick` group is a subset of `auto` comprising tests that complete
- "quickly" (i.e., in ~30 seconds or less on reasonable hardware).
-- The `timed` group comprises tests that honor the configured test timeout (see
- below)
+```sh
+./check loop block/002
+```
-`./check` can execute individual tests or test groups, as well as exclude tests
-or test groups. See `./check -h`.
+will run all tests in the `loop` group and the `block/002` test.
## Configuration
TIMEOUT=30
```
-Note that only tests in the `timed` group honor the timeout.
+Note that not all tests honor this timeout.
. common/rc
+_found_test() {
+ local test_name="$1"
+
+ unset DESCRIPTION requires device_requires test test_device
+
+ if ! . "tests/${test_name}"; then
+ return 1
+ fi
+
+ if [[ -z $DESCRIPTION ]]; then
+ _warning "${test_name} does not define DESCRIPTION"
+ return 1
+ fi
+
+ if declare -fF test >/dev/null && declare -fF test_device >/dev/null; then
+ _warning "${test_name} defines both test() and test_device()"
+ return 1
+ fi
+
+ if ! declare -fF test >/dev/null && ! declare -fF test_device >/dev/null; then
+ _warning "${test_name} does not define test() or test_device()"
+ return 1
+ fi
+
+ if declare -fF device_requires >/dev/null && ! declare -fF test_device >/dev/null; then
+ _warning "${test_name} defines device_requires() but not test_device()"
+ return 1
+ fi
+
+ printf '%s\0' "$test_name"
+}
+
+_found_group() {
+ local group="$1"
+
+ local test_path
+ while IFS= read -r -d '' test_path; do
+ _found_test "${test_path#tests/}"
+ done < <(find "tests/$group" -type f -name '[0-9][0-9][0-9]' -print0)
+}
+
+_find_tests() {
+ if [[ $# -eq 0 ]]; then
+ # No filters given, run all tests except for the meta group.
+ local group_path
+ while IFS= read -r -d '' group_path; do
+ if [[ $group_path != tests/meta ]]; then
+ _found_group "${group_path#tests/}"
+ fi
+ done < <(find tests -mindepth 2 -type f -name group -printf '%h\0')
+ else
+ local filter
+ for filter in "$@"; do
+ # A filter is bad if it:
+ # - Is an absolute path
+ # - Is a relative path containing ".."
+ if [[ $filter =~ ^/|(^|/)\.\.(/|$) ]]; then
+ _warning "bad filter ${filter}"
+ continue
+ fi
+ # Remove leading and internal "." components.
+ filter="${filter##+(./)}"
+ filter="${filter//\/+(.\/)/\/}"
+ # Remove leading "tests/"
+ filter="${filter#tests/}"
+
+ if [[ -d tests/$filter ]]; then
+ _found_group "$filter"
+ elif [[ -f tests/$filter ]]; then
+ _found_test "$filter"
+ else
+ _warning "no group or test named ${filter}"
+ fi
+ done
+ fi
+}
+
_check_dmesg() {
local dmesg_marker="$1"
local seqres="${RESULTS_DIR}/${TEST_NAME}"
local test="$1"
local status="$2"
- printf '%-60s' "$test ($DESCRIPTION)"
+ if [[ -v DESCRIPTION ]]; then
+ printf '%-60s' "$test ($DESCRIPTION)"
+ else
+ printf '%-60s' "$test"
+ fi
if [[ -z $status ]]; then
echo
return
echo "]"
}
+_output_notrun() {
+ _output_status "$1" "not run"
+ echo " $SKIP_REASON"
+}
+
_output_last_test_run() {
if [[ -v TEST_DEV ]]; then
_output_status "$TEST_NAME => $(basename "$TEST_DEV")" ""
fi
trap _cleanup EXIT
- TMPDIR="$(mktemp --tmpdir -d "blktests.${category}.${seq}.XXX")"
+ TMPDIR="$(mktemp --tmpdir -d "blktests.${TEST_NAME//\//.}.XXX")"
if [[ $? -ne 0 ]]; then
return
fi
fi
}
-_should_run_test() {
- local test
- local group
- local include_group
- local exclude_group
-
- if [[ -n ${TESTS[$TEST_NAME]} ]]; then
- return 0
- fi
-
- local ret=1
- for group in "${TEST_GROUPS[@]}"; do
- if [[ -n ${INCLUDE_GROUPS[$group]} ]]; then
- ret=0
- fi
- if [[ -n ${EXCLUDE_GROUPS[$group]} ]]; then
- return 1
- fi
- done
-
- return $ret
-}
-
-_output_notrun() {
- _output_status "$1" "not run"
- echo " $SKIP_REASON"
-}
-
_run_test() {
TEST_NAME="$1"
CHECK_DMESG=1
DMESG_FILTER=cat
- if ! . "tests/${TEST_NAME}"; then
- return
- fi
-
- if [[ ! -v TEST_GROUPS ]]; then
- _warning "${TEST_NAME} does not define TEST_GROUPS"
- return
- fi
-
- if [[ -z $DESCRIPTION ]]; then
- _warning "${TEST_NAME} does not define DESCRIPTION"
- return
- fi
-
- if declare -fF test >/dev/null && declare -fF test_device >/dev/null; then
- _warning "${TEST_NAME} defines both test() and test_device()"
- return
- fi
-
- if ! declare -fF test >/dev/null && ! declare -fF test_device >/dev/null; then
- _warning "${TEST_NAME} does not define test() or test_device()"
- return
- fi
-
- if ! _should_run_test; then
- return
- fi
+ . "tests/${TEST_NAME}"
if declare -fF test >/dev/null; then
- if declare -fF prepare >/dev/null && ! prepare; then
+ if declare -fF requires >/dev/null && ! requires; then
_output_notrun "$TEST_NAME"
- return
+ return 0
fi
RESULTS_DIR="results/nodev"
_call_test test
else
- if declare -fF prepare >/dev/null && ! prepare; then
- _output_notrun "$TEST_NAME => *"
- return
+ if [[ ${#TEST_DEVS[@]} -eq 0 ]]; then
+ return 0
+ fi
+
+ if declare -fF requires >/dev/null && ! requires; then
+ _output_notrun "$TEST_NAME"
+ return 0
fi
local ret=0
- for TEST_DEV in "${CATEGORY_TEST_DEVS[@]}"; do
+ for TEST_DEV in "${TEST_DEVS[@]}"; do
TEST_DEV_SYSFS="${TEST_DEV_SYSFS_DIRS["$TEST_DEV"]}"
- local test_dev="$(basename "$TEST_DEV")"
- if declare -fF prepare_device >/dev/null && ! prepare_device; then
- _output_notrun "$TEST_NAME => $test_dev"
- continue
+ if declare -fF device_requires >/dev/null && ! device_requires; then
+ _output_notrun "$TEST_NAME => $(basename "$TEST_DEV")"
+ return 0
fi
- RESULTS_DIR="results/${test_dev}"
+ RESULTS_DIR="results/$(basename "$TEST_DEV")"
if ! _call_test test_device; then
ret=1
fi
fi
}
-_run_category() {
- local category="$1"
+_run_group() {
+ local tests=("$@")
- # Most of this script is written defensively against whitespace in the
- # test name, but we can't handle it in the test logs.
- if [[ $category =~ [[:space:]] ]]; then
- _error "category name \"${category}\" contains whitespace"
- return
+ if [[ ${#tests} -eq 0 ]]; then
+ return 0
fi
- if ! . "tests/${category}/category"; then
- return
- fi
+ local group="${tests[0]%/*}"
- if ! declare -fF prepare >/dev/null; then
- _warning "${category} does not define prepare()"
- return
- fi
+ . "tests/${group}/group"
- if ! declare -fF prepare_device >/dev/null; then
- _warning "${category} does not define prepare_device()"
- return
- fi
-
- if ! prepare; then
- _output_notrun "$category/***"
- return
+ if declare -fF group_requires >/dev/null && ! group_requires; then
+ _output_notrun "${group}/***"
+ return 0
fi
- declare -a CATEGORY_TEST_DEVS
- local test_dev
- for test_dev in "${TEST_DEVS[@]}"; do
- if prepare_device; then
- CATEGORY_TEST_DEVS+=("$test_dev")
- fi
- done
- if [[ ${#CATEGORY_TEST_DEVS} -eq 0 ]]; then
- _output_notrun "$category/***"
- return
+ if declare -fF group_device_requires >/dev/null; then
+ local i
+ for i in "${!TEST_DEVS[@]}"; do
+ TEST_DEV="${TEST_DEVS[$i]}"
+ if ! group_device_requires; then
+ _output_notrun "${group}/*** => $(basename "$TEST_DEV")"
+ unset TEST_DEVS[$i]
+ fi
+ done
+ # Fix the array indices.
+ TEST_DEVS=("${TEST_DEVS[@]}")
+ unset TEST_DEV
fi
- unset prepare prepare_device
-
local ret=0
- local seq
- while IFS= read -r -d '' seq; do
- if ! ( _run_test "${category}/${seq}" ); then
+ local test_name
+ for test_name in "${tests[@]}"; do
+ if ! ( _run_test "$test_name" ); then
ret=1
fi
- done < <(find "tests/${category}" -mindepth 1 -maxdepth 1 -type f \
- -name '[0-9][0-9][0-9]' -printf '%P\0' | sort -z)
+ done
return $ret
}
}
declare -A TEST_DEV_SYSFS_DIRS
-_check_test_devs() {
+_check() {
local test_dev
-
for test_dev in "${TEST_DEVS[@]}"; do
if [[ ! -e $test_dev ]]; then
_error "${test_dev} does not exist"
fi
TEST_DEV_SYSFS_DIRS["$test_dev"]="$sysfs_dir"
done
-}
-_run_tests() {
+ local test_name group prev_group
+ local tests=()
local ret=0
- local category
- while IFS= read -r -d '' category; do
- if ! ( _run_category "${category}" ); then
- ret=1
+ while IFS= read -r -d '' test_name; do
+ group="${test_name%/*}"
+ if [[ $group != $prev_group ]]; then
+ prev_group="$group"
+ if ! ( _run_group "${tests[@]}" ); then
+ ret=1
+ fi
fi
- done < <(find tests -mindepth 1 -maxdepth 1 -type d -printf '%P\0' | sort -z)
+ tests+=("$test_name")
+ done < <(_find_tests "$@" | sort -zu)
+
+ if ! ( _run_group "${tests[@]}" ); then
+ ret=1
+ fi
+
return $ret
}
usage () {
USAGE_STRING="\
-usage: $0 [-g group] [-x exclude_group] [test...]
- $0 -h
+usage: $0 [options] [group-or-test...]
-Test groups:
- -g group run tests belonging to this group; may be specified multiple
- times
- -x group don't run tests belonging to this group; takes precedence over
- -g, may be specified multiple times
+Run blktests
Miscellaneous:
- -h display this help message and exit
-
-Examples:
-Run the default set of tests, i.e., the \"auto\" group:
- ./check
-Run all NVMe and SCSI tests except for those that involve discard:
- ./check -g nvme -g scsi -x discard
-Run two specific tests:
- ./check block/001 block/002
-Run a specific test in addition to the default set of tests:
- ./check -g auto block/003"
+ -h display this help message and exit"
case "$1" in
out)
esac
}
-declare -A INCLUDE_GROUPS
-declare -A EXCLUDE_GROUPS
-declare -A TESTS
-
-while getopts "g:x:h" OPT; do
+while getopts "h" OPT; do
case "$OPT" in
- g)
- INCLUDE_GROUPS["$OPTARG"]=1
- ;;
- x)
- EXCLUDE_GROUPS["$OPTARG"]=1
- ;;
h)
- usage out;
+ usage out
;;
*)
- usage err;
+ usage err
;;
esac
done
shift $((OPTIND - 1))
-for test in "$@"; do
- TESTS["$test"]=1
-done
-
-if [[ ${#TESTS[@]} -eq 0 && ${#INCLUDE_GROUPS[@]} -eq 0 ]]; then
- INCLUDE_GROUPS[auto]=1
-fi
-
-if ! . config; then
- exit 1
+if [[ -r config ]]; then
+ . config
fi
if [[ ! -v TEST_DEVS ]]; then
- _error "\$TEST_DEVS not defined in ./config"
+ TEST_DEVS=()
fi
-_check_test_devs
-_run_tests
+_check "$@"
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+shopt -s extglob
+
# Include fio helpers by default.
. common/fio
fi
}
-echo "Available test categories:"
-while IFS= read -r -d '' category; do
- if [[ $category != meta ]]; then
- echo " ${category}"
+echo "Available test groups:"
+while IFS= read -r -d '' group; do
+ if [[ $group != meta ]]; then
+ echo " ${group}"
fi
done < <(find tests -mindepth 1 -maxdepth 1 -type d -printf '%P\0')
-read -r -p "Category for new test (pick one of the above or create a new one): " category
+read -r -p "Category for new test (pick one of the above or create a new one): " group
-if [[ -z $category ]]; then
+if [[ -z $group ]]; then
exit 1
fi
-if [[ $category =~ [[:space:]] ]]; then
- _error "category name must not contain whitespace"
+if [[ $group =~ [[:space:]/] ]]; then
+ _error 'group name must not contain whitespace or "/"'
fi
-if [[ ! -e tests/${category} ]]; then
+if [[ ! -e tests/${group} ]]; then
if ! prompt_yes_no "Category does not exist; create it?"; then
exit 1
fi
- mkdir -p "tests/${category}"
- cat << EOF > "tests/${category}/category"
+ mkdir -p "tests/${group}"
+ cat << EOF > "tests/${group}/group"
#!/bin/bash
#
-# TODO: provide a brief description of the category here.
+# TODO: provide a brief description of the group here.
#
# Copyright (C) $(date +%Y) TODO YOUR NAME HERE
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# TODO: source any more common helpers needed for this category script.
-# Anything sourced here will also be available in the test scripts.
-# Additionally, any functions defined here (except for prepare() and
-# prepare_device()) will also be available in the test scripts.
-. common/rc
+# TODO: source any common helpers needed for this group. Anything sourced here
+# will also be available in the test scripts. Additionally, any functions
+# defined here will also be available in the test scripts. Note that common/rc
+# and common/fio are automatically sourced for all tests.
+# . common/foo
-# TODO: prepare() should check whether tests in this category can be run. If
-# so, it should return 0. Otherwise, it should return non-zero and set the
-# \$SKIP_REASON variable. Usually, prepare() just needs to check that any
-# necessary programs and kernel features are available using the _have_foo
-# helpers. If prepare() returns non-zero, all tests in this category will be
-# skipped.
-prepare() {
+# TODO: if this test group has any extra requirements, it should define a
+# group_requires() function. If tests in this group can be run,
+# group_requires() should return 0. Otherwise, it should return non-zero and
+# set the \$SKIP_REASON variable.
+#
+# Usually, group_requires() just needs to check that any necessary programs and
+# kernel features are available using the _have_foo helpers. If
+# group_requires() returns non-zero, all tests in this group will be skipped.
+group_requires() {
_have_root
}
-# TODO: prepare_device() should check whether tests in this category can be run
-# on the given test device. \$TEST_DEV is the full path of the block device
-# (e.g., /dev/nvme0n1 or /dev/sda1), and \$TEST_DEV_SYSFS is the sysfs path of
-# the disk (not the partition, e.g., /sys/block/nvme0n1 or /sys/block/sda). If
-# tests in this category can be run on the test device, it should return zero.
-# Otherwise, it should return non-zero and set the \$SKIP_REASON variable.
-# Usually, prepare_device() 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. Tests in this category will only be run on devices for
-# which prepare_device() returns zero.
-prepare_device() {
- return 0
-}
+# TODO: if this test group has extra requirements for what devices it can be
+# run on, it should define a group_device_requires() function. If tests in this
+# group can be run on the test device, it should return zero. Otherwise, it
+# should return non-zero and set the \$SKIP_REASON variable. \$TEST_DEV is the
+# full path of the block device (e.g., /dev/nvme0n1 or /dev/sda1), and
+# \$TEST_DEV_SYSFS is the sysfs path of the disk (not the partition, e.g.,
+# /sys/block/nvme0n1 or /sys/block/sda).
+#
+# 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() returns non-zero, all tests
+# in this group will be skipped on that device.
+# group_device_requires() {
+# _test_dev_is_foo && _test_dev_supports_bar
+# }
EOF
- echo "Created tests/${category}/category"
+ echo "Created tests/${group}/group"
fi
for ((i = 1; ; i++)); do
seq="$(printf "%03d" $i)"
- test_name="${category}/${seq}"
+ test_name="${group}/${seq}"
if [[ ! -e tests/${test_name} ]]; then
break
fi
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# TODO: if this test shouldn't be run by default, remove the "auto" group. If
-# this test runs quickly, add it to the "quick" group. If this test honors the
-# configured \$TIMEOUT, add it to the "timed" group.
-# Add any other groups describing what functionality this tests (e.g.,
-# "discard" or "hotplug"). Feel free to create new groups if it makes sense.
-TEST_GROUPS=($category auto)
# TODO: fill in a very brief description of what this test does. The
# description should complete the sentence "This test will...". For example,
# "run a mixed read/write workload" would be a good description.
DESCRIPTION=""
+# TODO: if this test completes quickly (i.e., in ~30 seconds or less on
+# reasonable hardware), uncomment the line below.
+# QUICK=1
+
+# TODO: if this test honors the configured \$TIMEOUT, uncomment the line below.
+# TIMED=1
+
# TODO: dmesg is checked after each test run by default. You can suppress this
# by defining:
# CHECK_DMESG=0
# Alternatively, you can filter out any unimportant messages in dmesg like so:
# DMESG_FILTER="grep -v sysfs"
-# TODO: if this test has any extra requirements, it should define a prepare()
-# function. If the test can be run, prepare() should return 0. Otherwise, it
-# should return non-zero and set the \$SKIP_REASON variable. Usually, prepare()
-# just needs to check that any necessary programs and kernel features are
-# available using the _have_foo helpers. If prepare() returns non-zero, the
-# test is skipped.
-# prepare() {
+# TODO: if this test has any extra requirements, it should define a requires()
+# function. If the test can be run, requires() should return 0. Otherwise, it
+# should return non-zero and set the \$SKIP_REASON variable. Usually,
+# requires() just needs to check that any necessary programs and kernel
+# features are available using the _have_foo helpers. If requires() returns
+# non-zero, the test is skipped.
+# requires() {
# _have_foo
# }
# TODO: if this test has extra requirements for what devices it can be run on,
-# it should define a prepare_device() function. If the test can be run on
-# \$TEST_DEV, then prepare_device() should return zero. Otherwise, it should
-# return non-zero and set the \$SKIP_REASON variable. Usually, prepare_device()
-# 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. The test
-# will only be run on devices for which prepare_device() returns zero.
-# prepare_device() {
-# _test_dev_foo
+# it should define a device_requires() function. If this test can be run on the
+# test device, it should return zero. Otherwise, it should return non-zero and
+# set the \$SKIP_REASON variable. \$TEST_DEV is the full path of the block
+# device (e.g., /dev/nvme0n1 or /dev/sda1), and \$TEST_DEV_SYSFS is the sysfs
+# path of the disk (not the partition, e.g., /sys/block/nvme0n1 or
+# /sys/block/sda).
+#
+# 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() returns non-zero, the test will
+# be skipped on that device.
+# device_requires() {
+# _test_dev_is_foo && _test_dev_supports_bar
# }
# TODO: define the test. The output of this function (stdout and stderr) will
# - \$TEST_RUN -- an associative array of additional test data to display
# after the test is run and store for comparison on future
# test runs. Use like TEST_RUN[iops]="\$(measure_iops)".
+# - \$TIMEOUT -- an optional timeout configured by the user. If possible, limit
+# the runtime of the entire test to this value if it is set.
#
# Many tests do not need a test device (usually because they set up their own
# virtual devices, like null-blk or loop). These tests should define the test()
# E.g., TEST_NAME and GROUPS. Variables local to the test are lowercase
# with underscores.
# - Functions defined by the testing framework, including helpers, have a leading
-# underscore. E.g., _have_scsi_debug. Functions local to the test or category
+# underscore. E.g., _have_scsi_debug. Functions local to the test or group
# should not have a leading underscore.
# - Use the bash [[ ]] form of tests instead of [ ].
# - Always quote variable expansions unless the variable is a number or inside of
. common/scsi_debug
-TEST_GROUPS=(block auto timed hotplug)
DESCRIPTION="stress device hotplugging"
+TIMED=1
-prepare() {
+requires() {
_have_scsi_debug
}
. common/scsi_debug
-TEST_GROUPS=(block auto quick blktrace hotplug)
DESCRIPTION="remove a device while running blktrace"
+QUICK=1
-prepare() {
+requires() {
_have_blktrace && _have_scsi_debug
}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(block auto timed discard)
DESCRIPTION="run various discard sizes"
+TIMED=1
-prepare() {
+requires() {
_have_fio
}
-prepare_device() {
+device_requires() {
_test_dev_can_discard
}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(block auto timed flush)
DESCRIPTION="run lots of flushes"
+TIMED=1
-prepare() {
+requires() {
_have_fio
}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(block auto timed sched)
DESCRIPTION="switch schedulers while doing IO"
+TIMED=1
-prepare() {
+requires() {
_have_fio
}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(block auto timed)
DESCRIPTION="run null-blk in blocking mode"
+TIMED=1
-prepare() {
+requires() {
_have_module null_blk
}
. common/iopoll
-TEST_GROUPS=(block auto timed poll)
DESCRIPTION="test classic and hybrid IO polling"
+TIMED=1
-prepare() {
+requires() {
_have_fio_with_poll
}
-prepare_device() {
+device_requires() {
_test_dev_supports_io_poll && _test_dev_supports_io_poll_delay
}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-. common/rc
-
-prepare() {
+group_requires() {
_have_root
}
-
-prepare_device() {
- return 0
-}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(loop auto quick)
DESCRIPTION="scan loop device partitions"
+QUICK=1
-prepare() {
+requires() {
_have_program parted
}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-. common/rc
-
-prepare() {
+group_requires() {
_have_root && _have_loop
}
-
-prepare_device() {
- return 0
-}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
DESCRIPTION="do nothing"
test() {
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
DESCRIPTION="do nothing"
test_device() {
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
DESCRIPTION="exit with non-zero status"
test() {
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
DESCRIPTION="exit with non-zero status"
test_device() {
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
DESCRIPTION="produce bad output"
test() {
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
DESCRIPTION="produce lots of bad output"
test() {
#!/bin/bash
#
-# Test prepare().
+# Test requires().
#
# Copyright (C) 2017 Omar Sandoval
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
-DESCRIPTION="skip in prepare()"
+DESCRIPTION="skip in requires()"
-prepare() {
+requires() {
SKIP_REASON="(╯°□°)╯︵ ┻━┻"
return 1
}
#!/bin/bash
#
-# Test prepare_device().
+# Test device_requires().
#
# Copyright (C) 2017 Omar Sandoval
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
-DESCRIPTION="skip in prepare_device()"
+DESCRIPTION="skip in device_requires()"
-prepare_device() {
+device_requires() {
SKIP_REASON="(╯°□°)╯︵ $TEST_DEV ┻━┻"
return 1
}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
DESCRIPTION="check dmesg"
-prepare() {
+requires() {
_have_writeable_kmsg
}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
DESCRIPTION="disable check dmesg"
CHECK_DMESG=0
-prepare() {
+requires() {
_have_writeable_kmsg
}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
DESCRIPTION="filter dmesg"
DMESG_FILTER="grep -v BUG"
-prepare() {
+requires() {
_have_writeable_kmsg
}
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-TEST_GROUPS=(meta)
DESCRIPTION="record pid"
test() {
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-. common/rc
-
-prepare() {
- if [[ -v META_PREPARE_SHOULD_FAIL ]]; then
- SKIP_REASON="META_PREPARE_SHOULD_FAIL"
+group_requires() {
+ if [[ -v META_REQUIRES_SKIP ]]; then
+ SKIP_REASON="META_REQUIRES_SKIP was set"
return 1
fi
return 0
}
-prepare_device() {
- if [[ -v META_PREPARE_DEVICE_SHOULD_FAIL ]]; then
- SKIP_REASON="META_PREPARE_DEVICE_SHOULD_FAIL"
+group_device_requires() {
+ if [[ -v META_DEVICE_REQUIRES_SKIP ]]; then
+ SKIP_REASON="META_DEVICE_REQUIRES_SKIP was set"
return 1
fi
return 0