Skip to content

Commit

Permalink
test: adjust workflow and case for recent change
Browse files Browse the repository at this point in the history
Signed-off-by: zhongjie <zhongjie.shi@intel.com>
  • Loading branch information
intelzhongjie committed Mar 5, 2024
1 parent bc6ef6d commit 431e0e8
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
22 changes: 21 additions & 1 deletion .github/workflows/vmsdk-test-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,37 @@ on:
paths:
- 'vmsdk/**/*.py'
- 'common/**/*.py'
- 'setupenv.sh'
- '.github/workflows/vmsdk-test-python.yaml'
pull_request:
paths:
- 'vmsdk/**/*.py'
- 'common/**/*.py'
- 'setupenv.sh'
- '.github/workflows/vmsdk-test-python.yaml'
workflow_dispatch:

env:
VMSDK_PYTEST_DIR: 'vmsdk_pytest'

jobs:
vmsdk_pytest:
runs-on: [self-hosted, tdx-guest]
defaults:
run:
working-directory: ${{env.VMSDK_PYTEST_DIR}}
steps:
- uses: actions/checkout@v3
- name: Clean up intermediate files
continue-on-error: true
run: |
# Remove the intermediate files that could be left
# by previous run with sudo. Otherwise, the checkout
# will fail with permission issue.
sudo rm -fr ./*
- name: Checkout repo
uses: actions/checkout@v4
with:
path: ${{env.VMSDK_PYTEST_DIR}}
- name: Run PyTest for VMSDK
run: |
set -ex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ on:
- main
paths:
- 'vmsdk/rust/**/*'
- '.github/workflows/vmsdk-test-rust.yaml'
pull_request:
paths:
- 'vmsdk/rust/**/*'
- '.github/workflows/vmsdk-test-rust.yaml'
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
VMSDK_RUST_TEST_DIR: vmsdk_rust_test

jobs:
vmsdk_rust_test:
runs-on: [self-hosted, tdx-guest]
defaults:
run:
working-directory: ${{env.VMSDK_RUST_TEST_DIR}}
steps:
- name: Clean up intermediate files
continue-on-error: true
Expand All @@ -26,7 +32,10 @@ jobs:
# will fail with permission issue.
sudo rm -f vmsdk/rust/cctrusted_vm/Cargo.lock
sudo rm -fr vmsdk/rust/cctrusted_vm/target
- uses: actions/checkout@v3
- name: Checkout repo
uses: actions/checkout@v4
with:
path: ${{env.VMSDK_RUST_TEST_DIR}}
- name: Run tests
run: |
cd vmsdk/rust/cctrusted_vm/
Expand Down
2 changes: 1 addition & 1 deletion vmsdk/python/cctrusted_vm/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def get_cc_eventlog(self, start:int = None, count:int = None) -> list:
self._cvm.process_eventlog()

event_logs = EventLogs(self._cvm.boot_time_event_log, self._cvm.runtime_event_log,
TcgEventLog.TCG_PCCLIENT_FORMAT)
TcgEventLog.TCG_FORMAT_PCCLIENT)

event_logs.select(start, count)

Expand Down
3 changes: 2 additions & 1 deletion vmsdk/python/tests/test_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from cctrusted_base.ccreport import CcReport, CcReportData, CcReportSignature
from cctrusted_base.tcg import TcgImrEvent, TcgPcClientImrEvent
from cctrusted_base.tcgcel import TcgTpmsCelEvent
import pytest

def test_get_default_algorithms(vm_sdk, default_alg_id):
Expand Down Expand Up @@ -81,7 +82,7 @@ def test_get_cc_eventlog_with_valid_input(vm_sdk):
event_count = 0
for e in eventlog:
event_count += 1
assert isinstance(e, (TcgImrEvent, TcgPcClientImrEvent))
assert isinstance(e, (TcgImrEvent, TcgPcClientImrEvent, TcgTpmsCelEvent))

def test_get_cc_report_with_valid_input(vm_sdk, check_quote_valid_input):
"""Test get_cc_report() function with valid input."""
Expand Down

0 comments on commit 431e0e8

Please sign in to comment.