diff --git a/core/test_run_utils.py b/core/test_run_utils.py index 3871bab..51e6435 100644 --- a/core/test_run_utils.py +++ b/core/test_run_utils.py @@ -211,7 +211,7 @@ def __makereport(cls, item, call, res): if res.outcome == "skipped": cls.LOGGER.skip("Test skipped.") - if res.when == "call" and cls.LOGGER.get_result() == BaseLogResult.FAILED: + if res.when in ["call", "setup"] and cls.LOGGER.get_result() >= BaseLogResult.FAILED: res.outcome = "failed" # To print additional message in final test report, assign it to res.longrepr diff --git a/log/base_log.py b/log/base_log.py index 0f717a4..29c5b60 100644 --- a/log/base_log.py +++ b/log/base_log.py @@ -1,13 +1,14 @@ # # Copyright(c) 2019-2021 Intel Corporation +# Copyright(c) 2024 Huawei Technologies # SPDX-License-Identifier: BSD-3-Clause # -from enum import Enum +from enum import IntEnum from re import sub -class BaseLogResult(Enum): +class BaseLogResult(IntEnum): DEBUG = 10 PASSED = 11 WORKAROUND = 12 diff --git a/storage_devices/disk.py b/storage_devices/disk.py index 8e2cbbc..00bd486 100644 --- a/storage_devices/disk.py +++ b/storage_devices/disk.py @@ -288,8 +288,8 @@ class SataDisk(Disk): @classmethod def plug_all(cls) -> Output: cmd = ( - f"for i in $(find -H /sys/devices/ -path '*/scsi_host/*/scan' -type f); do echo " - f"'- - -' > $i; done;" + "find -H /sys/devices/ -path '*/scsi_host/*/scan' -type f |" + " xargs -P20 -I % sh -c \"echo '- - -' | tee %\"" ) output = TestRun.executor.run_expect_success(cmd) return output diff --git a/test_tools/mdadm.py b/test_tools/mdadm.py index ae962bb..db5e60a 100644 --- a/test_tools/mdadm.py +++ b/test_tools/mdadm.py @@ -1,11 +1,14 @@ # # Copyright(c) 2020-2021 Intel Corporation +# Copyright(c) 2024 Huawei Technologies Co., Ltd. # SPDX-License-Identifier: BSD-3-Clause # + import re from core.test_run import TestRun from test_utils.size import Unit +from test_utils.os_utils import Udev class Mdadm: @@ -33,7 +36,11 @@ class Mdadm: if conf.size: cmd += f"--size={int(conf.size.get_value(Unit.KibiByte))} " cmd += device_paths - return TestRun.executor.run_expect_success(cmd) + ret = TestRun.executor.run_expect_success(cmd) + Udev.trigger() + Udev.settle() + + return ret @staticmethod def detail(raid_device_paths: str): @@ -76,8 +83,6 @@ class Mdadm: raids = [] uuid_path_prefix = "/dev/disk/by-id/md-uuid-" - # sometimes links for RAIDs are not properly created, force udev to create them - TestRun.executor.run("udevadm trigger && udevadm settle") for line in output.stdout.splitlines(): split_line = line.split() diff --git a/test_utils/os_utils.py b/test_utils/os_utils.py index c0bb0e2..e9c01f1 100644 --- a/test_utils/os_utils.py +++ b/test_utils/os_utils.py @@ -381,10 +381,13 @@ def get_udev_service_path(unit_name): return path -def kill_all_io(): - # TERM signal should be used in preference to the KILL signal, since a - # process may install a handler for the TERM signal in order to perform - # clean-up steps before terminating in an orderly fashion. +def kill_all_io(graceful=True): + if graceful: + # TERM signal should be used in preference to the KILL signal, since a + # process may install a handler for the TERM signal in order to perform + # clean-up steps before terminating in an orderly fashion. + TestRun.executor.run("killall -q --signal TERM dd fio blktrace") + time.sleep(3) TestRun.executor.run("killall -q --signal TERM dd fio blktrace") time.sleep(3) TestRun.executor.run("killall -q --signal KILL dd fio blktrace")