From 7587d1c4b5465f3b5315536b439b63a5ffe0311d Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 25 Jun 2021 22:30:43 +0200 Subject: 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 Signed-off-by: Jozsef Kadlecsik --- tests/xlate/runtest.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 tests/xlate/runtest.sh (limited to 'tests/xlate/runtest.sh') 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 -- cgit v1.2.3