Skip to content

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

Open
kanavin wants to merge 2 commits into
Linutronix:masterfrom
kanavin:add-base-extended-validation
Open

Further preparing the testing infrastructure for base image tarballs#475
kanavin wants to merge 2 commits 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.

kanavin added 2 commits August 6, 2026 13:47
…o the tests from build_dir/source.xml

This will be used so that the tests can know what image is actually
being tested (e.g. base, extended, classic simple-validation, etc.)
and can self-adjust accordingly.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
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 tests. More can be added
if/when needed.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>

@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.


@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.

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
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
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.

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