Commit e094574f authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

selftests: forwarding: lib: Add require_command()

The logic for testing whether a certain command is available is used
several times in the current code base. The tests in follow-up patches
add more requirements like that.

Therefore extract the logic into a named function, require_command(),
that can be used directly from lib.sh as well as from any test that
wishes to declare dependence on some command.
Signed-off-by: default avatarPetr Machata <petrm@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 778c4d5c
...@@ -62,15 +62,18 @@ if [[ "$CHECK_TC" = "yes" ]]; then ...@@ -62,15 +62,18 @@ if [[ "$CHECK_TC" = "yes" ]]; then
check_tc_version check_tc_version
fi fi
if [[ ! -x "$(command -v jq)" ]]; then require_command()
echo "SKIP: jq not installed" {
exit 1 local cmd=$1; shift
fi
if [[ ! -x "$(command -v $MZ)" ]]; then if [[ ! -x "$(command -v "$cmd")" ]]; then
echo "SKIP: $MZ not installed" echo "SKIP: $cmd not installed"
exit 1 exit 1
fi fi
}
require_command jq
require_command $MZ
if [[ ! -v NUM_NETIFS ]]; then if [[ ! -v NUM_NETIFS ]]; then
echo "SKIP: importer does not define \"NUM_NETIFS\"" echo "SKIP: importer does not define \"NUM_NETIFS\""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment