]> git.proxmox.com Git - mirror_frr.git/commitdiff
topotest: fix a regression in version_cmp
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Tue, 7 Nov 2017 23:17:15 +0000 (21:17 -0200)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 28 Nov 2018 01:22:12 +0000 (20:22 -0500)
It was found a regression on an edge case when the second number in the
comparison was (at least) 2 numbers longer the comparison would fail
with a wrong return value. It succeeded for some cases because the
first comparison in the exception was correct, but not the second.

tests/topotests/lib/test/test_version.py [changed mode: 0644->0755]
tests/topotests/lib/topotest.py

old mode 100644 (file)
new mode 100755 (executable)
index 4bb1c0b..9204ac2
@@ -78,3 +78,10 @@ def test_invalid_versions():
         assert version_cmp(curver, badver2)
         assert version_cmp(curver, badver3)
         assert version_cmp(curver, badver4)
+
+def test_regression_1():
+    """
+    Test regression on the following type of comparison: '3.0.2' > '3'
+    Expected result is 1.
+    """
+    assert version_cmp('3.0.2', '3') == 1
index 0e0a1e8876d62c280bf8fe694d2a58ac6df3e442..ccdea83393ed61d5ed31d716f558d548b91ccb9d 100644 (file)
@@ -291,7 +291,7 @@ def version_cmp(v1, v2):
             while v1g:
                 v1n = int(v1g.pop())
                 if v1n > 0:
-                    return -1
+                    return 1
             break
 
         if v1n > v2n: