Exemple #1
0
def load_tests(loader, tests, pattern):
    for entry in pkg_resources.iter_entry_points('qubes.tests.extra'):
        try:
            for test_case in entry.load()():
                tests.addTests(loader.loadTestsFromTestCase(test_case))
        except Exception as err:  # pylint: disable=broad-except
            def runTest(self):
                raise err
            ExtraLoadFailure = type('ExtraLoadFailure',
                (qubes.tests.QubesTestCase,),
                {entry.name: runTest})
            tests.addTest(ExtraLoadFailure(entry.name))

    for entry in pkg_resources.iter_entry_points(
            'qubes.tests.extra.for_template'):
        try:
            for test_case in entry.load()():
                for template in qubes.tests.list_templates():
                    tests.addTests(loader.loadTestsFromTestCase(
                        type(
                            '{}_{}_{}'.format(
                                entry.name, test_case.__name__, template),
                            (test_case,),
                            {'template': template}
                        )
                    ))
        except Exception as err:  # pylint: disable=broad-except
            def runTest(self):
                raise err
            ExtraForTemplateLoadFailure = type('ExtraForTemplateLoadFailure',
                (qubes.tests.QubesTestCase,),
                {entry.name: runTest})
            tests.addTest(ExtraForTemplateLoadFailure(entry.name))

    return tests
def load_tests(loader, tests, pattern):
    for entry in pkg_resources.iter_entry_points('qubes.tests.extra'):
        for test_case in entry.load()():
            tests.addTests(loader.loadTestsFromTestCase(test_case))

    try:
        qc = qubes.qubes.QubesVmCollection()
        qc.lock_db_for_reading()
        qc.load()
        qc.unlock_db()
        templates = [vm.name for vm in qc.values() if
                     isinstance(vm, qubes.qubes.QubesTemplateVm)]
    except OSError:
        templates = []

    for entry in pkg_resources.iter_entry_points(
            'qubes.tests.extra.for_template'):
        for test_case in entry.load()():
            for template in templates:
                tests.addTests(loader.loadTestsFromTestCase(
                    type(
                        '{}_{}_{}'.format(
                            entry.name, test_case.__name__, template),
                        (test_case,),
                        {'template': template}
                    )
                ))

    return tests
Exemple #3
0
def load_tests(loader, tests, pattern):
    for template in qubes.tests.list_templates():
        tests.addTests(loader.loadTestsFromTestCase(
            type(
                'TC_10_VMSalt_' + template,
                (SaltVMTestMixin, qubes.tests.SystemTestCase),
                {'template': template})))
    return tests
Exemple #4
0
def load_tests(loader, tests, pattern):
    for template in qubes.tests.list_templates():
        tests.addTests(loader.loadTestsFromTestCase(
            type(
                'TC_20_DispVM_' + template,
                (TC_20_DispVMMixin, qubes.tests.SystemTestCase),
                {'template': template})))

    return tests
Exemple #5
0
def load_tests(loader, tests, pattern):
    for template in qubes.tests.list_templates():
        tests.addTests(
            loader.loadTestsFromTestCase(
                type('TC_40_PVGrub_' + template,
                     (TC_40_PVGrub, qubes.tests.SystemTestCase),
                     {'template': template})))

    return tests
Exemple #6
0
def load_tests(loader, tests, pattern):
    tests.addTests(
        loader.loadTestsFromNames(
            qubes.tests.create_testcases_for_templates(
                'TC_10_BackupVM',
                TC_10_BackupVMMixin,
                qubes.tests.SystemTestCase,
                module=sys.modules[__name__])))
    return tests
def load_tests(loader, tests, pattern):
    tests.addTests(
        loader.loadTestsFromNames(
            qubes.tests.create_testcases_for_templates(
                'TC_10_BackupVM',
                TC_10_BackupVMMixin,
                qubes.tests.SystemTestCase,
                globals=globals())))
    return tests
Exemple #8
0
def load_tests(loader, tests, pattern):
    for template in qubes.tests.list_templates():
        tests.addTests(
            loader.loadTestsFromTestCase(
                type('TC_05_StandaloneVM_' + template,
                     (TC_05_StandaloneVMMixin, qubes.tests.SystemTestCase),
                     {'template': template})))

    return tests
