Skip to content
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

vmsdk/python/tests: add tests for TDX #57

Merged
merged 3 commits into from
Jan 17, 2024
Merged

Conversation

intelzhongjie
Copy link
Contributor

No description provided.

@intelzhongjie intelzhongjie force-pushed the main branch 3 times, most recently from dfe1870 to afe6941 Compare January 10, 2024 11:52

def test_get_eventlog(self):
"""Test get_eventlog result."""
#TODO: verify the eventlog value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the test if not implemented yet, otherwise the blank test will fail to run, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let me remove it to avoid confusion (although it doesn't fail the test). I'll add them back when the TODO is done. Thanks!

rtmrs[event.imr_index] = sha384_algo.digest()
return rtmrs

def check_imr(self, imr_index: int, alg_id: int, rtmr: bytes):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not a test case with the prefix of "test_", then please add "_" to indicate it as an internal function.

will measure boot_aggregate by default.
"""

RTMR_LENGTH_BY_BYTES = 48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this is not a constant value from cctrusted_base package?

assert cmdline is not None

ima_policy = None
if "ima_hash=sha384" in cmdline:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why measurement is related to ima_policy? @ruomengh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my misunderstanding. I'll resolve this and update PR.

count = CCTrustedVmSdk.inst().get_measurement_count()
assert count == TestCCTrustedVmSdkTdx.MEASUREMENT_COUNT

def replay_eventlog(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add "_" as the prefix for internal function.

Copy link
Member

@kenplusplus kenplusplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update according to comments.

@intelzhongjie
Copy link
Contributor Author

Please update according to comments.

OK, I'll resolve the issue and update this PR per review feedbacks.

@intelzhongjie intelzhongjie force-pushed the main branch 5 times, most recently from 36cba8e to a587769 Compare January 11, 2024 07:39
def get_quote(self, nonce: bytearray, data: bytearray, extraArgs=None) -> Quote:
return self._cvm.imrs[imr_index]

def get_quote(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change to this style, looks wierd.

Copy link
Contributor Author

@intelzhongjie intelzhongjie Jan 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After adding default values for parameters "nonce" and "data", the line became too long. So I followed the https://google.github.io/styleguide/pyguide.html#3192-line-breaking 3.19.2 Line Breaking for that style.

@intelzhongjie intelzhongjie force-pushed the main branch 10 times, most recently from 9529220 to 704fe53 Compare January 12, 2024 08:18
@intelzhongjie intelzhongjie force-pushed the main branch 2 times, most recently from 59b9598 to ff0b6ab Compare January 12, 2024 08:25
@intelzhongjie
Copy link
Contributor Author

Please update according to comments.

Please review the latest version which has the changes per review. Thanks!

if args.no_cacheprovider is True:
pytest_options += ["-p", "no:cacheprovider"]

cc_type = ConfidentialVM.detect_cc_type()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dongx1x @ruomengh @intelzhongjie do you have better approach to make filter in conftest?
I know you already add mark.basic mark.tdx. But it looks wierd...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this for a while. A rough idea on one alternative might be to specify the type of confidential VM we want to test and start that explicitly. It needs some change on the existing workflow (currently the test will be run in existing VM directly, we need to change this to that start VM and run the tests).

The current way leverages the existing running confidential VM as the action runner. So it needs to detect the type of that existing VM where it runs to decide if it needs to run TDX specific tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with Ruomeng and Xiaocheng, I'll modify and update this per feedbacks.

@intelzhongjie intelzhongjie force-pushed the main branch 4 times, most recently from 6154b91 to 4cc0cc4 Compare January 16, 2024 00:51
This patch mainly adds some tests for TDX.
And it refactors some corresponding code accordingly.

Signed-off-by: zhongjie <zhongjie.shi@intel.com>
Copy link
Member

@kenplusplus kenplusplus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kenplusplus kenplusplus merged commit e3dcb82 into cc-api:main Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants