From: Jeremy Sowden <jeremy@azazel.net>
To: Netfilter Devel <netfilter-devel@vger.kernel.org>
Subject: [iptables PATCH 3/4] tests: support explicit variant test result
Date: Sat, 12 Feb 2022 16:58:31 +0000 [thread overview]
Message-ID: <20220212165832.2452695-4-jeremy@azazel.net> (raw)
In-Reply-To: <20220212165832.2452695-1-jeremy@azazel.net>
Now that there are more than two test results, add support for
explicitly indicating which result to expect if the variants differ.
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
---
iptables-test.py | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/iptables-test.py b/iptables-test.py
index 4a587a29c823..6acaa82228fa 100755
--- a/iptables-test.py
+++ b/iptables-test.py
@@ -186,22 +186,23 @@ def execute_cmd(cmd, filename, lineno):
log_file.flush()
# generic check for segfaults
- if ret == -11:
+ if ret == -11:
reason = "command segfaults: " + cmd
print_error(reason, filename, lineno)
return ret
-def variant_res(res, variant):
+def variant_res(res, variant, alt_res=None):
'''
Adjust expected result with given variant
If expected result is scoped to a variant, the other one yields a different
- result. Therefore map @res to itself if given variant is current, invert it
- otherwise.
+ result. Therefore map @res to itself if given variant is current, use the
+ alternate result, @alt_res, if specified, invert @res otherwise.
:param res: expected result from test spec ("OK", "FAIL" or "NOMATCH")
:param variant: variant @res is scoped to by test spec ("NFT" or "LEGACY")
+ :param alt_res: optional expected result for the alternate variant.
'''
variant_executable = {
"NFT": "xtables-nft-multi",
@@ -215,6 +216,8 @@ def variant_res(res, variant):
if variant_executable[variant] == EXECUTABLE:
return res
+ if alt_res is not None:
+ return alt_res
return res_inverse[res]
@@ -312,7 +315,12 @@ def run_test_file(filename, netns):
res = item[2].rstrip()
if len(item) > 3:
- res = variant_res(res, item[3].rstrip())
+ variant = item[3].rstrip()
+ if len(item) > 4:
+ alt_res = item[4].rstrip()
+ else:
+ alt_res = None
+ res = variant_res(res, variant, alt_res)
ret = run_test(iptables, rule, rule_save,
res, filename, lineno + 1, netns)
--
2.34.1
next prev parent reply other threads:[~2022-02-12 16:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-12 16:58 [iptables PATCH 0/4] Re-enable NFLOG tests Jeremy Sowden
2022-02-12 16:58 ` [iptables PATCH 1/4] tests: iptables-test: rename variable Jeremy Sowden
2022-02-12 16:58 ` [iptables PATCH 2/4] tests: add `NOMATCH` test result Jeremy Sowden
2022-02-14 10:01 ` Phil Sutter
2022-02-20 13:10 ` Jeremy Sowden
2022-02-22 10:09 ` Phil Sutter
2022-02-12 16:58 ` Jeremy Sowden [this message]
2022-02-12 16:58 ` [iptables PATCH 4/4] tests: NFLOG: enable `--nflog-range` tests Jeremy Sowden
2022-02-13 21:28 ` [iptables PATCH 0/4] Re-enable NFLOG tests Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220212165832.2452695-4-jeremy@azazel.net \
--to=jeremy@azazel.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).