Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DpdkTestpmd: Installation path cleanup #3426

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions lisa/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
from .lsvmbus import Lsvmbus
from .make import Make
from .mdadm import Mdadm
from .meson import Meson
from .mkdir import Mkdir
from .mkfs import FileSystem, Mkfs, Mkfsext, Mkfsxfs
from .modinfo import Modinfo
Expand Down Expand Up @@ -184,6 +185,7 @@
"Lspci",
"Lsvmbus",
"Make",
"Meson",
"Mdadm",
"Mkdir",
"Mkfs",
Expand Down
10 changes: 9 additions & 1 deletion lisa/tools/ln.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ def command(self) -> str:
def can_install(self) -> bool:
return False

def create_link(self, target: str, link: str, is_symbolic: bool = True) -> None:
def create_link(
self,
target: str,
link: str,
is_symbolic: bool = True,
force: bool = False,
) -> None:
cmd = ""
if is_symbolic:
cmd += " -s "
if force:
cmd += " -f "
cmd += f"{target} {link}"
self.run(
cmd,
Expand Down
56 changes: 56 additions & 0 deletions lisa/tools/meson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from pathlib import PurePath
from typing import cast

from semver import VersionInfo

from lisa.executable import Tool
from lisa.operating_system import Posix

from .ln import Ln
from .python import Pip
from .whoami import Whoami


class Meson(Tool):
@property
def command(self) -> str:
return "meson"

def _check_exists(self) -> bool:
result = self.node.execute("meson --version", shell=True)
return result.exit_code == 0 and VersionInfo.parse(result.stdout) >= "0.52.0"

@property
def can_install(self) -> bool:
return self.node.is_posix

def _install(self) -> bool:
posix_os: Posix = cast(Posix, self.node.os)
# use pip to make sure we install a recent version
if (not posix_os.package_exists("meson")) or posix_os.get_package_information(
"meson", use_cached=False
) < "0.52.0":
username = self.node.tools[Whoami].get_username()
self.node.tools[Pip].install_packages("meson", install_to_user=True)
# environment variables won't expand even when using shell=True :\
self.node.tools[Ln].create_link(
f"/home/{username}/.local/bin/meson", "/usr/bin/meson", force=True
)

return self._check_exists()

def setup(self, args: str, cwd: PurePath, build_dir: str = "build") -> PurePath:
self.run(
f"{args} {build_dir}",
force_run=True,
shell=True,
cwd=cwd,
expected_exit_code=0,
expected_exit_code_failure_message=(
f"Could not configure {str(cwd)} with meson using args {args}"
),
)
return cwd.joinpath(build_dir)
9 changes: 7 additions & 2 deletions lisa/tools/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ def _install(self) -> bool:
self.node.os.install_packages(package_name)
return self._check_exists()

def install_packages(self, packages_name: str, install_path: str = "") -> None:
def install_packages(
self, packages_name: str, install_path: str = "", install_to_user: bool = False
) -> None:
node = self.node
cmd_line = f"install -q {packages_name}"
if not install_to_user:
cmd_line = f"install -q {packages_name}"
else:
cmd_line = f"install --user -q {packages_name}"

envs = {}
if install_path != "":
Expand Down
Loading
Loading