Skip to content

Commit ca09fb6

Browse files
lubaihua33LiliDeng
authored andcommitted
Add verify_os_architecture_is_64bit test case
1 parent d1b498f commit ca09fb6

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

lisa/base_tools/uname.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
if TYPE_CHECKING:
1414
from lisa.node import Node
15+
from lisa.operating_system import CpuArchitecture
1516

1617

1718
@dataclass
@@ -80,6 +81,21 @@ def get_linux_information(
8081

8182
return result
8283

84+
def get_machine_architecture(self, force_run: bool = False) -> "CpuArchitecture":
85+
# To avoid circular import
86+
from lisa.operating_system import CpuArchitecture
87+
88+
arch_map = {
89+
"x86_64": CpuArchitecture.X64,
90+
"amd64": CpuArchitecture.X64,
91+
"aarch64": CpuArchitecture.ARM64,
92+
"arm64": CpuArchitecture.ARM64,
93+
"i386": CpuArchitecture.I386,
94+
}
95+
self.initialize()
96+
arch_str = self.run("-m", force_run=force_run).stdout.strip().lower()
97+
return arch_map.get(arch_str, CpuArchitecture.UNKNOWN)
98+
8399

84100
class FreeBSDUname(Uname):
85101
_key_info_pattern = re.compile(

lisa/operating_system.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class CpuArchitecture(str, Enum):
7777
X64 = "x86_64"
7878
ARM64 = "aarch64"
7979
I386 = "i386"
80+
UNKNOWN = "unknown"
8081

8182

8283
class AzureCoreRepo(str, Enum):

microsoft/testsuites/core/azure_image_standard.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
schema,
1818
simple_requirement,
1919
)
20+
from lisa.base_tools.uname import Uname
2021
from lisa.features import Disk
2122
from lisa.operating_system import (
2223
BSD,
@@ -1365,6 +1366,28 @@ def verify_openssl_version(self, node: Node) -> None:
13651366
library_name="OpenSSL",
13661367
)
13671368

1369+
@TestCaseMetadata(
1370+
description="""
1371+
This test verifies that the Linux operating system has a 64-bit architecture.
1372+
1373+
Steps:
1374+
1. Retrieve the OS architecture using the Uname tool.
1375+
2. Verify that the architecture is either x86_64 (AMD64) or aarch64 (ARM64).
1376+
3. Fail the test if the architecture is not 64-bit.
1377+
""",
1378+
priority=1,
1379+
requirement=simple_requirement(supported_platform_type=[AZURE]),
1380+
)
1381+
def verify_azure_64bit_os(self, node: Node) -> None:
1382+
uname_tool = node.tools[Uname]
1383+
arch = uname_tool.get_machine_architecture()
1384+
arch_64bit = [CpuArchitecture.X64, CpuArchitecture.ARM64]
1385+
if arch not in arch_64bit:
1386+
raise LisaException(
1387+
f"Architecture '{arch.value}' is not supported. Azure only supports "
1388+
f"64-bit architectures: {', '.join(str(a.value) for a in arch_64bit)}."
1389+
)
1390+
13681391
def _check_version_by_pattern_value(
13691392
self,
13701393
node: Node,

0 commit comments

Comments
 (0)