Skip to content

Commit

Permalink
Added BareMetal platform support for LTP/Kselftest
Browse files Browse the repository at this point in the history
  • Loading branch information
paull committed Aug 3, 2024
1 parent 9de078a commit d4365dd
Show file tree
Hide file tree
Showing 4 changed files with 255 additions and 190 deletions.
7 changes: 6 additions & 1 deletion lisa/operating_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class OperatingSystem:
__release_pattern = re.compile(r"^DISTRIB_ID='?([^ \n']+).*$", re.M)
__suse_release_pattern = re.compile(r"^(SUSE).*$", re.M)
__bmc_release_pattern = re.compile(r".*(wcscli).*$", re.M)
__soc_variant_pattern = re.compile(r"^VARIANT=\"?([^\" \r\n]+).*?\"?\r?$", re.M)

__posix_factory: Optional[Factory[Any]] = None

Expand Down Expand Up @@ -217,6 +218,7 @@ def _get_detect_string(cls, node: Any) -> Iterable[str]:
cmd_result = typed_node.execute(cmd="cat /etc/os-release", no_error_log=True)
yield get_matched_str(cmd_result.stdout, cls.__os_release_pattern_name)
yield get_matched_str(cmd_result.stdout, cls.__os_release_pattern_id)
yield get_matched_str(cmd_result.stdout, cls.__soc_variant_pattern)
cmd_result_os_release = cmd_result

# for RedHat, CentOS 6.x
Expand Down Expand Up @@ -683,10 +685,13 @@ class MacOS(Posix):
def name_pattern(cls) -> Pattern[str]:
return re.compile("^Darwin$")


class Linux(Posix):
...

class M4O(Linux):
@classmethod
def name_pattern(cls) -> Pattern[str]:
return re.compile("^SoC$")

class CoreOs(Linux):
@classmethod
Expand Down
23 changes: 14 additions & 9 deletions microsoft/testsuites/kselftest/kselftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from lisa.executable import Tool
from lisa.messages import TestStatus, send_sub_test_result_message
from lisa.node import Node
from lisa.operating_system import CBLMariner, Ubuntu
from lisa.operating_system import CBLMariner, Ubuntu, M4O
from lisa.testsuite import TestResult
from lisa.tools import Cp, Git, Ls, Make, RemoteCopy, Tar
from lisa.tools.chmod import Chmod
Expand Down Expand Up @@ -99,14 +99,19 @@ def __init__(
# tar file path specified in yml
self._tar_file_path = kselftest_file_path
if self._tar_file_path:
self._remote_tar_path = (
self.node.get_pure_path("/tmp/kselftest") / os.path.basename(self._tar_file_path)
)
self._kself_installed_dir = (
self.node.get_pure_path("/tmp/kselftest") / "kselftest-packages"
)
else:
self._remote_tar_path = self.get_tool_path(
use_global=True
) / os.path.basename(self._tar_file_path)

# command to run kselftests
self._kself_installed_dir = (
self.get_tool_path(use_global=True) / "kselftest-packages"
)
self._kself_installed_dir = (
self.get_tool_path(use_global=True) / "kselftest-packages"
)

self._command = self._kself_installed_dir / "run_kselftest.sh"

Expand All @@ -117,7 +122,7 @@ def _install(self) -> bool:
isinstance(self.node.os, Ubuntu)
and self.node.os.information.version >= "18.4.0"
)
or isinstance(self.node.os, CBLMariner)
or isinstance(self.node.os, CBLMariner) or isinstance(self.node.os, M4O)
):
raise UnsupportedDistroException(
self.node.os, "kselftests in LISA does not support this os"
Expand Down Expand Up @@ -209,7 +214,7 @@ def run_all(

# get username
username = self.node.tools[Whoami].get_username()
result_directory = f"/home/{username}"
result_directory = f"/tmp/{username}"
if os.path.exists(result_directory) is False:
mkdir = self.node.tools[Mkdir]
mkdir.create_directory(result_directory)
Expand All @@ -218,7 +223,7 @@ def run_all(
result_file = f"{result_directory}/{result_file_name}"
self.run(
f" 2>&1 | tee {result_file}",
sudo=run_test_as_root,
sudo=True,
force_run=True,
shell=True,
timeout=timeout,
Expand Down
Loading

0 comments on commit d4365dd

Please sign in to comment.