예제 #1
0
 def test_filters(self):
     tree2 = copy.deepcopy(self.tree)
     exp = ['intel', 'amd', 'arm', 'fedora', 'mint', 'prod']
     act = tree.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 = tree.apply_filters(tree2,
                              filter_out=['/hw/cpu', '']).get_leaves()
     self.assertEqual(exp, act)
예제 #2
0
 def test_filters(self):
     tree2 = copy.deepcopy(self.tree)
     exp = ['intel', 'amd', 'arm', 'fedora', 'mint', 'prod']
     act = tree.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 = tree.apply_filters(tree2,
                              filter_out=['/hw/cpu', '']).get_leaves()
     self.assertEqual(exp, act)
예제 #3
0
 def test_filter_only(self):
     exp = (['intel', 'scsi'], ['intel', 'virtio'])
     act = yaml_to_mux.create_from_yaml(["/:" + PATH_PREFIX +
                                         'examples/mux-selftest.yaml'])
     act = tree.apply_filters(act, ('/hw/cpu/intel', '/distro/fedora',
                                    '/hw'))
     act = tuple(multiplexer.MuxTree(act))
     self.assertEqual(act, exp)
예제 #4
0
 def test_filter_only(self):
     exp = (['intel', 'scsi'], ['intel', 'virtio'])
     act = yaml_to_mux.create_from_yaml(
         ["/:" + PATH_PREFIX + 'examples/mux-selftest.yaml'])
     act = tree.apply_filters(act,
                              ('/hw/cpu/intel', '/distro/fedora', '/hw'))
     act = tuple(multiplexer.MuxTree(act))
     self.assertEqual(act, exp)
예제 #5
0
def multiplex_yamls(input_yamls, filter_only=None, filter_out=None,
                    debug=False):
    if filter_only is None:
        filter_only = []
    if filter_out is None:
        filter_out = []
    input_tree = tree.create_from_yaml(input_yamls, debug)
    # TODO: Process filters and multiplex simultaneously
    final_tree = tree.apply_filters(input_tree, filter_only, filter_out)
    result = MuxTree(final_tree)
    return result
예제 #6
0
def multiplex_yamls(input_yamls, filter_only=None, filter_out=None,
                    debug=False):
    if filter_only is None:
        filter_only = []
    if filter_out is None:
        filter_out = []
    input_tree = tree.create_from_yaml(input_yamls, debug)
    final_tree = tree.apply_filters(input_tree, filter_only, filter_out)
    leaves = (x for x in final_tree.iter_leaves() if x.parent is not None)
    variants = multiplex(leaves)
    return variants
예제 #7
0
파일: multiplexer.py 프로젝트: ypu/avocado
def parse_yamls(input_yamls, filter_only=None, filter_out=None, debug=False):
    if filter_only is None:
        filter_only = []
    if filter_out is None:
        filter_out = []
    input_tree = tree.create_from_yaml(input_yamls, debug)
    # TODO: Process filters and multiplex simultaneously
    final_tree = tree.apply_filters(input_tree, filter_only, filter_out)
    leaves, pools = tree2pools(final_tree, final_tree.multiplex)
    if leaves:  # Add remaining leaves (they are not variants, only endpoints
        pools.extend(leaves)
    return pools
예제 #8
0
def parse_yamls(input_yamls, filter_only=None, filter_out=None,
                debug=False):
    if filter_only is None:
        filter_only = []
    if filter_out is None:
        filter_out = []
    input_tree = tree.create_from_yaml(input_yamls, debug)
    # TODO: Process filters and multiplex simultaneously
    final_tree = tree.apply_filters(input_tree, filter_only, filter_out)
    leaves, pools = tree2pools(final_tree, final_tree.multiplex)
    if leaves:  # Add remaining leaves (they are not variants, only endpoints
        pools.extend(leaves)
    return pools
예제 #9
0
 def test_filter_out(self):
     act = yaml_to_mux.create_from_yaml(
         ["/:" + PATH_PREFIX + 'examples/mux-selftest.yaml'])
     act = tree.apply_filters(
         act, None, ('/hw/cpu/intel', '/distro/fedora', '/distro'))
     act = tuple(multiplexer.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)
예제 #10
0
 def test_filter_out(self):
     act = yaml_to_mux.create_from_yaml(["/:" + PATH_PREFIX +
                                         'examples/mux-selftest.yaml'])
     act = tree.apply_filters(act, None, ('/hw/cpu/intel', '/distro/fedora',
                                          '/distro'))
     act = tuple(multiplexer.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)
