[PATCH nft] tests: py: replace calls to cmp()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



cmp() is not in python3.

Signed-off-by: Eric Garver <eric@xxxxxxxxxxx>
---
 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




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux