From: Alvaro Neira <alvaroneay@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: eric@regit.org
Subject: [libnftables PATCH 5/6] chain: test: test the chain parser support
Date: Thu, 25 Jul 2013 22:52:47 +0200 [thread overview]
Message-ID: <20130725205247.26223.37905.stgit@Ph0enix> (raw)
In-Reply-To: <20130725205215.26223.77001.stgit@Ph0enix>
From: Álvaro Neira Ayuso <alvaroneay@gmail.com>
Test the functions for parsing chains in JSON Support
Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
---
tests/jsonfiles/11-chain.json | 1 +
tests/jsonfiles/12-chain.json | 1 +
tests/jsonfiles/13-chain.json | 1 +
tests/jsonfiles/14-chain.json | 1 +
tests/nft-parsing-test.c | 9 +++++++++
5 files changed, 13 insertions(+)
create mode 100644 tests/jsonfiles/11-chain.json
create mode 100644 tests/jsonfiles/12-chain.json
create mode 100644 tests/jsonfiles/13-chain.json
create mode 100644 tests/jsonfiles/14-chain.json
diff --git a/tests/jsonfiles/11-chain.json b/tests/jsonfiles/11-chain.json
new file mode 100644
index 0000000..9b716f2
--- /dev/null
+++ b/tests/jsonfiles/11-chain.json
@@ -0,0 +1 @@
+{ "chain": {"name": "input","handle": 1,"bytes": 2238649,"packets": 14177,"version": 0,"properties": {"family": "ip","table": "filter","use": 0,"type": "filter","hooknum": "NF_INET_LOCAL_IN","prio": 0,"policy": "accept"}}}
diff --git a/tests/jsonfiles/12-chain.json b/tests/jsonfiles/12-chain.json
new file mode 100644
index 0000000..0af8588
--- /dev/null
+++ b/tests/jsonfiles/12-chain.json
@@ -0,0 +1 @@
+{ "chain": {"name": "forward","handle": 2,"bytes": 0,"packets": 0,"version": 0,"properties": {"family": "ip","table": "filter","use": 0,"type": "filter","hooknum": "NF_INET_FORWARD","prio": 0,"policy": "accept"}}}
diff --git a/tests/jsonfiles/13-chain.json b/tests/jsonfiles/13-chain.json
new file mode 100644
index 0000000..835fc2b
--- /dev/null
+++ b/tests/jsonfiles/13-chain.json
@@ -0,0 +1 @@
+{ "chain": {"name": "output","handle": 3,"bytes": 781933,"packets": 6506,"version": 0,"properties": {"family": "ip","table": "filter","use": 0,"type": "filter","hooknum": "NF_INET_LOCAL_OUT","prio": 0,"policy": "accept"}}}
diff --git a/tests/jsonfiles/14-chain.json b/tests/jsonfiles/14-chain.json
new file mode 100644
index 0000000..de3bc35
--- /dev/null
+++ b/tests/jsonfiles/14-chain.json
@@ -0,0 +1 @@
+{ "chain": {"name": "chain1","handle": 4,"bytes": 0,"packets": 0,"version": 0,"properties": {"family": "ip","table": "filter","use": 0}}}
diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c
index 83a627c..777e2e0 100644
--- a/tests/nft-parsing-test.c
+++ b/tests/nft-parsing-test.c
@@ -23,6 +23,7 @@ static int test_json(const char *filename)
#ifdef JSON_PARSING
int ret = -1;
struct nft_table *t = NULL;
+ struct nft_chain *c = NULL;
json_t *root;
json_error_t error;
char *json = NULL;
@@ -46,6 +47,14 @@ static int test_json(const char *filename)
nft_table_free(t);
}
+ }else if (json_object_get(root, "chain") != NULL) {
+ c = nft_chain_alloc();
+ if (c != NULL) {
+ if (nft_chain_parse(c, NFT_CHAIN_PARSE_JSON, json) == 0)
+ ret = 0;
+
+ nft_chain_free(c);
+ }
}
return ret;
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-07-25 20:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-25 20:52 [libnftables PATCH 1/6] table: json: Add Json parser support Alvaro Neira
2013-07-25 20:52 ` [libnftables PATCH 2/6] table : tests: test the table json " Alvaro Neira
2013-07-25 21:07 ` Pablo Neira Ayuso
2013-07-25 20:52 ` [libnftables PATCH 3/6] examples: Add nft-table-json-add Alvaro Neira
2013-07-25 21:07 ` Pablo Neira Ayuso
2013-07-25 20:52 ` [libnftables PATCH 4/6] chain: json: add function for parsing chain Alvaro Neira
2013-07-25 21:13 ` Pablo Neira Ayuso
2013-07-25 20:52 ` Alvaro Neira [this message]
2013-07-25 20:52 ` [libnftables PATCH 6/6] examples: Add nft-chain-json-add Alvaro Neira
2013-07-25 21:07 ` [libnftables PATCH 1/6] table: json: Add Json parser support Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130725205247.26223.37905.stgit@Ph0enix \
--to=alvaroneay@gmail.com \
--cc=eric@regit.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).