[PATCH] add some test cases to improve code coverage

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

 



From: shixuantong <tongxiaoge1001@xxxxxxx>

---
 tests/nft-rule-test.c  | 3 +++
 tests/nft-table-test.c | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/tests/nft-rule-test.c b/tests/nft-rule-test.c
index 3a92223..8cbd961 100644
--- a/tests/nft-rule-test.c
+++ b/tests/nft-rule-test.c
@@ -106,6 +106,9 @@ int main(int argc, char *argv[])
 
 	cmp_nftnl_rule(a,b);
 
+	nftnl_rule_unset(a, NFTNL_RULE_TABLE);
+	nftnl_rule_unset(a, NFTNL_RULE_CHAIN);
+	nftnl_rule_unset(a, NFTNL_RULE_USERDATA);
 	nftnl_rule_free(a);
 	nftnl_rule_free(b);
 	if (!test_ok)
diff --git a/tests/nft-table-test.c b/tests/nft-table-test.c
index 53cf3d1..61becd4 100644
--- a/tests/nft-table-test.c
+++ b/tests/nft-table-test.c
@@ -35,6 +35,12 @@ static void cmp_nftnl_table(struct nftnl_table *a, struct nftnl_table *b)
 	if (nftnl_table_get_u32(a, NFTNL_TABLE_FAMILY) !=
 	    nftnl_table_get_u32(b, NFTNL_TABLE_FAMILY))
 		print_err("table family mismatches");
+	if (nftnl_table_get_u64(a, NFTNL_TABLE_HANDLE) !=
+            nftnl_table_get_u64(b, NFTNL_TABLE_HANDLE))
+                print_err("tabke handle mismatches");
+	if (strcmp(nftnl_table_get_str(a, NFTNL_TABLE_USERDATA),
+                   nftnl_table_get_str(b, NFTNL_TABLE_USERDATA)) != 0)
+                print_err("table userdata mismatches");
 }
 
 int main(int argc, char *argv[])
@@ -53,6 +59,8 @@ int main(int argc, char *argv[])
 	nftnl_table_set_str(a, NFTNL_TABLE_NAME, "test");
 	nftnl_table_set_u32(a, NFTNL_TABLE_FAMILY, AF_INET);
 	nftnl_table_set_u32(a, NFTNL_TABLE_FLAGS, 0);
+	nftnl_table_set_u64(a, NFTNL_TABLE_HANDLE, 0x12345678);
+	nftnl_table_set_str(a, NFTNL_TABLE_USERDATA, "test for userdata");
 
 	/* cmd extracted from include/linux/netfilter/nf_tables.h */
 	nlh = nftnl_nlmsg_build_hdr(buf, NFT_MSG_NEWTABLE, AF_INET, 0, 1234);
-- 
2.33.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux