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 9, 2024
1 parent 9de078a commit 2a32c00
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 200 deletions.
42 changes: 24 additions & 18 deletions microsoft/testsuites/kselftest/kselftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
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 (
BSD, FreeBSD, OpenBSD, BMC, MacOS, CoreOs, Alpine,
Debian, Ubuntu, RPMDistro, Fedora, Redhat, CentOs,
Oracle, AlmaLinux, CBLMariner, Suse, SLES, NixOS, OtherLinux,
)
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,27 +103,31 @@ 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"

# install common dependencies
def _install(self) -> bool:
if not (
(
isinstance(self.node.os, Ubuntu)
and self.node.os.information.version >= "18.4.0"
)
or isinstance(self.node.os, CBLMariner)
if (isinstance(self.node.os,
(BSD, FreeBSD, OpenBSD, BMC, MacOS, CoreOs, Alpine,
Debian, RPMDistro, Fedora, Redhat, CentOs, Oracle,
AlmaLinux, Suse, SLES, NixOS, OtherLinux))
or (isinstance(self.node.os, Ubuntu) and self.node.os.information.version < "18.4.0")
):
raise UnsupportedDistroException(
raise UnsupportedDistroException(
self.node.os, "kselftests in LISA does not support this os"
)

Expand Down Expand Up @@ -202,14 +210,12 @@ def run_all(
test_result: TestResult,
log_path: str,
timeout: int = 5000,
run_test_as_root: bool = False,
) -> List[KselftestResult]:
# Executing kselftest as root may cause
# VM to hang

# get username
username = self.node.tools[Whoami].get_username()
result_directory = f"/home/{username}"
# get result directory
result_directory = f"/tmp/"
if os.path.exists(result_directory) is False:
mkdir = self.node.tools[Mkdir]
mkdir.create_directory(result_directory)
Expand All @@ -218,7 +224,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 2a32c00

Please sign in to comment.