Fixed OpenSSH patch version comparison. (#74)

This commit is contained in:
Joe Testa 2020-10-19 18:49:52 -04:00
parent 2bb31b306f
commit 83d8014a50
2 changed files with 9 additions and 7 deletions

View File

@ -83,8 +83,8 @@ class Software:
if not re.match(r'^test\d.*$', spatch):
spatch = 'z{}'.format(spatch)
elif self.product == Product.OpenSSH:
mx1 = re.match(r'^p\d(.*)', opatch)
mx2 = re.match(r'^p\d(.*)', spatch)
mx1 = re.match(r'^p(\d).*', opatch)
mx2 = re.match(r'^p(\d).*', spatch)
if not (bool(mx1) and bool(mx2)):
if mx1 is not None:
opatch = mx1.group(1)

View File

@ -136,13 +136,15 @@ class TestVersionCompare:
s2 = self.get_openssh_software('2.1.1p2')
assert s1.compare_version(s1) == 0
assert s2.compare_version(s2) == 0
assert s1.compare_version('2.1.1p1') == 0
assert s1.compare_version('2.1.1p2') == 0
assert s2.compare_version('2.1.1') == 0
assert s1.compare_version('2.1.1') == 0
assert s2.compare_version('2.1.1p2') == 0
assert s1.compare_version('2.1.1p1') != 0
assert s1.compare_version('2.1.1p2') != 0
assert s2.compare_version('2.1.1') != 0
assert s2.compare_version('2.1.1p1') > 0
assert s2.compare_version('2.1.1p3') < 0
assert s1.compare_version(s2) == 0
assert s2.compare_version(s1) == 0
assert s1.compare_version(s2) != 0
assert s2.compare_version(s1) != 0
def test_openbsd_compare_version_sequential(self):
versions = []