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: fix test for get_cc_eventlog #86

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions vmsdk/python/tests/test_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ def test_get_cc_measurement_with_valid_input(vm_sdk, check_measurement):
check_measurement()

def test_get_cc_eventlog_with_invalid_input(vm_sdk):
"""Test get_cc_eventlog() function with invalid input."""
event_num = vm_sdk.get_cc_eventlog().count
"""Test get_cc_eventlog() function with invalid input.

The test logic currently has an assumption that the return result of get_cc_eventlog
doesn't change if the input parameters are the same within a short period of time.
"""
event_num = len(vm_sdk.get_cc_eventlog().event_logs)
idx_min = 0
idx_max = event_num - 1
cnt_min = 1
Expand All @@ -49,8 +53,12 @@ def test_get_cc_eventlog_with_invalid_input(vm_sdk):
invalid_start = idx_min - 1
vm_sdk.get_cc_eventlog(start=invalid_start, count=1)
with pytest.raises(ValueError):
invalid_start = idx_max + 1
invalid_start = idx_max + 2
vm_sdk.get_cc_eventlog(start=invalid_start, count=1)
# a special case works as current design
invalid_start = idx_max + 1
eventlog = vm_sdk.get_cc_eventlog(start=invalid_start, count=1)
assert len(eventlog.event_logs) == 0

# calling get_cc_eventlog with invalid "count"
with pytest.raises(ValueError):
Expand Down
Loading