Message ID | 20240607045246.248590-1-shinichiro.kawasaki@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [blktests] check: confirm dependent commands | expand |
On Fri, Jun 07, 2024 at 01:52:46PM +0900, Shin'ichiro Kawasaki wrote: > 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. Loks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
On 6/6/2024 9:52 PM, Shin'ichiro Kawasaki wrote: > 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@lst.de> > Signed-off-by: Shin'ichiro Kawasaki<shinichiro.kawasaki@wdc.com> > --- LGTM ... Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> -ck
On Jun 07, 2024 / 13:52, Shin'ichiro Kawasaki wrote: > 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. FYI, this patch has got applied.
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
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@lst.de> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> --- check | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)