From d9d2dbba05d6da9c00dfda6c27d63109497890c3 Mon Sep 17 00:00:00 2001 From: Hector Cao <122458375+hector-cao@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:52:33 +0200 Subject: [PATCH] tests: add test to check tdx flag in CPU info (#246) --- tests/lib/tdx-tools/src/tdxtools/host.py | 2 +- tests/tests/test_host_tdx_software.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/lib/tdx-tools/src/tdxtools/host.py b/tests/lib/tdx-tools/src/tdxtools/host.py index ff19c270..38fbdb9b 100644 --- a/tests/lib/tdx-tools/src/tdxtools/host.py +++ b/tests/lib/tdx-tools/src/tdxtools/host.py @@ -25,7 +25,7 @@ def support_tdx(): """ Check whether support TDX in CPU info """ - return 'tdx' in cpuinfo.get_cpu_info()['flags'] + return 'tdx_host_platform' in cpuinfo.get_cpu_info()['flags'] def support_sgx(): diff --git a/tests/tests/test_host_tdx_software.py b/tests/tests/test_host_tdx_software.py index 6da83330..c7c30bf1 100644 --- a/tests/tests/test_host_tdx_software.py +++ b/tests/tests/test_host_tdx_software.py @@ -19,6 +19,14 @@ import re import subprocess +import tdxtools + +def test_host_tdx_cpu(): + """ + Check that the CPU has TDX support enabled + (the flag tdx_host_platform is present) + """ + assert tdxtools.host.support_tdx() def test_host_tdx_software():