-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
security/virt_what: add test for expected value
Since virt-what-1.25-9, there's an additional command 'virt-what-cvm' that gives information about if and which confidential VM mode is running. The test per default assumes that the VM runs without confidentiality. It can be configured to cover other values depending on the guest. The supported outputs are listed on the man virt-what-cvm. Signed-off-by: Sebastian Mitterle <[email protected]>
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- virt_what.cvm: | ||
type = virt_what_cvm | ||
start_vm = yes | ||
variants: | ||
- expected_value: | ||
# The EXPECTED_VALUE depends on the VM. A normal VM would have "". | ||
# man virt-what-cvm lists the available values for VM where | ||
# confidentiality is enabled | ||
expected_cvm = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import logging as log | ||
|
||
from virttest import utils_misc, utils_package | ||
|
||
|
||
logging = log.getLogger("avocado." + __name__) | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
Confirms that the output of virt-what-cvm is as expected. | ||
:params test: The avocado test object | ||
:params params: Parameters for the test | ||
:params env: The avocado test environment object | ||
""" | ||
vm_name = params.get("main_vm") | ||
vm = env.get_vm(vm_name) | ||
expected_cvm = params.get("expected_cvm") | ||
session = vm.wait_for_login() | ||
utils_package.package_install("virt-what", session=session) | ||
_, o = utils_misc.cmd_status_output("virt-what-cvm", session=session) | ||
if o.strip() != expected_cvm.strip(): | ||
test.fail( | ||
f"Unexpected value '{o.strip()}' instead of {expected_cvm.strip()}." | ||
" Note that the command is supported since virt-what-1.25-10." | ||
) |