* [PATCH 1/3 linux-next] selftests: netfilter: add checktool function
@ 2020-08-07 19:31 Fabian Frederick
2020-08-13 2:24 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Fabian Frederick @ 2020-08-07 19:31 UTC (permalink / raw)
To: pablo, kadlec, fw; +Cc: netfilter-devel, coreteam, netdev, Fabian Frederick
avoid repeating the same test for different toolcheck
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
.../selftests/netfilter/nft_flowtable.sh | 33 +++++++------------
1 file changed, 11 insertions(+), 22 deletions(-)
diff --git a/tools/testing/selftests/netfilter/nft_flowtable.sh b/tools/testing/selftests/netfilter/nft_flowtable.sh
index d3e0809ab3681..68a183753c6c3 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
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/3 linux-next] selftests: netfilter: add checktool function
2020-08-07 19:31 [PATCH 1/3 linux-next] selftests: netfilter: add checktool function Fabian Frederick
@ 2020-08-13 2:24 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2020-08-13 2:24 UTC (permalink / raw)
To: Fabian Frederick; +Cc: kadlec, fw, netfilter-devel, coreteam, netdev
On Fri, Aug 07, 2020 at 09:31:11PM +0200, Fabian Frederick wrote:
> avoid repeating the same test for different toolcheck
Applied to nf.git, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-08-13 2:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-07 19:31 [PATCH 1/3 linux-next] selftests: netfilter: add checktool function Fabian Frederick
2020-08-13 2:24 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).