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

pytest: Isolate directories, start permission store and add umockdev support #1477

Merged
merged 10 commits into from
Oct 28, 2024

Conversation

swick
Copy link
Contributor

@swick swick commented Oct 17, 2024

Based on #1451

What the title says. This is prep work for being able to test the USB portal with the python harness.

@swick
Copy link
Contributor Author

swick commented Oct 17, 2024

/cc @whot

@swick swick mentioned this pull request Oct 17, 2024
@swick swick force-pushed the wip/pytest-improvements-part2 branch from 6bedc64 to 97bb235 Compare October 21, 2024 09:48
Copy link
Contributor

@whot whot left a comment

Choose a reason for hiding this comment

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

a few style nitpicks on style but this LGTM, thanks

tests/conftest.py Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
tests/__init__.py Outdated Show resolved Hide resolved
tests/__init__.py Show resolved Hide resolved
@swick swick force-pushed the wip/pytest-improvements-part2 branch from 97bb235 to 701f80f Compare October 24, 2024 18:19
@swick
Copy link
Contributor Author

swick commented Oct 24, 2024

Depends on #1486 now.

It also adds a workaround to keep ASAN working while using LD_PRELOAD.

@swick swick force-pushed the wip/pytest-improvements-part2 branch 2 times, most recently from 316bb2b to 4ff06c8 Compare October 25, 2024 16:31
@TingPing
Copy link
Member

Needs rebase. The leak commits could also be its own PR.

swick added 9 commits October 28, 2024 15:38
If PortalMock was subclassing DBusTestCase, then TearDown would be
called, but it's not. Yield the PortalMock and call tear_down
afterwards.

This also reveals a bug where the loop iterated over the keys instead of
the values.
This ensure that we don't use or modify any data from the actual system
and instead have a clean, predictable environment for tests without the
risk of accidentally modifying something on the host.
This way it becomes reusable when we want to start more components.
We now isolate the test environment so that the permission store will
start with an empty state but.
This makes sure that the portal frontend exited cleanly. This includes
no memory leaks detected by ASAN and for that to work we need our
suppression file.
We re-exec the test case in pytest_configure if the LD_PRELOAD doesn't
contain libumockdev-preload.so. Even if the system doesn't have it, it
will show up in the environment and we can continue.

It also sets the UMOCKDEV_DIR env for the portal frontend. In theory
dbusmock should already do this for us but it doesn't seem to be
working.

Finally, it makes sure that ASAN keeps working even when LD_PRELOAD is
being used which is always the case because we require umockdev.
@swick swick force-pushed the wip/pytest-improvements-part2 branch from 4ff06c8 to 41d06b8 Compare October 28, 2024 14:38
@swick
Copy link
Contributor Author

swick commented Oct 28, 2024

Rebased. Created a new PR for the memory leak fixes #1491. This PR still depends on them because it requires ASAN to pass for the tests to pass.

@TingPing TingPing merged commit 09874be into flatpak:main Oct 28, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Triaged
Development

Successfully merging this pull request may close these issues.

3 participants