예제 #11
0
def multiplex_yamls(input_yamls,
                    filter_only=None,
                    filter_out=None,
                    debug=False):
    if filter_only is None:
        filter_only = []
    if filter_out is None:
        filter_out = []
    input_tree = tree.create_from_yaml(input_yamls, debug)
    # TODO: Process filters and multiplex simultaneously
    final_tree = tree.apply_filters(input_tree, filter_only, filter_out)
    leaves, pools = tree2pools(final_tree, final_tree.multiplex)
    if leaves:  # Add remaining leaves (they are not variants, only endpoints
        pools.extend(leaves)
    return itertools.product(*pools)  # *magic required pylint: disable=W0142
예제 #12
0
    def run(self, args):
        view = output.View(app_args=args)
        multiplex_files = args.multiplex_files
        if args.tree:
            view.notify(event='message', msg='Config file tree structure:')
            t = tree.create_from_yaml(multiplex_files)
            t = tree.apply_filters(t, args.filter_only, args.filter_out)
            view.notify(event='minor',
                        msg=t.get_ascii(attributes=args.attr))
            sys.exit(exit_codes.AVOCADO_ALL_OK)

        try:
            variants = multiplexer.multiplex_yamls(multiplex_files,
                                                   args.filter_only,
                                                   args.filter_out,
                                                   args.debug)
        except IOError, details:
            view.notify(event='error',
                        msg="%s: '%s'" % (details.strerror, details.filename))
            sys.exit(exit_codes.AVOCADO_JOB_FAIL)
예제 #13
0
파일: multiplexer.py 프로젝트: ypu/avocado
    def run(self, args):
        view = output.View(app_args=args)
        multiplex_files = tuple(os.path.abspath(_)
                                for _ in args.multiplex_files)
        for path in multiplex_files:
            if not os.path.isfile(path):
                view.notify(event='error',
                            msg='Invalid multiplex file %s' % path)
                sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        if args.tree:
            view.notify(event='message', msg='Config file tree structure:')
            t = tree.create_from_yaml(multiplex_files)
            t = tree.apply_filters(t, args.filter_only, args.filter_out)
            view.notify(event='minor', msg=t.get_ascii())
            sys.exit(exit_codes.AVOCADO_ALL_OK)

        variants = multiplexer.multiplex_yamls(multiplex_files,
                                               args.filter_only,
                                               args.filter_out,
                                               args.debug)

        view.notify(event='message', msg='Variants generated:')
        for (index, tpl) in enumerate(variants):
            if not args.debug:
                paths = ', '.join([x.path for x in tpl])
            else:
                color = output.term_support.LOWLIGHT
                cend = output.term_support.ENDC
                paths = ', '.join(["%s%s@%s%s" % (_.name, color, _.yaml, cend)
                                   for _ in tpl])
            view.notify(event='minor', msg='\nVariant %s:    %s' %
                        (index + 1, paths))
            if args.contents:
                env = {}
                for node in tpl:
                    env.update(node.environment)
                for k in sorted(env.keys()):
                    view.notify(event='minor', msg='    %s: %s' % (k, env[k]))

        sys.exit(exit_codes.AVOCADO_ALL_OK)
예제 #14
0
    def run(self, args):
        view = output.View(app_args=args)
        multiplex_files = tuple(
            os.path.abspath(_) for _ in args.multiplex_files)
        for path in multiplex_files:
            if not os.path.isfile(path):
                view.notify(event='error',
                            msg='Invalid multiplex file %s' % path)
                sys.exit(exit_codes.AVOCADO_JOB_FAIL)

        if args.tree:
            view.notify(event='message', msg='Config file tree structure:')
            t = tree.create_from_yaml(multiplex_files)
            t = tree.apply_filters(t, args.filter_only, args.filter_out)
            view.notify(event='minor', msg=t.get_ascii())
            sys.exit(exit_codes.AVOCADO_ALL_OK)

        variants = multiplexer.multiplex_yamls(multiplex_files,
                                               args.filter_only,
                                               args.filter_out, args.debug)

        view.notify(event='message', msg='Variants generated:')
        for (index, tpl) in enumerate(variants):
            if not args.debug:
                paths = ', '.join([x.path for x in tpl])
            else:
                color = output.term_support.LOWLIGHT
                cend = output.term_support.ENDC
                paths = ', '.join(
                    ["%s%s@%s%s" % (_.name, color, _.yaml, cend) for _ in tpl])
            view.notify(event='minor',
                        msg='\nVariant %s:    %s' % (index + 1, paths))
            if args.contents:
                env = {}
                for node in tpl:
                    env.update(node.environment)
                for k in sorted(env.keys()):
                    view.notify(event='minor', msg='    %s: %s' % (k, env[k]))

        sys.exit(exit_codes.AVOCADO_ALL_OK)
예제 #15
0
def create_variants_from_yaml(input_yaml, filter_only=[], filter_out=[]):
    input_tree = tree.create_from_yaml(input_yaml)
    final_tree = tree.apply_filters(input_tree, filter_only, filter_out)
    leaves = (x for x in final_tree.iter_leaves() if x.parent is not None)
    variants = multiplex(leaves)
    return variants