def start(self, test): """ Start ftrace profiler :param test: Autotest test in which the profiler will operate on. """ # Make sure debugfs is mounted and tracing disabled. utils.system('%s reset' % self.trace_cmd) output_dir = os.path.join(test.profdir, 'ftrace') if not os.path.isdir(output_dir): os.makedirs(output_dir) self.output = os.path.join(output_dir, 'trace.dat') cmd = [self.trace_cmd, 'record', '-o', self.output] cmd += self.trace_cmd_args self.record_job = utils.BgJob(self.join_command(cmd), stderr_tee=utils.TEE_TO_LOGS) # Wait for tracing to be enabled. If trace-cmd dies before enabling # tracing, then there was a problem. tracing_on = os.path.join(self.tracing_dir, 'tracing_on') while (self.record_job.sp.poll() is None and utils.read_file(tracing_on).strip() != '1'): time.sleep(0.1) if self.record_job.sp.poll() is not None: utils.join_bg_jobs([self.record_job]) raise error.CmdError(self.record_job.command, self.record_job.sp.returncode, 'trace-cmd exited early.')
def get_jeos_info(): """ Gets the correct asset and variant information depending on host OS. """ jeos_info = {'asset': 'jeos-19-64', 'variant': 'JeOS.19'} issue_contents = utils.read_file('/etc/issue') if 'Fedora' in issue_contents and '20' in issue_contents: jeos_info = {'asset': 'jeos-20-64', 'variant': 'JeOS.20'} return jeos_info
def gather_stats(self, results): per_cpu = os.path.join(self.tracing_dir, 'per_cpu') for cpu in os.listdir(per_cpu): cpu_stats = os.path.join(per_cpu, cpu, 'stats') for line in utils.read_file(cpu_stats).splitlines(): key, val = line.split(': ') key = key.replace(' ', '_') val = int(val) cpu_key = '%s_%s' % (cpu, key) total_key = 'total_' + key results[cpu_key] = val results[total_key] = (results.get(total_key, 0) + results[cpu_key])
def get_default_guest_os_info(): """ Gets the default asset and variant information depending on host OS """ os_info = {'asset': 'jeos-19-64', 'variant': DEFAULT_GUEST_OS} from autotest.client import utils issue_contents = utils.read_file('/etc/issue') if 'Fedora' in issue_contents and '20' in issue_contents: os_info = {'asset': 'jeos-20-64', 'variant': 'JeOS.20'} return os_info
def initialize(self): # Store the setting if the system has CPUQuiet feature if os.path.exists(SYSFS_CPUQUIET_ENABLE): self.is_cpuquiet_enabled = utils.read_file(SYSFS_CPUQUIET_ENABLE) utils.write_one_line(SYSFS_CPUQUIET_ENABLE, '0')