зеркало из https://github.com/microsoft/lisa.git
Create Mv tool for simple file move operations
This commit is contained in:
Родитель
ed7531449e
Коммит
bcf1706d52
|
@ -1,8 +1,9 @@
|
|||
from .cat import Cat
|
||||
from .mv import Mv
|
||||
from .rpm import Rpm
|
||||
from .sed import Sed
|
||||
from .uname import Uname
|
||||
from .wget import Wget
|
||||
from .yum_config_manager import YumConfigManager
|
||||
|
||||
__all__ = ["Uname", "Sed", "Wget", "Cat", "Rpm", "YumConfigManager"]
|
||||
__all__ = ["Uname", "Sed", "Wget", "Cat", "Rpm", "YumConfigManager", "Mv"]
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT license.
|
||||
|
||||
from lisa.executable import Tool
|
||||
|
||||
|
||||
class Mv(Tool):
|
||||
@property
|
||||
def command(self) -> str:
|
||||
return "mv"
|
||||
|
||||
@property
|
||||
def can_install(self) -> bool:
|
||||
return False
|
||||
|
||||
def move(
|
||||
self, src_path: str, dest_path: str, overwrite: bool = False, sudo: bool = False
|
||||
) -> None:
|
||||
args = "-f" if overwrite else ""
|
||||
self.run(
|
||||
f"{args} {src_path} {dest_path}",
|
||||
sudo=sudo,
|
||||
shell=True,
|
||||
force_run=True,
|
||||
expected_exit_code=0,
|
||||
)
|
|
@ -2,7 +2,7 @@
|
|||
# Licensed under the MIT license.
|
||||
|
||||
|
||||
from lisa.base_tools import Cat, Rpm, Sed, Uname, Wget, YumConfigManager
|
||||
from lisa.base_tools import Cat, Mv, Rpm, Sed, Uname, Wget, YumConfigManager
|
||||
|
||||
from .blkid import Blkid
|
||||
from .chmod import Chmod
|
||||
|
@ -155,6 +155,7 @@ __all__ = [
|
|||
"Modinfo",
|
||||
"Modprobe",
|
||||
"Mount",
|
||||
"Mv",
|
||||
"Netperf",
|
||||
"NFSClient",
|
||||
"NFSServer",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
from pathlib import PurePath
|
||||
|
||||
from lisa.base_tools import Uname, Wget
|
||||
from lisa.base_tools import Mv, Uname, Wget
|
||||
from lisa.executable import Tool
|
||||
from lisa.operating_system import CBLMariner, Posix, Redhat
|
||||
from lisa.tools.service import Service
|
||||
|
@ -45,8 +45,8 @@ class DockerCompose(Tool):
|
|||
sudo=True,
|
||||
)
|
||||
self.node.execute(f"sudo chmod +x {filename}")
|
||||
self.node.execute(
|
||||
"mv docker-compose /usr/bin/", sudo=True, expected_exit_code=0
|
||||
self.node.tools[Mv].move(
|
||||
"docker-compose", "/usr/bin/", overwrite=True, sudo=True
|
||||
)
|
||||
|
||||
def _install(self) -> bool:
|
||||
|
|
|
@ -8,6 +8,7 @@ from typing import Any, List, Optional, Type, cast
|
|||
from dataclasses_json import dataclass_json
|
||||
|
||||
from lisa import schema
|
||||
from lisa.base_tools import Mv
|
||||
from lisa.node import Node
|
||||
from lisa.operating_system import Redhat, Ubuntu
|
||||
from lisa.tools import Echo, Git, Make, Sed, Uname
|
||||
|
@ -219,7 +220,7 @@ class SourceInstaller(BaseInstaller):
|
|||
# the gcc version of Redhat 7.x is too old. Upgrade it.
|
||||
if isinstance(node.os, Redhat) and node.os.information.version < "8.0.0":
|
||||
node.os.install_packages(["devtoolset-8"])
|
||||
result = node.execute("mv /bin/gcc /bin/gcc_back", sudo=True)
|
||||
node.tools[Mv].move("/bin/gcc", "/bin/gcc_back", overwrite=True, sudo=True)
|
||||
result.assert_exit_code()
|
||||
result = node.execute(
|
||||
"ln -s /opt/rh/devtoolset-8/root/usr/bin/gcc /bin/gcc", sudo=True
|
||||
|
|
|
@ -8,6 +8,7 @@ from typing import Any, List, Pattern, Tuple, Type, Union
|
|||
from assertpy import assert_that, fail
|
||||
from semver import VersionInfo
|
||||
|
||||
from lisa.base_tools import Mv
|
||||
from lisa.executable import Tool
|
||||
from lisa.nic import NicInfo
|
||||
from lisa.operating_system import Debian, Fedora, Ubuntu
|
||||
|
@ -811,15 +812,8 @@ class DpdkTestpmd(Tool):
|
|||
),
|
||||
)
|
||||
if node.shell.exists(node.get_pure_path("/usr/bin/meson")):
|
||||
node.execute(
|
||||
"mv /usr/bin/meson /usr/bin/meson.bak",
|
||||
cwd=cwd,
|
||||
sudo=True,
|
||||
expected_exit_code=0,
|
||||
expected_exit_code_failure_message=(
|
||||
"renaming previous meson binary or link in /usr/bin/meson"
|
||||
" failed."
|
||||
),
|
||||
node.tools[Mv].move(
|
||||
"/usr/bin/meson", "/usr/bin/meson.bak", overwrite=True, sudo=True
|
||||
)
|
||||
node.execute(
|
||||
"ln -s /usr/local/bin/meson /usr/bin/meson",
|
||||
|
@ -843,15 +837,7 @@ class DpdkTestpmd(Tool):
|
|||
dest_dir=str(cwd),
|
||||
sudo=True,
|
||||
)
|
||||
node.execute(
|
||||
"mv ninja /usr/bin/ninja",
|
||||
cwd=cwd,
|
||||
sudo=True,
|
||||
expected_exit_code=0,
|
||||
expected_exit_code_failure_message=(
|
||||
"Could not move latest ninja script after unzip into /usr/bin."
|
||||
),
|
||||
)
|
||||
node.tools[Mv].move("ninja", "/usr/bin/ninja", overwrite=True, sudo=True)
|
||||
node.execute(
|
||||
"pip3 install --upgrade pyelftools",
|
||||
sudo=True,
|
||||
|
|
Загрузка…
Ссылка в новой задаче