selftests: netfilter: place checktool helper in lib.sh

... so it doesn't have to be repeated everywhere.

Signed-off-by: Florian Westphal <fw@strlen.de>
Link: https://lore.kernel.org/r/20240411233624.8129-10-fw@strlen.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Florian Westphal 2024-04-12 01:36:14 +02:00 committed by Jakub Kicinski
parent 0413156eec
commit 10e2ed3fcd
3 changed files with 8 additions and 12 deletions

View File

@ -11,11 +11,7 @@
source lib.sh
nft --version > /dev/null 2>&1
if [ $? -ne 0 ];then
echo "SKIP: Could not run test without nft tool"
exit $ksft_skip
fi
checktool "nft --version" "run test without nft tool"
cleanup() {
cleanup_all_ns

View File

@ -24,13 +24,6 @@ source lib.sh
rx=$(mktemp)
checktool (){
if ! $1 > /dev/null 2>&1; then
echo "SKIP: Could not $2"
exit $ksft_skip
fi
}
checktool "iptables --version" "run test without iptables"
checktool "socat -h" "run test without socat"

View File

@ -1,3 +1,10 @@
net_netfilter_dir=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
source "$net_netfilter_dir/../lib.sh"
checktool (){
if ! $1 > /dev/null 2>&1; then
echo "SKIP: Could not $2"
exit $ksft_skip
fi
}