Exemple #9
0
def load_tests(loader, tests, pattern):
    for template in qubes.tests.list_templates():
        tests.addTests(
            loader.loadTestsFromTestCase(
                type('TC_10_BackupVM_' + template,
                     (TC_10_BackupVMMixin, qubes.tests.QubesTestCase),
                     {'template': template})))

    return tests
Exemple #10
0
def load_tests(loader, tests, pattern):
    include_list = None
    if 'QUBES_TEST_EXTRA_INCLUDE' in os.environ:
        include_list = os.environ['QUBES_TEST_EXTRA_INCLUDE'].split()
    exclude_list = []
    if 'QUBES_TEST_EXTRA_EXCLUDE' in os.environ:
        exclude_list = os.environ['QUBES_TEST_EXTRA_EXCLUDE'].split()

    for entry in pkg_resources.iter_entry_points('qubes.tests.extra'):
        if include_list is not None and entry.name not in include_list:
            continue
        if entry.name in exclude_list:
            continue
        try:
            for test_case in entry.load()():
                tests.addTests(
                    loader.loadTestsFromNames([
                        '{}.{}'.format(test_case.__module__,
                                       test_case.__name__)
                    ]))
        except Exception as err:  # pylint: disable=broad-except

            def runTest(self):
                raise err

            ExtraLoadFailure = type('ExtraLoadFailure',
                                    (qubes.tests.QubesTestCase, ),
                                    {entry.name: runTest})
            tests.addTest(ExtraLoadFailure(entry.name))

    for entry in pkg_resources.iter_entry_points(
            'qubes.tests.extra.for_template'):
        if include_list is not None and entry.name not in include_list:
            continue
        if entry.name in exclude_list:
            continue
        try:
            for test_case in entry.load()():
                tests.addTests(
                    loader.loadTestsFromNames(
                        qubes.tests.create_testcases_for_templates(
                            test_case.__name__,
                            test_case,
                            module=sys.modules[test_case.__module__])))
        except Exception as err:  # pylint: disable=broad-except

            def runTest(self):
                raise err

            ExtraForTemplateLoadFailure = type('ExtraForTemplateLoadFailure',
                                               (qubes.tests.QubesTestCase, ),
                                               {entry.name: runTest})
            tests.addTest(ExtraForTemplateLoadFailure(entry.name))

    return tests
Exemple #11
0
def load_tests(loader, tests, pattern):
    for template in qubes.tests.list_templates():
        tests.addTests(loader.loadTestsFromTestCase(
            type(
                'VmNetworking_' + template,
                (VmNetworkingMixin, qubes.tests.SystemTestCase),
                {'template': template})))
        tests.addTests(loader.loadTestsFromTestCase(
            type(
                'VmUpdates_' + template,
                (VmUpdatesMixin, qubes.tests.SystemTestCase),
                {'template': template})))
    return tests
Exemple #12
0
def load_tests(loader, tests, pattern):
    try:
        qc = qubes.qubes.QubesVmCollection()
        qc.lock_db_for_reading()
        qc.load()
        qc.unlock_db()
        templates = [vm.name for vm in qc.values() if
                     isinstance(vm, qubes.qubes.QubesTemplateVm)]
    except OSError:
        templates = []
    for template in templates:
        tests.addTests(loader.loadTestsFromTestCase(
            type(
                'TC_50_MimeHandlers_' + template,
                (TC_50_MimeHandlers, qubes.tests.QubesTestCase),
                {'template': template})))
    return tests
Exemple #13
0
def load_tests(loader, tests, pattern):
    try:
        app = qubes.Qubes()
        templates = [
            vm.name for vm in app.domains
            if isinstance(vm, qubes.vm.templatevm.TemplateVM)
        ]
    except OSError:
        templates = []
    for template in templates:
        tests.addTests(
            loader.loadTestsFromTestCase(
                type('TC_20_DispVM_' + template,
                     (TC_20_DispVMMixin, qubes.tests.QubesTestCase),
                     {'template': template})))

    return tests
Exemple #14
0
def load_tests(loader, tests, pattern):
    try:
        qc = qubes.qubes.QubesVmCollection()
        qc.lock_db_for_reading()
        qc.load()
        qc.unlock_db()
        templates = [vm.name for vm in qc.values() if isinstance(vm, QubesTemplateVm)]
    except OSError:
        templates = []
    for template in templates:
        tests.addTests(
            loader.loadTestsFromTestCase(
                type(
                    "TC_10_BackupVM_" + template,
                    (TC_10_BackupVMMixin, qubes.tests.QubesTestCase),
                    {"template": template},
                )
            )
        )

    return tests
