diff options
| author | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2023-05-15 10:50:55 +0000 |
|---|---|---|
| committer | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2023-05-15 10:50:55 +0000 |
| commit | 97760572a0e4c287a67730df80e7a7b4cf735977 (patch) | |
| tree | 6fb9f929241fb74a03c63bc8dca6fb376ba6d25f /tests/atf_python/utils.py | |
| parent | f0ffe1ce0fba262b458399dcd4c5e8c84e024606 (diff) | |
Diffstat (limited to 'tests/atf_python/utils.py')
| -rw-r--r-- | tests/atf_python/utils.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/tests/atf_python/utils.py b/tests/atf_python/utils.py index 1c0a68dad383..4bd4b642b131 100644 --- a/tests/atf_python/utils.py +++ b/tests/atf_python/utils.py @@ -47,14 +47,21 @@ class BaseTest(object): TARGET_USER = None # Set to the target user by the framework REQUIRED_MODULES: List[str] = [] + def require_module(self, mod_name: str, skip=True): + error_code = libc.modfind(mod_name) + if error_code == 0: + return + err_str = os.strerror(error_code) + txt = "kernel module '{}' not available: {}".format(mod_name, err_str) + if skip: + pytest.skip(txt) + else: + raise ValueError(txt) + def _check_modules(self): for mod_name in self.REQUIRED_MODULES: - error_code = libc.modfind(mod_name) - if error_code != 0: - err_str = os.strerror(error_code) - pytest.skip( - "kernel module '{}' not available: {}".format(mod_name, err_str) - ) + self.require_module(mod_name) + @property def atf_vars(self) -> Dict[str, str]: px = "_ATF_VAR_" |
