As described in README, blktests requires some commands to run tests. Check them and warn if they are not available. Also confirm that the bash version is 4.2 or larger. Suggested-by: Christoph Hellwig <hch@xxxxxx> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx> --- check | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/check b/check index 3ed4510..7f43a31 100755 --- a/check +++ b/check @@ -709,6 +709,32 @@ _check() { return $ret } +_check_dependencies() { + local v1 v2 v3 + local -A required_commands_and_packages + local cmd + + # Require bash version 4.2 + IFS='.' read -r v1 v2 v3 < <(bash --version | grep version | head -1 | \ + sed 's/.*version \([0-9.]\+\).*/\1/') + if ((v1 * 65536 + v2 * 256 + v3 < 4 * 65536 + 2 * 256)); then + _warning "bash version is older than 4.2" + fi + + # Check dependent commands to run blktests + required_commands_and_packages[dd]="GNU coreutils" + required_commands_and_packages[gawk]="GNU awk" + required_commands_and_packages[blockdev]="util-linux" + required_commands_and_packages[fio]="fio" + required_commands_and_packages[udevadm]="systemd-udev" + + for cmd in "${!required_commands_and_packages[@]}"; do + command -v "$cmd" &> /dev/null && continue + _warning "$cmd is not available." \ + "Install ${required_commands_and_packages[$cmd]}." + done +} + usage () { USAGE_STRING="\ usage: $0 [options] [group-or-test...] @@ -748,6 +774,8 @@ Miscellaneous: esac } +_check_dependencies + if ! TEMP=$(getopt -o 'do:q::x:c:h' --long 'device-only,quick::,exclude:,output:,config:,help' -n "$0" -- "$@"); then exit 1 fi -- 2.45.0