Exemple #15
0
def load_tests(loader, tests, pattern):
    for entry in pkg_resources.iter_entry_points('qubes.tests.extra'):
        try:
            for test_case in entry.load()():
                tests.addTests(
                    loader.loadTestsFromNames([
                        '{}.{}'.format(test_case.__module__,
                                       test_case.__name__)
                    ]))
        except Exception as err:  # pylint: disable=broad-except

            def runTest(self):
                raise err

            ExtraLoadFailure = type('ExtraLoadFailure',
                                    (qubes.tests.QubesTestCase, ),
                                    {entry.name: runTest})
            tests.addTest(ExtraLoadFailure(entry.name))

    for entry in pkg_resources.iter_entry_points(
            'qubes.tests.extra.for_template'):
        try:
            for test_case in entry.load()():
                tests.addTests(
                    loader.loadTestsFromNames(
                        qubes.tests.create_testcases_for_templates(
                            test_case.__name__,
                            test_case,
                            module=sys.modules[test_case.__module__])))
        except Exception as err:  # pylint: disable=broad-except

            def runTest(self):
                raise err

            ExtraForTemplateLoadFailure = type('ExtraForTemplateLoadFailure',
                                               (qubes.tests.QubesTestCase, ),
                                               {entry.name: runTest})
            tests.addTest(ExtraForTemplateLoadFailure(entry.name))

    return tests
Exemple #16
0
def load_tests(loader, tests, pattern):
    for entry in pkg_resources.iter_entry_points('qubes.tests.extra'):
        try:
            for test_case in entry.load()():
                tests.addTests(loader.loadTestsFromTestCase(test_case))
        except Exception as err:  # pylint: disable=broad-except

            def runTest(self):
                raise err

            ExtraLoadFailure = type('ExtraLoadFailure',
                                    (qubes.tests.QubesTestCase, ),
                                    {entry.name: runTest})
            tests.addTest(ExtraLoadFailure(entry.name))

    for entry in pkg_resources.iter_entry_points(
            'qubes.tests.extra.for_template'):
        try:
            for test_case in entry.load()():
                for template in qubes.tests.list_templates():
                    tests.addTests(
                        loader.loadTestsFromTestCase(
                            type(
                                '{}_{}_{}'.format(entry.name,
                                                  test_case.__name__,
                                                  template), (test_case, ),
                                {'template': template})))
        except Exception as err:  # pylint: disable=broad-except

            def runTest(self):
                raise err

            ExtraForTemplateLoadFailure = type('ExtraForTemplateLoadFailure',
                                               (qubes.tests.QubesTestCase, ),
                                               {entry.name: runTest})
            tests.addTest(ExtraLoadFailure(entry.name))

    return tests
Exemple #17
0
def load_tests(loader, tests, pattern):
    for entry in pkg_resources.iter_entry_points('qubes.tests.extra'):
        for test_case in entry():
            tests.addTests(
                loader.loadTestsFromTestCase(
                    type(
                        entry.name + '_' + test_case.__name__,
                        (test_case, ExtraTestMixin, qubes.tests.QubesTestCase),
                        {})))

    try:
        qc = qubes.qubes.QubesVmCollection()
        qc.lock_db_for_reading()
        qc.load()
        qc.unlock_db()
        templates = [
            vm.name for vm in qc.values()
            if isinstance(vm, qubes.qubes.QubesTemplateVm)
        ]
    except OSError:
        templates = []

    for entry in pkg_resources.iter_entry_points(
            'qubes.tests.extra.for_template'):
        for test_case in entry.load()():
            for template in templates:
                tests.addTests(
                    loader.loadTestsFromTestCase(
                        type(
                            '{}_{}_{}'.format(entry.name, test_case.__name__,
                                              template),
                            (test_case, ExtraTestMixin,
                             qubes.tests.QubesTestCase),
                            {'template': template})))

    return tests
Exemple #18
0
def load_tests(loader, tests, pattern):
    tests.addTests(loader.loadTestsFromNames(
        create_testcases_for_templates()))
    return tests