예제 #1
0
파일: generic.py 프로젝트: johnny90/lisa
    def _getExperimentsConf(cls, test_env):
        if not test_env.nrg_model:
            try:
                test_env.nrg_model = EnergyModel.from_target(test_env.target)
            except Exception as e:
                raise SkipTest(
                    'This test requires an EnergyModel for the platform. '
                    'Either provide one manually or ensure it can be read '
                    'from the filesystem: {}'.format(e))

        conf = {
            'tag': 'energy_aware',
            'flags': ['ftrace', 'freeze_userspace'],
        }

        if 'cpufreq' in test_env.target.modules:
            available_govs = test_env.target.cpufreq.list_governors(0)
            if 'schedutil' in available_govs:
                conf['cpufreq'] = {'governor': 'schedutil'}
            elif 'sched' in available_govs:
                conf['cpufreq'] = {'governor': 'sched'}

        return {
            'wloads': cls.workloads,
            'confs': [conf],
        }
예제 #2
0
파일: generic.py 프로젝트: msrasmussen/lisa
    def _getExperimentsConf(cls, test_env):
        if not test_env.nrg_model:
            try:
                test_env.nrg_model = EnergyModel.from_target(test_env.target)
            except Exception as e:
                raise SkipTest(
                    'This test requires an EnergyModel for the platform. '
                    'Either provide one manually or ensure it can be read '
                    'from the filesystem: {}'.format(e))

        conf = {
            'tag' : 'energy_aware',
            'flags' : ['ftrace', 'freeze_userspace'],
        }

        if 'cpufreq' in test_env.target.modules:
            available_govs = test_env.target.cpufreq.list_governors(0)
            if 'schedutil' in available_govs:
                conf['cpufreq'] = {'governor' : 'schedutil'}
            elif 'sched' in available_govs:
                conf['cpufreq'] = {'governor' : 'sched'}

        return {
            'wloads' : cls.workloads,
            'confs' : [conf],
        }
예제 #3
0
    def _init_target(self, force = False):

        if not force and self.target is not None:
            return self.target

        self.__connection_settings = {}

        # Configure username
        if 'username' in self.conf:
            self.__connection_settings['username'] = self.conf['username']
        else:
            self.__connection_settings['username'] = USERNAME_DEFAULT

        # Configure password or SSH keyfile
        if 'keyfile' in self.conf:
            self.__connection_settings['keyfile'] = self.conf['keyfile']
        elif 'password' in self.conf:
            self.__connection_settings['password'] = self.conf['password']
        else:
            self.__connection_settings['password'] = PASSWORD_DEFAULT

        # Configure port
        if 'port' in self.conf:
            self.__connection_settings['port'] = self.conf['port']

        # Configure the host IP/MAC address
        if 'host' in self.conf:
            try:
                if ':' in self.conf['host']:
                    (self.mac, self.ip) = self.resolv_host(self.conf['host'])
                else:
                    self.ip = self.conf['host']
                self.__connection_settings['host'] = self.ip
            except KeyError:
                raise ValueError('Config error: missing [host] parameter')

        try:
            platform_type = self.conf['platform']
        except KeyError:
            raise ValueError('Config error: missing [platform] parameter')

        if platform_type.lower() == 'android':
            self.ANDROID_HOME = self.conf.get('ANDROID_HOME',
                                              self.ANDROID_HOME)
            if self.ANDROID_HOME:
                self._adb = os.path.join(self.ANDROID_HOME,
                                         'platform-tools', 'adb')
                self._fastboot = os.path.join(self.ANDROID_HOME,
                                              'platform-tools', 'fastboot')
                os.environ['ANDROID_HOME'] = self.ANDROID_HOME
                os.environ['CATAPULT_HOME'] = self.CATAPULT_HOME
            else:
                raise RuntimeError('Android SDK not found, ANDROID_HOME must be defined!')

            self._log.info('External tools using:')
            self._log.info('   ANDROID_HOME: %s', self.ANDROID_HOME)
            self._log.info('   CATAPULT_HOME: %s', self.CATAPULT_HOME)

            if not os.path.exists(self._adb):
                raise RuntimeError('\nADB binary not found\n\t{}\ndoes not exists!\n\n'
                                   'Please configure ANDROID_HOME to point to '
                                   'a valid Android SDK installation folder.'\
                                   .format(self._adb))

        ########################################################################
        # Board configuration
        ########################################################################

        # Setup board default if not specified by configuration
        self.nrg_model = None
        platform = None
        self.__modules = ['cpufreq', 'cpuidle']
        if 'board' not in self.conf:
            self.conf['board'] = 'UNKNOWN'

        # Initialize TC2 board
        if self.conf['board'].upper() == 'TC2':
            platform = devlib.platform.arm.TC2()
            self.__modules = ['bl', 'hwmon', 'cpufreq']

        # Initialize JUNO board
        elif self.conf['board'].upper() in ('JUNO', 'JUNO2'):
            platform = devlib.platform.arm.Juno()
            self.nrg_model = juno_energy
            self.__modules = ['bl', 'hwmon', 'cpufreq']

        # Initialize OAK board
        elif self.conf['board'].upper() == 'OAK':
            platform = Platform(model='MT8173')
            self.__modules = ['bl', 'cpufreq']

        # Initialized HiKey board
        elif self.conf['board'].upper() == 'HIKEY':
            self.nrg_model = hikey_energy
            self.__modules = [ "cpufreq", "cpuidle" ]
            platform = Platform(model='hikey')

        # Initialize HiKey960 board
        elif self.conf['board'].upper() == 'HIKEY960':
            self.__modules = ['bl', 'cpufreq', 'cpuidle']
            platform = Platform(model='hikey960')

        # Initialize Pixel phone
        elif self.conf['board'].upper() == 'PIXEL':
            self.nrg_model = pixel_energy
            self.__modules = ['bl', 'cpufreq']
            platform = Platform(model='pixel')

        # Initialize gem5 platform
        elif self.conf['board'].upper() == 'GEM5':
            self.nrg_model = None
            self.__modules=['cpufreq']
            platform = self._init_target_gem5()

        elif self.conf['board'] != 'UNKNOWN':
            # Initilize from platform descriptor (if available)
            board = self._load_board(self.conf['board'])
            if board:
                core_names=board['cores']
                platform = Platform(
                    model=self.conf['board'],
                    core_names=core_names,
                    core_clusters = self._get_clusters(core_names),
                    big_core=board.get('big_core', None)
                )
                if 'modules' in board:
                    self.__modules = board['modules']

        ########################################################################
        # Modules configuration
        ########################################################################

        modules = set(self.__modules)

        # Refine modules list based on target.conf
        modules.update(self.conf.get('modules', []))
        # Merge tests specific modules
        modules.update(self.test_conf.get('modules', []))

        remove_modules = set(self.conf.get('exclude_modules', []) +
                             self.test_conf.get('exclude_modules', []))
        modules.difference_update(remove_modules)

        self.__modules = list(modules)
        self._log.info('Devlib modules to load: %s', self.__modules)

        ########################################################################
        # Devlib target setup (based on target.config::platform)
        ########################################################################

        # If the target is Android, we need just (eventually) the device
        if platform_type.lower() == 'android':
            self.__connection_settings = None
            device = 'DEFAULT'

            # Workaround for ARM-software/devlib#225
            if not self.workdir:
                self.workdir = '/data/local/tmp/devlib-target'

            if 'device' in self.conf:
                device = self.conf['device']
                self.__connection_settings = {'device' : device}
            elif 'host' in self.conf:
                host = self.conf['host']
                port = '5555'
                if 'port' in self.conf:
                    port = str(self.conf['port'])
                device = '{}:{}'.format(host, port)
                self.__connection_settings = {'device' : device}
            self._log.info('Connecting Android target [%s]', device)
        else:
            self._log.info('Connecting %s target:', platform_type)
            for key in self.__connection_settings:
                self._log.info('%10s : %s', key,
                               self.__connection_settings[key])

        self._log.info('Connection settings:')
        self._log.info('   %s', self.__connection_settings)

        if platform_type.lower() == 'linux':
            self._log.debug('Setup LINUX target...')
            if "host" not in self.__connection_settings:
                raise ValueError('Missing "host" param in Linux target conf')

            self.target = devlib.LinuxTarget(
                    platform = platform,
                    connection_settings = self.__connection_settings,
                    working_directory = self.workdir,
                    load_default_modules = False,
                    modules = self.__modules)
        elif platform_type.lower() == 'android':
            self._log.debug('Setup ANDROID target...')
            self.target = devlib.AndroidTarget(
                    platform = platform,
                    connection_settings = self.__connection_settings,
                    working_directory = self.workdir,
                    load_default_modules = False,
                    modules = self.__modules)
        elif platform_type.lower() == 'host':
            self._log.debug('Setup HOST target...')
            self.target = devlib.LocalLinuxTarget(
                    platform = platform,
                    working_directory = self.workdir,
                    load_default_modules = False,
                    modules = self.__modules,
                    connection_settings = {'unrooted': True})
        else:
            raise ValueError('Config error: not supported [platform] type {}'\
                    .format(platform_type))

        self._log.debug('Checking target connection...')
        self._log.debug('Target info:')
        self._log.debug('      ABI: %s', self.target.abi)
        self._log.debug('     CPUs: %s', self.target.cpuinfo)
        self._log.debug(' Clusters: %s', self.target.core_clusters)

        self._log.info('Initializing target workdir:')
        self._log.info('   %s', self.target.working_directory)

        self.target.setup()
        self.install_tools(self.__tools)

        # Verify that all the required modules have been initialized
        for module in self.__modules:
            self._log.debug('Check for module [%s]...', module)
            if not hasattr(self.target, module):
                self._log.warning('Unable to initialize [%s] module', module)
                self._log.error('Fix your target kernel configuration or '
                                'disable module from configuration')
                raise RuntimeError('Failed to initialized [{}] module, '
                        'update your kernel or test configurations'.format(module))

        if not self.nrg_model:
            try:
                self._log.info('Attempting to read energy model from target')
                self.nrg_model = EnergyModel.from_target(self.target)
            except (TargetError, RuntimeError, ValueError) as e:
                self._log.error("Couldn't read target energy model: %s", e)
