Ejemplo n.º 1
0
def get_runner_config(build_dir, yaml_path, runners_yaml, args=None):
    # Get a RunnerConfig object for the current run. yaml_config is
    # runners.yaml's config: map, and args are the command line arguments.
    yaml_config = runners_yaml['config']
    yaml_dir = yaml_path.parent
    if args is None:
        args = argparse.Namespace()

    def output_file(filetype):

        from_args = getattr(args, f'{filetype}_file', None)
        if from_args is not None:
            return from_args

        from_yaml = yaml_config.get(f'{filetype}_file')
        if from_yaml is not None:
            # Output paths in runners.yaml are relative to the
            # directory containing the runners.yaml file.
            return fspath(yaml_dir / from_yaml)

        return None

    def config(attr):
        return getattr(args, attr, None) or yaml_config.get(attr)

    return RunnerConfig(build_dir, yaml_config['board_dir'],
                        output_file('elf'), output_file('hex'),
                        output_file('bin'), config('gdb'), config('openocd'),
                        config('openocd_search'))
Ejemplo n.º 2
0
def runner_cfg_from_args(args, build_dir):
    return RunnerConfig(build_dir,
                        args.board_dir,
                        args.elf_file,
                        args.hex_file,
                        args.bin_file,
                        gdb=args.gdb,
                        openocd=args.openocd,
                        openocd_search=args.openocd_search)
Ejemplo n.º 3
0
def runner_config():
    '''Fixture which provides a runners.core.RunnerConfig.'''
    return RunnerConfig(RC_BUILD_DIR,
                        RC_BOARD_DIR,
                        RC_KERNEL_ELF,
                        RC_KERNEL_HEX,
                        RC_KERNEL_BIN,
                        gdb=RC_GDB,
                        openocd=RC_OPENOCD,
                        openocd_search=RC_OPENOCD_SEARCH)
def cached_runner_config(build_dir, cache):
    '''Parse the RunnerConfig from a build directory and CMake Cache.'''
    board_dir = cache['ZEPHYR_RUNNER_CONFIG_BOARD_DIR']
    kernel_elf = cache['ZEPHYR_RUNNER_CONFIG_KERNEL_ELF']
    kernel_hex = cache['ZEPHYR_RUNNER_CONFIG_KERNEL_HEX']
    kernel_bin = cache['ZEPHYR_RUNNER_CONFIG_KERNEL_BIN']
    gdb = cache.get('ZEPHYR_RUNNER_CONFIG_GDB')
    openocd = cache.get('ZEPHYR_RUNNER_CONFIG_OPENOCD')
    openocd_search = cache.get('ZEPHYR_RUNNER_CONFIG_OPENOCD_SEARCH')

    return RunnerConfig(build_dir, board_dir,
                        kernel_elf, kernel_hex, kernel_bin,
                        gdb=gdb, openocd=openocd,
                        openocd_search=openocd_search)
Ejemplo n.º 5
0
def cached_runner_config(build_dir, cache):
    '''Parse the RunnerConfig from a build directory and CMake Cache.'''
    board_dir = cache['ZEPHYR_RUNNER_CONFIG_BOARD_DIR']
    elf_file = cache.get('ZEPHYR_RUNNER_CONFIG_KERNEL_ELF')
    hex_file = cache.get('ZEPHYR_RUNNER_CONFIG_KERNEL_HEX')
    bin_file = cache.get('ZEPHYR_RUNNER_CONFIG_KERNEL_BIN')
    gdb = cache.get('ZEPHYR_RUNNER_CONFIG_GDB')
    openocd = cache.get('ZEPHYR_RUNNER_CONFIG_OPENOCD')
    openocd_search = cache.get('ZEPHYR_RUNNER_CONFIG_OPENOCD_SEARCH')

    return RunnerConfig(build_dir,
                        board_dir,
                        elf_file,
                        hex_file,
                        bin_file,
                        gdb=gdb,
                        openocd=openocd,
                        openocd_search=openocd_search)
def fix_up_runner_config(test_case, runner_config, tmpdir):
    # Helper that adjusts the common runner_config fixture for our
    # nRF53-specific tests that use real hex files.

    if test_case.family != 'NRF53':
        return runner_config

    config_as_dict = runner_config._asdict()

    if test_case.coprocessor == 'APP':
        config_as_dict['hex_file'] = NRF5340_APP_ONLY_HEX
    elif test_case.coprocessor == 'NET':
        config_as_dict['hex_file'] = NRF5340_NET_ONLY_HEX
    elif test_case.coprocessor == 'APP+NET':
        # Since the runner is going to generate files next to its input
        # file, we need to stash a copy in a tmpdir it can use.
        outfile = tmpdir / Path(NRF5340_APP_AND_NET_HEX).name
        shutil.copyfile(NRF5340_APP_AND_NET_HEX, outfile)
        config_as_dict['hex_file'] = os.fspath(outfile)
    else:
        assert False, f'bad test case {test_case}'

    return RunnerConfig(**config_as_dict)