Beispiel #1
0
    def filter(cls, config, msg, tc):

        dax_devices, _ = ctx.get_requirement(tc, 'devdax', ())
        if not dax_devices:
            return ctx.NO_CONTEXT
        elif sys.platform == 'win32' and tc.enabled:
            raise futils.Fail('dax device functionality required by "{}" is '
                              'not available on Windows. Please disable the '
                              'test for this platform'.format(tc))

        if not config.device_dax_path:
            raise futils.Skip('No dax devices defined in testconfig')

        if len(dax_devices) > len(config.device_dax_path):
            raise futils.Skip('Not enough dax devices defined in testconfig '
                              '({} needed)'.format(len(dax_devices)))

        ndctl = tools.Ndctl()
        for c in config.device_dax_path:
            if not ndctl.is_devdax(c):
                raise futils.Fail('{} is not a dax device'.format(c))

        assigned = _try_assign_by_requirements(config.device_dax_path,
                                               dax_devices)
        if not assigned:
            raise futils.Skip('Dax devices in test configuration do not '
                              'meet test requirements')

        return [
            DevDaxes(*assigned),
        ]
Beispiel #2
0
    def filter(cls, config, msg, tc):

        dax_devices, _ = ctx.get_requirement(tc, 'devdax', ())
        if not dax_devices:
            return ctx.NO_CONTEXT
        elif sys.platform == 'win32' and tc.enabled:
            raise futils.Fail('dax device functionality required by "{}" is '
                              'not available on Windows. Please disable the '
                              'test for this platform'.format(tc))

        if not config.device_dax_path:
            raise futils.Skip('No dax devices defined in testconfig')

        if len(dax_devices) > len(config.device_dax_path):
            raise futils.Skip('Not enough dax devices defined in testconfig '
                              '({} needed)'.format(len(dax_devices)))

        ndctl = tools.Ndctl()
        for dd, cddp in zip(dax_devices, config.device_dax_path):
            dd.path = cddp
            if not ndctl.is_devdax(cddp):
                raise futils.Fail('{} is not a dax device'.format(cddp))
            dd.size = ndctl.get_dev_size(cddp)
            dd.alignment = ndctl.get_dev_alignment(cddp)

        return [
            DevDaxes(*dax_devices),
        ]
Beispiel #3
0
    def filter(cls, config, msg, tc):
        """
        Acquire valgrind tool for the test to be run based on configuration
        and test requirements
        """
        vg_tool, kwargs = ctx.get_requirement(tc, 'enabled_valgrind', NONE)
        disabled = ctx.get_requirement(tc, 'disabled_valgrind', NONE)

        if config.force_enable:
            if vg_tool and vg_tool != config.force_enable:
                raise futils.Skip("test enables the '{}' Valgrind tool while "
                                  "execution configuration forces '{}'".format(
                                      vg_tool, config.force_enable))

            elif config.force_enable in disabled:
                raise futils.Skip(
                    "forced Valgrind tool '{}' is disabled by test".format(
                        config.force_enable))

            else:
                vg_tool = config.force_enable

        return [
            cls(vg_tool, tc.cwd, tc.testnum, **kwargs),
        ]
Beispiel #4
0
    def __getattr__(self, name):
        if name == 'pmem_fs_dir':
            raise futils.Skip('No PMEM test directory provided')
        if name == 'non_pmem_fs_dir':
            raise futils.Skip('No non-PMEM test directory provided')

        sys.exit('Provided test configuration may be invalid. '
                 'No "{}" field found in configuration.'.format(name))
