def __init__(self, dimensions=[320,480], swipe_padding=[40,40,40,40], script_path="script"): self.dimensions = dimensions self.swipe_padding = swipe_padding self.script_path = script_path self.range_action_steps = 10 self.short_steps_duration = 200 self.long_steps_duration = 2000 self.range_sleep = 5.0 options = Parser.parser(sys.argv[1:]) if 'config' in options: with open(options.config) as f: self.config = eval(f.read())
def main(): if len(sys.argv) == 1: Parser.parser(["-h"]) return options = Parser.parser(sys.argv[1:]) config = load_config(options.config) startTime = datetime.now() logger.info("Starting " + startTime.strftime("%Y/%m/%d %H:%M:%S")) if not config['execution_time'] == 0: runningTime = timedelta(hours=config['execution_time']).total_seconds() logger.info("Running Time: %d " % runningTime) runner = Runner(config, options) signal.signal(signal.SIGALRM, runner.stopRunning) signal.alarm(int(runningTime)) try: runner.run() except: logger.warn("Orangutan Test failed occasionally") signal.alarm(0) else: logger.info("Runnining Time: Infinity") try: logger.info("Press Control + C to force stop") while True: runner = Runner(config, options) runner.run(infinity=True) if runner.forceStopped: break except KeyboardInterrupt: logger.info("Receive keyboard interrupt to force stop") runner.stopRunning() except: logger.warn("Orangutan Test failed unexpectedly") logger.info("Orangutan Test is Done at " + datetime.now().strftime("%Y/%m/%d %H:%M:%S"))
def __init__(self, dimensions=[320, 480], swipe_padding=[40, 40, 40, 40], script_path="script"): self.dimensions = dimensions self.swipe_padding = swipe_padding self.script_path = script_path self.range_action_steps = 10 self.short_steps_duration = 200 self.long_steps_duration = 2000 self.range_sleep = 5.0 options = Parser.parser(sys.argv[1:]) if 'config' in options: with open(options.config) as f: self.config = eval(f.read())
def __init__(self, dimensions=[320,480], swipe_padding=[40,40,40,40], script_repo="script", amount=1, steps=10000, deviceName="Device"): self.dimensions = dimensions self.swipe_padding = swipe_padding self.script_repo = script_repo self.amount = amount self.steps = steps self.deviceName = deviceName self.range_action_steps = 10 self.short_steps_duration = 200 self.long_steps_duration = 2000 self.range_sleep = 5.0 if len(sys.argv) > 1: options = Parser.parser(sys.argv[1:]) if str(options.config): with open(options.config) as f: self.config = eval(f.read()) self.dimensions = [self.config['res_x'], self.config['res_y']] self.deviceName = self.config['device_name'] self.script_repo = self.config['script_repo'] self.amount = int(self.config['script_amount']) self.steps = int(self.config['script_steps']) if int(options.gen_scripts_amount): self.amount = int(options.gen_scripts_amount) if int(options.gen_scripts_steps): self.steps = int(options.gen_scripts_steps) if str(options.gen_scripts_output): self.script_repo = str(options.gen_scripts_output)
def __init__(self, dimensions=[320,480], swipe_padding=[40,40,40,40], script_repo="script", amount=1, steps=10000, deviceName="Device"): self.dimensions = dimensions self.swipe_padding = swipe_padding self.script_repo = script_repo self.amount = amount self.steps = steps self.deviceName = deviceName self.range_action_steps = 20 self.short_steps_duration = 200 self.long_steps_duration = 2000 self.range_sleep = 5.0 if len(sys.argv) > 1: options = Parser.parser(sys.argv[1:]) if str(options.config): with open(options.config) as f: self.config = eval(f.read()) self.dimensions = [self.config['res_x'], self.config['res_y']] self.deviceName = self.config['device_name'] self.script_repo = self.config['script_repo'] self.amount = int(self.config['script_amount']) self.steps = int(self.config['script_steps']) if int(options.gen_scripts_amount): self.amount = int(options.gen_scripts_amount) if int(options.gen_scripts_steps): self.steps = int(options.gen_scripts_steps) if str(options.gen_scripts_output): self.script_repo = str(options.gen_scripts_output)
def log_dumpstate(self, attach): os.system('adb shell dumpstate > dumpstate_' + attach + '.log') def log_crash_report(self): os.system('adb pull /data/b2g/Crash\ Reports' + self.logFolder) def getLogs(self): curTime = time.strftime('%m%d%H%M%S', time.localtime()) if self.option['b2g-ps']: log_b2g_ps(curTime) if self.option['b2g-info']: log_b2g_info(curTime) if self.option['b2g-procrank']: log_b2g_proprank(curTime) if self.option['dumpstate']: log_dumpstate(curTime) if self.option['crash-report']: log_crash_report() if __name__ == '__main__': if len(sys.argv) > 1: options = Parser.parser(sys.argv[1:]) print os.getcwd() if 'config' in options: config = {} with open(options.config) as f: config = eval(f.read()) log = LogCollector(config['device_name'], config['logs'])
cmdevents = self.get_tap_event(*coord_1st, times=1, duration=short_latency[1]) elif cmd == "double_tap": cmdevents = self.get_tap_event(*coord_1st, times=2) elif cmd == "pinch": args = coord_1st + coord_2nd + coord_3rd + coord_4th + short_latency cmdevents = self.get_pinch_event(*args) elif cmd == "sleep": if use_default: cmdevents = self.get_sleep_event() else: sleep_time = self.get_sleep_time() cmdevents = self.get_sleep_event(sleep_time) else: raise Exception("Unknown command") return cmdevents def main(): getrandomsc = GenRandomSC() if __name__ == '__main__': testSample = ["--config", "testConfig"] if len(sys.argv) > 1: options = Parser.parser(sys.argv[1:]) if 'config' in options: main() else: print Parser.parser(testSample) else: print Parser.parser(testSample)
r = subprocess.check_output('adb shell ls -al /data/b2g/mozilla/Crash\ Reports | grep LastCrash', shell=True) except: return False, None return True, r[38:54] def getCrashReport(self): if self.option['crash-report']: self.log_crash_report() def genReport(self): report = open(self.logFolder+'report.html', 'w') for dir_path, dir_names, dir_files in os.walk(self.logFolder): for f in dir_files: if dir_names: report.write('File: <a href="%s">%s</a><br>\n' % (f, f)) else: base = os.path.basename(dir_path) report.write('File: <a href="%s/%s">%s/%s</a><br>\n' % (base, f, base, f)) report.close() if __name__ == '__main__': if len(sys.argv) > 1: options = Parser.parser(sys.argv[1:]) if 'config' in options: config = {} with open(options.config) as f: config = eval(f.read()) log = LogCollector(config['device_name'], config['logs']) log.getLogs() log.genReport()
cmdevents = self.get_tap_event(*coord_1st, times=2) elif cmd == "pinch": args = coord_1st + coord_2nd + coord_3rd + coord_4th + short_latency cmdevents = self.get_pinch_event(*args) elif cmd == "sleep": if use_default: cmdevents = self.get_sleep_event() else: sleep_time = self.get_sleep_time() cmdevents = self.get_sleep_event(sleep_time) else: raise Exception("Unknown command") return cmdevents def main(): getrandomsc = GenRandomSC() if __name__ == '__main__': testSample = ["--config", "testConfig"] if len(sys.argv) > 1: options = Parser.parser(sys.argv[1:]) if 'config' in options: main() else: print Parser.parser(testSample) else: print Parser.parser(testSample)