* [LTP] [PATCH 1/1] lib: test.sh: Backport tst_cmd_available (DRY)
@ 2026-08-25 4:55 Petr Vorel
2026-08-25 5:32 ` [LTP] " linuxtestproject.agent
2026-08-25 7:50 ` [LTP] [PATCH 1/1] " Andrea Cervesato via ltp
0 siblings, 2 replies; 3+ messages in thread
From: Petr Vorel @ 2026-08-25 4:55 UTC (permalink / raw)
To: ltp
Backport tst_cmd_available() from tst_test.sh in order to have 'command -v'
used only once. That helps to maintain LTP preferred way to check
command in shell.
Follow-up: 772e7d6851 ("lib: test: check systemd in tst_virt_hyperv() as tst_test.sh")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
testcases/lib/test.sh | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
index edae1313ed..0d4f3fe4d2 100644
--- a/testcases/lib/test.sh
+++ b/testcases/lib/test.sh
@@ -148,6 +148,11 @@ tst_rmdir()
fi
}
+tst_cmd_available()
+{
+ command -v $1 >/dev/null 2>&1
+}
+
#
# Checks if commands passed as arguments exists
#
@@ -155,9 +160,7 @@ tst_require_cmds()
{
local cmd
for cmd in $*; do
- if ! command -v $cmd > /dev/null 2>&1; then
- tst_brkm TCONF "'$cmd' not found"
- fi
+ tst_cmd_available $cmd || tst_brkm TCONF "'$cmd' not found"
done
}
@@ -331,7 +334,7 @@ tst_virt_hyperv()
{
local v
- command -v systemd-detect-virt > /dev/null 2>&1 || return 1
+ tst_cmd_available systemd-detect-virt || return 1
v="$(systemd-detect-virt)"
--
2.55.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-25 7:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25 4:55 [LTP] [PATCH 1/1] lib: test.sh: Backport tst_cmd_available (DRY) Petr Vorel
2026-08-25 5:32 ` [LTP] " linuxtestproject.agent
2026-08-25 7:50 ` [LTP] [PATCH 1/1] " Andrea Cervesato via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox