summaryrefslogtreecommitdiffstats
path: root/tests/xlate/runtest.sh
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2021-06-25 22:30:43 +0200
committerJozsef Kadlecsik <kadlec@netfilter.org>2021-06-26 23:07:41 +0200
commit7587d1c4b5465f3b5315536b439b63a5ffe0311d (patch)
treebd804ddc0b5aa02d48ceccebea8ed4a1ad47e08c /tests/xlate/runtest.sh
parent325af556cd3a6d1636c0cd355b494c87f58397e0 (diff)
tests: add tests ipset to nftables
This test checks that the translation from ipset to nftables is correct. term$ cd tests/xlate term$ ./runtest.sh in case that the translation is not correct, it shows the diff with expected translation output. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
Diffstat (limited to 'tests/xlate/runtest.sh')
-rwxr-xr-xtests/xlate/runtest.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/xlate/runtest.sh b/tests/xlate/runtest.sh
new file mode 100755
index 0000000..a2a02c0
--- /dev/null
+++ b/tests/xlate/runtest.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+DIFF=$(which diff)
+if [ ! -x "$DIFF" ] ; then
+ echo "ERROR: missing diff"
+ exit 1
+fi
+
+IPSET_XLATE=$(which ipset-translate)
+if [ ! -x "$IPSET_XLATE" ] ; then
+ echo "ERROR: ipset-translate is not installed yet"
+ exit 1
+fi
+
+TMP=$(mktemp)
+ipset-translate restore < xlate.t &> $TMP
+if [ $? -ne 0 ]
+then
+ cat $TMP
+ echo -e "[\033[0;31mERROR\033[0m] failed to run ipset-translate"
+ exit 1
+fi
+${DIFF} -u xlate.t.nft $TMP
+if [ $? -eq 0 ]
+then
+ echo -e "[\033[0;32mOK\033[0m] tests are fine!"
+else
+ echo -e "[\033[0;31mERROR\033[0m] unexpected ipset to nftables translation"
+fi