tests: tests for libnftables
PATCH v4 1/1 tests: tests for libnftables
Makefile and tests files for libnftables.
In this patch, I create a initial object 'a' and I set a testing values. Then, I convert this object in a Netlink message.
Quoted 1 line
From this Netlink message, I parse that (through
nft_table_nlmsg_parse
function) in 'b' objetc.
Thus, we make sure that object transformations are correct.
---
v2: fix writing erorres in messages that I unintentionally added in v1 that were spotted by Phil Oester.
Fix a multiline comment error. The nft-ruleset-test is not included in this patch, also, I delete it in the tests/test-script.sh. Those errors were spotted by Arturo Borrero.
v3: I fix some initialization errors, I remove unnecessary comments and I include a copyright notice. Those errors were spotted by Artulo Borreo.
v4: I fix some initialization errors.
Also, I add a global variable 'test_ok' to check if there are some errors in the test. This way, I make sure that the test is run at all and all memory is released properly.
tests/Makefile.am | 82 ++++++++++++++++++++++++++- tests/nft-chain-test.c | 106 +++++++++++++++++++++++++++++++++++ tests/nft-expr_bitwise-test.c | 115 ++++++++++++++++++++++++++++++++++++++ tests/nft-expr_byteorder-test.c | 107 ++++++++++++++++++++++++++++++++++++ tests/nft-expr_cmp-test.c | 101 ++++++++++++++++++++++++++++++++++ tests/nft-expr_counter-test.c | 93 +++++++++++++++++++++++++++++++ tests/nft-expr_ct-test.c | 97 ++++++++++++++++++++++++++++++++ tests/nft-expr_exthdr-test.c | 101 ++++++++++++++++++++++++++++++++++ tests/nft-expr_immediate-test.c | 111 +++++++++++++++++++++++++++++++++++++ tests/nft-expr_limit-test.c | 96 ++++++++++++++++++++++++++++++++ tests/nft-expr_log-test.c | 101 ++++++++++++++++++++++++++++++++++ tests/nft-expr_lookup-test.c | 104 +++++++++++++++++++++++++++++++++++ tests/nft-expr_match-test.c | 119 ++++++++++++++++++++++++++++++++++++++++ tests/nft-expr_meta-test.c | 94 +++++++++++++++++++++++++++++++ tests/nft-expr_nat-test.c | 112 +++++++++++++++++++++++++++++++++++++ tests/nft-expr_payload-test.c | 103 ++++++++++++++++++++++++++++++++++ tests/nft-expr_reject-test.c | 96 ++++++++++++++++++++++++++++++++ tests/nft-expr_target-test.c | 118 +++++++++++++++++++++++++++++++++++++++ tests/nft-rule-test.c | 86 +++++++++++++++++++++++++++++ tests/nft-set-test.c | 88 +++++++++++++++++++++++++++++ tests/nft-table-test.c | 74 +++++++++++++++++++++++++ tests/test-script.sh | 20 +++++++ 22 files changed, 2123 insertions(+), 1 deletion(-) create mode 100644 tests/nft-chain-test.c create mode 100644 tests/nft-expr_bitwise-test.c create mode 100644 tests/nft-expr_byteorder-test.c create mode 100644 tests/nft-expr_cmp-test.c create mode 100644 tests/nft-expr_counter-test.c create mode 100644 tests/nft-expr_ct-test.c create mode 100644 tests/nft-expr_exthdr-test.c create mode 100644 tests/nft-expr_immediate-test.c create mode 100644 tests/nft-expr_limit-test.c create mode 100644 tests/nft-expr_log-test.c create mode 100644 tests/nft-expr_lookup-test.c create mode 100644 tests/nft-expr_match-test.c create mode 100644 tests/nft-expr_meta-test.c create mode 100644 tests/nft-expr_nat-test.c create mode 100644 tests/nft-expr_payload-test.c create mode 100644 tests/nft-expr_reject-test.c create mode 100644 tests/nft-expr_target-test.c create mode 100644 tests/nft-rule-test.c create mode 100644 tests/nft-set-test.c create mode 100644 tests/nft-table-test.c create mode 100755 tests/test-script.sh
tests/Makefile.am +81 -1
@@ -1,6 +1,86 @@ include $(top_srcdir)/Make_global.am -check_PROGRAMS = nft-parsing-test +check_PROGRAMS = nft-parsing-test \ + nft-table-test \ + nft-chain-test \ + nft-rule-test \ + nft-set-test \ + nft-expr_bitwise-test \ + nft-expr_byteorder-test \ + nft-expr_counter-test \ + nft-expr_cmp-test \ + nft-expr_ct-test \ + nft-expr_exthdr-test \ + nft-expr_immediate-test \ + nft-expr_limit-test \ + nft-expr_lookup-test \ + nft-expr_log-test \ + nft-expr_match-test \ + nft-expr_meta-test \ + nft-expr_nat-test \ + nft-expr_payload-test \ + nft-expr_reject-test \ + nft-expr_target-test nft_parsing_test_SOURCES = nft-parsing-test.c nft_parsing_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} ${LIBXML_LIBS} ${LIBJSON_LIBS} + +nft_table_test_SOURCES = nft-table-test.c +nft_table_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_chain_test_SOURCES = nft-chain-test.c +nft_chain_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_rule_test_SOURCES = nft-rule-test.c +nft_rule_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_set_test_SOURCES = nft-set-test.c +nft_set_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_bitwise_test_SOURCES = nft-expr_bitwise-test.c +nft_expr_bitwise_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_byteorder_test_SOURCES = nft-expr_byteorder-test.c +nft_expr_byteorder_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_cmp_test_SOURCES = nft-expr_cmp-test.c +nft_expr_cmp_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_counter_test_SOURCES = nft-expr_counter-test.c +nft_expr_counter_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_exthdr_test_SOURCES = nft-expr_exthdr-test.c +nft_expr_exthdr_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_ct_test_SOURCES = nft-expr_ct-test.c +nft_expr_ct_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_immediate_test_SOURCES = nft-expr_counter-test.c +nft_expr_immediate_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_limit_test_SOURCES = nft-expr_limit-test.c +nft_expr_limit_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_lookup_test_SOURCES = nft-expr_limit-test.c +nft_expr_lookup_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_log_test_SOURCES = nft-expr_log-test.c +nft_expr_log_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_match_test_SOURCES = nft-expr_match-test.c +nft_expr_match_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_meta_test_SOURCES = nft-expr_meta-test.c +nft_expr_meta_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_nat_test_SOURCES = nft-expr_nat-test.c +nft_expr_nat_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_payload_test_SOURCES = nft-expr_payload-test.c +nft_expr_payload_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_reject_test_SOURCES = nft-expr_reject-test.c +nft_expr_reject_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS} + +nft_expr_target_test_SOURCES = nft-expr_target-test.c +nft_expr_target_test_LDADD = ../src/libnftables.la ${LIBMNL_LIBS}
tests/nft-chain-test.c new file +106 -0
106 lines not on this page · raw message
tests/nft-expr_bitwise-test.c new file +115 -0
115 lines not on this page · raw message
tests/nft-expr_byteorder-test.c new file +107 -0
107 lines not on this page · raw message
tests/nft-expr_cmp-test.c new file +101 -0
101 lines not on this page · raw message
tests/nft-expr_counter-test.c new file +93 -0
93 lines not on this page · raw message
tests/nft-expr_ct-test.c new file +97 -0
97 lines not on this page · raw message
tests/nft-expr_exthdr-test.c new file +101 -0
101 lines not on this page · raw message
tests/nft-expr_immediate-test.c new file +111 -0
111 lines not on this page · raw message
tests/nft-expr_limit-test.c new file +96 -0
96 lines not on this page · raw message
tests/nft-expr_log-test.c new file +101 -0
101 lines not on this page · raw message
tests/nft-expr_lookup-test.c new file +104 -0
104 lines not on this page · raw message
tests/nft-expr_match-test.c new file +119 -0
119 lines not on this page · raw message
tests/nft-expr_meta-test.c new file +94 -0
94 lines not on this page · raw message
tests/nft-expr_nat-test.c new file +112 -0
112 lines not on this page · raw message
tests/nft-expr_payload-test.c new file +103 -0
103 lines not on this page · raw message
tests/nft-expr_reject-test.c new file +96 -0
96 lines not on this page · raw message
tests/nft-expr_target-test.c new file +118 -0
118 lines not on this page · raw message
tests/nft-rule-test.c new file +86 -0
86 lines not on this page · raw message
tests/nft-set-test.c new file +88 -0
88 lines not on this page · raw message
tests/nft-table-test.c new file +74 -0
74 lines not on this page · raw message
tests/test-script.sh new file +20 -0
@@ -0,0 +1,20 @@ +./nft-chain-test +./nft-expr_bitwise-test +./nft-expr_byteorder-test +./nft-expr_cmp-test +./nft-expr_counter-test +./nft-expr_ct-test +./nft-expr_exthdr-test +./nft-expr_immediate-test +./nft-expr_limit-test +./nft-expr_log-test +./nft-expr_lookup-test +./nft-expr_match-test +./nft-expr_meta-test +./nft-expr_nat-test +./nft-expr_payload-test +./nft-expr_reject-test +./nft-expr_target-test +./nft-rule-test +./nft-set-test +./nft-table-test
Signature · 1 line
1.8.4.rc3
Quoted 9 lines · Ana Rey
Makefileand tests files for libnftables.In this patch, I create a initial object 'a' and I set a testing values. Then, I convert this object in a Netlink message.
From this Netlink message, I parse that (through
nft_table_nlmsg_parsefunction) in 'b' objetc.Thus, we make sure that object transformations are correct.
I have renamed the 'die' functions to 'print_err' as your tests don't seem to die anymore if we hit a problem, no problem it was fast :).
Applied, good job Ana.