!35 [sync] PR-34: 添加一些测试场景提升代码测试覆盖率
From: @openeuler-sync-bot Reviewed-by: @hubin95 Signed-off-by: @hubin95
This commit is contained in:
commit
f64efb1ded
53
add-some-test-cases-to-improve-code-coverage.patch
Normal file
53
add-some-test-cases-to-improve-code-coverage.patch
Normal file
@ -0,0 +1,53 @@
|
||||
From 0ddcddb289c6355d6f533aeceb6895a38fcf0a0f Mon Sep 17 00:00:00 2001
|
||||
From: shixuantong <shixuantong1@huawei.com>
|
||||
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
|
||||
|
||||
@ -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 <shixuantong1@huawei.com> - 1.2.0-6
|
||||
- add some test cases to improve code coverage
|
||||
|
||||
* Mon Jun 05 2023 shixuantong <shixuantong1@huawei.com> - 1.2.0-5
|
||||
- Do not leave free'd expr_list elements in place and add test cases
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user