netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: "Carlos Falgueras García" <carlosfg@riseup.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 2/2 v2 libnftnl] test: Use libnftnl comparators in all tests
Date: Mon, 15 Aug 2016 14:27:32 +0200	[thread overview]
Message-ID: <20160815122732.GA14674@salvia> (raw)
In-Reply-To: <20160815122343.29329-2-carlosfg@riseup.net>

On Mon, Aug 15, 2016 at 02:23:43PM +0200, Carlos Falgueras García wrote:
> Use 'nftnl_expr_cmp' and 'nftnl_rule_cmp' in all tests instead of custom
> comparator for each one. If objects differ both are printed.
>
[...] 
> diff --git a/tests/nft-chain-test.c b/tests/nft-chain-test.c
> index b42fb86..1b6672a 100644
> --- a/tests/nft-chain-test.c
> +++ b/tests/nft-chain-test.c
> @@ -19,43 +19,56 @@
>  
>  static void cmp_nftnl_chain(struct nftnl_chain *a, struct nftnl_chain *b)
>  {
> +	bool test_ok = true;
> +	bool ret;
>  
> -	if (strcmp(nftnl_chain_get_str(a, NFTNL_CHAIN_NAME),
> -		   nftnl_chain_get_str(b, NFTNL_CHAIN_NAME)) != 0)
> -		print_err("Chain name mismatches");
> -	if (strcmp(nftnl_chain_get_str(a, NFTNL_CHAIN_TABLE),
> -		   nftnl_chain_get_str(b, NFTNL_CHAIN_TABLE)) != 0)
> -		print_err("Chain table mismatches");
> -	if (nftnl_chain_get_u32(a, NFTNL_CHAIN_FAMILY) !=
> -	    nftnl_chain_get_u32(b, NFTNL_CHAIN_FAMILY))
> -		print_err("Chain family mismatches");
> -	if (nftnl_chain_get_u32(a, NFTNL_CHAIN_POLICY) !=
> -	    nftnl_chain_get_u32(b, NFTNL_CHAIN_POLICY))
> -		print_err("Chain policy mismatches");
> -	if (nftnl_chain_get_u32(a, NFTNL_CHAIN_HOOKNUM) !=
> -	    nftnl_chain_get_u32(b, NFTNL_CHAIN_HOOKNUM))
> -		print_err("Chain hooknum mismatches");
> -	if (nftnl_chain_get_s32(a, NFTNL_CHAIN_PRIO) !=
> -	    nftnl_chain_get_s32(b, NFTNL_CHAIN_PRIO))
> -		print_err("Chain Prio mismatches");
> -	if (nftnl_chain_get_u32(a, NFTNL_CHAIN_USE) !=
> -	    nftnl_chain_get_u32(b, NFTNL_CHAIN_USE))
> -		print_err("Chain use mismatches");
> -	if (nftnl_chain_get_u64(a, NFTNL_CHAIN_PACKETS) !=
> -	    nftnl_chain_get_u64(b, NFTNL_CHAIN_PACKETS))
> -		print_err("Chain packets mismatches");
> -	if (nftnl_chain_get_u64(a, NFTNL_CHAIN_BYTES) !=
> -	    nftnl_chain_get_u64(b, NFTNL_CHAIN_BYTES))
> -		print_err("Chain bytes mismatches");
> -	if (nftnl_chain_get_u64(a, NFTNL_CHAIN_HANDLE) !=
> -	    nftnl_chain_get_u64(b, NFTNL_CHAIN_HANDLE))
> -		print_err("Chain handle mismatches");
> -	if (strcmp(nftnl_chain_get_str(a, NFTNL_CHAIN_TYPE),
> -		   nftnl_chain_get_str(b, NFTNL_CHAIN_TYPE)) != 0)
> -		print_err("Chain type mismatches");
> -	if (strcmp(nftnl_chain_get_str(a, NFTNL_CHAIN_DEV),
> -		   nftnl_chain_get_str(b, NFTNL_CHAIN_DEV)) != 0)
> -		print_err("Chain device mismatches");

You description says your our aiming at expressions and rules, but
this is also modifying chain.

Please, check this chunk out of this patch, same for other objects
that are not expression and rules. This patch is already quite large
so not need to get this more complicated.

Thanks.

  reply	other threads:[~2016-08-15 12:27 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-11 13:25 [PATCH 1/2, libnftnl] tests: Consolidate printing error utilities Carlos Falgueras García
2016-08-11 13:25 ` [PATCH 2/2, libnftnl] Use libnftnl comparators in all tests Carlos Falgueras García
2016-08-11 23:32   ` Pablo Neira Ayuso
2016-08-12 20:16     ` Carlos Falgueras García
2016-08-15 12:23       ` [PATCH 1/2 v2 libnftnl] tests: Consolidate printing error utilities Carlos Falgueras García
2016-08-15 12:23         ` [PATCH 2/2 v2 libnftnl] test: Use libnftnl comparators in all tests Carlos Falgueras García
2016-08-15 12:27           ` Pablo Neira Ayuso [this message]
2016-08-16 10:30             ` [PATCH 1/3 v3 nft] tests: Consolidate printing error utilities Carlos Falgueras García
2016-08-16 10:30               ` [PATCH 2/3 v3 nft] tests: Use libnftnl comparators in all tests Carlos Falgueras García
2016-08-16 11:58                 ` Pablo Neira Ayuso
2016-08-16 10:30               ` [PATCH 3/3 v3 nft] tests: Elimine static variable 'test_ok' Carlos Falgueras García
2016-08-12 20:17     ` [PATCH 1/4, V2, libnftnl] tests: Fix segfaults due outbound access Carlos Falgueras García
2016-08-12 20:17       ` [PATCH 2/4, V2, libnftnl] tests: Fix wrong expression creation Carlos Falgueras García
2016-08-13 10:25         ` Pablo Neira Ayuso
2016-08-12 20:17       ` [PATCH 3/4, V2, libnftnl] tests: Consolidate printing error utilities Carlos Falgueras García
2016-08-12 20:17       ` [PATCH 4/4, V2, libnftnl] tests: Use libnftnl comparators in all tests Carlos Falgueras García
2016-08-13 10:12       ` [PATCH 1/4, V2, libnftnl] tests: Fix segfaults due outbound access Pablo Neira Ayuso
2016-08-13 15:25         ` Carlos Falgueras García
2016-08-15  9:12           ` Pablo Neira Ayuso
2016-08-15 10:27             ` [PATCH 1/2 libnftnl] expr: Improve bound checking in stringification functions Carlos Falgueras García
2016-08-15 10:27               ` [PATCH 2/2 libnftnl] expr: cmp: Use cmp2str() instead of directly access to array Carlos Falgueras García
2016-08-15 10:32                 ` Pablo Neira Ayuso
2016-08-15 10:51                   ` [PATCH 1/2 libnftnl] utils: Fix out of bound access in nftnl_family2str Carlos Falgueras García
2016-08-15 10:51                     ` [PATCH 2/2 libnfntl] expr: cmp: Use cmp2str() instead of directly access to array Carlos Falgueras García
2016-08-15 11:49                       ` Pablo Neira Ayuso
2016-08-15 11:03                     ` [PATCH 1/2 libnftnl] utils: Fix out of bound access in nftnl_family2str Pablo Neira Ayuso
2016-08-15 11:45                       ` Carlos Falgueras García
2016-08-15 11:46                         ` Pablo Neira Ayuso
2016-08-15 10:32               ` [PATCH 1/2 libnftnl] expr: Improve bound checking in stringification functions Pablo Neira Ayuso
2016-08-11 23:26 ` [PATCH 1/2, libnftnl] tests: Consolidate printing error utilities Pablo Neira Ayuso
2016-08-12 20:16   ` Carlos Falgueras García

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=20160815122732.GA14674@salvia \
    --to=pablo@netfilter.org \
    --cc=carlosfg@riseup.net \
    --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).