pytest_mh.utils.coredumpd

Classes

Coredumpd(*args, **kwargs)

Coredumpd utilities.

class pytest_mh.utils.coredumpd.Coredumpd(*args, **kwargs)

Bases: MultihostUtility[MultihostHost]

Coredumpd utilities.

Collects generated core files from /var/lib/systemd/coredump and if there are any, optionally fail the test.

Note

In order for this functionality to work correctly, systemd-coredumpd must be configured to store the core files in a directory (default), not in a journal.

See man coredump.conf and its Storage option for more information.

mode values:

  • ignore: all failures are ignored

  • warn: test result category is set to “COREDUMPS” and the test is marked as such in a test summary, however test outcome and pytest exit code is kept intact

  • fail: test result category is set to “COREDUMPS” and the test is marked as such in a test summary, if a test outcome is passed it is set to failed and pytest will return non-zero exit code

Parameters:
  • host (MultihostHost) – Multihost host.

  • mode (Literal["fail", "warn", "ignore"]) – Action taken when a core file is found.

  • filter (str | None, optional) – Regular expression used to filter the core file names, defaults to None

  • path (str) – Path to the directory where core files are stored, defaults to /var/lib/systemd/coredump

mode: Literal['fail', 'warn', 'ignore']

Action taken when a core file is found.

filter: str | None

Regular expression to filter core file names.

path: str

Path to the directory where core files are stored.

setup() None

Backup and remove /var/lib/systemd/coredump.

This directory will be automatically re-created by systemd-coredumpd if needed.

list_core_files() list[str]

List available core files.

Returns:

List of core file names.

Return type:

list[str]

parse_core_file_name(name: str) tuple[str, str]

Parse core file name and get the PID and timestamp information.

Expected format is core.{binary}.{bootid}.{pid}.{timestamp}[.zst]

Parameters:

name (str) – Core file name.

Raises:

ValueError – If the core file name has unexpected format.

Returns:

Tuple of (PID, timestamp).

Return type:

tuple[str, str] | None

get_artifacts_list(host: MultihostHost, artifacts_type: Literal['pytest_setup', 'pytest_teardown', 'topology_setup', 'topology_teardown', 'test']) set[str]

Dump backtrace and other information from generated core files for easy access.

Parameters:
  • host (MultihostHost) – Host where the artifacts are being collected.

  • artifacts_type (MultihostArtifactsType) – Type of artifacts that are being collected.

Returns:

List of artifacts to collect.

Return type:

set[str]

pytest_report_teststatus(report: CollectReport | TestReport, config: Config) tuple[str, str, str | tuple[str, dict[str, bool]]] | None

Report core file found error if found and matches requested filter.

Parameters:
Returns:

Pytest test status

Return type:

tuple[str, str, str | tuple[str, dict[str, bool]]] | None