Commit 0a852e7
committed
Add post-mortem information collection for failed tests
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 #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]>1 parent b659473 commit 0a852e7
3 files changed
+79
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
0 commit comments