]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: add huge JSON transaction
authorEric Garver <eric@garver.life>
Tue, 10 Sep 2019 13:43:27 +0000 (09:43 -0400)
committerPhil Sutter <phil@nwl.cc>
Tue, 10 Sep 2019 16:10:20 +0000 (18:10 +0200)
Expand the test case to also check for returned rule handles in the JSON
output.

Signed-off-by: Eric Garver <eric@garver.life>
Signed-off-by: Phil Sutter <phil@nwl.cc>
tests/shell/testcases/transactions/0049huge_0

index 2791249512b6d7e13282dc5ab9c056f21fd84cff..f029ee3c54d78ac469a742dd231e273e129af9e6 100755 (executable)
@@ -13,3 +13,19 @@ for ((i = 0; i < ${RULE_COUNT}; i++)); do
 done
 )
 test $($NFT -e -a -f - <<< "$RULESET" |grep "#[ ]\+handle[ ]\+[0-9]\+" |wc -l) -eq ${RULE_COUNT} || exit 1
+
+# same thing, but with JSON rules
+#
+$NFT flush ruleset
+$NFT add table inet test
+$NFT add chain inet test c
+
+RULESET=$(
+echo '{"nftables": ['
+for ((i = 0; i < $((${RULE_COUNT} - 1)); i++)); do
+       echo '{"add": {"rule": {"family": "inet", "table": "test", "chain": "c", "expr": [{"accept": null}], "comment": "rule'$i'"}}},'
+done
+       echo '{"add": {"rule": {"family": "inet", "table": "test", "chain": "c", "expr": [{"accept": null}], "comment": "rule'$((${RULE_COUNT} - 1))'"}}}'
+echo ']}'
+)
+test $($NFT -j -e -a -f - <<< "$RULESET" |sed 's/\({"add":\)/\n\1/g' |grep '"handle"' |wc -l) -eq ${RULE_COUNT} || exit 1