From patchwork Wed Jul 31 13:21:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alvaro Neira X-Patchwork-Id: 263700 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E1E922C00AD for ; Wed, 31 Jul 2013 23:21:33 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752528Ab3GaNVb (ORCPT ); Wed, 31 Jul 2013 09:21:31 -0400 Received: from mail-wg0-f47.google.com ([74.125.82.47]:34062 "EHLO mail-wg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759424Ab3GaNVb (ORCPT ); Wed, 31 Jul 2013 09:21:31 -0400 Received: by mail-wg0-f47.google.com with SMTP id j13so578355wgh.2 for ; Wed, 31 Jul 2013 06:21:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=ByimGojKJquurVOa4jjCvoSHJ7UZdm9ssaHx3ac0gKw=; b=A89j81c2Bh034UuMUp8G78xUbOQVcpWO2anYhjFikb3q1c7seSuLTaGzs2iOqr5gQO TLGw2rClanr1Vykv0ZupFQSVz3TLqRls8UddwWmc5ZaDHvxZNf7Rz2CvWNNIeNdlXCPv qBeJoebfd67PzSoVERDJwoFjGkceDYVzOfaYj82Ia5Rz/ZGEHJzx66yRGgYxcVrw/QIP LgnMmGPo4ax1K3J1uREezgvdgLaNVUXEWPWNBNL+AdrJjsFdp8MVJm1MEQDjNcNTcxMC ECV52FcmzEd8RUvcvIBpzzgUBuP1bze9YsCXG+tH6IoObJSFwiIQHyQaobwWnsbPE7SG ABCQ== X-Received: by 10.194.9.101 with SMTP id y5mr49782124wja.86.1375276889722; Wed, 31 Jul 2013 06:21:29 -0700 (PDT) Received: from [127.0.1.1] (85.136.70.56.dyn.user.ono.com. [85.136.70.56]) by mx.google.com with ESMTPSA id fd3sm35310033wic.10.2013.07.31.06.21.28 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 31 Jul 2013 06:21:29 -0700 (PDT) Subject: [libnftables PATCH 6/7] test:chain:test json parsing support To: netfilter-devel@vger.kernel.org From: Alvaro Neira Cc: eric@regit.org Date: Wed, 31 Jul 2013 15:21:27 +0200 Message-ID: <20130731132127.29730.40714.stgit@Ph0enix> In-Reply-To: <20130731132051.29730.53717.stgit@Ph0enix> References: <20130731132051.29730.53717.stgit@Ph0enix> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org From: Álvaro Neira Ayuso Test the functions for parsing chains in JSON Support Signed-off-by: Alvaro Neira Ayuso --- 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 -- 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 diff --git a/tests/jsonfiles/11-chain.json b/tests/jsonfiles/11-chain.json new file mode 100644 index 0000000..0e71e8f --- /dev/null +++ b/tests/jsonfiles/11-chain.json @@ -0,0 +1 @@ +{ "chain": {"name": "input","handle": 1,"bytes": 1375696,"packets": 4136,"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..e841032 --- /dev/null +++ b/tests/jsonfiles/12-chain.json @@ -0,0 +1 @@ +{ "chain": {"name": "forward","handle": 2,"bytes": 0,"packets": 0,"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..9967233 --- /dev/null +++ b/tests/jsonfiles/13-chain.json @@ -0,0 +1 @@ +{ "chain": {"name": "output","handle": 3,"bytes": 454786,"packets": 2681,"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..716d022 --- /dev/null +++ b/tests/jsonfiles/14-chain.json @@ -0,0 +1 @@ +{ "chain": {"name": "chain1","handle": 4,"bytes": 0,"packets": 0,"family": "ip","table": "filter","use": 0}} diff --git a/tests/nft-parsing-test.c b/tests/nft-parsing-test.c index 0734f07..e111fd0 100644 --- a/tests/nft-parsing-test.c +++ b/tests/nft-parsing-test.c @@ -24,6 +24,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; @@ -47,6 +48,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;