Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace sharness-based test suite by pytest #1401

Merged
merged 23 commits into from
May 10, 2024
Merged

Conversation

ejoerns
Copy link
Member

@ejoerns ejoerns commented May 3, 2024

In the past, we faced many limitations of the sharness-based RAUC test suite and additionally, the growing size of the rauc.t file made it harder to keep oversight over the test cases.

With the sharness-based tests, we were often limited to having a simple program exit code check. But the reasons for exiting in RAUC are manifold.
With pytest, we can easily check for expected stdout/stderr output. Almost all tests were extended with this simple enhancement.

The new tests are now also split up into different test files, based on their test purpose.

Copy link
Member

@jluebbe jluebbe left a comment

Choose a reason for hiding this comment

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

Instead of replicating the skipif marks everywhere, they could be defined once in a helper module as suggested here: https://docs.pytest.org/en/8.2.x/how-to/skipping.html#id1

You should probably run https://github.com/astral-sh/ruff on the new code. I'd suggest a .ruff.toml with line-length = 119 (the same our other projects).

test/conftest.py Outdated Show resolved Hide resolved
test/meson.build Outdated Show resolved Hide resolved
test/conftest.py Outdated Show resolved Hide resolved
test/conftest.py Show resolved Hide resolved
test/conftest.py Show resolved Hide resolved
test/conftest.py Outdated Show resolved Hide resolved
test/test_cmdline.py Outdated Show resolved Hide resolved
test/test_rauc_sign.py Outdated Show resolved Hide resolved
@ejoerns ejoerns force-pushed the pytest branch 2 times, most recently from ad34ec1 to 3d9a721 Compare May 6, 2024 16:21
@ejoerns
Copy link
Member Author

ejoerns commented May 6, 2024

@jluebbe Thank you for the quick review!

Instead of replicating the skipif marks everywhere, they could be defined once in a helper module as suggested here: https://docs.pytest.org/en/8.2.x/how-to/skipping.html#id1

Indeed. While the skipif statements were easy to copy&paste, they are probably not that easy to maintain and change and pollute the set files a bit. Fixed.

You should probably run https://github.com/astral-sh/ruff on the new code. I'd suggest a .ruff.toml with line-length = 119 (the same our other projects).

Ran ruff on it and added ruff to our style-check flow.

Also the other review comments should be addressed by this updated version.

@jluebbe
Copy link
Member

jluebbe commented May 7, 2024

As we don't have pytest in our container, this the tests are not yet running in CI. We should add the necessary dependencies in a separate PR first.

test/.ruff.toml Outdated Show resolved Hide resolved
@ejoerns
Copy link
Member Author

ejoerns commented May 8, 2024

As we don't have pytest in our container, this the tests are not yet running in CI. We should add the necessary dependencies in a separate PR first.

I've created #1410 for this.

I have updated this PR to contain a commit referencing the Docker container built by #1410.

I've also renamed all test files and test cases to not contain rauc_ anymore.

Addressed the remaining review comments.
A small number of additional unexpected adaptions were required due to varying outputs etc.

@jluebbe

This comment was marked as outdated.

@ejoerns

This comment was marked as outdated.

@ejoerns
Copy link
Member Author

ejoerns commented May 8, 2024

I've updated the PR and rebased to drop the intermediate container commit and add a workaround for 9pfs-related issues using sendfile() for file copying in qemu-test as suggested by @jluebbe

@ejoerns
Copy link
Member Author

ejoerns commented May 8, 2024

Added some missing bundle copying in convert tests that previously failed for cross (386) only (for some reason).

@ejoerns ejoerns marked this pull request as ready for review May 8, 2024 12:16
@ejoerns ejoerns requested a review from jluebbe May 8, 2024 12:17
@ejoerns
Copy link
Member Author

ejoerns commented May 8, 2024

Applied two minor cleanups

@jluebbe
Copy link
Member

jluebbe commented May 8, 2024

Force-pushed to sort imports and to remove some redundant comments.

Copy link
Member

@jluebbe jluebbe left a comment

Choose a reason for hiding this comment

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

Only a few minor things left. Other improvements can wait until this is merged.

test/test_mount.py Outdated Show resolved Hide resolved
test/test_install.py Outdated Show resolved Hide resolved
test/test_verify.py Outdated Show resolved Hide resolved
test/test_replace_signature.py Show resolved Hide resolved
test/test_replace_signature.py Outdated Show resolved Hide resolved
helper.py partly copied from rauc-hawkbit-updater.

Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Only if pytest is available.

Since the tests require a notable amount of disk space, we need to
limit the number of temporary directories kept, according to pytest doc,
using --basetemp is a proper workaround:

> The number of entries currently cannot be changed, but using the
> --basetemp option will remove the directory before every run,
> effectively meaning the temporary directories of only the most recent
> run will be kept.

[1] https://docs.pytest.org/en/7.1.x/how-to/tmp_path.html#the-default-base-temporary-directory

Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
ejoerns added 20 commits May 9, 2024 00:57
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
Signed-off-by: Enrico Joerns <ejo@pengutronix.de>
@ejoerns ejoerns merged commit cd3aa7c into rauc:master May 10, 2024
16 checks passed
@ejoerns ejoerns deleted the pytest branch May 10, 2024 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants