Further preparing the testing infrastructure for base image tarballs - #475
Further preparing the testing infrastructure for base image tarballs#475kanavin wants to merge 2 commits into
Conversation
…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
left a comment
There was a problem hiding this comment.
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 |
| def project_name(request, build_dir): | ||
| from elbepack.treeutils import etree | ||
| xml = etree(build_dir / 'source.xml') | ||
| return xml.text('project/name') |
There was a problem hiding this comment.
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.
| return self.tar.getmember('.' + self._path) | ||
|
|
||
| def read_bytes(self): | ||
| return self.tar.extractfile('.' + self._path).read() |
There was a problem hiding this comment.
Shouldn't this close the object returned by .extractfile()?
| return self.tar.extractfile('.' + self._path).read() | ||
|
|
||
| def exists(self): | ||
| return ('.' + self._path) in self.tar.getnames() |
There was a problem hiding this comment.
This should reuse self._info() and catch the KeyError.
The current code will read all names.
| ]) | ||
|
|
||
|
|
||
| class TarballPath(Path): |
There was a problem hiding this comment.
A unittest for this would be nice.
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.