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 = varianter.AvocadoParams(variant, "YamlTestsuiteLoader", ["/run/*"], {}) 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 + 'examples/mux-selftest.yaml']) act = mux.apply_filters(act, ('/hw/cpu/intel', '/distro/fedora', '/hw')) act = tuple(mux.MuxTree(act)) self.assertEqual(act, exp)
def setUp(self): yamls = yaml_to_mux.create_from_yaml( ["/:" + PATH_PREFIX + 'examples/mux-selftest-params.yaml']) self.yamls = iter(mux.MuxTree(yamls)) self.params1 = varianter.AvocadoParams(self.yamls.next(), 'Unittest1', ['/ch0/*', '/ch1/*'], {}) self.yamls.next() # Skip 2nd self.yamls.next() # and 3rd self.params2 = varianter.AvocadoParams(self.yamls.next(), 'Unittest2', ['/ch1/*', '/ch0/*'], {})
def test_filter_out(self): act = yaml_to_mux.create_from_yaml( ["/:" + PATH_PREFIX + 'examples/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_create_variants(self): from_file = yaml_to_mux.create_from_yaml( ["/:" + PATH_PREFIX + 'examples/mux-selftest.yaml']) from_file = mux.MuxTree(from_file) self.assertEqual(self.mux_full, tuple(from_file))
def test_partial(self): exp = (['intel', 'scsi'], ['intel', 'virtio'], ['amd', 'scsi'], ['amd', 'virtio'], ['arm', 'scsi'], ['arm', 'virtio']) act = tuple(mux.MuxTree(self.mux_tree.children[0])) self.assertEqual(act, exp)
def test_empty(self): act = tuple(mux.MuxTree(mux.MuxTreeNode())) self.assertEqual(act, ([ '', ], ))
def setUp(self): self.mux_tree = yaml_to_mux.create_from_yaml( ['/:' + PATH_PREFIX + 'examples/mux-selftest.' 'yaml']) self.mux_full = tuple(mux.MuxTree(self.mux_tree))