def test_filters(self): tree2 = copy.deepcopy(self.tree) exp = ['intel', 'amd', 'arm', 'fedora', u'\u0161mint', 'prod'] act = mux.apply_filters(tree2, filter_only=['/hw/cpu', '']).get_leaves() self.assertEqual(exp, act) tree2 = copy.deepcopy(self.tree) exp = ['scsi', 'virtio', 'fedora', u'\u0161mint', 'prod'] act = mux.apply_filters(tree2, filter_out=['/hw/cpu', '']).get_leaves() self.assertEqual(exp, act)
def test_filters(self): tree2 = copy.deepcopy(self.tree) exp = ['intel', 'amd', 'arm', 'fedora', 'mint', 'prod'] act = mux.apply_filters(tree2, filter_only=['/hw/cpu', '']).get_leaves() self.assertEqual(exp, act) tree2 = copy.deepcopy(self.tree) exp = ['scsi', 'virtio', 'fedora', 'mint', 'prod'] act = mux.apply_filters(tree2, filter_out=['/hw/cpu', '']).get_leaves() self.assertEqual(exp, act)
def discover(self, reference, which_tests=loader.DiscoverMode.DEFAULT): tests = [] try: root = mux.apply_filters(create_from_yaml([reference], False), getattr(self.args, "mux_suite_only", []), getattr(self.args, "mux_suite_out", [])) except Exception: return [] mux_tree = mux.MuxTree(root) for variant in mux_tree: params = parameters.AvocadoParams(variant, ["/run/*"], output.LOG_JOB.name) references = params.get("test_reference") if not isinstance(references, (list, tuple)): references = [references] for reference in references: test_loader = self._get_loader(params) if not test_loader: continue _tests = test_loader.discover(reference, which_tests) self._extra_type_label_mapping.update( test_loader.get_full_type_label_mapping()) self._extra_decorator_mapping.update( test_loader.get_full_decorator_mapping()) name_prefix = params.get("mux_suite_test_name_prefix") if _tests: if isinstance(name_prefix, list): name_prefix = "".join(name_prefix) for tst in _tests: if name_prefix: tst[1]["name"] = name_prefix + tst[1]["name"] tst[1]["params"] = (variant, ["/run/*"]) tests.extend(_tests) return tests
def discover(self, reference, which_tests=loader.DEFAULT): tests = [] try: root = mux.apply_filters(create_from_yaml([reference], False), getattr(self.args, "mux_suite_only", []), getattr(self.args, "mux_suite_out", [])) except Exception: return [] mux_tree = mux.MuxTree(root) for variant in mux_tree: params = parameters.AvocadoParams(variant, ["/run/*"], output.LOG_UI.name) reference = params.get("test_reference") test_loader = self._get_loader(params) if not test_loader: continue _tests = test_loader.discover(reference, which_tests) self._extra_type_label_mapping.update( test_loader.get_full_type_label_mapping()) self._extra_decorator_mapping.update( test_loader.get_full_decorator_mapping()) if _tests: for tst in _tests: tst[1]["params"] = (variant, ["/run/*"]) tests.extend(_tests) return tests
def discover(self, reference, which_tests=loader.DEFAULT): tests = [] try: root = mux.apply_filters(create_from_yaml([reference], False), getattr(self.args, "mux_suite_only", []), getattr(self.args, "mux_suite_out", [])) except Exception: return [] mux_tree = mux.MuxTree(root) for variant in mux_tree: params = parameters.AvocadoParams(variant, ["/run/*"], output.LOG_JOB.name) reference = params.get("test_reference") test_loader = self._get_loader(params) if not test_loader: continue _tests = test_loader.discover(reference, which_tests) self._extra_type_label_mapping.update( test_loader.get_full_type_label_mapping()) self._extra_decorator_mapping.update( test_loader.get_full_decorator_mapping()) if _tests: for tst in _tests: tst[1]["params"] = (variant, ["/run/*"]) tests.extend(_tests) return tests
def test_filter_only(self): exp = (['intel', 'scsi'], ['intel', 'virtio']) act = yaml_to_mux.create_from_yaml( ["/:" + PATH_PREFIX + 'selftests/.data/mux-selftest.yaml']) act = mux.apply_filters(act, ('/hw/cpu/intel', '/distro/fedora', '/hw')) act = tuple(mux.MuxTree(act)) self.assertEqual(act, exp)
def test_filter_only(self): exp = (['intel', 'scsi'], ['intel', 'virtio']) act = yaml_to_mux.create_from_yaml(["/:" + PATH_PREFIX + 'selftests/.data/mux-selftest.yaml']) act = mux.apply_filters(act, ('/hw/cpu/intel', '/distro/fedora', '/hw')) act = tuple(mux.MuxTree(act)) self.assertEqual(act, exp)
def test_filter_only(self): exp = (['intel', 'scsi'], ['intel', 'virtio']) tree_yaml_path = os.path.join(BASEDIR, 'tests/.data/mux-selftest.yaml') tree_yaml_url = '/:%s' % tree_yaml_path act = yaml_to_mux.create_from_yaml([tree_yaml_url]) act = mux.apply_filters(act, ('/hw/cpu/intel', '/distro/fedora', '/hw')) act = tuple(mux.MuxTree(act)) self.assertEqual(act, exp)
def test_filter_only(self): exp = (['intel', 'scsi'], ['intel', 'virtio']) tree_yaml_path = os.path.join(BASEDIR, 'tests/.data/mux-selftest.yaml') tree_yaml_url = '/:%s' % tree_yaml_path act = yaml_to_mux.create_from_yaml([tree_yaml_url]) act = mux.apply_filters(act, ('/hw/cpu/intel', '/distro/fedora', '/hw')) act = tuple(mux.MuxTree(act)) self.assertEqual(act, exp)
def test_filter_out(self): act = yaml_to_mux.create_from_yaml( ["/:" + PATH_PREFIX + 'selftests/.data/mux-selftest.yaml']) act = mux.apply_filters(act, None, ('/hw/cpu/intel', '/distro/fedora', '/distro')) act = tuple(mux.MuxTree(act)) self.assertEqual(len(act), 4) self.assertEqual(len(act[0]), 3) str_act = str(act) self.assertIn('amd', str_act) self.assertIn('prod', str_act) self.assertNotIn('intel', str_act) self.assertNotIn('fedora', str_act)
def test_filter_out(self): act = yaml_to_mux.create_from_yaml(["/:" + PATH_PREFIX + 'selftests/.data/mux-selftest.yaml']) act = mux.apply_filters(act, None, ('/hw/cpu/intel', '/distro/fedora', '/distro')) act = tuple(mux.MuxTree(act)) self.assertEqual(len(act), 4) self.assertEqual(len(act[0]), 3) str_act = str(act) self.assertIn('amd', str_act) self.assertIn('prod', str_act) self.assertNotIn('intel', str_act) self.assertNotIn('fedora', str_act)
def test_filter_out(self): tree_yaml_path = os.path.join(BASEDIR, 'tests/.data/mux-selftest.yaml') tree_yaml_url = '/:%s' % tree_yaml_path act = yaml_to_mux.create_from_yaml([tree_yaml_url]) act = mux.apply_filters(act, None, ('/hw/cpu/intel', '/distro/fedora', '/distro')) act = tuple(mux.MuxTree(act)) self.assertEqual(len(act), 4) self.assertEqual(len(act[0]), 3) str_act = str(act) self.assertIn('amd', str_act) self.assertIn('prod', str_act) self.assertNotIn('intel', str_act) self.assertNotIn('fedora', str_act)
def test_filter_out(self): tree_yaml_path = os.path.join(BASEDIR, 'tests/.data/mux-selftest.yaml') tree_yaml_url = '/:%s' % tree_yaml_path act = yaml_to_mux.create_from_yaml([tree_yaml_url]) act = mux.apply_filters(act, None, ('/hw/cpu/intel', '/distro/fedora', '/distro')) act = tuple(mux.MuxTree(act)) self.assertEqual(len(act), 4) self.assertEqual(len(act[0]), 3) str_act = str(act) self.assertIn('amd', str_act) self.assertIn('prod', str_act) self.assertNotIn('intel', str_act) self.assertNotIn('fedora', str_act)
def initialize(self, config): subcommand = config.get('subcommand') data = None # Merge the multiplex multiplex_files = config.get("yaml_to_mux.files") if multiplex_files: data = mux.MuxTreeNode() try: data.merge(create_from_yaml(multiplex_files)) except IOError as details: error_msg = "%s : %s" % (details.strerror, details.filename) LOG_UI.error(error_msg) if subcommand == 'run': sys.exit(exit_codes.AVOCADO_JOB_FAIL) else: sys.exit(exit_codes.AVOCADO_FAIL) # Extend default multiplex tree of --mux-inject values for inject in config.get("yaml_to_mux.inject"): entry = inject.split(':', 2) if len(entry) < 2: raise ValueError("key:entry pairs required, found only %s" % (entry)) elif len(entry) == 2: # key, entry entry.insert(0, '') # add path='' (root) # We try to maintain the data type of the provided value try: entry[2] = ast.literal_eval(entry[2]) except (ValueError, SyntaxError, NameError, RecursionError): pass if data is None: data = mux.MuxTreeNode() data.get_node(entry[0], True).value[entry[1]] = entry[2] if data is not None: mux_filter_only = config.get('yaml_to_mux.filter_only') mux_filter_out = config.get('yaml_to_mux.filter_out') data = mux.apply_filters(data, mux_filter_only, mux_filter_out) paths = config.get("yaml_to_mux.parameter_paths") self.initialize_mux(data, paths)