Ejemplo n.º 1
0
def test_component(test, create_configuration):
    test_dict = osl_tests.get_test_params(test)
    component = test_dict["test"]
    machine = test_dict["machine"]
    variant = get_variant(machine)
    board = re.sub("_", "-", machine)

    if component not in components:
        elf = test_dict["test"]
        if variant:
            config = create_configuration(params=["elf", variant, elf],
                                          machine=machine)
            overrides(config, variant)

        if elf:
            overrides(config, elf)
        else:
            config = create_configuration(params=[component])

        config["variant"] = variant
        config["xsct_elf_name"] = elf
        mkdir(config["deploy_artifacts"])
        # Call Buildapp
        assert xsct.xsct_builder(config)
    else:
        if variant != None:
            config = create_configuration(params=[component, variant],
                                          machine=machine)
            config["variant"] = variant
            overrides(config, variant)
            overrides(config, board)
        else:
            config = create_configuration(params=[component], machine=machine)
        opensource_builder(config, component, variant, board, machine)
Ejemplo n.º 2
0
def test_performance_bif_randomization(request, test, build_dir):
    rootdir = request.config.rootdir.strpath
    fspath = request.node.fspath
    wsDir = build_dir
    logDir = os.path.join(wsDir, "log")
    workDir = os.path.join(wsDir, "work")
    imagesDir = os.path.join(wsDir, "images")
    logger = Logger(logDir)
    overrides = [
        f"buildDir={build_dir}",
        f"wsDir={wsDir}",
        f"logDir={logDir}",
        f"workDir={workDir}",
        f"imagesDir={imagesDir}",
        "randomize=True",
    ]
    config = generate_conf(
        rootdir=rootdir,
        test_path=fspath,
        test_name="performance",
        params=[test],
        overrides=overrides,
    )
    mkdir(workDir)
    mkdir(imagesDir)
    generate_bif(config=config, format_type="new")
    logger.close()
    test_dir = os.path.join(os.path.dirname(__file__), "performance", test)
    assert filecmp.cmp(
        os.path.join(config["imagesDir"], "boot.bif"),
        os.path.join(test_dir, "boot.bif"),
    )
Ejemplo n.º 3
0
def test_bif_no_seed(request, build_dir):
    rootdir = request.config.rootdir.strpath
    fspath = request.node.fspath
    wsDir = build_dir
    logDir = os.path.join(wsDir, "log")
    workDir = os.path.join(wsDir, "work")
    imagesDir = os.path.join(wsDir, "images")
    overrides = [
        f"buildDir={build_dir}",
        f"wsDir={wsDir}",
        f"logDir={logDir}",
        f"workDir={workDir}",
        f"imagesDir={imagesDir}",
        "randomize=True",
    ]
    config = generate_conf(
        rootdir=rootdir,
        test_path=fspath,
        test_name="performance",
        params=["003"],
        overrides=overrides,
    )
    mkdir(workDir)
    mkdir(imagesDir)
    del config["seed"]
    try:
        generate_bif(config=config, format_type="new")
    except:
        assert False, f"generate_bif() raised exception"
Ejemplo n.º 4
0
def test_component(test_case, create_configuration):
    board, component = test_case.split("-")
    machine = board
    variant = get_variant(machine)

    if component not in components:
        elf = component
        if variant:
            config = create_configuration(
                params=["elf", variant, elf],
                overrides=[f"osl_demo_basic/component/elf.py"],
                machine=machine,
            )
            overrides(config, variant)

        if elf:
            overrides(config, elf)
        else:
            config = create_configuration(
                params=[component],
                overrides=[f"osl_demo_basic/component/elf.py"])

        config["variant"] = variant
        config["xsct_elf_name"] = elf
        mkdir(config["deploy_artifacts"])
        # Call Buildapp
        assert xsct.xsct_builder(config)
    else:
        if variant != None:
            config = create_configuration(
                params=[component, variant],
                overrides=[f"osl_demo_basic/component/{component}.py"],
                machine=machine,
            )
            config["variant"] = variant
            overrides(config, variant)
            overrides(config, board)

        else:
            config = create_configuration(
                params=[component],
                overrides=[f"osl_demo_basic/component/{component}.py"],
                machine=machine,
            )
        opensource_builder(config, component, variant, board)
Ejemplo n.º 5
0
def setup_logger(
    log_dirname,
    log_filename=None,
    console_level=logging.INFO,
    file_level=logging.DEBUG,
    **kwargs,
):
    """This defines two logging handlers - file at DEBUG level and console at INFO level.
    Any keyword arguments will be passed to logging.Formatter.

    Args:
        log_dirname (str): Directory where log files will be written.
        log_filename (str, optional): Name for log file. If not specified,
            name will be generated based on timestamp. Defaults to None.
    """
    mkdir(log_dirname)
    if log_filename is None:
        log_filename = datetime.now().strftime("%Y%m%d-%H%M%S") + ".log"
    log_path = os.path.join(log_dirname, log_filename)

    global logger, fh, ch
    logger = logging.getLogger("roast")
    logger.setLevel(logging.DEBUG)
    fh = logging.FileHandler(log_path)
    fh.setLevel(file_level)
    ch = logging.StreamHandler()
    ch.setLevel(console_level)
    if kwargs:
        formatter = logging.Formatter(**kwargs)
    else:
        formatter = logging.Formatter(
            "%(asctime)s.%(msecs)03d - %(name)s - %(levelname)s - %(message)s",
            datefmt="%Y-%m-%d %H:%M:%S",
        )
    fh.setFormatter(formatter)
    ch.setFormatter(formatter)
    logger.addHandler(fh)
    logger.addHandler(ch)
    return logger
