Skip to content

Commit

Permalink
Merge pull request #4131 from qcheng-redhat/tpm_windows
Browse files Browse the repository at this point in the history
Add check points in tpm_verify_device test case
  • Loading branch information
vivianQizhu authored Sep 4, 2024
2 parents 050920b + bd528b5 commit af63fc5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions qemu/tests/cfg/tpm_verify_device.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
pattern_output_wmic = IsActivated_InitialValue=TRUE;IsEnabled_InitialValue=TRUE
cmd_get_tpm = 'powershell -command "get-tpm"'
pattern_output_get_tpm = TpmPresent\s+:\s+True;TpmReady\s+:\s+True
cmd_check_event_log = 'powershell -command "Get-EventLog -LogName System -EntryType Error -Source TPM"'
pattern_output_event_log = 'No matches found'
cmd_get_tpmsupportedfeature = 'powershell -command "Get-TpmSupportedFeature"'
output_get_tpmsupportedfeature = 'key attestation'
variants:
- with_emulator:
tpm_type = emulator
Expand Down
21 changes: 21 additions & 0 deletions qemu/tests/tpm_verify_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@ def search_keywords(patterns, string, flags=re.M, split_string=';'):
for vm in vms:
vm.verify_alive()
sessions.append(vm.wait_for_login())

for vm, session in zip(vms, sessions):
error_context.context("%s: Check Windows event log inside guest before test." % vm.name,
test.log.info)
cmd_check_event_log = params.get("cmd_check_event_log")
event_log_pattern = params.get('pattern_output_event_log')
if cmd_check_event_log:
event_log = session.cmd_output(cmd_check_event_log)
search_keywords(event_log_pattern, event_log)

error_context.context("%s: Check TPM info inside guest." % vm.name,
test.log.info)
for name in params.get('check_cmd_names').split():
Expand All @@ -61,12 +70,24 @@ def search_keywords(patterns, string, flags=re.M, split_string=';'):
cmd = params.get('cmd_%s' % name)
search_keywords(pattern, session.cmd(cmd))

cmd_get_tpmsupportedfeature = params.get('cmd_get_tpmsupportedfeature')
output_get_tpmsupportedfeature = params.get('output_get_tpmsupportedfeature')
if cmd_get_tpmsupportedfeature:
tpmspportedfeature = session.cmd(cmd_get_tpmsupportedfeature)
search_keywords(output_get_tpmsupportedfeature, tpmspportedfeature)

reboot_method = params.get("reboot_method")
if reboot_method:
error_context.context("Reboot guest '%s'." % vm.name, test.log.info)
vm.reboot(session, reboot_method).close()
continue

error_context.context("%s: Check Windows event log inside guest after test." % vm.name,
test.log.info)
if cmd_check_event_log:
event_log = session.cmd_output(cmd_check_event_log)
search_keywords(event_log_pattern, event_log)

error_context.context("Check TPM info on host.", test.log.info)
cmd_check_log = params.get('cmd_check_log')
if cmd_check_log:
Expand Down

0 comments on commit af63fc5

Please sign in to comment.