Skip to content

Commit

Permalink
squash: fixing based on real-life plan
Browse files Browse the repository at this point in the history
  • Loading branch information
happz committed Feb 21, 2024
1 parent 43f22ee commit 8ef36dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 12 additions & 5 deletions tests/unit/provision/testcloud/test_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,26 @@ def test_tpm(
levelno=logging.DEBUG)

else:
allowed_combinations: list[tuple[str, Operator]] = []

for version in TPM_VERSION_SUPPORTED_VERSIONS[TPM_CONFIG_ALLOWS_VERSIONS]:
for op in virtual_TPM_VERSION_ALLOWED_OPERATORS:
allowed_combinations.append((version, op))

@pytest.mark.parametrize(
'op',
virtual_TPM_VERSION_ALLOWED_OPERATORS,
ids=[op.value for op in virtual_TPM_VERSION_ALLOWED_OPERATORS]
('version', 'op'),
allowed_combinations,
ids=[f'{op.value} {version}' for version, op in allowed_combinations]
)
def test_tpm_with_default_version(
root_logger: Logger,
caplog: _pytest.logging.LogCaptureFixture,
version: str,
op: Operator) -> None:
mock_domain = MagicMock(name='<domain>')

_apply_hw_tpm(
Hardware.from_spec({'tpm': {'version': f'{op.value} 2.0'}}),
Hardware.from_spec({'tpm': {'version': f'{op.value} {version}'}}),
mock_domain,
root_logger)

Expand All @@ -84,7 +91,7 @@ def test_tpm_with_default_version(

assert_log(
caplog,
message=MATCH(rf"tpm.version: set to '2.0' because of 'tpm.version: {op.value} 2.0'"),
message=MATCH(rf"tpm.version: set to '{version}' because of 'tpm.version: {op.value} {version}'"), # noqa: E501
levelno=logging.DEBUG)


Expand Down
6 changes: 3 additions & 3 deletions tmt/steps/provision/testcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ def import_testcloud() -> None:

#: TPM versions supported by the plugin. The key is :py:const:`TPM_CONFIG_ALLOWS_VERSIONS`.
TPM_VERSION_SUPPORTED_VERSIONS = {
True: ['2.0', '1.2'],
True: ['2.0', '2', '1.2'],
# This is the default version used by testcloud before version became
# an input parameter of TPM configuration.
False: ['2.0']
False: ['2.0', '2']
}


Expand Down Expand Up @@ -285,7 +285,7 @@ def _report_hw_requirement_support(constraint: tmt.hardware.Constraint[Any]) ->

if components.name == 'tpm' \
and components.child_name == 'version' \
and constraint.value == '2.0' \
and constraint.value in TPM_VERSION_SUPPORTED_VERSIONS[TPM_CONFIG_ALLOWS_VERSIONS] \
and constraint.operator in TPM_VERSION_ALLOWED_OPERATORS:
return True

Expand Down

0 comments on commit 8ef36dd

Please sign in to comment.