mirror of
https://git.yoctoproject.org/poky
synced 2026-05-02 18:32:15 +02:00
add CVE_VERSION_SUFFIX to indicate the version suffix type, currently works in two value, "alphabetical" if the version string uses single alphabetical character suffix as incremental release, blank to not consider the unidentified suffixes. This can be expand when more suffix pattern identified. refactor cve_check.Version class to use functools and add parameter to handle suffix condition. Also update testcases to cover new changes. (From OE-Core rev: 37a40c30709bf80c74948f47361b2be2c646c9d8) Signed-off-by: Lee Chee Yang <chee.yang.lee@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 5dfd5ad5144708b474ef31eaa89a846c57be8ac0) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
37 lines
2.0 KiB
Python
37 lines
2.0 KiB
Python
from oe.cve_check import Version
|
|
from oeqa.selftest.case import OESelftestTestCase
|
|
|
|
class CVECheck(OESelftestTestCase):
|
|
|
|
def test_version_compare(self):
|
|
result = Version("100") > Version("99")
|
|
self.assertTrue( result, msg="Failed to compare version '100' > '99'")
|
|
result = Version("2.3.1") > Version("2.2.3")
|
|
self.assertTrue( result, msg="Failed to compare version '2.3.1' > '2.2.3'")
|
|
result = Version("2021-01-21") > Version("2020-12-25")
|
|
self.assertTrue( result, msg="Failed to compare version '2021-01-21' > '2020-12-25'")
|
|
result = Version("1.2-20200910") < Version("1.2-20200920")
|
|
self.assertTrue( result, msg="Failed to compare version '1.2-20200910' < '1.2-20200920'")
|
|
|
|
result = Version("1.0") >= Version("1.0beta")
|
|
self.assertTrue( result, msg="Failed to compare version '1.0' >= '1.0beta'")
|
|
result = Version("1.0-rc2") > Version("1.0-rc1")
|
|
self.assertTrue( result, msg="Failed to compare version '1.0-rc2' > '1.0-rc1'")
|
|
result = Version("1.0.alpha1") < Version("1.0")
|
|
self.assertTrue( result, msg="Failed to compare version '1.0.alpha1' < '1.0'")
|
|
result = Version("1.0_dev") <= Version("1.0")
|
|
self.assertTrue( result, msg="Failed to compare version '1.0_dev' <= '1.0'")
|
|
|
|
# ignore "p1" and "p2", so these should be equal
|
|
result = Version("1.0p2") == Version("1.0p1")
|
|
self.assertTrue( result ,msg="Failed to compare version '1.0p2' to '1.0p1'")
|
|
# ignore the "b" and "r"
|
|
result = Version("1.0b") == Version("1.0r")
|
|
self.assertTrue( result ,msg="Failed to compare version '1.0b' to '1.0r'")
|
|
|
|
# consider the trailing alphabet as patched level when comparing
|
|
result = Version("1.0b","alphabetical") < Version("1.0r","alphabetical")
|
|
self.assertTrue( result ,msg="Failed to compare version with suffix '1.0b' < '1.0r'")
|
|
result = Version("1.0b","alphabetical") > Version("1.0","alphabetical")
|
|
self.assertTrue( result ,msg="Failed to compare version with suffix '1.0b' > '1.0'")
|