diff --git a/examples/testsuites/helloworld.py b/examples/testsuites/helloworld.py index b53ea4337..779f49c12 100644 --- a/examples/testsuites/helloworld.py +++ b/examples/testsuites/helloworld.py @@ -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: diff --git a/lisa/core/node.py b/lisa/core/node.py index 04f4a6573..b4a122263 100644 --- a/lisa/core/node.py +++ b/lisa/core/node.py @@ -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( diff --git a/lisa/tool/uname.py b/lisa/tool/uname.py index d2799ae71..f7a5067a2 100644 --- a/lisa/tool/uname.py +++ b/lisa/tool/uname.py @@ -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[^ ]*?) (?P[\w\W]*) (?P[\w_]+?)$" + r"(?P[^ ]*?) (?P[\w\W]*) (?P[\w\W]+?) " + r"(?P[\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, )