test-framework: Add nullblock to test-framework
Signed-off-by: Kamil Gierszewski <kamil.gierszewski@huawei.com>
This commit is contained in:
parent
d62106e850
commit
83e8064bfb
@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2023 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
@ -375,7 +376,13 @@ def _is_by_id_path(path: str):
|
||||
|
||||
def _is_dev_path_whitelisted(path: str):
|
||||
"""check if given path is whitelisted"""
|
||||
whitelisted_paths = [r"cas\d+-\d+", r"/dev/dm-\d+"]
|
||||
whitelisted_paths = [
|
||||
r"/dev/ram\d+",
|
||||
r"/nullb\d+",
|
||||
r"/dev/drbd\d+",
|
||||
r"cas\d+-\d+",
|
||||
r"/dev/dm-\d+"
|
||||
]
|
||||
|
||||
for whitelisted_path in whitelisted_paths:
|
||||
if re.search(whitelisted_path, path) is not None:
|
||||
|
@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2023 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
@ -99,6 +100,10 @@ def check_if_regular_file_exists(path):
|
||||
return TestRun.executor.run(f"test -f \"{path}\"").exit_code == 0
|
||||
|
||||
|
||||
def check_if_special_block_exist(path):
|
||||
return TestRun.executor.run(f"test -b \"{path}\"").exit_code == 0
|
||||
|
||||
|
||||
def check_if_symlink_exists(path):
|
||||
return TestRun.executor.run(f"test -L \"{path}\"").exit_code == 0
|
||||
|
||||
@ -266,7 +271,7 @@ def uncompress_archive(file, destination=None):
|
||||
def ls(path, options=''):
|
||||
default_options = "-lA --time-style=+'%Y-%m-%d %H:%M:%S'"
|
||||
output = TestRun.executor.run(
|
||||
f"ls {default_options} {options} \"{path}\"")
|
||||
f"ls {default_options} {options} {path}")
|
||||
return output.stdout
|
||||
|
||||
|
||||
@ -308,7 +313,6 @@ def parse_ls_output(ls_output, dir_path=''):
|
||||
from test_utils.filesystem.file import File, FsItem
|
||||
from test_utils.filesystem.directory import Directory
|
||||
from test_utils.filesystem.symlink import Symlink
|
||||
|
||||
if file_type == '-':
|
||||
fs_item = File(full_path)
|
||||
elif file_type == 'd':
|
||||
|
@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright(c) 2019-2021 Intel Corporation
|
||||
# Copyright(c) 2023 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
@ -9,6 +10,7 @@ from test_tools.fs_utils import (
|
||||
create_directory,
|
||||
check_if_symlink_exists,
|
||||
check_if_directory_exists,
|
||||
check_if_special_block_exist
|
||||
)
|
||||
from test_utils.filesystem.file import File
|
||||
|
||||
@ -76,6 +78,11 @@ class Symlink(File):
|
||||
elif not create:
|
||||
raise FileNotFoundError("Requested symlink does not exist.")
|
||||
|
||||
is_special_block = check_if_special_block_exist(link_path)
|
||||
if is_special_block:
|
||||
if not target or readlink(link_path) == readlink(target):
|
||||
return cls(link_path)
|
||||
|
||||
is_dir = check_if_directory_exists(link_path)
|
||||
if is_dir:
|
||||
raise IsADirectoryError(
|
||||
|
Loading…
Reference in New Issue
Block a user