Skip to content

Commit

Permalink
Add essential requirements to checks
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Feb 19, 2024
1 parent b7d75ce commit 5010f88
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tmt/checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,22 @@ def delegate(
return cast(CheckPlugin[CheckT], find_plugin(raw_data['how'])) \
._check_class.from_spec(raw_data, logger)

@classmethod
def essential_requires(
cls,
test: 'tmt.base.Test',
logger: tmt.log.Logger) -> list['tmt.base.DependencySimple']:
"""
Collect all essential requirements of the test check.
Essential requirements of a check are necessary for the check to
perform its basic functionality.
:returns: a list of requirements.
"""

return []

@classmethod
def before_test(
cls,
Expand Down
14 changes: 14 additions & 0 deletions tmt/checks/avc.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from tmt.utils import CommandOutput, Path, ShellScript, render_run_exception_streams

if TYPE_CHECKING:
import tmt.base
from tmt.steps.execute import TestInvocation

#: The filename of the final check report file.
Expand Down Expand Up @@ -285,6 +286,19 @@ class AvcDenials(CheckPlugin[Check]):

_check_class = Check

@classmethod
def essential_requires(
cls,
test: 'tmt.base.Test',
logger: tmt.log.Logger) -> list['tmt.base.DependencySimple']:
# Avoid circular imports
import tmt.base

return [
tmt.base.DependencySimple('/usr/bin/sestatus'),
tmt.base.DependencySimple('/usr/sbin/ausearch')
]

@classmethod
def before_test(
cls,
Expand Down
11 changes: 11 additions & 0 deletions tmt/checks/dmesg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from tmt.utils import Path, render_run_exception_streams

if TYPE_CHECKING:
import tmt.base
from tmt.steps.execute import TestInvocation

TEST_POST_DMESG_FILENAME = 'dmesg-{event}.txt'
Expand Down Expand Up @@ -42,6 +43,16 @@ class DmesgCheck(CheckPlugin[Check]):

_check_class = Check

@classmethod
def essential_requires(
cls,
test: 'tmt.base.Test',
logger: tmt.log.Logger) -> list['tmt.base.DependencySimple']:
# Avoid circular imports
import tmt.base

return [tmt.base.DependencySimple('/usr/bin/dmesg')]

@classmethod
def _fetch_dmesg(
cls,
Expand Down
5 changes: 5 additions & 0 deletions tmt/steps/prepare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ def as_key(self) -> frozenset['tmt.base.DependencySimple']:
test,
self._logger)

for check in test.check:
collected_requires[guest].dependencies += check.plugin.essential_requires(
test,
self._logger)

# Now we have guests and all their requirements. There can be
# duplicities, multiple tests requesting the same package, but also
# some guests may share the set of packages to be installed on them.
Expand Down

0 comments on commit 5010f88

Please sign in to comment.