Commit 6d006a4e authored by Fabian Frederick's avatar Fabian Frederick Committed by Pablo Neira Ayuso

selftests: netfilter: add checktool function

avoid repeating the same test for different toolcheck
Signed-off-by: default avatarFabian Frederick <fabf@skynet.be>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 59136aa3
...@@ -21,29 +21,18 @@ ns2out="" ...@@ -21,29 +21,18 @@ ns2out=""
log_netns=$(sysctl -n net.netfilter.nf_log_all_netns) log_netns=$(sysctl -n net.netfilter.nf_log_all_netns)
nft --version > /dev/null 2>&1 checktool (){
if [ $? -ne 0 ];then $1 > /dev/null 2>&1
echo "SKIP: Could not run test without nft tool" if [ $? -ne 0 ];then
exit $ksft_skip echo "SKIP: Could not $2"
fi exit $ksft_skip
fi
ip -Version > /dev/null 2>&1 }
if [ $? -ne 0 ];then
echo "SKIP: Could not run test without ip tool"
exit $ksft_skip
fi
which nc > /dev/null 2>&1
if [ $? -ne 0 ];then
echo "SKIP: Could not run test without nc (netcat)"
exit $ksft_skip
fi
ip netns add nsr1 checktool "nft --version" "run test without nft tool"
if [ $? -ne 0 ];then checktool "ip -Version" "run test without ip tool"
echo "SKIP: Could not create net namespace" checktool "which nc" "run test without nc (netcat)"
exit $ksft_skip checktool "ip netns add nsr1" "create net namespace"
fi
ip netns add ns1 ip netns add ns1
ip netns add ns2 ip netns add ns2
......
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