Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lisa/microsoft/testsuites/display/modetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
from typing import List, Type, Union

from lisa.executable import Tool
from lisa.operating_system import SLES, CpuArchitecture, Oracle, Redhat, Suse, Ubuntu
from lisa.operating_system import (
SLES,
CBLMariner,
CpuArchitecture,
Oracle,
Redhat,
Suse,
Ubuntu,
)
from lisa.tools.gcc import Gcc
from lisa.tools.git import Git
from lisa.util import UnsupportedDistroException
Expand Down Expand Up @@ -33,6 +41,11 @@ def is_status_connected(self, driver_name: str) -> bool:
def _install(self) -> bool:
if isinstance(self.node.os, Ubuntu):
self.node.os.install_packages("libdrm-tests")
if (
isinstance(self.node.os, CBLMariner)
and self.node.os.information.version.major >= 4
):
self.node.os.install_packages("drm-utils")
if isinstance(self.node.os, Redhat) or isinstance(self.node.os, Suse):
self._install_from_src()
return self._check_exists()
Expand Down
28 changes: 26 additions & 2 deletions lisa/operating_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,7 @@ def name_pattern(cls) -> Pattern[str]:

def __init__(self, node: Any) -> None:
super().__init__(node)
self._dnf_tool_name: str
self._dnf_tool_name: Optional[str] = None

def _initialize_package_installation(self) -> None:
self.set_kill_user_processes()
Expand All @@ -2187,6 +2187,8 @@ def _initialize_package_installation(self) -> None:
self._dnf_tool_name = "tdnf -q"

def _dnf_tool(self) -> str:
if not self._dnf_tool_name:
self._initialize_package_installation()
return self._dnf_tool_name

Comment on lines 2189 to 2193
def _package_exists(self, package: str) -> bool:
Expand Down Expand Up @@ -2241,13 +2243,35 @@ def _create_local_repo(self, source_tarball: Path) -> None:
# Disable KillUserProcesses to avoid test processes being terminated when
# the SSH session is reset
def set_kill_user_processes(self) -> None:
service = self._node.tools[Service]
if not service.check_service_exists("systemd-logind"):
self._log.debug(
"Skipping restart because systemd-logind service is absent."
)
return

if self.information.version.major >= 4:
from lisa.tools import Mkdir, Tee

drop_in_dir = self._node.get_pure_path("/etc/systemd/logind.conf.d")
drop_in_file = drop_in_dir / "90-lisa.conf"

self._node.tools[Mkdir].create_directory(str(drop_in_dir), sudo=True)
self._node.tools[Tee].write_to_file(
value="[Login]\nKillUserProcesses=no",
file=drop_in_file,
sudo=True,
)
service.restart_service("systemd-logind")
return

sed = self._node.tools[Sed]
sed.append(
text="KillUserProcesses=no",
file="/etc/systemd/logind.conf",
sudo=True,
)
self._node.tools[Service].restart_service("systemd-logind")
service.restart_service("systemd-logind")

def _replace_default_entry(self, entry: str) -> None:
self._log.debug(f"set boot entry to: {entry}")
Expand Down
29 changes: 19 additions & 10 deletions lisa/tools/grub_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ def create(cls, node: "Node", *args: Any, **kwargs: Any) -> Tool:
return GrubConfigAzl2(node, args, kwargs)
if node.os.information.release == "3.0":
return GrubConfigAzl3(node, args, kwargs)
if node.os.information.version.major >= 4:
return GrubConfigAzl4(node, args, kwargs)
elif isinstance(node.os, Debian):
return GrubConfigDebian(node, args, kwargs)
elif isinstance(node.os, Redhat):
return GrubConfigRedhat(node, args, kwargs)

raise UnsupportedDistroException(
os=node.os,
message="Grub tool only supported on CBLMariner 2.0/3.0, "
message="Grub tool only supported on CBLMariner 2.0/3.0/4.0, "
"Debian-based distributions, and RHEL-based distributions.",
)
Comment on lines 34 to 38

Expand Down Expand Up @@ -167,6 +169,13 @@ def set_kernel_cmdline_arg(self, arg: str, value: str) -> None:
class GrubConfigRedhat(GrubConfig):
_GRUB_CMDLINE_LINE_REGEX = r"^GRUB_CMDLINE_LINUX="
_GRUB_DEFAULT_FILE = "/etc/default/grub"
_UEFI_GRUB_PATHS = [
"/boot/efi/EFI/redhat/grub.cfg",
"/boot/efi/EFI/centos/grub.cfg",
"/boot/efi/EFI/almalinux/grub.cfg",
"/boot/efi/EFI/rocky/grub.cfg",
"/boot/efi/EFI/BOOT/grub.cfg",
]

def __init__(self, node: "Node", *args: Any, **kwargs: Any) -> None:
super().__init__("grub2-mkconfig", "grub2-tools", node, *args, **kwargs)
Expand Down Expand Up @@ -251,15 +260,7 @@ def _get_grub_config_path(self) -> str:
self._log.debug("Detected UEFI system, checking for UEFI GRUB paths")

# UEFI system - check common UEFI paths
uefi_paths = [
"/boot/efi/EFI/redhat/grub.cfg",
"/boot/efi/EFI/centos/grub.cfg",
"/boot/efi/EFI/almalinux/grub.cfg",
"/boot/efi/EFI/rocky/grub.cfg",
"/boot/efi/EFI/BOOT/grub.cfg",
]

for path in uefi_paths:
for path in self._UEFI_GRUB_PATHS:
ls_result = ls_tool.run(path, sudo=True, force_run=True)
if ls_result.exit_code == 0:
self._log.debug(f"Found UEFI GRUB config at: {path}")
Expand All @@ -278,3 +279,11 @@ def _get_grub_config_path(self) -> str:
# Default to BIOS path
self._log.debug("Using default BIOS GRUB config path")
return "/boot/grub2/grub.cfg"


class GrubConfigAzl4(GrubConfigRedhat):
# On Azure Linux 4 the grub config is under the azurelinux EFI directory.
_UEFI_GRUB_PATHS = [
"/boot/efi/EFI/azurelinux/grub.cfg",
"/boot/efi/EFI/BOOT/grub.cfg",
]
Loading