Beispiel #1
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 #2
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 #3
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 #4
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 #5
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 #6
0
    def filter(cls, config, msg, tc):
        """
        Initialize granularity classes 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 granularity
                requirements are obtained

        Returns:
            list of granularities on which the test should be run

        """
        req_gran, kwargs = ctx.get_requirement(tc, 'granularity', None)

        # remove granularities if respective test directories in
        # test config are not defined
        conf_defined = [c for c in config.granularity
                        if c.testdir_defined(config)]

        if req_gran == Non:
            return [Non(**kwargs), ]

        if req_gran == _CACHELINE_OR_LESS:
            tmp_req_gran = [Byte, CacheLine]
        elif req_gran == _PAGE_OR_LESS:
            tmp_req_gran = [Byte, CacheLine, Page]
        elif req_gran == [ctx.Any, ]:
            tmp_req_gran = ctx.Any.get(conf_defined)
        else:
            tmp_req_gran = req_gran

        filtered = ctx.filter_contexts(conf_defined, tmp_req_gran)

        kwargs['tc_dirname'] = tc.tc_dirname

        if len(filtered) > 1 and req_gran == _CACHELINE_OR_LESS or \
           req_gran == _PAGE_OR_LESS:

            def order_by_smallest(elem):
                ordered = [Byte, CacheLine, Page]
                return ordered.index(elem)

            # take the smallest available granularity
            filtered.sort(key=order_by_smallest)
            filtered = [filtered[0], ]

        gs = []
        for g in filtered:
            try:
                gran = g(**kwargs)
                gran._check_usc_req_is_met(tc)
                gran._check_real_pmem_req_is_met(tc)
                gs.append(gran)
            except futils.Skip as s:
                msg.print_verbose('{}: SKIP: {}'.format(tc, s))

        return gs
Beispiel #7
0
    def filter(cls, config, msg, tc):
        req_builds, kwargs = ctx.get_requirement(tc, 'build', None)

        builds = []
        for b in ctx.filter_contexts(config.build, req_builds):
            try:
                builds.append(b(**kwargs))
            except futils.Skip as s:
                msg.print('{}: SKIP: {}'.format(tc, s))

        return builds
Beispiel #8
0
    def filter(cls, config, msg, tc):
        """
        Acquire file system granularity for the test to be run
        based on configuration and test requirements
        """
        req_gran, kwargs = ctx.get_requirement(tc, 'granularity', None)

        # remove granularities if respective test directories in
        # test config are not defined
        conf_defined = [
            c for c in config.granularity if c.testdir_defined(config)
        ]

        if req_gran == Non:
            return [
                Non(**kwargs),
            ]

        if req_gran == _CACHELINE_OR_LESS:
            tmp_req_gran = [Byte, CacheLine]
        elif req_gran == _PAGE_OR_LESS:
            tmp_req_gran = [Byte, CacheLine, Page]
        elif req_gran == ctx.Any:
            tmp_req_gran = [
                ctx.Any.get(conf_defined),
            ]
        else:
            tmp_req_gran = req_gran

        filtered = ctx.filter_contexts(conf_defined, tmp_req_gran)

        kwargs['tc_dirname'] = tc.tc_dirname

        if len(filtered) > 1 and req_gran == _CACHELINE_OR_LESS or \
           req_gran == _PAGE_OR_LESS:

            def order_by_smallest(elem):
                ordered = [Byte, CacheLine, Page]
                return ordered.index(elem)

            # take the smallest available granularity
            filtered.sort(key=order_by_smallest)
            filtered = [
                filtered[0],
            ]

        gs = []
        for g in filtered:
            try:
                gs.append(g(**kwargs))
            except futils.Skip as s:
                msg.print_verbose('{}: SKIP: {}'.format(tc, s))

        return gs
Beispiel #9
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

        self.check_ndctl_enable()
        self.check_ndctl()

        return True
Beispiel #10
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 #11
0
    def _check_ndctl_req_is_met(self, tc):
        """
        Check if all conditions for the ndctl requirement are met
        """
        require_ndctl, kwargs = ctx.get_requirement(tc, 'require_ndctl', ())
        if not require_ndctl:
            return True

        self.check_ndctl_enable()
        self.check_ndctl()

        if kwargs.get('require_namespace', False):
            self.check_namespace()

        return True
Beispiel #12
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 #13
0
    def filter(cls, config, msg, tc):
        req_fs, kwargs = ctx.get_requirement(tc, 'fs', None)
        kwargs['tc_dirname'] = tc.tc_dirname

        if req_fs == Non:
            return [
                Non(**kwargs),
            ]
        else:
            fss = []
            for f in ctx.filter_contexts(config.fs, req_fs):
                try:
                    fss.append(f(**kwargs))
                except futils.Skip as s:
                    msg.print_verbose('{}: SKIP: {}'.format(tc, s))

            return fss
Beispiel #14
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 #15
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