Esempio n. 1
0
def handle(suite):
    if common.is_package(suite):
        fail = False
        for subsuite in common.list_subsuites(suite):
            if not handle(subsuite):
                fail = True
        return not fail
    elif common.is_testcase(suite):
        handler_name = '_'.join(suite.split('.')[:-1])
        if not eval('%s(suite)' % handler_name):
            backupdir = os.getcwd() + '_' + suite
            if not os.path.exists(backupdir):
                shutil.copytree(os.getcwd(), backupdir)
            return False
        else:
            return True
Esempio n. 2
0
def handle(suite):
    if common.is_package(suite):
        fail = False
        for subsuite in common.list_subsuites(suite):
            if not handle(subsuite):
                fail = True
        return not fail
    elif common.is_testcase(suite):
        handler_name = '_'.join(suite.split('.')[:-1])
        if not eval('%s(suite)' % handler_name):
            backupdir = os.getcwd() + '_' + suite
            if not os.path.exists(backupdir):
                shutil.copytree(os.getcwd(), backupdir)
            return False
        else:
            return True
Esempio n. 3
0
def find_suites(prefix, dir):
    suites = []
    for f in os.listdir(dir):
        if f.startswith('.'):
            continue # ignore hidden files and directories
        path = os.path.join(dir, f)
        if os.path.isfile(path):
            name, ext = os.path.splitext(f)
            suite = prefix + name
            if common.is_source(ext) and common.is_testcase(suite):
                suites.append(suite)
        if os.path.isdir(path):
            new_prefix = prefix + f + '.'
            suites.append(prefix + f)
            suites.extend(find_suites(new_prefix, path))
    return suites
Esempio n. 4
0
def systematic_chess(suite):
    assert common.is_testcase(suite)
    clean_currdir()
    testcase = common.testcase_name(suite)
    source_path = common.source_path(suite)
    script_path = common.script_path(suite)
    target_path = os.path.join(os.getcwd(), 'target')
    output_path = os.path.join(os.getcwd(), 'stdout')
    f, p, d = imp.find_module(testcase, [os.path.dirname(script_path)])
    module = imp.load_module(testcase, f, p, d)
    f.close()
    flags = common.default_flags(suite)
    if hasattr(module, 'disabled'):
        common.echo(suite, 'disabled!')
        return True
    if hasattr(module, 'setup_flags'):
        module.setup_flags(flags)
    if not common.compile(source_path, target_path, flags, True):
        common.echo(suite, 'failed! compile error')
        return False
    pin = pintool.Pin(config.pin_home())
    controller = systematic_pintool.Controller()
    controller.knobs['enable_chess_scheduler'] = True
    if hasattr(module, 'setup_controller'):
        module.setup_controller(controller)
    test = testing.InteractiveTest([target_path], sout=output_path)
    test.set_prefix(get_prefix(pin, controller))
    testcase = systematic_testing.ChessTestCase(test, 'finish', 1, controller)
    if hasattr(module, 'setup_testcase'):
        module.setup_testcase(testcase)
    logging.message_off()
    testcase.run()
    logging.message_on()
    if not hasattr(module, 'verify'):
        common.echo(suite, 'failed! no verify')
        return False
    else:
        success = module.verify(controller, testcase)
        if success:
            common.echo(suite, 'succeeded!')
        else:
            common.echo(suite, 'failed!')
        return success
Esempio n. 5
0
def idiom_observer(suite):
    assert common.is_testcase(suite)
    clean_currdir()
    testcase = common.testcase_name(suite)
    source_path = common.source_path(suite)
    script_path = common.script_path(suite)
    target_path = os.path.join(os.getcwd(), "target")
    output_path = os.path.join(os.getcwd(), "stdout")
    f, p, d = imp.find_module(testcase, [os.path.dirname(script_path)])
    module = imp.load_module(testcase, f, p, d)
    f.close()
    flags = common.default_flags(suite)
    if hasattr(module, "disabled"):
        common.echo(suite, "disabled!")
        return True
    if hasattr(module, "setup_flags"):
        module.setup_flags(flags)
    if not common.compile(source_path, target_path, flags, True):
        common.echo(suite, "failed! compile error")
        return False
    pin = pintool.Pin(config.pin_home())
    profiler = idiom_pintool.Profiler()
    profiler.knobs["enable_observer_new"] = True
    if hasattr(module, "setup_profiler"):
        module.setup_profiler(profiler)
    test = testing.InteractiveTest([target_path], sout=output_path)
    test.set_prefix(get_prefix(pin, profiler))
    testcase = idiom_testing.ProfileTestCase(test, "runout", 3, profiler)
    if hasattr(module, "setup_testcase"):
        module.setup_testcase(testcase)
    logging.message_off()
    testcase.run()
    logging.message_on()
    if not hasattr(module, "verify"):
        common.echo(suite, "failed! no verify")
        return False
    else:
        success = module.verify(profiler, testcase)
        if success:
            common.echo(suite, "succeeded!")
        else:
            common.echo(suite, "failed!")
        return success
Esempio n. 6
0
def systematic_chess(suite):
    assert common.is_testcase(suite)
    clean_currdir()
    testcase = common.testcase_name(suite)
    source_path = common.source_path(suite)
    script_path = common.script_path(suite)
    target_path = os.path.join(os.getcwd(), 'target')
    output_path = os.path.join(os.getcwd(), 'stdout')
    f, p, d = imp.find_module(testcase, [os.path.dirname(script_path)])
    module = imp.load_module(testcase, f, p, d)
    f.close()
    flags = common.default_flags(suite)
    if hasattr(module, 'disabled'):
        common.echo(suite, 'disabled!')
        return True
    if hasattr(module, 'setup_flags'):
        module.setup_flags(flags)
    if not common.compile(source_path, target_path, flags, True):
        common.echo(suite, 'failed! compile error')
        return False
    pin = pintool.Pin(config.pin_home())
    controller = systematic_pintool.Controller()
    controller.knobs['enable_chess_scheduler'] = True
    if hasattr(module, 'setup_controller'):
        module.setup_controller(controller)
    test = testing.InteractiveTest([target_path], sout=output_path)
    test.set_prefix(get_prefix(pin, controller))
    testcase = systematic_testing.ChessTestCase(test, 'finish', 1, controller)
    if hasattr(module, 'setup_testcase'):
        module.setup_testcase(testcase)
    logging.message_off()
    testcase.run()
    logging.message_on()
    if not hasattr(module, 'verify'):
        common.echo(suite, 'failed! no verify')
        return False
    else:
        success = module.verify(controller, testcase)
        if success:
            common.echo(suite, 'succeeded!')
        else:
            common.echo(suite, 'failed!')
        return success