mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-17 06:48:51 +00:00
tests: Add is_confidential_hardware()
This function is a helper to check whether the KATA_HYPERVISOR being used is a confidential hardware (TEE) or not, and we can use it to skip or only run tests on those platforms when needed. Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
@@ -44,7 +44,7 @@ function check_hypervisor_for_confidential_tests() {
|
|||||||
local kata_hypervisor="${1}"
|
local kata_hypervisor="${1}"
|
||||||
# This check must be done with "<SPACE>${KATA_HYPERVISOR}<SPACE>" to avoid
|
# This check must be done with "<SPACE>${KATA_HYPERVISOR}<SPACE>" to avoid
|
||||||
# having substrings, like qemu, being matched with qemu-$something.
|
# having substrings, like qemu, being matched with qemu-$something.
|
||||||
if [[ " ${SUPPORTED_TEE_HYPERVISORS[*]} " =~ " ${kata_hypervisor} " ]] ||\
|
if check_hypervisor_for_confidential_tests_tee_only "${kata_hypervisor}" ||\
|
||||||
[[ " ${SUPPORTED_NON_TEE_HYPERVISORS[*]} " =~ " ${kata_hypervisor} " ]]; then
|
[[ " ${SUPPORTED_NON_TEE_HYPERVISORS[*]} " =~ " ${kata_hypervisor} " ]]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
@@ -52,6 +52,19 @@ function check_hypervisor_for_confidential_tests() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# This function verifies whether the input hypervisor supports confidential tests and
|
||||||
|
# relies on `KATA_HYPERVISOR` being an environment variable
|
||||||
|
function check_hypervisor_for_confidential_tests_tee_only() {
|
||||||
|
local kata_hypervisor="${1}"
|
||||||
|
# This check must be done with "<SPACE>${KATA_HYPERVISOR}<SPACE>" to avoid
|
||||||
|
# having substrings, like qemu, being matched with qemu-$something.
|
||||||
|
if [[ " ${SUPPORTED_TEE_HYPERVISORS[*]} " =~ " ${kata_hypervisor} " ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Common check for confidential tests.
|
# Common check for confidential tests.
|
||||||
function is_confidential_runtime_class() {
|
function is_confidential_runtime_class() {
|
||||||
ensure_yq
|
ensure_yq
|
||||||
@@ -61,3 +74,12 @@ function is_confidential_runtime_class() {
|
|||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Common check for confidential hardware tests.
|
||||||
|
function is_confidential_hardware() {
|
||||||
|
if check_hypervisor_for_confidential_tests_tee_only "${KATA_HYPERVISOR}"; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user