diff options
author | Fabian Frederick <fabf@skynet.be> | 2020-08-07 21:31:11 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2020-08-13 04:25:08 +0200 |
commit | 6d006a4e38d5a52ef27a8204ac358b96da8148ec (patch) | |
tree | ea828deccd52db1b28c86c11dc05145a728f94ed /tools | |
parent | 59136aa3b2649796a3a1fd90158675f1f640ce0e (diff) | |
download | linux-stable-6d006a4e38d5a52ef27a8204ac358b96da8148ec.tar.gz linux-stable-6d006a4e38d5a52ef27a8204ac358b96da8148ec.tar.bz2 linux-stable-6d006a4e38d5a52ef27a8204ac358b96da8148ec.zip |
selftests: netfilter: add checktool function
avoid repeating the same test for different toolcheck
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/testing/selftests/netfilter/nft_flowtable.sh | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/tools/testing/selftests/netfilter/nft_flowtable.sh b/tools/testing/selftests/netfilter/nft_flowtable.sh index d3e0809ab368..68a183753c6c 100755 --- a/tools/testing/selftests/netfilter/nft_flowtable.sh +++ b/tools/testing/selftests/netfilter/nft_flowtable.sh @@ -21,29 +21,18 @@ ns2out="" log_netns=$(sysctl -n net.netfilter.nf_log_all_netns) -nft --version > /dev/null 2>&1 -if [ $? -ne 0 ];then - echo "SKIP: Could not run test without nft tool" - 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 +checktool (){ + $1 > /dev/null 2>&1 + if [ $? -ne 0 ];then + echo "SKIP: Could not $2" + exit $ksft_skip + fi +} -ip netns add nsr1 -if [ $? -ne 0 ];then - echo "SKIP: Could not create net namespace" - exit $ksft_skip -fi +checktool "nft --version" "run test without nft tool" +checktool "ip -Version" "run test without ip tool" +checktool "which nc" "run test without nc (netcat)" +checktool "ip netns add nsr1" "create net namespace" ip netns add ns1 ip netns add ns2 |