From: Alvaro Neira <alvaroneay@gmail.com>
To: netfilter-devel@vger.kernel.org
Cc: eric@regit.org
Subject: [libnftables PATCH 3/4] tests: set: add json parsing support
Date: Tue, 27 Aug 2013 20:10:55 +0200 [thread overview]
Message-ID: <20130827181055.9399.10176.stgit@Ph0enix> (raw)
In-Reply-To: <20130827181037.9399.30579.stgit@Ph0enix>
From: Álvaro Neira Ayuso <alvaroneay@gmail.com>
Test the functions for parsing set in JSON.
Signed-off-by: Alvaro Neira Ayuso <alvaroneay@gmail.com>
---
tests/jsonfiles/62-set.json | 1 +
tests/jsonfiles/63-set.json | 1 +
tests/nft-parsing-test.c | 11 +++++++++++
3 files changed, 13 insertions(+)
create mode 100644 tests/jsonfiles/62-set.json
create mode 100644 tests/jsonfiles/63-set.json
diff --git a/tests/jsonfiles/62-set.json b/tests/jsonfiles/62-set.json
new file mode 100644
index 0000000..c5200eb
--- /dev/null
+++ b/tests/jsonfiles/62-set.json
@@ -0,0 +1 @@
+{ "set": { "name": "set0","table": "filter","flags": 3,"family": "ip","key_type": 12,"key_len": 2,"set_elem": [{"flags": 0,"key": {"data_reg": { "type" : "value", "len" : 2, "data0" : "0x00001700"}}}, {"flags": 0,"key": {"data_reg": { "type" : "value", "len" : 2, "data0" : "0x00001600"}}}]}}
diff --git a/tests/jsonfiles/63-set.json b/tests/jsonfiles/63-set.json
new file mode 100644
index 0000000..be3e564
--- /dev/null
+++ b/tests/jsonfiles/63-set.json
@@ -0,0 +1 @@
+{ "set": { "name": "map0","table": "filter","flags": 11,"family": "ip","key_type": 12,"key_len": 2,"data_type": 4294967040,"data_len": 16,"set_elem": [{"flags": 0,"key": {"data_reg": { "type" : "value", "len" : 2, "data0" : "0x00001700"}},"data": {"data_reg": { "type" : "chain", "chain" : "forward"}}}, {"flags": 0,"key": {"data_reg": { "type" : "value", "len" : 2, "data0" : "0x00001600"}},"data": {"data_reg": { "type" : "chain", "chain" : "chain1"}}}]}}
diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c
index 648ed36..ecde0e2 100644
--- a/tests/nft-parsing-test.c
+++ b/tests/nft-parsing-test.c
@@ -158,6 +158,7 @@ static int test_json(const char *filename)
struct nft_table *t;
struct nft_chain *c;
struct nft_rule *r;
+ struct nft_set *s;
json_t *root;
json_error_t error;
char *json;
@@ -200,6 +201,16 @@ static int test_json(const char *filename)
nft_rule_free(r);
}
+ } else if (json_object_get(root, "set") != NULL) {
+ s = nft_set_alloc();
+ if (s != NULL) {
+ if (nft_set_parse(s, NFT_SET_PARSE_JSON, json) == 0)
+ ret = compare_test(TEST_JSON_SET, s, filename);
+ else
+ goto failparsing;
+
+ nft_set_free(s);
+ }
}
free(json);
--
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-08-27 18:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-27 18:10 [libnftables PATCH 1/4] tests: remove unnecessary variable initialization Alvaro Neira
2013-08-27 18:10 ` [libnftables PATCH 2/4] set: Add json parser support Alvaro Neira
2013-08-27 22:52 ` Pablo Neira Ayuso
2013-08-27 18:10 ` Alvaro Neira [this message]
2013-08-27 22:52 ` [libnftables PATCH 3/4] tests: set: add json parsing support Pablo Neira Ayuso
2013-08-27 18:11 ` [libnftables PATCH 4/4] examples: Add nft-set-json-add Alvaro Neira
2013-08-27 22:52 ` Pablo Neira Ayuso
2013-08-27 22:51 ` [libnftables PATCH 1/4] tests: remove unnecessary variable initialization 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=20130827181055.9399.10176.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).