def test_caseless_string(self): cs1 = caseless_string('TeSt') assert_equal(cs1, 'TeSt') assert_equal('test', cs1) assert_equal(cs1[0], 'T') assert_not_equal(cs1[0], 't') assert_not_equal(cs1, 'test2')
def initialize(self, context): # pylint: disable=r0912 if not self.device.is_rooted: raise InstrumentError('The device must be rooted to sweep frequencies') if 'userspace' not in self.device.list_available_cluster_governors(0): raise InstrumentError("'userspace' cpufreq governor must be enabled") # Create sweeps for each core type using num_cpus cores if not self.sweeps: self.sweeps = [] for core in set(self.device.core_names): sweep_spec = {} sweep_spec['cluster'] = core sweep_spec['label'] = core self.sweeps.append(sweep_spec) new_specs = [] old_specs = [] for job in context.runner.job_queue: if job.spec not in old_specs: old_specs.append(job.spec) # Validate sweeps, add missing sections and create workload specs for i, sweep_spec in enumerate(self.sweeps): if 'cluster' not in sweep_spec: raise ConfigError('cluster must be define for all sweeps') # Check if cluster exists on device if caseless_string(sweep_spec['cluster']) not in self.device.core_names: raise ConfigError('Only {} cores are present on this device, you specified {}' .format(", ".join(set(self.device.core_names)), sweep_spec['cluster'])) # Default to all available frequencies if 'frequencies' not in sweep_spec: self.device.enable_cpu(self.device.core_names.index(sweep_spec['cluster'])) sweep_spec['frequencies'] = self.device.list_available_core_frequencies(sweep_spec['cluster']) # Check that given frequencies are valid of the core cluster else: self.device.enable_cpu(self.device.core_names.index(sweep_spec['cluster'])) available_freqs = self.device.list_available_core_frequencies(sweep_spec['cluster']) for freq in sweep_spec['frequencies']: if freq not in available_freqs: raise ConfigError('Frequency {} is not supported by {} cores'.format(freq, sweep_spec['cluster'])) # Add default labels if 'label' not in sweep_spec: sweep_spec['label'] = "sweep{}".format(i + 1) new_specs.extend(self.get_sweep_workload_specs(old_specs, sweep_spec, context)) # Update config to refect jobs that will actually run. context.config.workload_specs = new_specs config_file = os.path.join(context.host_working_directory, 'run_config.json') with open(config_file, 'wb') as wfh: context.config.serialize(wfh) context.runner.init_queue(new_specs)
def initialize(self, context): # pylint: disable=r0912 if not self.device.is_rooted: raise InstrumentError( 'The device must be rooted to sweep frequencies') if 'userspace' not in self.device.list_available_cluster_governors(0): raise InstrumentError( "'userspace' cpufreq governor must be enabled") # Create sweeps for each core type using num_cpus cores if not self.sweeps: self.sweeps = [] for core in set(self.device.core_names): sweep_spec = {} sweep_spec['cluster'] = core sweep_spec['label'] = core self.sweeps.append(sweep_spec) new_specs = [] old_specs = [] for job in context.runner.job_queue: if job.spec not in old_specs: old_specs.append(job.spec) # Validate sweeps, add missing sections and create workload specs for i, sweep_spec in enumerate(self.sweeps): if 'cluster' not in sweep_spec: raise ConfigError('cluster must be define for all sweeps') # Check if cluster exists on device if caseless_string( sweep_spec['cluster']) not in self.device.core_names: raise ConfigError( 'Only {} cores are present on this device, you specified {}' .format(", ".join(set(self.device.core_names)), sweep_spec['cluster'])) # Default to all available frequencies if 'frequencies' not in sweep_spec: self.device.enable_cpu( self.device.core_names.index(sweep_spec['cluster'])) sweep_spec[ 'frequencies'] = self.device.list_available_core_frequencies( sweep_spec['cluster']) # Check that given frequencies are valid of the core cluster else: self.device.enable_cpu( self.device.core_names.index(sweep_spec['cluster'])) available_freqs = self.device.list_available_core_frequencies( sweep_spec['cluster']) for freq in sweep_spec['frequencies']: if freq not in available_freqs: raise ConfigError( 'Frequency {} is not supported by {} cores'.format( freq, sweep_spec['cluster'])) # Add default labels if 'label' not in sweep_spec: sweep_spec['label'] = "sweep{}".format(i + 1) new_specs.extend( self.get_sweep_workload_specs(old_specs, sweep_spec, context)) # Update config to refect jobs that will actually run. context.config.workload_specs = new_specs config_file = os.path.join(context.host_working_directory, 'run_config.json') with open(config_file, 'wb') as wfh: context.config.serialize(wfh) context.runner.init_queue(new_specs)