diff --git a/src/test/unittest/devdax.py b/src/test/unittest/devdax.py index b1d670c1c3d086a28188ca4626b773429710c53f..538b9d845ae4899b3a2c0f6d8d737326409e0975 100644 --- a/src/test/unittest/devdax.py +++ b/src/test/unittest/devdax.py @@ -11,6 +11,7 @@ import sys import context as ctx import futils +import requirements as req import tools @@ -66,6 +67,10 @@ class DevDaxes(): setattr(self, dd.name, dd) def setup(self, **kwargs): + # DevDax tests always require ndctl + req.Requirements().check_ndctl_enable() + req.Requirements().check_ndctl() + tools = kwargs['tools'] for dd in self.dax_devices: proc = tools.pmemdetect('-d', dd.path) diff --git a/src/test/unittest/requirements.py b/src/test/unittest/requirements.py index 6d57fb4165cac20868160218af0f555bb38a44cf..1afe7800b5682f9e22d90aedf04edfa39da0b9f6 100644 --- a/src/test/unittest/requirements.py +++ b/src/test/unittest/requirements.py @@ -30,12 +30,31 @@ class Requirements: stdout=sp.PIPE, stderr=sp.STDOUT) return proc.returncode == 0 + def _is_ndctl_enabled(self): + path = futils.get_tool_path(ctx, "pmempool") + s = sp.check_output(["strings", path]) + if "compiled with libndctl" in str(s): + return True + + return False + def _check_is_admin(self): if sys.platform == 'win32': return ctypes.windll.shell32.IsUserAnAdmin() != 0 else: return os.getuid() == 0 + def check_ndctl(self): + is_ndctl = self._check_pkgconfig('libndctl', NDCTL_MIN_VERSION) + if not is_ndctl: + raise futils.Skip('libndctl (>=v{}) is not installed' + .format(NDCTL_MIN_VERSION)) + + def check_ndctl_enable(self): + if self._is_ndctl_enabled() is False: + raise futils.Skip('ndctl is disabled - binary not ' + 'compiled with libndctl') + def _check_ndctl_req_is_met(self, tc): """ Check if all conditions for the ndctl requirement are met @@ -44,14 +63,9 @@ class Requirements: if not require_ndctl: return True - ndctl_enable = os.environ.get('NDCTL_ENABLE') - if ndctl_enable == 'n': - raise futils.Skip('libndctl is disabled (NDCTL_ENABLE == \'n\')') + self.check_ndctl_enable() + self.check_ndctl() - is_ndctl = self._check_pkgconfig('libndctl', NDCTL_MIN_VERSION) - if not is_ndctl: - raise futils.Skip('libndctl (>=v{}) is not installed' - .format(NDCTL_MIN_VERSION)) return True def _check_admin_req_is_met(self, tc):