Skip to content

tests/simple-validation-image-test.py: adjust to support base image tarballs - #478

Closed
kanavin wants to merge 7 commits into
Linutronix:masterfrom
kanavin:add-base-extended-validation-test-tweaks
Closed

tests/simple-validation-image-test.py: adjust to support base image tarballs#478
kanavin wants to merge 7 commits into
Linutronix:masterfrom
kanavin:add-base-extended-validation-test-tweaks

Conversation

@kanavin

@kanavin kanavin commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

With these commits, base image tarballs (generated from tests/base-extended/simple-validation/image-base.xml) can be validated (with 100% pass) using the validation script directly:

$ PYTHONPATH=. tests/simple-validation-image-test.py elbe-build-20260806-142454/

or with a higher level elbe command:

$ ./elbe check-build img elbe-build-20260806-142454/

@kanavin
kanavin force-pushed the add-base-extended-validation-test-tweaks branch from b8be70e to 4e8a8f0 Compare August 12, 2026 11:58
…ter function

The getter function reads the image name from source.xml in the build directory and looks it up in a dictionary.

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.

There are three parameters:

'base-image' specifies whether this is a tarball with a root filesystem (if True) or
a disk image (if False)

'has-local-gpio' specifies whether the image contains a locally built libgpio package
(done only for classic validation image)

'has-finetuning' specifies whether there's a particular set of fintuning tweaks that
are tested with _test_finetuning (also done only for the classic validation image)

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

Specifically:
- set a particular project name so tests can distinguish from the original
validation image

