From dc9733e097959f4e167244549f58cd3bef7af79b Mon Sep 17 00:00:00 2001 From: Arturo Borrero Gonzalez Date: Thu, 27 Jun 2013 20:09:34 +0200 Subject: test: add testbench for XML This patch add a testbench for XML parsing, which may be extended to test JSON as well. To use it: $ cd test/ $ make nft-parsing-test $ ./nft-parsing-test xmlfiles/ This testbench supersedes old .sh test scripts, so they are deleted. [ I have mangled this patch to rename/mangle files, to colorize the test output and not to compile XML inconditionally --pablo ] Signed-off-by: Arturo Borrero Gonzalez Signed-off-by: Pablo Neira Ayuso --- test/nft-rule-xml-add.sh | 125 ----------------------------------------------- 1 file changed, 125 deletions(-) delete mode 100755 test/nft-rule-xml-add.sh (limited to 'test/nft-rule-xml-add.sh') diff --git a/test/nft-rule-xml-add.sh b/test/nft-rule-xml-add.sh deleted file mode 100755 index 2a052b2..0000000 --- a/test/nft-rule-xml-add.sh +++ /dev/null @@ -1,125 +0,0 @@ -#!/bin/bash - -# -# (C) 2013 by Arturo Borrero Gonzalez -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This is a small testbench for adding nftables rules to kernel -# in XML format. - -BINARY="../examples/nft-rule-xml-add" -NFT="$( which nft )" -MKTEMP="$( which mktemp )" -TMPFILE="$( $MKTEMP )" - -if [ ! -x "$BINARY" ] ; then - echo "E: Binary not found $BINARY" - exit 1 -fi - -if [ ! -x "$MKTEMP" ] ; then - echo "E: mktemp not found. Is mandatory." - exit 1 -fi - -if [ ! -w "$TMPFILE" ] ; then - echo "E: Unable to create tempfile with mktemp" - exit 1 -fi - -[ ! -x "$NFT" ] && echo "W: nftables main binary not found but continuing anyway $NFT" - -XML=" - 0 - 0 - 0 - - 1 - iif - - - 1 - eq - - - 4 - 0x04000000 - - - - - 1 - transport - 12 - 4 - - - 1 - eq - - - 4 - 0x96d60496 - - - - - 1 - link - 16 - 4 - - - 1 - eq - - - 4 - 0x96d60329 - - - - - 1 - network - 9 - 1 - - - 1 - eq - - - 4 - 0x06000000 - - - - - state - - - 123123 - 321321 - - - LOG - -" - -$NFT add table filter 2>/dev/null >&2 -$NFT add chain filter INPUT 2>/dev/null >&2 - -echo $XML > $TMPFILE -if ! $BINARY "$TMPFILE" ; then - echo "E: Unable to add XML." - rm -rf $TMPFILE 2>/dev/null - exit 1 -fi - -rm -rf $TMPFILE 2>/dev/null -echo "I: Test OK" -- cgit v1.2.3