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
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
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
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