Ejemplo n.º 6
0
    def __init__(self, config, setup: bool = True):
        super().__init__(config)
        self.setup = setup

        # override workDir with customized option
        if config.get("work_root_dir"):
            work_dir = os.path.join(
                config.work_root_dir,
                *config.get("base_params", ""),
                *config.get("test_path_list", ""),
                *config.get("params", ""),
                "work",
            )
            if self.setup:
                reset(work_dir)
            config["workDir"] = work_dir

        self.wsDir = config["wsDir"]
        self.workDir = config["workDir"]
        self.logDir = config["logDir"]
        self.imagesDir = config["imagesDir"]
        if self.setup:
            reset(config["wsDir"])
        mkdir(config["workDir"])
        mkdir(config["logDir"])
        mkdir(config["imagesDir"])

        log_filename = config.get("log_filename")
        console_level = config.get("console_level", logging.INFO)
        file_level = config.get("file_level", logging.DEBUG)
        console_format = config.get("console_format", "")
        file_format = config.get("file_format", "")
        time_format = config.get("time_format", "")
        report_summary = config.get("report_summary", False)
        report_tokens = config.get("report_tokens", [])
        self.logger = setup_logger(
            config["logDir"],
            log_filename=log_filename,
            console_level=console_level,
            file_level=file_level,
            console_format=console_format,
            file_format=file_format,
            time_format=time_format,
            report_summary=report_summary,
            report_tokens=report_tokens,
        )
        log.info("Logger setup completed.")
        log.debug(f'wsDir={config["wsDir"]}')
        log.debug(f'workDir={config["workDir"]}')
        log.debug(f'logDir={config["logDir"]}')
        log.debug(f'imagesDir={config["imagesDir"]}')
        log.debug(
            f"logfile={self.logger.log_path}, console_level={console_level}, file_level={file_level}"
        )
        log.debug(
            f"console_format={console_format}, file_format={file_format}")
        atexit.register(self.__del__)
Ejemplo n.º 7
0
def setup_logger(
    log_dirname,
    log_filename=None,
    console_level=logging.INFO,
    file_level=logging.DEBUG,
    console_fmt={},
    file_fmt={},
    **kwargs,
):
    """This defines two logging handlers - file at DEBUG level and console at INFO level.
    If any keyword arguments are provided, all other parameters will be discarded with both
    handlers set to the same format.

    The dictionaries for console_fmt and file_fmt are in the format:
    {"fmt": <format string>, "datefmt": <format string>, "style': <format string>}

    Args:
        log_dirname (str): Directory where log files will be written.
        log_filename (str, optional): Name for log file. If not specified,
            name will be generated based on timestamp. Defaults to None.
        console_level (int): Logging level for console. Defaults to logging.INFO or 20.
        file_level (int): Logging level for file. Default to logging.DEBUG or 10.
        console_fmt (dict): Dictionary of formatting parameters.
        file_fmt (dict): Dictionary of file parameters.
        **fmt (str): Message format.
        **datefmt (str): Date format.
        **style (str): Style format.

    """
    mkdir(log_dirname)
    if log_filename is None:
        log_filename = datetime.now().strftime("%Y%m%d-%H%M%S") + ".log"
    log_path = os.path.join(log_dirname, log_filename)

    global logger, fh, ch
    logger = logging.getLogger("roast")
    logger.setLevel(logging.DEBUG)
    fh = logging.FileHandler(log_path)
    fh.setLevel(file_level)
    ch = logging.StreamHandler()
    ch.setLevel(console_level)

    file_formatter = logging.Formatter()
    console_formatter = logging.Formatter()
    if file_fmt:
        fmt = file_fmt.get("fmt")
        datefmt = file_fmt.get("datefmt")
        style = file_fmt.get("style", "%")
        file_formatter = logging.Formatter(fmt, datefmt, style)
    if console_fmt:
        fmt = console_fmt.get("fmt")
        datefmt = console_fmt.get("datefmt")
        style = console_fmt.get("style", "%")
        console_formatter = logging.Formatter(fmt, datefmt, style)
    if kwargs:
        file_formatter = logging.Formatter(**kwargs)
        console_formatter = logging.Formatter(**kwargs)
    fh.setFormatter(file_formatter)
    ch.setFormatter(console_formatter)
    logger.addHandler(fh)
    logger.addHandler(ch)
    return logger