Skip to content

Commit 7012e25

Browse files
committed
ngci/tests: Add helper for testing image versions
1 parent 5e01576 commit 7012e25

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

etc/tests.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,37 @@ def clang_image(images):
2525
return None
2626

2727

28+
# Check that `image` is at least as new as one of the images
29+
# in the `versions` list.
30+
def image_at_least(image, versions):
31+
# Split the image into the name and optional version number
32+
parts = image.split('@')
33+
iname = parts[0]
34+
if len(parts) == 2:
35+
iversion = int(parts[1].replace('.', ''))
36+
else:
37+
iversion = None
38+
39+
for version in versions:
40+
vname, vver = version.split('@')
41+
42+
# If the names don't match continue
43+
if iname != vname:
44+
continue
45+
46+
# If the input image has no version it's implicitly the latest, so
47+
# assume it's sufficiently new.
48+
if iversion is None:
49+
return True
50+
51+
# Compare the version numbers
52+
vver = int(vver.replace('.', ''))
53+
if iversion >= vver:
54+
return True
55+
56+
return False
57+
58+
2859
def qemu_coverage(args, suite=None):
2960
images = std_images(args)
3061
if suite is None:

0 commit comments

Comments
 (0)