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 13, 2024
1 parent 094aab1 commit 22b55f2
Show file tree
Hide file tree
Showing 3 changed files with 270 additions and 208 deletions.
72 changes: 52 additions & 20 deletions microsoft/testsuites/kselftest/kselftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@
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,
Debian,
Linux,
NixOS,
OtherLinux,
Posix,
RPMDistro,
Suse,
Ubuntu,
)
from lisa.testsuite import TestResult
from lisa.tools import Cp, Git, Ls, Make, RemoteCopy, Tar
from lisa.tools.chmod import Chmod
from lisa.tools.mkdir import Mkdir
from lisa.tools.whoami import Whoami
from lisa.util import LisaException, UnsupportedDistroException, find_groups_in_lines

_UBUNTU_OS_PACKAGES = [
Expand Down Expand Up @@ -98,31 +107,56 @@ def __init__(

# tar file path specified in yml
self._tar_file_path = kselftest_file_path
kselftest_install_path = "/tmp/kselftest"
kselftest_packages = "kselftest-packages"
if self._tar_file_path:
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._remote_tar_path = (
self.node.get_pure_path(
kselftest_install_path
) / os.path.basename(self._tar_file_path)
)
self._kself_installed_dir = (
self.node.get_pure_path(
kselftest_install_path
) / kselftest_packages
)
else:
self._remote_tar_path = (
self.get_tool_path(
use_global=True
) / os.path.basename(self._tar_file_path)
)
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 (
if (
(
isinstance(self.node.os, Posix)
and not isinstance(self.node.os, Linux)
)
or (
isinstance(self.node.os, Debian)
and not isinstance(self.node.os, Ubuntu)
)
or (
isinstance(self.node.os, Ubuntu)
and self.node.os.information.version >= "18.4.0"
and self.node.os.information.version < "18.4.0"
)
or isinstance(self.node.os, CBLMariner)
or (
isinstance(self.node.os, RPMDistro)
and not isinstance(self.node.os, CBLMariner)
)
or (isinstance(self.node.os, (Suse, NixOS, OtherLinux)))
):
raise UnsupportedDistroException(
self.node.os, "kselftests in LISA does not support this os"
self.node.os,
"kselftests in LISA does not support this os"
)

if self._tar_file_path:
mkdir = self.node.tools[Mkdir]
mkdir.create_directory(self._remote_tar_path.parent.as_posix())
Expand Down Expand Up @@ -202,14 +236,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 = "/tmp/"
if os.path.exists(result_directory) is False:
mkdir = self.node.tools[Mkdir]
mkdir.create_directory(result_directory)
Expand All @@ -218,7 +250,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 22b55f2

Please sign in to comment.