コード例 #1
0
ファイル: utils.py プロジェクト: TamasZakor/js-remote-test
def calculate_section_sizes(builddir):
    '''
    Return the sizes of the main sections.
    '''
    section_sizes = {'bss': 0, 'text': 0, 'data': 0, 'rodata': 0}

    mapfile = utils.join(builddir, 'linker.map')
    libdir = utils.join(builddir, 'libs')

    if not (utils.exists(mapfile) and utils.exists(libdir)):
        return section_sizes

    # Get the names of the object files that the static
    # libraries (libjerry-core.a, ...) have.
    objlist = read_objects_from_libs(libdir, _LIBLIST)

    raw_data = lumpy.load_map_data(mapfile)
    sections = lumpy.parse_to_sections(raw_data)
    # Extract .rodata section from the .text section.
    lumpy.hoist_section(sections, '.text', '.rodata')

    for section in sections:
        section_name = section['name'][1:]
        # Skip sections that are not relevant.
        if section_name not in section_sizes.keys():
            continue

        for entry in section['contents']:
            if any(obj in entry['path'] for obj in objlist):
                section_sizes[section_name] += entry['size']

    return section_sizes
コード例 #2
0
    def should_build(self, build_info):
        '''
        Test weather a component should be built or not.
        '''
        condition = build_info.get('build-condition', 'True')

        if not eval(condition):
            return False

        # Always build the projects that don't have 'build-once' marker.
        if 'build-once' not in build_info:
            return True

        build_info = build_info[self.device]
        # Some projects don't require to build them over-and-over again.
        # e.g. Freya, ST-Link. In their case, just check if the project
        # has already built.
        for artifact in build_info.get('artifacts', []):
            src = artifact.get('src', '')
            dst = artifact.get('dst', '')

            # If dst is provided, check that first. If it doesn't, it's
            # enough just check the src.
            if dst and not utils.exists(dst):
                return True

            if not dst and not utils.exists(src):
                return True

        return False
コード例 #3
0
ファイル: testresult.py プロジェクト: pmarkee/js-remote-test
    def create_result(self):
        '''
        Create a final JSON result file from the build and test information.
        '''
        result = {'bin': {}, 'date': {}, 'tests': {}, 'submodules': {}}

        labels = {
            'profiles/minimal-profile-build':
            'minimal-profile',
            'profiles/target-es5.1-profile-build':
            'target-es5_1-profile',
            'profiles/target-es2015subset-profile-build':
            'target-es2015subset-profile'
        }

        for job_id, build_path in self.results.iteritems():
            # Append the binary information.
            if 'test-build' in job_id:
                filename = utils.join(build_path, 'testresults.json')
                # Do not save the testresults if there is no available data.
                if not utils.exists(filename):
                    continue

                result.update(utils.read_json_file(filename))

            else:
                filename = utils.join(build_path, 'build.json')
                # Do not save build info if there is no available data.
                if not utils.exists(filename):
                    continue

                bin_data = utils.read_json_file(filename)
                # Translate job_id to database schema name.
                label = labels[job_id]

                result['bin'][label] = bin_data['bin']
                result['submodules'] = bin_data['submodules']
                result['date'] = bin_data['last-commit-date']

        filepath = utils.join(paths.RESULT_PATH, self.options.app,
                              self.options.device)
        filename = utils.join(filepath, utils.current_date() + '.json')
        # Save the content info a result file.
        utils.write_json_file(filename, result)

        console.log()
        console.log('The results are written into:', console.TERMINAL_BLUE)
        console.log('  {json_file}'.format(json_file=filename))
        console.log()

        return result
コード例 #4
0
ファイル: testrunner.py プロジェクト: pmarkee/js-remote-test
def read_testsets(env):
    '''
    Read all the tests into dictionary.
    '''
    testset = utils.join(env.modules.app.paths.tests, 'testsets.json')

    if utils.exists(testset):
        return utils.read_json_file(testset)

    return testrunner_utils.read_test_files(env)
コード例 #5
0
    def _build_stlink(self):
        '''
        Build the ST-Link flasher tool.
        '''
        stlink = self.env['modules']['stlink']

        # Do not build if not necessary.
        if utils.exists(stlink['paths']['st-flash']):
            return

        utils.execute(stlink['src'], 'make', ['release'])
コード例 #6
0
def fetch_modules(env):
    '''
    Download all the required modules.
    '''
    for module in env.modules.values():
        # Skip if the module is already exist.
        if utils.exists(module['src']):
            continue

        fetch_url = module['url']
        fetch_dir = module['src']

        utils.execute('.', 'git', ['clone', fetch_url, fetch_dir])
        utils.execute(module['src'], 'git', ['checkout', module['version']])
        utils.execute(module['src'], 'git', ['submodule', 'update', '--init'])
コード例 #7
0
    def read_modules(self):
        '''
        Collect buildable modules and their build instructions.
        '''
        modules = {}

        for name in self.env.modules:
            filename = utils.join(paths.BUILDER_MODULES_PATH,
                                  '%s.build.config' % name)
            # Skip modules that don't have configuration file (e.g. nuttx-apps).
            if not utils.exists(filename):
                continue

            build_info = utils.read_config_file(filename, self.env)
            # Check if the project is alredy built.
            if self.should_build(build_info):
                modules[name] = build_info[self.device]

        return modules