Skip to content
Snippets Groups Projects
Unverified Commit b86f9653 authored by Piotr Balcer's avatar Piotr Balcer Committed by GitHub
Browse files

Merge pull request #4868 from wlemkows/test-dd-skip-py

test: skip devdax tests when ndctl is unavailable (py)
parents 2192c2ac d8bcde2d
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ import sys ...@@ -11,6 +11,7 @@ import sys
import context as ctx import context as ctx
import futils import futils
import requirements as req
import tools import tools
...@@ -66,6 +67,10 @@ class DevDaxes(): ...@@ -66,6 +67,10 @@ class DevDaxes():
setattr(self, dd.name, dd) setattr(self, dd.name, dd)
def setup(self, **kwargs): def setup(self, **kwargs):
# DevDax tests always require ndctl
req.Requirements().check_ndctl_enable()
req.Requirements().check_ndctl()
tools = kwargs['tools'] tools = kwargs['tools']
for dd in self.dax_devices: for dd in self.dax_devices:
proc = tools.pmemdetect('-d', dd.path) proc = tools.pmemdetect('-d', dd.path)
......
...@@ -30,12 +30,31 @@ class Requirements: ...@@ -30,12 +30,31 @@ class Requirements:
stdout=sp.PIPE, stderr=sp.STDOUT) stdout=sp.PIPE, stderr=sp.STDOUT)
return proc.returncode == 0 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): def _check_is_admin(self):
if sys.platform == 'win32': if sys.platform == 'win32':
return ctypes.windll.shell32.IsUserAnAdmin() != 0 return ctypes.windll.shell32.IsUserAnAdmin() != 0
else: else:
return os.getuid() == 0 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): def _check_ndctl_req_is_met(self, tc):
""" """
Check if all conditions for the ndctl requirement are met Check if all conditions for the ndctl requirement are met
...@@ -44,14 +63,9 @@ class Requirements: ...@@ -44,14 +63,9 @@ class Requirements:
if not require_ndctl: if not require_ndctl:
return True return True
ndctl_enable = os.environ.get('NDCTL_ENABLE') self.check_ndctl_enable()
if ndctl_enable == 'n': self.check_ndctl()
raise futils.Skip('libndctl is disabled (NDCTL_ENABLE == \'n\')')
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 return True
def _check_admin_req_is_met(self, tc): def _check_admin_req_is_met(self, tc):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment