All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH blktests] check: confirm dependent commands
@ 2024-06-07  4:52 Shin'ichiro Kawasaki
  2024-06-07  4:56 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shin'ichiro Kawasaki @ 2024-06-07  4:52 UTC (permalink / raw)
  To: linux-block; +Cc: Christoph Hellwig, Shin'ichiro Kawasaki

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(+)

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-18  5:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-07  4:52 [PATCH blktests] check: confirm dependent commands Shin'ichiro Kawasaki
2024-06-07  4:56 ` Christoph Hellwig
2024-06-10  2:49 ` Chaitanya Kulkarni
2024-06-18  5:32 ` Shinichiro Kawasaki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.