From 6416683acc5b37766b2de35fa91b650029276cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Neira=20Ayuso?= Date: Tue, 20 Aug 2013 17:58:56 +0200 Subject: tests: rule: add json parsing support Test the functions for parsing rules in JSON. Signed-off-by: Alvaro Neira Ayuso --- tests/nft-parsing-test.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/nft-parsing-test.c') 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); -- cgit v1.2.3