diff options
author | Álvaro Neira Ayuso <alvaroneay@gmail.com> | 2013-08-20 17:58:56 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-08-20 21:01:15 +0200 |
commit | 6416683acc5b37766b2de35fa91b650029276cde (patch) | |
tree | e087150108e42f8bc59b173052d58c595e06f233 /tests/nft-parsing-test.c | |
parent | c83c53a26de25c1e2900f7841647cec3b57c7438 (diff) |
tests: rule: add json parsing support
Test the functions for parsing rules in JSON.
Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
Diffstat (limited to 'tests/nft-parsing-test.c')
-rw-r--r-- | tests/nft-parsing-test.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c index 9e457e8..bf5b519 100644 --- a/tests/nft-parsing-test.c +++ b/tests/nft-parsing-test.c @@ -157,6 +157,7 @@ static int test_json(const char *filename) int ret = -1; struct nft_table *t = NULL; struct nft_chain *c = NULL; + struct nft_rule *r = NULL; json_t *root; json_error_t error; char *json = NULL; @@ -189,6 +190,16 @@ static int test_json(const char *filename) nft_chain_free(c); } + } else if (json_object_get(root, "rule") != NULL) { + r = nft_rule_alloc(); + if (r != NULL) { + if (nft_rule_parse(r, NFT_RULE_PARSE_JSON, json) == 0) + ret = compare_test(TEST_JSON_RULE, r, filename); + else + goto failparsing; + + nft_rule_free(r); + } } free(json); |