fix Windows failure without WSL

This commit is contained in:
Chi Song 2020-08-10 17:48:12 +08:00
Родитель 2d62443079
Коммит 0c7a5a5dbe
3 изменённых файлов: 12 добавлений и 5 удалений

Просмотреть файл

@ -33,9 +33,10 @@ class HelloWorld(TestSuite):
if node.isLinux:
uname = node.getTool(Uname)
release, version, hardware = uname.getLinuxInformation()
release, version, hardware, os = uname.getLinuxInformation()
log.info(
f"release: '{release}', version: '{version}', hardware: '{hardware}'"
f"release: '{release}', version: '{version}', "
f"hardware: '{hardware}', os: '{os}'"
)
log.info("It's Linux, try on Windows!")
else:

Просмотреть файл

@ -39,6 +39,7 @@ class Node:
self.kernelRelease: str = ""
self.kernelVersion: str = ""
self.hardwarePlatform: str = ""
self.os: str = ""
self.tools: Dict[Type[Tool], Tool] = dict()
@ -172,8 +173,9 @@ class Node:
self.kernelRelease,
self.kernelVersion,
self.hardwarePlatform,
self.os,
) = uname.getLinuxInformation(noErrorLog=True)
if not self.kernelRelease:
if (not self.kernelRelease) or ("Linux" not in self.os):
self._isLinux = False
if self._isLinux:
log.info(

Просмотреть файл

@ -7,7 +7,8 @@ from lisa.core.tool import Tool
class Uname(Tool):
def initialize(self) -> None:
self.key_info_pattern = re.compile(
r"(?P<release>[^ ]*?) (?P<version>[\w\W]*) (?P<platform>[\w_]+?)$"
r"(?P<release>[^ ]*?) (?P<version>[\w\W]*) (?P<platform>[\w\W]+?) "
r"(?P<os>[\w\W]+?)$"
)
# uname's result suppose not be changed frequently,
# so cache it for performance.
@ -16,6 +17,7 @@ class Uname(Tool):
self.kernelRelease: str = ""
self.kernelVersion: str = ""
self.hardwarePlatform: str = ""
self.os: str = ""
@property
def command(self) -> str:
@ -40,7 +42,7 @@ class Uname(Tool):
"""
if (not self.hasResult) or force:
cmd_result = self.run("-vri", noErrorLog=noErrorLog)
cmd_result = self.run("-vrio", noErrorLog=noErrorLog)
if cmd_result.exitCode != 0:
self.isLinux = False
@ -51,9 +53,11 @@ class Uname(Tool):
self.kernelRelease = match_result.group("release")
self.kernelVersion = match_result.group("version")
self.hardwarePlatform = match_result.group("platform")
self.os = match_result.group("os")
self.hasResult = True
return (
self.kernelRelease,
self.kernelVersion,
self.hardwarePlatform,
self.os,
)