* [PATCH nft] tests: py: replace calls to cmp()
@ 2019-06-19 13:38 Eric Garver
0 siblings, 0 replies; only message in thread
From: Eric Garver @ 2019-06-19 13:38 UTC (permalink / raw)
To: Pablo Neira Ayuso, shekhar sharma; +Cc: netfilter-devel
cmp() is not in python3.
Signed-off-by: Eric Garver <eric@garver.life>
---
tests/py/nft-test.py | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
index 4da6fa650f6d..c712c1d9ebef 100755
--- a/tests/py/nft-test.py
+++ b/tests/py/nft-test.py
@@ -488,12 +488,11 @@ def set_check_element(rule1, rule2):
'''
Check if element exists in anonymous sets.
'''
- ret = -1
pos1 = rule1.find("{")
pos2 = rule2.find("{")
- if (cmp(rule1[:pos1], rule2[:pos2]) != 0):
- return ret;
+ if (rule1[:pos1] != rule2[:pos2]):
+ return False
end1 = rule1.find("}")
end2 = rule2.find("}")
@@ -503,13 +502,12 @@ def set_check_element(rule1, rule2):
list2 = (rule2[pos2 + 1:end2].replace(" ", "")).split(",")
list1.sort()
list2.sort()
- if cmp(list1, list2) == 0:
- ret = 0
+ if list1 != list2:
+ return False
- if ret != 0:
- return ret
+ return rule1[end1:] == rule2[end2:]
- return cmp(rule1[end1:], rule2[end2:])
+ return False
def obj_add(o, test_result, filename, lineno):
@@ -842,8 +840,8 @@ def rule_add(rule, filename, lineno, force_all_family_option, filename_path):
if rule_output.rstrip() != teoric_exit.rstrip():
if rule[0].find("{") != -1: # anonymous sets
- if set_check_element(teoric_exit.rstrip(),
- rule_output.rstrip()) != 0:
+ if not set_check_element(teoric_exit.rstrip(),
+ rule_output.rstrip()):
warning += 1
retest_output = True
print_differences_warning(filename, lineno,
--
2.20.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-06-19 13:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-19 13:38 [PATCH nft] tests: py: replace calls to cmp() Eric Garver
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).