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

DPDK: Add 32bit test #3489

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
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
34 changes: 29 additions & 5 deletions lisa/base_tools/wget.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from typing import TYPE_CHECKING, Optional, Tuple, Type
from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Type
from urllib.parse import urlparse

from retry import retry
Expand All @@ -24,6 +24,10 @@ class Wget(Tool):
def command(self) -> str:
return "wget"

def _initialize(self, *args: Any, **kwargs: Any) -> None:
self._url_file_cache: Dict[str, str] = dict()
super()._initialize(*args, **kwargs)

@property
def can_install(self) -> bool:
return True
Expand All @@ -45,8 +49,19 @@ def get(
force_run: bool = False,
timeout: int = 600,
) -> str:
cached_filename = self._url_file_cache.get(url, None)
if cached_filename:
if force_run:
del self._url_file_cache[url]
else:
return cached_filename

is_valid_url(url)

if not filename:
filename = urlparse(url).path.split("/")[-1]
self._log.debug(f"filename is not provided, use {filename} from url.")

file_path, download_path = self._ensure_download_path(file_path, filename)

# remove existing file and dir to download again.
Expand Down Expand Up @@ -85,25 +100,27 @@ def get(
f" stdout: {command_result.stdout}"
f" templog: {temp_log}"
)
self.node.tools[Rm].remove_file(log_file, sudo=sudo)
else:
download_file_path = download_path

if command_result.is_timeout:
raise LisaTimeoutException(
f"wget command is timed out after {timeout} seconds."
)
actual_file_path = self.node.execute(
ls_result = self.node.execute(
f"ls {download_file_path}",
shell=True,
sudo=sudo,
expected_exit_code=0,
expected_exit_code_failure_message="File path does not exist, "
f"{download_file_path}",
)
actual_file_path = ls_result.stdout.strip()
self._url_file_cache[url] = actual_file_path
if executable:
self.node.execute(f"chmod +x {actual_file_path}", sudo=sudo)
self.node.tools[Rm].remove_file(log_file, sudo=sudo)
return actual_file_path.stdout
return actual_file_path

def verify_internet_access(self) -> bool:
try:
Expand Down Expand Up @@ -156,6 +173,13 @@ def get(
force_run: bool = False,
timeout: int = 600,
) -> str:
cached_filename = self._url_file_cache.get(url, None)
if cached_filename:
if force_run:
del self._url_file_cache[url]
else:
return cached_filename

ls = self.node.tools[Ls]

if not filename:
Expand Down Expand Up @@ -183,5 +207,5 @@ def get(
force_run=force_run,
timeout=timeout,
)

self._url_file_cache[url] = download_path
return download_path
13 changes: 10 additions & 3 deletions lisa/tools/meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the MIT license.

from pathlib import PurePath
from typing import cast
from typing import Dict, Optional, cast

from semver import VersionInfo

Expand Down Expand Up @@ -50,15 +50,22 @@ def _install(self) -> bool:
)
return self._check_exists()

def setup(self, args: str, cwd: PurePath, build_dir: str = "build") -> PurePath:
def setup(
self,
args: str,
cwd: PurePath,
build_dir: str = "build",
update_envs: Optional[Dict[str, str]] = None,
) -> PurePath:
self.run(
f"{args} {build_dir}",
parameters=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}"
),
update_envs=update_envs,
)
return cwd.joinpath(build_dir)
39 changes: 33 additions & 6 deletions lisa/tools/pkgconfig.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

from typing import Optional

from assertpy import assert_that
from semver import VersionInfo

Expand All @@ -23,27 +25,52 @@ def install(self) -> bool:
self.node.os.install_packages("pkg-config")
return True

def package_info_exists(self, package_name: str) -> bool:
package_info_result = self.run(f"--modversion {package_name}", force_run=True)
def package_info_exists(
self, package_name: str, pkg_config_path: Optional[str] = None
) -> bool:
if pkg_config_path:
update_env = {"PKG_CONFIG_PATH": f"{pkg_config_path}"}
else:
update_env = None
package_info_result = self.run(
f"--modversion {package_name}",
force_run=True,
shell=True,
update_envs=update_env,
)
return package_info_result.exit_code == 0

def get_package_info(
self,
package_name: str,
update_cached: bool = False,
pkg_config_path: Optional[str] = None,
) -> str:
info_exists = self.package_info_exists(package_name=package_name)
info_exists = self.package_info_exists(
package_name=package_name, pkg_config_path=pkg_config_path
)
if pkg_config_path:
update_env = {"PKG_CONFIG_PATH": f"{pkg_config_path}"}
else:
update_env = None
assert_that(info_exists).described_as(
(
f"pkg-config information was not available for {package_name}. "
"This indicates an installation or package detection bug. "
f"ensure .pc file is available for {package_name} on this OS."
)
).is_true()
return self.run(f"--modversion {package_name}").stdout
return self.run(
f"--modversion {package_name}", shell=True, update_envs=update_env
).stdout

def get_package_version(
self, package_name: str, update_cached: bool = False
self,
package_name: str,
update_cached: bool = False,
pkg_config_path: Optional[str] = None,
) -> VersionInfo:
version_info = self.get_package_info(package_name, update_cached=update_cached)
version_info = self.get_package_info(
package_name, update_cached=update_cached, pkg_config_path=pkg_config_path
)
return parse_version(version_info)
17 changes: 17 additions & 0 deletions lisa/tools/tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def extract(
gzip: bool = False,
sudo: bool = False,
raise_error: bool = True,
skip_existing_files: bool = False,
) -> None:
# create folder when it doesn't exist
assert_that(strip_components).described_as(
Expand All @@ -48,6 +49,21 @@ def extract(
if strip_components:
# optionally strip N top level components from a tar file
tar_cmd += f" --strip-components={strip_components}"

if skip_existing_files:
# NOTE:
# This option is for when you are using
# Wget.get(..., force_run=False)
#
# Do not use this option if:
# - You may need to extract multiple versions of a
# given tarball on a node
# - You have provided a default output filename to Wget.get
# to fetch the tarball
#
# This skip-old-files option could silently skip extracting
# the second version of the tarball.
tar_cmd += " --skip-old-files"
result = self.run(tar_cmd, shell=True, force_run=True, sudo=sudo)
if raise_error:
result.assert_exit_code(
Expand Down Expand Up @@ -127,6 +143,7 @@ def extract(
gzip: bool = False,
sudo: bool = False,
raise_error: bool = True,
skip_existing_files: bool = False,
) -> None:
mkdir = self.node.tools[Mkdir]
mkdir.create_directory(dest_dir)
Expand Down
Loading
Loading