- set domain and archive (validation tests are checking for it, so to
avoid special casing let's just set it in the base image).

- set the validation script location, so 'elbe check-build' can pick it up

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
… ('sda.img') in test_build_directory_contents

Rather set it according to what image is being tested.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
- support images without local gpio package (useful for base-extended
images which do not contain the package)
- do not hardcode a project name when checking the content of the report

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
…ks in test_elbe_log_txt

This is useful for base-extended images which do not have them (as they do not have
finetuning from the original validation image).

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
…y into finetuning test

This copying isn't automatically done for all images, and is only a part of
finetuning tweaks in simple validation image.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
…ase image tarballs

There are numerous tweaks here:

- project_name is used to check the content of /etc/elbe_version in _test_generated_elbe_files()

- _test_rootfs is tweaked to adjust or skip various checks according
to image properties

- the top level test is adjusted to either run the disk image
code as before, or go directly into _test_rootfs if the image-under-test
is a base image tarball

With this commit, base image tarballs (generated from tests/base-extended/simple-validation/image-base.xml)
can be validated (with 100% pass) using the validation script directly:

$ PYTHONPATH=. tests/simple-validation-image-test.py elbe-build-20260806-142454/

or with a higher level elbe command:

$ ./elbe check-build img elbe-build-20260806-142454/

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
@kanavin
kanavin force-pushed the add-base-extended-validation-test-tweaks branch from 4e8a8f0 to 64bc810 Compare August 12, 2026 14:50
Comment thread tests/simple-validation-image-test.py
elbe_report = build_dir.joinpath('elbe-report.txt').read_text()

assert elbe_report.startswith('ELBE Report for Project simple-validation-image')
assert elbe_report.startswith('ELBE Report for Project {}'.format(project_name(build_dir)))

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.

f-strings would be fine.


assert 'I: Extracting util-linux...' in log
assert '[CMD] cat /etc/hosts | cat -n > /etc/hosts4' in log
if image_parameters(build_dir)['has-finetuning']:

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.

We should also test that finetuning works in both the base and the extended image.
Maybe we can use the full simple-validation image to also emit a base image tarball and use that.
(And then also reuse the existing test fully for that and both the base and the extended variants)

We could skip the pbuilder bits with a variant to keep the speed up, though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We should also test that finetuning works in both the base and the extended image. Maybe we can use the full simple-validation image to also emit a base image tarball and use that. (And then also reuse the existing test fully for that and both the base and the extended variants)

That won't work because the full simple-validation image does things in finetuning (e.g. delete packaging data) that make the output unsuitable for making extended images.

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.

The deletion of the packaging data is probably only cargo-culted from an example.
For this test we can just drop it. We have enough other tests for <command>.

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.

And the <rm>var/cache/apt/archives/*.deb</rm> bit should be fine to keep.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we need to step back and decide what should the top level test contain (e.g. elbepack/tests/test_xml.py). I have patches upcoming that modify the base-extended test to do this:

def test_base_extended_build(initvm, tmp_path):
...
     initvm('submit', '--output', base_build, '--skip-build-bin', '--skip-build-sources',
            base_xml_path)
    run_elbe_subcommand(['check-build', 'img', base_build])
     initvm('submit', '--output', extended_build, '--skip-build-bin', '--skip-build-sources',
            '--base-image', base_build_image, extended_xml_path)
    run_elbe_subcommand(['check-build', 'img', extended_build])

E.g. run the sequence:

  • build base image from tests/base-extended/simple-validation/
  • run validation script on it
  • build extended image from tests/base-extended/simple-validation/
  • run validation script and qemu bootup/login test on it.

The test for the existing classic validation image and the image itself aren't changed.

Should we complicate matters with also adding finetuning to those images and/or doing something with the original validation image? I'd rather improve tests incrementally. The goal for me, for now, is to make it possible to validate existing base-extended images and add that validation to existing tests for them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So how do we go from the above to actual implementation?

Here's the proposal:

  • do not validate images in tests/base-extended/simple-validation/ with a validation script. Only do the qemu boot/login test on the base/extended image. That way the script doesn't have to be modified to fit them with all the complication and parameters that brings.
  • add a tarball output to tests/simple-validation-image.xml
  • add test_extended(initvm, simple_build) which will take the tarball output from simple_build (if source.xml specifies that there's a tarball, otherwise skip the test), build an extended image, and validate it with 'elbe check-build'
  • the extended image definition is separate from one in tests/base-extended/simple-validation/ as it does need to include the validation script

Any tweaks to the above?

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.

  • do not validate images in tests/base-extended/simple-validation/ with a validation script. Only do the qemu boot/login test on the base/extended image. That way the script doesn't have to be modified to fit them with all the complication and parameters that brings.

I would have dropped the current image-base.xml completely. The boot test also doesn't make sense on the boot test.

  • add test_extended(initvm, simple_build) which will take the tarball output from simple_build (if source.xml specifies that there's a tarball, otherwise skip the test), build an extended image, and validate it with 'elbe check-build'

When would the tarball not exist?

  • the extended image definition is separate from one in tests/base-extended/simple-validation/ as it does need to include the validation script

Do we need two different extended images in the tests?

My idea was:

  • Add a tarball output to simple-validation-image.xml,
    Test both sda.img and the base tarball with the test script.
    Only do the boot tests for sda.img.
  • Add an extended image on top of simple-validation-image.xml.
    This extended image installs a package, does some light finetuning and an archive.
    The extended image is boot tests, and validated against the full simple-validation-image-test.py to make sure that everything is passed through and also test extended image specific bits.

@kanavin kanavin Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The issue is that build of simple-validation-image.xml isn't tested standalone. It's part of the 'test matrix' which takes available tests, images (obtained by making a list of tests/simple*.xml), and 'elbe check-build' options, and combines them in every possible way:

$ pytest --co
...
        <Function test_simple_build[simple-arm64.xml-schema]>
        <Function test_simple_build[simple-arm64.xml-cdrom]>
        <Function test_simple_build[simple-arm64.xml-img]>
        <Function test_simple_build[simple-arm64.xml-sdk]>
        <Function test_rebuild[simple-arm64.xml]>
        <Function test_check_updates[simple-arm64.xml]>
        <Function test_simple_build[simple-validation-image.xml-schema]>
        <Function test_simple_build[simple-validation-image.xml-cdrom]>
        <Function test_simple_build[simple-validation-image.xml-img]>
        <Function test_simple_build[simple-validation-image.xml-sdk]>
        <Function test_rebuild[simple-validation-image.xml]>
        <Function test_check_updates[simple-validation-image.xml]>
        <Function test_simple_build[simple-rescue-busybox-dyn-cpio.xml-schema]>
        <Function test_simple_build[simple-rescue-busybox-dyn-cpio.xml-cdrom]>
        <Function test_simple_build[simple-rescue-busybox-dyn-cpio.xml-img]>
        <Function test_simple_build[simple-rescue-busybox-dyn-cpio.xml-sdk]>
        <Function test_rebuild[simple-rescue-busybox-dyn-cpio.xml]>
        <Function test_check_updates[simple-rescue-busybox-dyn-cpio.xml]>
        <Function test_simple_build[simple-amd64-with-grub-uefi.xml-schema]>
        <Function test_simple_build[simple-amd64-with-grub-uefi.xml-cdrom]>
        <Function test_simple_build[simple-amd64-with-grub-uefi.xml-img]>
        <Function test_simple_build[simple-amd64-with-grub-uefi.xml-sdk]>
        <Function test_rebuild[simple-amd64-with-grub-uefi.xml]>
        <Function test_check_updates[simple-amd64-with-grub-uefi.xml]>

So either we need to fit building and validating extended image into this matrix (with a test_extended(), how I proposed above), or we need to take out simple-validation-image.xml out of it, and write its own special test for it, e.g. by tweaking test_base_extended_build().

The reason I want to keep the images in tests/base-extended/simple-validation/ (and the test for them) is that it's beneficial to test both 'rich' and 'minimal' images. Simple-validation-image.xml is used as a catch-all for all the features that need to be tested, and it will in the future gain even more, and be not so simple anymore. Those other images won't change much, and they're meant as a minimal example that's still bootable.

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.

I would also be fine with removing simple-validation-image from the default test_simple_build().
Or we keep it separate, but then we still need some basic test for things like finetuning and archives.
If we split it out, we should also split out the test script though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok. I'll propose an alternative pull request that reuses the original simple validation image and extends the existing tests for it. Then we'll tweak from there.

@kanavin kanavin closed this Aug 17, 2026
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