def preprocess(self, *args, **kwargs): assert "programs" in kwargs, "Must have programs specified" programs = kwargs["programs"] # find the first zipped app file assert "program" in programs, "program is not specified" program = programs["program"] assert program.endswith(".ipa"), \ "IOS program must be an ipa file" processRun(["unzip", "-o", "-d", self.tempdir, program]) # get the app name app_dir = os.path.join(self.tempdir, "Payload") dirs = [f for f in os.listdir(app_dir) if os.path.isdir(os.path.join(app_dir, f))] assert len(dirs) == 1, "Only one app in the Payload directory" app_name = dirs[0] self.app = os.path.join(app_dir, app_name) del programs["program"] bundle_id, _ = processRun(["osascript", "-e", "id of app \"" + self.app + "\""]) assert len(bundle_id) > 0, "bundle id cannot be found" self.util.setBundleId(bundle_id[0].strip()) # We know this command will fail. Avoid propogating this # failure to the upstream success = getRunStatus() self.util.run(["--bundle", self.app, "--uninstall", "--justlaunch"]) setRunStatus(success, overwrite=True)
def preprocess(self, *args, **kwargs): assert "programs" in kwargs, "Must have programs specified" programs = kwargs["programs"] # find the first zipped app file assert "program" in programs, "program is not specified" program = programs["program"] assert program.endswith(".ipa"), \ "IOS program must be an ipa file" processRun(["unzip", "-o", "-d", self.tempdir, program]) # get the app name app_dir = os.path.join(self.tempdir, "Payload") dirs = [f for f in os.listdir(app_dir) if os.path.isdir(os.path.join(app_dir, f))] assert len(dirs) == 1, "Only one app in the Payload directory" app_name = dirs[0] self.app = os.path.join(app_dir, app_name) del programs["program"] bundle_id, _ = processRun(["osascript", "-e", "id of app \"" + self.app + "\""]) self.util.setBundleId(bundle_id.strip()) self.util.run(["--bundle", self.app, "--uninstall", "--noninteractive"])
def _getProcessorName(self): if platform.system() == "Windows": return platform.processor() elif platform.system() == "Darwin": return processRun(["sysctl", "-n", "machdep.cpu.brand_string"])\ .rstrip() elif platform.system() == "Linux": proc_info = processRun(["cat", "/proc/cpuinfo"]) for line in proc_info.split("\n"): if "model name" in line: return re.sub(".*model name.*:", "", line, 1) return ""
def _getProcessorName(self): if platform.system() == "Windows": return platform.processor() elif platform.system() == "Darwin": processor_info, _ = processRun( ["sysctl", "-n", "machdep.cpu.brand_string"]) if len(processor_info) > 0: return processor_info[0].rstrip() elif platform.system() == "Linux": processor_info, _ = processRun(["cat", "/proc/cpuinfo"]) if processor_info: for line in processor_info: if "model name" in line: return re.sub(r".*model name.*:", "", line, 1) return ""
def _run(self, cmd, *args): git = ["git"] if self.dir: git.append("-C") git.append(self.dir) git.append(cmd) git.extend(args) return processRun(git)[0]
def _run(self, cmd, *args): hg = ["hg"] if self.dir: hg.append("-R") hg.append(self.dir) hg.append(cmd) hg.extend(args) return processRun(hg)
def run(self, *args, **kwargs): cmd = [] for item in args: if isinstance(item, list): cmd.extend(item) else: cmd.append(item) return processRun(cmd, **kwargs)[0]
def run(self, cmd, *args, **kwargs): adb = ["adb"] if self.device: adb.append("-s") adb.append(self.device) adb.append(cmd) for item in args: if isinstance(item, list): adb.extend(item) else: adb.append(item) return processRun(adb, **kwargs)[0]
def runBenchmark(self, cmd, *args, **kwargs): if not isinstance(cmd, list): cmd = shlex.split(cmd) host_kwargs = {} if "platform_args" in kwargs: platform_args = kwargs["platform_args"] if "timeout" in platform_args: host_kwargs["timeout"] = platform_args["timeout"] output, _ = processRun(cmd, **host_kwargs) if "platform_args" in kwargs: platform_args = kwargs["platform_args"] if "log_output" in platform_args and platform_args["log_output"]: getLogger().info(output) return output
def _buildProgramPlatform(self, repo_info, dst, platform): self.repo.checkout(repo_info['commit']) script = self._getBuildScript(platform) dst_dir = os.path.dirname(dst) shutil.rmtree(dst_dir, True) os.makedirs(dst_dir) if processRun(['sh', script, getArgs().repo_dir, dst]) is not None: os.chmod(dst, 0o777) if not os.path.isfile(dst): getLogger().error( "Build program using script {} failed.".format(script)) return False return True
def runBenchmark(self, cmd, *args, **kwargs): if not isinstance(cmd, list): cmd = shlex.split(cmd) platform_args = {} env = os.environ if "platform_args" in kwargs: platform_args = kwargs["platform_args"] if "env" in platform_args: customized_env = platform_args["env"] for k in customized_env: env[k] = str(customized_env[k]) platform_args["env"] = env output, _ = processRun(cmd, **platform_args) return output
def runBenchmark(self, cmd, *args, **kwargs): if not isinstance(cmd, list): cmd = shlex.split(cmd) host_kwargs = {} log_output = False if "platform_args" in kwargs: platform_args = kwargs["platform_args"] if "timeout" in platform_args: host_kwargs["timeout"] = platform_args["timeout"] # used for local or remote log control if "log_output" in platform_args and platform_args["log_output"]: log_output = True output, _ = processRun(cmd, **host_kwargs) if log_output: print(output) return output
def runBenchmark(self, cmd, *args, **kwargs): if not isinstance(cmd, list): cmd = shlex.split(cmd) host_kwargs = {} env = os.environ if "platform_args" in kwargs: platform_args = kwargs["platform_args"] if "timeout" in platform_args: host_kwargs["timeout"] = platform_args["timeout"] # used for local or remote log control host_kwargs["log_output"] = platform_args.get("log_output", False) if "env" in platform_args: customized_env = platform_args["env"] for k in customized_env: env[k] = str(customized_env[k]) host_kwargs["env"] = env output, _ = processRun(cmd, **host_kwargs) return output
def runBenchmark(self, cmd, *args, **kwargs): if not isinstance(cmd, list): cmd = shlex.split(cmd) platform_args = {} env = os.environ if "platform_args" in kwargs: platform_args = kwargs["platform_args"] if "env" in platform_args: customized_env = platform_args["env"] for k in customized_env: env[k] = str(customized_env[k]) platform_args["env"] = env # enable async if profiling was requested runAsync = False if "enable_profiling" in platform_args: runAsync = platform_args["enable_profiling"] del platform_args["enable_profiling"] if runAsync and not self._isGPUMachine(): if "env" not in platform_args: platform_args["env"] = env platform_args["env"]["GPUMON_CPU_ONLY_MODE"] = "y" platform_args["async"] = runAsync profiler_args = {} if "profiler_args" in platform_args: profiler_args = platform_args["profiler_args"] del platform_args["profiler_args"] # meta is used to store any data about the benchmark run # that is not the output of the command meta = {} if not runAsync: output, _ = processRun(cmd, **platform_args) if not output and getRunTimeout(): getLogger().info("Terminating...") sys.exit(0) return output, meta # from_time = datetime.datetime.now() procAndTimeout, err = processRun(cmd, **platform_args) if err: return [], meta ps, _ = procAndTimeout # profiler_server = getProfilerByUsage("server", ps.pid) # if profiler_server: # profilerServerFuture = profiler_server.start(**profiler_args) profiler_trace = getProfilerByUsage("trace", ps.pid) if profiler_trace: profiler_trace.start(**profiler_args) platform_args["filter"] = profiler_trace.getFilter() output, _ = processWait(procAndTimeout, **platform_args) # if profiler_server: # profilerRunId = profiler_server.getId(profilerServerFuture) # meta["profiler_run_id"] = profilerRunId # self._sleepHost(from_time) if profiler_trace: traceryLink = profiler_trace.getLink() filePathes = profiler_trace.getFilePathes() meta["tracery_link"] = traceryLink meta["file_pathes"] = filePathes return output, meta
def run(self, *args, **kwargs): cmd = self._prepareCMD(*args) return processRun(cmd, **kwargs)[0]
def runBenchmark(self, cmd, *args, **kwargs): if not isinstance(cmd, list): cmd = shlex.split(cmd) platform_args = {} env = os.environ if "platform_args" in kwargs: platform_args = kwargs["platform_args"] if "env" in platform_args: customized_env = platform_args["env"] for k in customized_env: env[k] = str(customized_env[k]) platform_args["env"] = env # enable async if profiling was requested runAsync = False if "enable_profiling" in platform_args: runAsync = platform_args["enable_profiling"] del platform_args["enable_profiling"] platform_args["async"] = runAsync profiler_args = {} if "profiler_args" in platform_args: profiler_args = platform_args["profiler_args"] del platform_args["profiler_args"] # meta is used to store any data about the benchmark run # that is not the output of the command meta = {} if not runAsync: output, _ = processRun(cmd, **platform_args) return output, meta from_time = datetime.datetime.now() procAndTimeout, err = processRun(cmd, **platform_args) if err: return [], meta ps, _ = procAndTimeout profiler = getProfilerByUsage("server", os.getpid()) if profiler: profilerFuture = profiler.start(**profiler_args) output, _ = processWait(procAndTimeout, **platform_args) # Sleep the host to make sure there is no other process running # if the duration of process is short to_time = datetime.datetime.now() duration = (to_time - from_time).total_seconds() min_duration = 5 if duration < min_duration * 60: diff = min_duration * 60 - duration getLogger().info( "Sleep for {} - {} = {} seconds".format( min_duration * 60, duration, diff) ) time.sleep(diff) if profiler: profilerRunId = profiler.getId(profilerFuture) meta["profiler_run_id"] = profilerRunId return output, meta