diff options
author | Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> | 2013-06-27 20:09:34 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-06-27 21:17:54 +0200 |
commit | dc9733e097959f4e167244549f58cd3bef7af79b (patch) | |
tree | e003e7557b63b7b00eb4864cb4bb0b2d92660ec6 /test/nft-table-xml-add.sh | |
parent | 443410dd335732dbcb2a6f1524d7481e506d67c1 (diff) |
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 <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'test/nft-table-xml-add.sh')
-rwxr-xr-x | test/nft-table-xml-add.sh | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/test/nft-table-xml-add.sh b/test/nft-table-xml-add.sh deleted file mode 100755 index 30b65e1..0000000 --- a/test/nft-table-xml-add.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash - -# -# (C) 2013 by Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com> -# -# 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 tables to kernel -# in XML format. - -BINARY="../examples/nft-table-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 and is neccesary" - exit 1 -fi - -if [ ! -w "$TMPFILE" ] ; then - echo "E: Unable to create temp file via mktemp" - exit 1 -fi - - -if [ ! -x "$NFT" ] ; then - echo "W: nftables main binary not found but continuing anyway $NFT" -fi - -# This is valid -XML="<table name=\"filter_test\" version=\"0\"> - <properties> - <family>ip</family> - <table_flags>0</table_flags> - </properties> -</table>" - -$NFT delete table filter_test 2>/dev/null >&2 -echo $XML > $TMPFILE -if ! $BINARY "$TMPFILE" ; then - echo "E: Unable to add XML:" - echo "$XML" - rm -rf $TMPFILE 2>/dev/null - exit 1 -fi - -# This is valid -XML="<table name=\"filter6_test\" version=\"0\"> - <properties> - <family>ip6</family> - <table_flags>0</table_flags> - </properties> -</table>" - -$NFT delete table filter6_test 2>/dev/null >&2 -echo $XML > $TMPFILE -if ! $BINARY "$TMPFILE" ; then - echo "E: Unable to add XML:" - echo "$XML" - rm -rf $TMPFILE 2>/dev/null - exit 1 -fi - -rm -rf $TMPFILE 2>/dev/null -echo "I: Test OK" |