Fix imports
Signed-off-by: Katarzyna Treder <katarzyna.treder@h-partners.com>
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
#
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright(c) 2019-2021 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
|
@@ -1,16 +1,17 @@
|
||||
#
|
||||
# Copyright(c) 2019-2021 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import test_tools.common.linux_command as linux_comm
|
||||
import type_def.size as size
|
||||
from core.test_run import TestRun
|
||||
from test_tools.common.linux_command import LinuxCommand
|
||||
|
||||
|
||||
class Dd(linux_comm.LinuxCommand):
|
||||
class Dd(LinuxCommand):
|
||||
def __init__(self):
|
||||
linux_comm.LinuxCommand.__init__(self, TestRun.executor, 'dd')
|
||||
LinuxCommand.__init__(self, TestRun.executor, 'dd')
|
||||
|
||||
def block_size(self, value: size.Size):
|
||||
return self.set_param('bs', int(value.get_value()))
|
||||
|
@@ -1,16 +1,17 @@
|
||||
#
|
||||
# Copyright(c) 2019-2021 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import test_tools.common.linux_command as linux_comm
|
||||
import type_def.size as size
|
||||
from core.test_run import TestRun
|
||||
from test_tools.common.linux_command import LinuxCommand
|
||||
from type_def.size import Size
|
||||
|
||||
|
||||
class Ddrescue(linux_comm.LinuxCommand):
|
||||
class Ddrescue(LinuxCommand):
|
||||
def __init__(self):
|
||||
linux_comm.LinuxCommand.__init__(self, TestRun.executor, 'ddrescue')
|
||||
LinuxCommand.__init__(self, TestRun.executor, 'ddrescue')
|
||||
self.source_path = None
|
||||
self.destination_path = None
|
||||
self.param_name_prefix = "--"
|
||||
@@ -35,13 +36,13 @@ class Ddrescue(linux_comm.LinuxCommand):
|
||||
def force(self):
|
||||
return self.set_flags("force")
|
||||
|
||||
def block_size(self, value: size.Size):
|
||||
def block_size(self, value: Size):
|
||||
return self.set_param('sector-size', int(value.get_value()))
|
||||
|
||||
def size(self, value: size.Size):
|
||||
def size(self, value: Size):
|
||||
return self.set_param('size', int(value.get_value()))
|
||||
|
||||
def __str__(self):
|
||||
command = linux_comm.LinuxCommand.__str__(self)
|
||||
command = LinuxCommand.__str__(self)
|
||||
command += f" {self.source_path} {self.destination_path}"
|
||||
return command
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2019-2021 Intel Corporation
|
||||
# Copyright(c) 2023-2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
@@ -30,11 +30,6 @@ class DmTarget(Enum):
|
||||
return self.name.lower()
|
||||
|
||||
|
||||
class DmTable:
|
||||
class TableEntry:
|
||||
pass
|
||||
|
||||
|
||||
class DmTable:
|
||||
class TableEntry:
|
||||
def __init__(self, offset: int, length: int, target: DmTarget, *params):
|
||||
@@ -131,7 +126,7 @@ class DmTable:
|
||||
|
||||
return self
|
||||
|
||||
def add_entry(self, entry: DmTable.TableEntry):
|
||||
def add_entry(self, entry: TableEntry):
|
||||
self.table.append(entry)
|
||||
return self
|
||||
|
||||
|
@@ -7,8 +7,7 @@ import os
|
||||
import posixpath
|
||||
|
||||
from core.test_run import TestRun
|
||||
from test_tools import disk_tools
|
||||
from test_tools.disk_tools import get_sysfs_path
|
||||
from test_tools.disk_tools import get_sysfs_path, get_block_size, get_size
|
||||
from test_tools.fs_tools import check_if_file_exists, readlink
|
||||
from connection.utils.output import CmdException
|
||||
|
||||
@@ -50,7 +49,7 @@ def discover_hdd_devices(block_devices, devices_res):
|
||||
for dev in block_devices:
|
||||
if TestRun.executor.run_expect_success(f"cat /sys/block/{dev}/removable").stdout == "1":
|
||||
continue # skip removable drives
|
||||
block_size = disk_tools.get_block_size(dev)
|
||||
block_size = get_block_size(dev)
|
||||
if int(block_size) == 4096:
|
||||
disk_type = 'hdd4k'
|
||||
else:
|
||||
@@ -62,7 +61,7 @@ def discover_hdd_devices(block_devices, devices_res):
|
||||
f"sg_inq /dev/{dev} | grep -i 'serial number'"
|
||||
).stdout.split(': ')[1].strip(),
|
||||
"blocksize": block_size,
|
||||
"size": disk_tools.get_size(dev)})
|
||||
"size": get_size(dev)})
|
||||
block_devices.clear()
|
||||
|
||||
|
||||
@@ -99,8 +98,8 @@ def discover_ssd_devices(block_devices, devices_res):
|
||||
"type": disk_type,
|
||||
"path": resolve_to_by_id_link(device_path),
|
||||
"serial": serial_number,
|
||||
"blocksize": disk_tools.get_block_size(dev),
|
||||
"size": disk_tools.get_size(dev)})
|
||||
"blocksize": get_block_size(dev),
|
||||
"size": get_size(dev)})
|
||||
block_devices.remove(dev)
|
||||
|
||||
|
||||
@@ -125,7 +124,7 @@ def get_system_disks():
|
||||
def __get_slaves(device_name: str):
|
||||
try:
|
||||
device_names = TestRun.executor.run_expect_success(
|
||||
f"ls {os.path.join(get_sysfs_path(device_name), "slaves")}").stdout.splitlines()
|
||||
f"ls {os.path.join(get_sysfs_path(device_name), 'slaves')}").stdout.splitlines()
|
||||
except CmdException as e:
|
||||
if "No such file or directory" not in e.output.stderr:
|
||||
raise
|
||||
|
@@ -10,11 +10,10 @@ import time
|
||||
from enum import Enum
|
||||
from typing import List
|
||||
|
||||
import test_tools.fs_tools
|
||||
from core.test_run import TestRun
|
||||
from test_tools.dd import Dd
|
||||
from test_tools.fs_tools import readlink, parse_ls_output, ls, check_if_directory_exists, \
|
||||
create_directory, wipe_filesystem
|
||||
create_directory, wipefs, is_mounted
|
||||
from test_tools.udev import Udev
|
||||
from type_def.size import Size, Unit
|
||||
|
||||
@@ -247,7 +246,7 @@ def get_first_partition_offset(device, aligned: bool):
|
||||
|
||||
|
||||
def remove_partitions(device):
|
||||
if test_tools.fs_tools.is_mounted(device.path):
|
||||
if is_mounted(device.path):
|
||||
device.unmount()
|
||||
|
||||
for partition in device.partitions:
|
||||
@@ -255,7 +254,7 @@ def remove_partitions(device):
|
||||
|
||||
TestRun.LOGGER.info(f"Removing partitions from device: {device.path} "
|
||||
f"({device.get_device_id()}).")
|
||||
wipe_filesystem(device)
|
||||
wipefs(device)
|
||||
Udev.trigger()
|
||||
Udev.settle()
|
||||
output = TestRun.executor.run(f"ls {device.path}* -1")
|
||||
|
@@ -8,12 +8,12 @@ import datetime
|
||||
import uuid
|
||||
|
||||
from packaging.version import Version
|
||||
import test_tools.fio.fio_param
|
||||
import test_tools.fs_tools
|
||||
import test_tools.wget
|
||||
|
||||
from core.test_run import TestRun
|
||||
from test_tools import fs_tools
|
||||
from connection.utils.output import CmdException
|
||||
from test_tools import wget
|
||||
from test_tools.fio.fio_param import FioParam, FioParamCmd, FioOutput, FioParamConfig
|
||||
from test_tools.fs_tools import uncompress_archive
|
||||
|
||||
|
||||
class Fio:
|
||||
@@ -22,12 +22,12 @@ class Fio:
|
||||
self.default_run_time = datetime.timedelta(hours=1)
|
||||
self.jobs = []
|
||||
self.executor = executor_obj if executor_obj is not None else TestRun.executor
|
||||
self.base_cmd_parameters: test_tools.fio.fio_param.FioParam = None
|
||||
self.global_cmd_parameters: test_tools.fio.fio_param.FioParam = None
|
||||
self.base_cmd_parameters: FioParam = None
|
||||
self.global_cmd_parameters: FioParam = None
|
||||
|
||||
def create_command(self, output_type=test_tools.fio.fio_param.FioOutput.json):
|
||||
self.base_cmd_parameters = test_tools.fio.fio_param.FioParamCmd(self, self.executor)
|
||||
self.global_cmd_parameters = test_tools.fio.fio_param.FioParamConfig(self, self.executor)
|
||||
def create_command(self, output_type=FioOutput.json):
|
||||
self.base_cmd_parameters = FioParamCmd(self, self.executor)
|
||||
self.global_cmd_parameters = FioParamConfig(self, self.executor)
|
||||
|
||||
self.fio_file = \
|
||||
f'fio_run_{datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")}_{uuid.uuid4().hex}'
|
||||
@@ -50,8 +50,8 @@ class Fio:
|
||||
|
||||
def install(self):
|
||||
fio_url = f"http://brick.kernel.dk/snaps/fio-{self.min_fio_version}.tar.bz2"
|
||||
fio_package = test_tools.wget.download_file(fio_url)
|
||||
fs_tools.uncompress_archive(fio_package)
|
||||
fio_package = wget.download_file(fio_url)
|
||||
uncompress_archive(fio_package)
|
||||
TestRun.executor.run_expect_success(
|
||||
f"cd {fio_package.parent_dir}/fio-{self.min_fio_version}"
|
||||
f" && ./configure && make -j && make install"
|
||||
@@ -106,7 +106,7 @@ class Fio:
|
||||
command = f"echo '{self.execution_cmd_parameters()}' |" \
|
||||
f" {str(self.base_cmd_parameters)} -"
|
||||
else:
|
||||
fio_parameters = test_tools.fio.fio_param.FioParamCmd(self, self.executor)
|
||||
fio_parameters = FioParamCmd(self, self.executor)
|
||||
fio_parameters.command_env_var.update(self.base_cmd_parameters.command_env_var)
|
||||
fio_parameters.command_param.update(self.base_cmd_parameters.command_param)
|
||||
fio_parameters.command_param.update(self.global_cmd_parameters.command_param)
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#
|
||||
|
||||
import secrets
|
||||
from aenum import Enum
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class Pattern(Enum):
|
||||
|
@@ -103,9 +103,6 @@ class FioResult:
|
||||
def write_runtime(self):
|
||||
return Time(microseconds=self.job.write.runtime)
|
||||
|
||||
def write_completion_latency_average(self):
|
||||
return Time(nanoseconds=self.job.write.lat_ns.mean)
|
||||
|
||||
def write_completion_latency_min(self):
|
||||
return Time(nanoseconds=self.job.write.lat_ns.min)
|
||||
|
||||
@@ -139,9 +136,6 @@ class FioResult:
|
||||
def trim_runtime(self):
|
||||
return Time(microseconds=self.job.trim.runtime)
|
||||
|
||||
def trim_completion_latency_average(self):
|
||||
return Time(nanoseconds=self.job.trim.lat_ns.mean)
|
||||
|
||||
def trim_completion_latency_min(self):
|
||||
return Time(nanoseconds=self.job.trim.lat_ns.min)
|
||||
|
||||
|
@@ -11,7 +11,8 @@ import re
|
||||
import textwrap
|
||||
from collections import namedtuple
|
||||
from datetime import datetime, timedelta
|
||||
from enum import Enum, IntFlag
|
||||
from enum import Enum
|
||||
from aenum import IntFlag # IntFlag from enum is not able to correctly parse string like "x|y|z"
|
||||
|
||||
from connection.utils.output import CmdException
|
||||
from core.test_run import TestRun
|
||||
@@ -402,7 +403,7 @@ def create_random_test_file(target_file_path: str,
|
||||
return file
|
||||
|
||||
|
||||
def create_filesystem(device, filesystem: Filesystem, force=True, blocksize=None):
|
||||
def mkfs(device, filesystem: Filesystem, force=True, blocksize=None):
|
||||
TestRun.LOGGER.info(
|
||||
f"Creating filesystem ({filesystem.name}) on device: {device.path}")
|
||||
force_param = ' -f ' if filesystem == Filesystem.xfs else ' -F '
|
||||
@@ -417,7 +418,7 @@ def create_filesystem(device, filesystem: Filesystem, force=True, blocksize=None
|
||||
f"Successfully created filesystem on device: {device.path}")
|
||||
|
||||
|
||||
def wipe_filesystem(device, force=True):
|
||||
def wipefs(device, force=True):
|
||||
TestRun.LOGGER.info(f"Erasing the device: {device.path}")
|
||||
force_param = ' -f' if force else ''
|
||||
cmd = f'wipefs -a{force_param} {device.path}'
|
||||
|
@@ -4,17 +4,18 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
from test_tools import fs_tools, systemctl
|
||||
from test_tools.fs_tools import append_line, remove_lines
|
||||
from test_tools.systemctl import reload_daemon, restart_service
|
||||
|
||||
|
||||
def add_mountpoint(device, mount_point, fs_type, mount_now=True):
|
||||
fs_tools.append_line("/etc/fstab",
|
||||
f"{device.path} {mount_point} {fs_type.name} defaults 0 0")
|
||||
systemctl.reload_daemon()
|
||||
append_line("/etc/fstab",
|
||||
f"{device.path} {mount_point} {fs_type.name} defaults 0 0")
|
||||
reload_daemon()
|
||||
if mount_now:
|
||||
systemctl.restart_service("local-fs.target")
|
||||
restart_service("local-fs.target")
|
||||
|
||||
|
||||
def remove_mountpoint(device):
|
||||
fs_tools.remove_lines("/etc/fstab", device.path)
|
||||
systemctl.reload_daemon()
|
||||
remove_lines("/etc/fstab", device.path)
|
||||
reload_daemon()
|
||||
|
@@ -3,6 +3,7 @@
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import itertools
|
||||
import os
|
||||
import posixpath
|
||||
|
@@ -3,10 +3,12 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import csv
|
||||
|
||||
from core.test_run import TestRun
|
||||
from type_def.size import Size, Unit, UnitPerSecond
|
||||
from type_def.time import Time
|
||||
import csv
|
||||
|
||||
|
||||
|
||||
class IOstatExtended:
|
||||
|
@@ -4,7 +4,6 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
|
@@ -1,3 +1,9 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import math
|
||||
|
||||
from connection.utils.output import CmdException
|
||||
|
@@ -1,7 +1,9 @@
|
||||
#
|
||||
# Copyright(c) 2021 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
import json
|
||||
from core.test_run import TestRun
|
||||
|
||||
|
@@ -16,7 +16,6 @@ from core.test_run import TestRun
|
||||
from storage_devices.device import Device
|
||||
from test_tools.disk_tools import get_sysfs_path
|
||||
from test_tools.fs_tools import check_if_file_exists, is_mounted
|
||||
from test_utils.filesystem.file import File
|
||||
from connection.utils.retry import Retry
|
||||
|
||||
DEBUGFS_MOUNT_POINT = "/sys/kernel/debug"
|
||||
@@ -86,7 +85,8 @@ def get_kernel_version():
|
||||
|
||||
|
||||
def is_kernel_module_loaded(module_name):
|
||||
output = TestRun.executor.run(f"lsmod | grep ^{module_name}$")
|
||||
command = f"lsmod | grep -E '^{module_name}\\b'"
|
||||
output = TestRun.executor.run(command)
|
||||
return output.exit_code == 0
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ def get_kernel_module_parameter(module_name, parameter):
|
||||
param_file_path = f"/sys/module/{module_name}/parameters/{parameter}"
|
||||
if not check_if_file_exists(param_file_path):
|
||||
raise FileNotFoundError(f"File {param_file_path} does not exist!")
|
||||
return File(param_file_path).read()
|
||||
return TestRun.executor.run(f"cat {param_file_path}").stdout
|
||||
|
||||
|
||||
def mount_debugfs():
|
||||
|
@@ -12,10 +12,10 @@ import tempfile
|
||||
import lxml.etree as etree
|
||||
from collections import namedtuple
|
||||
|
||||
import test_tools.wget
|
||||
from test_tools import wget
|
||||
from core.test_run import TestRun
|
||||
from test_tools import fs_tools
|
||||
from test_tools.fs_tools import create_directory, check_if_file_exists, write_file
|
||||
from test_tools.fs_tools import create_directory, check_if_file_exists, write_file, remove, \
|
||||
check_if_directory_exists
|
||||
|
||||
|
||||
class PeachFuzzer:
|
||||
@@ -75,7 +75,7 @@ class PeachFuzzer:
|
||||
cls._install()
|
||||
if not cls._is_xml_config_prepared():
|
||||
TestRun.block("No Peach Fuzzer XML config needed to generate fuzzed values was found!")
|
||||
fs_tools.remove(cls.fuzzy_output_file, force=True, ignore_errors=True)
|
||||
remove(cls.fuzzy_output_file, force=True, ignore_errors=True)
|
||||
TestRun.LOGGER.info(f"Generate {count} unique fuzzed values")
|
||||
cmd = f"cd {cls.base_dir}; {cls.peach_dir}/peach --range 0,{count - 1} " \
|
||||
f"--seed {random.randrange(2 ** 32)} {cls.xml_config_file} > " \
|
||||
@@ -155,7 +155,7 @@ class PeachFuzzer:
|
||||
Install Peach Fuzzer on the DUT
|
||||
"""
|
||||
create_directory(cls.base_dir, True)
|
||||
peach_archive = test_tools.wget.download_file(
|
||||
peach_archive = wget.download_file(
|
||||
cls.peach_fuzzer_3_0_url, destination_dir=cls.base_dir
|
||||
)
|
||||
TestRun.executor.run_expect_success(
|
||||
@@ -172,7 +172,7 @@ class PeachFuzzer:
|
||||
"""
|
||||
if not cls._is_mono_installed():
|
||||
TestRun.block("Mono is not installed, can't continue with Peach Fuzzer!")
|
||||
if fs_tools.check_if_directory_exists(posixpath.join(cls.base_dir, cls.peach_dir)):
|
||||
if check_if_directory_exists(posixpath.join(cls.base_dir, cls.peach_dir)):
|
||||
return "Peach" in TestRun.executor.run(
|
||||
f"cd {cls.base_dir} && {cls.peach_dir}/peach --version").stdout.strip()
|
||||
else:
|
||||
@@ -197,7 +197,7 @@ class PeachFuzzer:
|
||||
"""
|
||||
Check if Peach Fuzzer XML config is present on the DUT
|
||||
"""
|
||||
if fs_tools.check_if_file_exists(cls.xml_config_file):
|
||||
if check_if_file_exists(cls.xml_config_file):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
Reference in New Issue
Block a user