[PATCH v3 1/2 libnetfilter_conntrack] qa: update cmp ATTR_ZONE size mark and zone

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 qa/test_api.c | 102 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 78 insertions(+), 24 deletions(-)

diff --git a/qa/test_api.c b/qa/test_api.c
index 91b3dbf..1335b23 100644
--- a/qa/test_api.c
+++ b/qa/test_api.c
@@ -243,17 +243,17 @@ static int test_nfct_cmp_api_single(struct nf_conntrack *ct1,
 	return 0;
 }
 
-static int test_cmp_attr32(int attr, bool at1, bool at2,
-			   uint32_t v1, uint32_t v2, unsigned int flags)
+static int test_cmp_attr16(int attr, bool at1, bool at2,
+			   uint16_t v1, uint16_t v2, unsigned int flags)
 {
 	struct nf_conntrack *ct1 = nfct_new();
 	struct nf_conntrack *ct2 = nfct_new();
 	int ret;
 
 	if (at1)
-		nfct_set_attr_u32(ct1, attr, v1);
+		nfct_set_attr_u16(ct1, attr, v1);
 	if (at2)
-		nfct_set_attr_u32(ct2, attr, v2);
+		nfct_set_attr_u16(ct2, attr, v2);
 
 	ret = nfct_cmp(ct1, ct2, NFCT_CMP_ALL | flags);
 
@@ -264,26 +264,80 @@ static int test_cmp_attr32(int attr, bool at1, bool at2,
 }
 static void test_nfct_cmp_attr(int attr)
 {
-	assert(test_cmp_attr32(ATTR_ZONE, false, false, 0, 0, 0) == 1);
-	assert(test_cmp_attr32(ATTR_ZONE, true, true, 0, 0, 0) == 1);
-	assert(test_cmp_attr32(ATTR_ZONE, true, true, 1, 1, 0) == 1);
-
-	/* This compare should be true */
-	assert(test_cmp_attr32(ATTR_ZONE, false, true, 0, 1, 0) == 1);
-
-	assert(test_cmp_attr32(ATTR_ZONE, true, true, 1, 1, NFCT_CMP_STRICT) == 1);
-
-	assert(test_cmp_attr32(ATTR_ZONE, true, false, 0, 0, NFCT_CMP_STRICT) == 1);
-	assert(test_cmp_attr32(ATTR_ZONE, false, true, 0, 0, NFCT_CMP_STRICT) == 1);
-
-	assert(test_cmp_attr32(ATTR_ZONE, false, true, 0, 1, NFCT_CMP_STRICT) == 0);
-
-	assert(test_cmp_attr32(ATTR_ZONE, false, true, 0, 1, NFCT_CMP_MASK) == 1);
-	assert(test_cmp_attr32(ATTR_ZONE, true, true, 0, 1, NFCT_CMP_MASK) == 0);
-
-	assert(test_cmp_attr32(ATTR_ZONE, true, false, 0, 0, NFCT_CMP_MASK) == 1);
-
-	assert(test_cmp_attr32(ATTR_ZONE, true, false, 1, 0, NFCT_CMP_MASK) == 0);
+	unsigned int flags = 0;
+
+	/* 0000, 1000, 1100, 0010, 1010... */
+	/*		       attr       at1    at2    v1	v2 */
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	0,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, true,	 false,	0,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	0,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, true,	 true,	0,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	1,	0,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	1,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	1,	0,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	1,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	0,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	0,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	0,	1,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	0,	1,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	1,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	1,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	1,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	1,	1,	flags) == 1);
+
+	flags = NFCT_CMP_STRICT;
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	0,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, true,	 false,	0,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	0,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, true,	 true,	0,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	1,	0,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	1,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	1,	0,	flags) == 0); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	1,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	0,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	0,	1,	flags) == 0); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	0,	1,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	0,	1,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	1,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	1,	1,	flags) == 0); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	1,	1,	flags) == 0); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	1,	1,	flags) == 1);
+
+	flags = NFCT_CMP_MASK;
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	0,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, true,	 false,	0,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	0,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, true,	 true,	0,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	1,	0,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	1,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	1,	0,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	1,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	0,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	0,	1,	flags) == 0); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	0,	1,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	0,	1,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	1,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	1,	1,	flags) == 0); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	1,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	1,	1,	flags) == 1);
+
+	flags = NFCT_CMP_STRICT|NFCT_CMP_MASK;
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	0,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, true,	 false,	0,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	0,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, true,	 true,	0,	0,	flags) == 1);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	1,	0,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	1,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	1,	0,	flags) == 0); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	1,	0,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	0,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	0,	1,	flags) == 0); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	0,	1,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	0,	1,	flags) == 0);
+	assert(test_cmp_attr16(ATTR_ZONE, false, false,	1,	1,	flags) == 1); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  false,	1,	1,	flags) == 0); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, false, true,	1,	1,	flags) == 0); /* verbose */
+	assert(test_cmp_attr16(ATTR_ZONE, true,  true,	1,	1,	flags) == 1);
 }
 
 static void test_nfct_cmp_api(struct nf_conntrack *ct1, struct nf_conntrack *ct2)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux