Пример #1
0
    def __update_status_icon(self, app_name, device_type):
        '''
        Update the status icon.
        '''
        results_web_path = TEST_RESULTS_WEB_PATH[app_name]
        if not utils.exists(results_web_path):
            return

        utils.execute(results_web_path, 'git', ['pull', 'origin', 'gh-pages'])
        status = 'passing'
        for test in self.results:
            if test['result'] == 'fail':
                status = 'failing'
                break

        current_status_icon = utils.join(results_web_path, 'status',
                                         '%s.svg' % device_type)

        if not utils.exists(current_status_icon):
            return

        with open(current_status_icon) as file:
            if status in file.read():
                return

        image = 'pass.svg' if status is 'passing' else 'fail.svg'
        copied_status_icon = utils.join(results_web_path, 'img', image)
        utils.copy_file(copied_status_icon, current_status_icon)

        utils.execute(results_web_path, 'git', ['add', current_status_icon])
        utils.execute(results_web_path, 'git',
                      ['commit', '-m', 'Update the status badge.'])
        utils.execute(results_web_path, 'git', ['push'])
Пример #2
0
    def install_dependencies(self):
        '''
        Install dependencies of the board.
        '''
        if utils.exists(utils.join(paths.STLINK_BUILD_PATH, 'st-flash')):
            return

        utils.execute(paths.STLINK_PATH, 'make', ['release'])
Пример #3
0
    def __copy_test_files(self, app):
        '''
        Copy sample files into the NuttX apps.
        '''
        if utils.exists(paths.TIZENRT_ROMFS_CONTENTS_PATH):
            utils.execute(paths.TIZENRT_FS_PATH, 'rm', ['-rf', 'contents'])

        utils.execute(
            paths.ROOT_FOLDER, 'cp',
            [app.get_test_dir(), paths.TIZENRT_ROMFS_CONTENTS_PATH, '-r'])
Пример #4
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'])
Пример #5
0
def fetch_modules(env):
    '''
    Download all the required modules.
    '''
    modules = env['modules']

    for module in 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'])
Пример #6
0
    def __save(self, app, device, is_publish):
        '''
        Save the testresults.
        '''

        os = device.get_os()
        device_type = device.get_type()

        # Create submodule information.
        submodules = {
            app.get_name(): utils.last_commit_info(app.get_home_dir()),
            os.get_name(): utils.last_commit_info(os.get_home_dir())
        }

        if os.get_name() is 'nuttx':
            submodules['apps'] = utils.last_commit_info(paths.NUTTX_APPS_PATH)

        # Create the result.
        bin_sizes = {}
        if app.get_name() == 'iotjs':
            target_profile_mapfile = app.get_target_profile_mapfile()
            minimal_profile_mapfile = app.get_minimal_profile_mapfile()

            target_bin_sizes = utils.get_section_sizes_from_map(
                target_profile_mapfile)
            minimal_bin_sizes = utils.get_section_sizes_from_map(
                minimal_profile_mapfile)

            bin_sizes = {
                'target_profile': target_bin_sizes,
                'minimal_profile': minimal_bin_sizes
            }

        else:
            bin_sizes = utils.get_section_sizes(app.get_minimal_image())

        result = {
            'bin': bin_sizes,
            'date': utils.get_standardized_date(),
            'tests': self.results,
            'submodules': submodules
        }

        device_dir = "stm32" if device_type == "stm32f4dis" else device_type

        # Save the results into a JSON file.

        result_dir = utils.join(paths.OUTPUT_PATH, app.get_name(), device_dir)

        if not utils.exists(result_dir):
            utils.mkdir(result_dir)

        result_file_name = result['date'] + '.json'
        result_file_name = result_file_name.replace(':', '.')
        result_file_path = utils.join(result_dir, result_file_name)

        utils.write_json_file(result_file_path, result)

        # Do not share the results if it not public.
        if not is_publish:
            return

        # Publish results to firebase

        user = utils.get_environment('FIREBASE_USER')
        pwd = utils.get_environment('FIREBASE_PWD')

        if not (pwd and user):
            return

        config = {
            "apiKey": "AIzaSyDMgyPr0V49Rdf5ODAU9nLY02ZGEUNoxiM",
            "authDomain": "remote-testrunner.firebaseapp.com",
            "databaseURL": "https://remote-testrunner.firebaseio.com",
            "storageBucket": "remote-testrunner.appspot.com",
        }

        firebase = pyrebase.initialize_app(config)
        auth = firebase.auth()
        db = firebase.database()

        user = auth.sign_in_with_email_and_password(user, pwd)

        with open(result_file_path) as result_file:
            result_data = json.load(result_file)
            db.child(app.get_name() + '/' + device_dir).push(
                result_data, user['idToken'])

            # Update the status icon after upload was successful.
            self.__update_status_icon(app.get_name(), device.get_type())