-
Notifications
You must be signed in to change notification settings - Fork 3
Add post-mortem information collection for failed tests #21
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
Conversation
0d725e2 to
a4fcdac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is great. Sometimes it is quite tricky to reproduce a specific failure. Collecting as much information as possible should help us with that.
I have two suggestions you could look into, if you like. But I would also be fine with merging it as-is.
In some situations, when examine failed tests it would be helpful to
collect some extra information on the system state.
This changeset adds a fixture that triggers data collection.
A fixture, contrary to a hook, allows to re-use existing
fixtures (e.g. the `strategy`-fixture).
Using `autouse=True` this fixture is injected into every test.
To make the test result available in fixtures a hook in
`pytest_runtest_makereport` is used.
The actual diagnosis data is collected inside the strategy.
This way the infrastructure is re-useable and knowledge on the system
state stays inside the strategy.
In case of a test failure this generates log output that may look like
this:
---- 8< ----
========== FAILURES ==========
____ test_tacd_uart_3v3 ______
(...)
@pytest.mark.lg_feature("eet")
def test_tacd_uart_3v3(strategy, shell, eet, record_property):
(...)
> assert True == False
E assert True == False
tests/test_tacd.py:248: AssertionError
---- Captured log teardown -----
(...)
WARNING post-mortem: POST-MORTEM INFO: status
WARNING post-mortem: | shell
WARNING post-mortem: POST-MORTEM INFO: uname -a
WARNING post-mortem: | Linux lxatac-00034 6.17.0-20251007-1 linux-automation#1 SMP PREEMPT Sun Sep 28 21:39:22 UTC 2025 armv7l GNU/Linux
WARNING post-mortem: POST-MORTEM INFO: cat /etc/os-release
WARNING post-mortem: | ID=tacos
WARNING post-mortem: | NAME="TAC OS - The LXA TAC operating system"
WARNING post-mortem: | VERSION="25.09+dev (tacos-walnascar)"
WARNING post-mortem: | VERSION_ID=25.09-dev
WARNING post-mortem: | VERSION_CODENAME="tacos-walnascar"
WARNING post-mortem: | PRETTY_NAME="TAC OS - The LXA TAC operating system 25.09+dev (tacos-walnascar)"
WARNING post-mortem: | CPE_NAME="cpe:/o:openembedded:tacos:25.09+dev"
WARNING post-mortem: POST-MORTEM INFO: cat /etc/buildinfo
WARNING post-mortem: | -----------------------
WARNING post-mortem: | Build Configuration: |
WARNING post-mortem: | -----------------------
WARNING post-mortem: | DISTRO = tacos
WARNING post-mortem: | DISTRO_VERSION = 25.09+dev
WARNING post-mortem: | -----------------------
WARNING post-mortem: | Layer Revisions: |
WARNING post-mortem: | -----------------------
WARNING post-mortem: | meta = HEAD:d0b46a6624ec9c61c47270745dd0b2d5abbe6ac1
WARNING post-mortem: | meta-poky = HEAD:d0b46a6624ec9c61c47270745dd0b2d5abbe6ac1
WARNING post-mortem: | meta-arm = HEAD:21894cc2ea3197e6bfc1a56d889f757a09dc8b31
WARNING post-mortem: | meta-arm-toolchain = HEAD:21894cc2ea3197e6bfc1a56d889f757a09dc8b31
WARNING post-mortem: | meta-ptx = HEAD:23e46e92946ca0a1b1da4cf3ad212169d46b0af8
WARNING post-mortem: | meta-oe = HEAD:80ab58cc404959ae2f0e8b2e68935b3bfd8e8cfe
WARNING post-mortem: | meta-python = HEAD:80ab58cc404959ae2f0e8b2e68935b3bfd8e8cfe
WARNING post-mortem: | meta-filesystems = HEAD:80ab58cc404959ae2f0e8b2e68935b3bfd8e8cfe
WARNING post-mortem: | meta-networking = HEAD:80ab58cc404959ae2f0e8b2e68935b3bfd8e8cfe
WARNING post-mortem: | meta-lxatac-bsp = HEAD:44e447b099a268f87a305915a386568e0ff72b6a
WARNING post-mortem: | meta-lxatac-software = HEAD:44e447b099a268f87a305915a386568e0ff72b6a
WARNING post-mortem: | meta-labgrid = HEAD:fa2c78d1fc3ff9519ddd14168807519ec0b6d9ee
WARNING post-mortem: | meta-rauc = HEAD:a0b83842d131093e89fa4fefaaa1997f05afdf62
WARNING post-mortem: | meta-virtualization = HEAD:4fedb61ebf60745a367d857af255006bd3509a39
WARNING post-mortem: | meta-selinux = HEAD:7ba3272c1f23266a1822442d640a40b6b4feff8c
(...)
---- 8< ----
Signed-off-by: Chris Fiege <[email protected]>
This test depends on the DUT being in the `shell` status. Thus it needs to depend on the appropriate fixture. Signed-off-by: Chris Fiege <[email protected]>
6120cfc to
23ce352
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool feature
In some situations, when examine failed tests it would be helpful to
collect some extra information on the system state.
This changeset adds a fixture that triggers data collection.
A fixture, contrary to a hook, allows to re-use existing
fixtures (e.g. the
strategy-fixture).Using
autouse=Truethis fixture is injected into every test.To make the test result available in fixtures a hook in
pytest_runtest_makereportis used.The actual diagnosis data is collected inside the strategy.
This way the infrastructure is re-useable and knowledge on the system
state stays inside the strategy.
In case of a test failure this generates log output that may look like
this: