Skip to content

Further preparing the testing infrastructure for base image tarballs - #475

Closed
kanavin wants to merge 1 commit into
Linutronix:masterfrom
kanavin:add-base-extended-validation
Closed

Further preparing the testing infrastructure for base image tarballs#475
kanavin wants to merge 1 commit into
Linutronix:masterfrom
kanavin:add-base-extended-validation

Conversation

@kanavin

@kanavin kanavin commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

There are two commits here: one is adding a test fixture to pass the project name into tests, so they know what is being tested, another adds a tarball implementation for inspecting the root filesystems. Please see the commit messages for details.

@t-8ch t-8ch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both changes look good in general.

It would be nice to have users for this new code, to have at least a bit of testing.
So the path changes can go in when there are some unittests for them.
The test fixture I would like to merge together with its users.

Comment thread elbevalidate/_pytest_plugin.py Outdated

@pytest.fixture
def project_name(request, build_dir):
from elbepack.treeutils import etree

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imports at the top please.

Comment thread elbevalidate/_pytest_plugin.py Outdated
def project_name(request, build_dir):
from elbepack.treeutils import etree
xml = etree(build_dir / 'source.xml')
return xml.text('project/name')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again, it could be a regular function called by the interested tests.
They have access to the build directory anyways.
This would make things a bit less magic.

Comment thread elbevalidate/path.py Outdated
return self.tar.getmember('.' + self._path)

def read_bytes(self):
return self.tar.extractfile('.' + self._path).read()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this close the object returned by .extractfile()?

Comment thread elbevalidate/path.py Outdated
return self.tar.extractfile('.' + self._path).read()

def exists(self):
return ('.' + self._path) in self.tar.getnames()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should reuse self._info() and catch the KeyError.
The current code will read all names.

Comment thread elbevalidate/path.py
])


class TarballPath(Path):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A unittest for this would be nice.

This allows looking into root filesystems that are packaged
as tarballs (in addition to an implementation that looks into
disk images using guestfs), and is useful for testing the content
of base images.

Note that this is a 'lazy' implementation; I have added only
the methods that are actually called by image validation tests.
More can be added if/when needed.

Also, tarballs do not necessarily have normalized paths (e.g. there can be
a './' prefix), so this needs to be accounted for in member lookups
and iterations. The test also checks for both options (dir1/ and ./dir2).

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
@kanavin
kanavin force-pushed the add-base-extended-validation branch from 9e5a7a9 to 8caf93e Compare August 11, 2026 14:57
@kanavin

kanavin commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Alright. This pull request now only adds tarball path implementation and tests for it.

@t-8ch

t-8ch commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Applied, thanks.

Please note: I changed the constructors to match the other patch class in elbevalidate.
use elbevalidate.Tar.files().

@t-8ch t-8ch closed this Aug 12, 2026
@kanavin
kanavin deleted the add-base-extended-validation branch August 12, 2026 09:40
@kanavin

kanavin commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

Applied, thanks.

Please note: I changed the constructors to match the other patch class in elbevalidate. use elbevalidate.Tar.files().

Don't forget to run pytest after you tweak :)
#477

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants