Date: Mon, 15 May 2023 10:53:39 GMT From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 97760572a0e4 - main - testing: add public method for requiring module presense in pytest Message-ID: <202305151053.34FArdx6095647@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=97760572a0e4c287a67730df80e7a7b4cf735977 commit 97760572a0e4c287a67730df80e7a7b4cf735977 Author: Alexander V. Chernikov <melifaro@FreeBSD.org> AuthorDate: 2023-05-15 10:50:55 +0000 Commit: Alexander V. Chernikov <melifaro@FreeBSD.org> CommitDate: 2023-05-15 10:50:55 +0000 testing: add public method for requiring module presense in pytest MFC after: 2 weeks --- tests/atf_python/utils.py | 19 +++++++++++++------ 1 file 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_"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202305151053.34FArdx6095647>