Beispiel #5
0
    def filter(cls, config, msg, tc):
        """
        Initialize DevDaxes class for the test to be run
        based on configuration and test requirements.

        Args:
            config: configuration as returned by Configurator class
            msg (Message): level based logger class instance
            tc (BaseTest): test case, from which the dax device run
                requirements are obtained

        Returns:
            Initialized DevDaxes class as single element list for type
            compliance

        """
        dax_devices, _ = ctx.get_requirement(tc, 'devdax', ())
        cls.check_fs_exec, _ = ctx.get_requirement(tc, 'require_fs_exec',
                                                   None)
        req_real_pmem, _ = ctx.get_requirement(tc, 'require_real_pmem', False)

        if not dax_devices:
            return ctx.NO_CONTEXT
        elif sys.platform == 'win32' and tc.enabled:
            raise futils.Fail('dax device functionality required by "{}" is '
                              'not available on Windows. Please disable the '
                              'test for this platform'.format(tc))

        if not config.device_dax_path:
            raise futils.Skip('No dax devices defined in testconfig')

        if len(dax_devices) > len(config.device_dax_path):
            raise futils.Skip('Not enough dax devices defined in testconfig '
                              '({} needed)'.format(len(dax_devices)))

        ndctl = tools.Ndctl()
        for c in config.device_dax_path:
            if not ndctl.is_devdax(c):
                raise futils.Fail('{} is not a dax device'.format(c))

        assigned = _try_assign_by_requirements(config.device_dax_path,
                                               dax_devices)

        # filter out the emulated devdaxes from the assigned ones
        if req_real_pmem:
            assigned_filtered = []

            for dd in assigned:
                if not ndctl.is_emulated(dd.path):
                    assigned_filtered.append(dd)

            assigned = tuple(assigned_filtered)

        if not assigned:
            raise futils.Skip('Dax devices in test configuration do not '
                              'meet test requirements')

        return [DevDaxes(*assigned)]
Beispiel #6
0
    def verify(self):
        """
        Checks that Valgrind can be used.
        """
        if self.valgrind_exe is None:
            raise futils.Skip('Valgrind not found')

        # verify tool
        cmd = '{} --tool={} --help'.format(self.valgrind_exe, self.tool_name)
        try:
            sp.check_output(cmd, shell=True, stderr=sp.STDOUT)
        except sp.CalledProcessError:
            raise futils.Skip("Valgrind tool '{}' was not found".format(
                self.tool_name))
Beispiel #7
0
    def _check_ndctl_req_is_met(self, tc):
        """
        Check if all conditions for the ndctl requirement are met
        """
        require_ndctl, _ = ctx.get_requirement(tc, 'require_ndctl', ())
        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\')')

        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
Beispiel #8
0
    def __getattr__(self, name):
        if name == 'page_fs_dir':
            raise futils.Skip('Configuration field "{}" not found. '
                              'No page granularity test directory '
                              'provided'.format(name))

        if name == 'cacheline_fs_dir':
            raise futils.Skip('Configuration field "{}" not found. '
                              'No cache line granularity test '
                              'directory provided'.format(name))

        if name == 'byte_fs_dir':
            raise futils.Skip('Configuration field "{}" not found. '
                              'No byte granularity test directory '
                              'provided'.format(name))

        raise AttributeError('Provided test configuration may be '
                             'invalid. No "{}" field found in '
                             'configuration.'.format(name))
Beispiel #9
0
 def check_namespace(self):
     cmd = ['ndctl', 'list']
     cmd_as_str = ' '.join(cmd)
     proc = sp.run(cmd,
                   stdout=sp.PIPE,
                   stderr=sp.STDOUT,
                   universal_newlines=True)
     if proc.returncode != 0:
         raise futils.Fail('"{}" failed:{}{}'.format(
             cmd_as_str, os.linesep, proc.stdout))
     if not proc.stdout or proc.stdout.isspace():
         raise futils.Skip('no ndctl namespace set')
Beispiel #10
0
    def _check_real_pmem_req_is_met(self, tc):
        req_real_pmem, _ = ctx.get_requirement(tc, 'require_real_pmem', False)
        if not req_real_pmem:
            return True

        devdaxes, _ = ctx.get_requirement(tc, 'require_devdax', None)
        # devdax cases should be dealt in devdax module
        if devdaxes is not None:
            return True

        if Ndctl().is_emulated(self.dir_):
            raise futils.Skip('skip emulated pmem')

        return True
Beispiel #11
0
    def filter(cls, config, msg, tc):
        """
        Acquire Valgrind tool for the test to be run with.
        Takes into account configuration 'force-enable' options,
        and Valgrind tools enabled or disabled by test requirements.

        Args:
            config: configuration as returned by Configurator class
            msg (Message): level based logger class instance
            tc (BaseTest): test case, from which the Valgrind
                requirements are obtained

        Returns:
            list of initialized Valgrind tool classes with which the test
            should be run

        """
        vg_tool, kwargs = ctx.get_requirement(tc, 'enabled_valgrind', NONE)
        disabled, _ = ctx.get_requirement(tc, 'disabled_valgrind', ())

        if config.force_enable:
            if vg_tool and vg_tool != config.force_enable:
                raise futils.Skip("test enables the '{}' Valgrind tool while "
                                  "execution configuration forces '{}'".format(
                                      vg_tool, config.force_enable))

            elif config.force_enable in disabled:
                raise futils.Skip(
                    "forced Valgrind tool '{}' is disabled by test".format(
                        config.force_enable))

            else:
                vg_tool = config.force_enable

        return [
            cls(vg_tool, tc.cwd, tc.testnum, **kwargs),
        ]