예제 #4
0
파일: env.py 프로젝트: credp/lisa
    def _init_target(self, force = False):

        if not force and self.target is not None:
            return self.target

        self.__connection_settings = {}

        # Configure username
        if 'username' in self.conf:
            self.__connection_settings['username'] = self.conf['username']
        else:
            self.__connection_settings['username'] = USERNAME_DEFAULT

        # Configure password or SSH keyfile
        if 'keyfile' in self.conf:
            self.__connection_settings['keyfile'] = self.conf['keyfile']
        elif 'password' in self.conf:
            self.__connection_settings['password'] = self.conf['password']
        else:
            self.__connection_settings['password'] = PASSWORD_DEFAULT

        # Configure port
        if 'port' in self.conf:
            self.__connection_settings['port'] = self.conf['port']

        # Configure the host IP/MAC address
        if 'host' in self.conf:
            try:
                if ':' in self.conf['host']:
                    (self.mac, self.ip) = self.resolv_host(self.conf['host'])
                else:
                    self.ip = self.conf['host']
                self.__connection_settings['host'] = self.ip
            except KeyError:
                raise ValueError('Config error: missing [host] parameter')

        try:
            platform_type = self.conf['platform']
        except KeyError:
            raise ValueError('Config error: missing [platform] parameter')

        if platform_type.lower() == 'android':
            self.ANDROID_HOME = self.conf.get('ANDROID_HOME',
                                              self.ANDROID_HOME)
            if self.ANDROID_HOME:
                self._adb = os.path.join(self.ANDROID_HOME,
                                         'platform-tools', 'adb')
                self._fastboot = os.path.join(self.ANDROID_HOME,
                                              'platform-tools', 'fastboot')
                os.environ['ANDROID_HOME'] = self.ANDROID_HOME
                os.environ['CATAPULT_HOME'] = self.CATAPULT_HOME
            else:
                raise RuntimeError('Android SDK not found, ANDROID_HOME must be defined!')

            self._log.info('External tools using:')
            self._log.info('   ANDROID_HOME: %s', self.ANDROID_HOME)
            self._log.info('   CATAPULT_HOME: %s', self.CATAPULT_HOME)

            if not os.path.exists(self._adb):
                raise RuntimeError('\nADB binary not found\n\t{}\ndoes not exists!\n\n'
                                   'Please configure ANDROID_HOME to point to '
                                   'a valid Android SDK installation folder.'\
                                   .format(self._adb))

        ########################################################################
        # Board configuration
        ########################################################################

        # Setup board default if not specified by configuration
        self.nrg_model = None
        platform = None
        self.__modules = ['cpufreq', 'cpuidle']
        if 'board' not in self.conf:
            self.conf['board'] = 'UNKNOWN'

        # Initialize TC2 board
        if self.conf['board'].upper() == 'TC2':
            platform = devlib.platform.arm.TC2()
            self.__modules = ['bl', 'hwmon', 'cpufreq']

        # Initialize JUNO board
        elif self.conf['board'].upper() in ('JUNO', 'JUNO2'):
            platform = devlib.platform.arm.Juno()
            self.nrg_model = juno_energy
            self.__modules = ['bl', 'hwmon', 'cpufreq']

        # Initialize OAK board
        elif self.conf['board'].upper() == 'OAK':
            platform = Platform(model='MT8173')
            self.__modules = ['bl', 'cpufreq']

        # Initialized HiKey board
        elif self.conf['board'].upper() == 'HIKEY':
            self.nrg_model = hikey_energy
            self.__modules = [ "cpufreq", "cpuidle" ]
            platform = Platform(model='hikey')

        # Initialize HiKey960 board
        elif self.conf['board'].upper() == 'HIKEY960':
            self.__modules = ['bl', 'cpufreq', 'cpuidle']
            platform = Platform(model='hikey960')

        # Initialize Pixel phone
        elif self.conf['board'].upper() == 'PIXEL':
            self.nrg_model = pixel_energy
            self.__modules = ['bl', 'cpufreq']
            platform = Platform(model='pixel')

        # Initialize gem5 platform
        elif self.conf['board'].upper() == 'GEM5':
            self.nrg_model = None
            self.__modules=['cpufreq']
            platform = self._init_target_gem5()

        elif self.conf['board'] != 'UNKNOWN':
            # Initilize from platform descriptor (if available)
            board = self._load_board(self.conf['board'])
            if board:
                core_names=board['cores']
                platform = Platform(
                    model=self.conf['board'],
                    core_names=core_names,
                    core_clusters = self._get_clusters(core_names),
                    big_core=board.get('big_core', None)
                )
                if 'modules' in board:
                    self.__modules = board['modules']

        ########################################################################
        # Modules configuration
        ########################################################################

        modules = set(self.__modules)

        # Refine modules list based on target.conf
        modules.update(self.conf.get('modules', []))
        # Merge tests specific modules
        modules.update(self.test_conf.get('modules', []))

        remove_modules = set(self.conf.get('exclude_modules', []) +
                             self.test_conf.get('exclude_modules', []))
        modules.difference_update(remove_modules)

        self.__modules = list(modules)
        self._log.info('Devlib modules to load: %s', self.__modules)

        ########################################################################
        # Devlib target setup (based on target.config::platform)
        ########################################################################

        # If the target is Android, we need just (eventually) the device
        if platform_type.lower() == 'android':
            self.__connection_settings = None
            device = 'DEFAULT'

            # Workaround for ARM-software/devlib#225
            if not self.workdir:
                self.workdir = '/data/local/tmp/devlib-target'

            if 'device' in self.conf:
                device = self.conf['device']
                self.__connection_settings = {'device' : device}
            elif 'host' in self.conf:
                host = self.conf['host']
                port = '5555'
                if 'port' in self.conf:
                    port = str(self.conf['port'])
                device = '{}:{}'.format(host, port)
                self.__connection_settings = {'device' : device}
            self._log.info('Connecting Android target [%s]', device)
        else:
            self._log.info('Connecting %s target:', platform_type)
            for key in self.__connection_settings:
                self._log.info('%10s : %s', key,
                               self.__connection_settings[key])

        self._log.info('Connection settings:')
        self._log.info('   %s', self.__connection_settings)

        if platform_type.lower() == 'linux':
            self._log.debug('Setup LINUX target...')
            if "host" not in self.__connection_settings:
                raise ValueError('Missing "host" param in Linux target conf')

            self.target = devlib.LinuxTarget(
                    platform = platform,
                    connection_settings = self.__connection_settings,
                    working_directory = self.workdir,
                    load_default_modules = False,
                    modules = self.__modules)
        elif platform_type.lower() == 'android':
            self._log.debug('Setup ANDROID target...')
            self.target = devlib.AndroidTarget(
                    platform = platform,
                    connection_settings = self.__connection_settings,
                    working_directory = self.workdir,
                    load_default_modules = False,
                    modules = self.__modules)
        elif platform_type.lower() == 'host':
            self._log.debug('Setup HOST target...')
            self.target = devlib.LocalLinuxTarget(
                    platform = platform,
                    working_directory = '/tmp/devlib-target',
                    executables_directory = '/tmp/devlib-target/bin',
                    load_default_modules = False,
                    modules = self.__modules,
                    connection_settings = {'unrooted': True})
        else:
            raise ValueError('Config error: not supported [platform] type {}'\
                    .format(platform_type))

        self._log.debug('Checking target connection...')
        self._log.debug('Target info:')
        self._log.debug('      ABI: %s', self.target.abi)
        self._log.debug('     CPUs: %s', self.target.cpuinfo)
        self._log.debug(' Clusters: %s', self.target.core_clusters)

        self._log.info('Initializing target workdir:')
        self._log.info('   %s', self.target.working_directory)

        self.target.setup()
        self.install_tools(self.__tools)

        # Verify that all the required modules have been initialized
        for module in self.__modules:
            self._log.debug('Check for module [%s]...', module)
            if not hasattr(self.target, module):
                self._log.warning('Unable to initialize [%s] module', module)
                self._log.error('Fix your target kernel configuration or '
                                'disable module from configuration')
                raise RuntimeError('Failed to initialized [{}] module, '
                        'update your kernel or test configurations'.format(module))

        if not self.nrg_model:
            try:
                self._log.info('Attempting to read energy model from target')
                self.nrg_model = EnergyModel.from_target(self.target)
            except (TargetError, RuntimeError, ValueError) as e:
                self._log.error("Couldn't read target energy model: %s", e)