Skip to content

Commit

Permalink
Update pytest mark on TestExtractVmImage
Browse files Browse the repository at this point in the history
Signed-off-by: Jono Yang <jyang@nexb.com>
  • Loading branch information
JonoYang committed May 15, 2024
1 parent b2bf13a commit 5429e9c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/test_vmimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,31 @@
from extractcode import vmimage


@pytest.mark.skipif(not on_linux, reason='Only linux supports image extraction')
def get_etc_os_release_info(os_release_path='/etc/os-release'):
cfg_kv = {}
with open(os_release_path) as f:
for line in f:
split_line = line.split('=')
if not split_line:
continue
k = split_line[0].strip()
v = split_line[-1].strip()
cfg_kv[k] = v
return cfg_kv


def is_on_ubuntu_22():
if not on_linux:
return False
os_release_info = get_etc_os_release_info()
return os_release_info['ID'] == 'ubuntu' and '22' in os_release_info['VERSION_ID']

on_ubuntu_22 = is_on_ubuntu_22()

del is_on_ubuntu_22


@pytest.mark.skipif(not on_linux or on_ubuntu_22, reason='Only linux supports image extraction, kernel is unreadable on Ubuntu 22.04')
class TestExtractVmImage(BaseArchiveTestCase):
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')

Expand Down

0 comments on commit 5429e9c

Please sign in to comment.