diff --git a/add-some-test-cases-to-improve-code-coverage.patch b/add-some-test-cases-to-improve-code-coverage.patch new file mode 100644 index 0000000..dab2b5f --- /dev/null +++ b/add-some-test-cases-to-improve-code-coverage.patch @@ -0,0 +1,53 @@ +From 0ddcddb289c6355d6f533aeceb6895a38fcf0a0f Mon Sep 17 00:00:00 2001 +From: shixuantong +Date: Mon, 5 Jun 2023 16:31:58 +0800 +Subject: [PATCH] add some test cases to improve code coverage + +--- + 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 c48381e..8186752 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 1031ffe..ab111ba 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("tabke 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_table_nlmsg_build_hdr(buf, NFT_MSG_NEWTABLE, AF_INET, 0, +-- +2.27.0 + diff --git a/libnftnl.spec b/libnftnl.spec index 8df7380..5ade28c 100644 --- a/libnftnl.spec +++ b/libnftnl.spec @@ -1,6 +1,6 @@ Name: libnftnl Version: 1.2.0 -Release: 5 +Release: 6 Summary: Library for low-level interaction with nftables Netlink's API over libmnl License: GPLv2+ URL: http://netfilter.org/projects/libnftnl/ @@ -12,6 +12,8 @@ Patch6002: backport-libnftnl-Fix-res_id-byte-order.patch Patch6003: backport-set-Do-not-leave-free-d-expr_list-elements-in-place.patch Patch6004: backport-tests-nft-rule-test-Add-test-cases-to-improve-code-c.patch +Patch9000: add-some-test-cases-to-improve-code-coverage.patch + BuildRequires: libmnl-devel jansson-devel gcc # replace old libnftables package @@ -57,6 +59,9 @@ make %{?_smp_mflags} check %{_includedir}/libnftnl %changelog +* Mon Jun 05 2023 shixuantong - 1.2.0-6 +- add some test cases to improve code coverage + * Mon Jun 05 2023 shixuantong - 1.2.0-5 - Do not leave free'd expr_list elements in place and add test cases