Skip to content

Commit

Permalink
Add skip for when kernel is not readable
Browse files Browse the repository at this point in the history
Signed-off-by: ArkaprabhaChakraborty <[email protected]>
  • Loading branch information
ArkaprabhaChakraborty committed Jan 25, 2025
1 parent db9dd08 commit 54e8179
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_vmimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,24 @@

from extractcode import vmimage

def is_kernel_readable():
"""
Check if the kernel is readable by testing access to /boot/vmlinuz-*.
Return True if readable, False otherwise.
"""
if not os.name == "posix":
return False # Skip on non-Linux systems

try:
kernels = list(Path("/boot").glob("vmlinuz-*"))
if not kernels:
return False # No kernel found
return all(os.access(kern, os.R_OK) for kern in kernels)
except Exception:
return False # Kernel check failed

@pytest.mark.skipif(not on_linux, reason='Only linux supports image extraction')
@pytest.mark.skipif(not is_kernel_readable(), reason="Kernel not readable")
class TestExtractVmImage(BaseArchiveTestCase):
test_data_dir = os.path.join(os.path.dirname(__file__), 'data')

Expand Down

0 comments on commit 54e8179

Please sign in to comment.