Beispiel #12
0
    def _valgrind_init(self):
        vg_tool = vg.enabled_tool(self)

        if sys.platform == 'win32':
            if vg_tool:
                self.enabled = False
            return

        if self.config.force_enable:
            if vg_tool and vg_tool != self.config.force_enable:
                raise futils.Skip(
                    "{}: SKIP: test enables the '{}' Valgrind tool while "
                    "execution configuration forces '{}'".format(
                        self, vg_tool, self.config.force_enable))

            elif self.config.force_enable in vg.disabled_tools(self):
                raise futils.Skip(
                    "{}: SKIP: forced Valgrind tool '{}' is disabled by test".
                    format(self, self.config.force_enable))

            else:
                vg_tool = self.config.force_enable

        self.valgrind = vg.Valgrind(vg_tool, self.cwd, self.testnum)
Beispiel #13
0
    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)
            if proc.returncode != 0:
                raise futils.Fail('checking {} with pmemdetect failed:{}{}'
                                  .format(dd.path, os.linesep, proc.stdout))

            if self.check_fs_exec:
                exec_allowed = tools.mapexec(dd.path)
                if exec_allowed.returncode != 1:
                    raise futils.Skip('dax device {} has no exec rights for'
                                      ' mmap'.format(dd.path))
Beispiel #14
0
    def _valgrind_init(self):
        vg_tool = vg.enabled_tool(self)

        if sys.platform == 'win32':
            if vg_tool:
                self.enabled = False
            return

        if self.config.force_enable:
            if self.config.force_enable not in vg.disabled_tools(self):
                vg_tool = self.config.force_enable
            else:
                raise futils.Skip(
                    '{}: SKIP: forced Valgrind tool is disabled by test'.
                    format(self))

        self.valgrind = vg.Valgrind(vg_tool, self.cwd, self.testnum)
Beispiel #15
0
    def _get_valgrind_exe(self):
        """
        On some systems "valgrind" is a shell script that calls the actual
        executable "valgrind.bin".
        The wrapper script does not work well with LD_PRELOAD so we want
        to call Valgrind directly.
        """
        try:
            out = sp.check_output('which valgrind', shell=True,
                                  universal_newlines=True)
        except sp.CalledProcessError:
            raise futils.Skip('Valgrind not found')

        valgrind_bin = path.join(path.dirname(out), 'valgrind.bin')
        if path.isfile(valgrind_bin):
            return valgrind_bin
        return 'valgrind'
Beispiel #16
0
    def _check_usc_req_is_met(self, tc):
        require_usc, _ = ctx.get_requirement(tc, 'require_usc', False)
        if not require_usc:
            return True

        basedir = self.testdir.replace(self.testdir, '')
        filepath = os.path.join(basedir, "__usc_test_file")
        f = open(filepath, 'w')
        f.close()

        check = self.tools.usc_permission_check(filepath)
        usc_available = check.returncode == 0

        os.remove(filepath)

        if not usc_available:
            raise futils.Skip('unsafe shutdown count is not available')

        return usc_available
Beispiel #17
0
    def _check_admin_req_is_met(self, tc):
        """
        Check if all conditions for the admin requirement are met
        """
        require_admin, _ = ctx.get_requirement(tc, 'require_admin', ())
        if not require_admin:
            # admin is not required
            return True

        if not self.cfg.enable_admin_tests:
            raise futils.Skip('admin tests are not enabled in config '
                              '(enable_admin_tests)')

        if not self._check_is_admin():
            raise futils.Fail('Error: admin tests are enabled in config, '
                              'but the user does not have administrative '
                              'privileges')
        # user is admin
        return True
Beispiel #18
0
 def verify(self):
     """
     Checks that Valgrind can be used.
     """
     if self.valgrind_exe is None:
         raise futils.Skip('Valgrind not found')
Beispiel #19
0
 def check_ndctl_enable(self):
     if self._is_ndctl_enabled() is False:
         raise futils.Skip('ndctl is disabled - binary not '
                           'compiled with libndctl')
Beispiel #20
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))