def check_devices(previous_step="prepare for gts", send_mail=False, return_data=None): global devices print "Check serials for availability after {0} step".format(previous_step) device_to_remove = [] for device in devices: serial = device["serial"] previous_check_fail = return_data is not None and not return_data[ serial] if previous_check_fail or not local_utils.has_adb_serial( serial=serial): devices.remove(device) for device in device_to_remove: devices.remove(device) serials = [device["serial"] for device in devices] print "Serials still available after {0} step: {1}".format( previous_step, str(serials)) if send_mail: cts_steps.send_report( debug=True, critical=False, recipients=report_recipients, subject="{0} shards available after {1} for {2} with {3}".format( len(serials), previous_step, build_platform, str(build_no)), objective="Serials: {0}".format(serials))()
def prepare_for_next_run(suite): devices = [device for device in all_devices] print "Start preparing for the next {0} run".format(suite.upper()) if len(devices) > 0: for device in devices: serial = device["serial"] print "Prepare device {0} for next build.".format(device) print "Will try to use adb connection to shutdown/put the device into sleep mode" if local_utils.has_adb_serial(serial = serial): if shutdown_to_charge: print "[ {0} ]: Shutdown device to charge".format(serial) local_steps.command(command = "adb -s {0} shell reboot -p".format(serial))() time.sleep(5) print "[ {0} ]: Shutdown - Done!".format(serial) else: print "[ {0} ]: Put device into sleep mode".format(serial) adb_steps.put_device_into_sleep_mode(serial = serial)() print "[ {0} ]: Sleep - Done!".format(serial) else: print "[ {0} ]: does not have adb connection!!!".format(serial) print "[ {0} ]: Try to use relay to shutdown the devices".format(serial) try: my_relay = Relayed_device(relay_port = device["relay"]["tty"], power_port = device["relay"]["power_port"], v_up_port = device["relay"]["v_up_port"], v_down_port = device["relay"]["v_down_port"]) my_relay.power_on() my_relay.power_off() my_relay.close() except Exception, e: print "{0} devivice has no relay - {1}!!!".format(serial, e.message)
def do(self): count = 0 while count < self.timeout: self.step_data = not local_utils.has_adb_serial(serial=self.serial, device_state=self.device_state) if self.step_data: break time.sleep(1) count += 1 else: print "{0}: Error waiting for device to disconnect - {1}".format(self.serial, traceback.format_exc())
def do(self): print "{0}: {1}".format(self.serial, self.img_path) ################################################################################ # Device has to be in fastboot # - if already in fastboot, do nothing # - if it has adb, reboot in fastboot via adb # - for any other state: # * force poweroff via relay # * boot in fastboot via relay (poweron & volume down) ################################################################################ print "{0}: reboot to fastboot".format(self.serial) if local_utils.has_fastboot_serial(self.serial): pass elif local_utils.has_adb_serial(self.serial): adb_steps.reboot(serial=self.serial, command="fastboot")() else: ############################################################################ # device file should be made dynamic to support multiple relays ############################################################################ print "{0}: Relay needed!!!!!!!!".format(self.serial) my_relay = Relay(port=self.device["relay"]["tty"]) my_relay.power_on(self.device["relay"]["v_up_port"]) my_relay.power_on(self.device["relay"]["power_port"]) my_relay.close() print "{0}: Done rebooting for fastboot!".format(self.serial) print "{0}: Wait for fastboot".format(self.serial) local_steps.wait_for_fastboot(serial=self.serial, timeout=100)() print "{0}: Done waiting for fastboot!".format(self.serial) old_folder, err = local_steps.command("pwd")() local_steps.change_dir(new_folder=self.img_path)() print "{0}: Wait for flash-all.sh".format(self.serial) #TODO: add stdout_gprep for flash-all.sh sout, serr = local_steps.command( command="./flash-all.sh -s {0}".format(self.serial))() print "{0}: Done! Image flashed".format(self.serial) print "{0}: Wait for adb".format(self.serial) local_steps.wait_for_adb(serial=self.serial, timeout=720)() print "{0}: Done! adb connected".format(self.serial) local_steps.change_dir(new_folder=old_folder.strip())()
def check_condition(self): self.step_data = local_utils.has_adb_serial( serial=self.serial, device_state=self.device_state) return self.step_data
def check_devices(previous_step = "prepare for cts", send_mail = False, return_data = None, suite = 'cts', SUITE_NAME_STATICS = {}): global devices print "Check serials for availability after {0} step: {1}".format(previous_step, return_data) device_to_remove = [] for device in devices: serial = device["serial"] previous_check_fail = return_data is not None and not return_data[serial] if previous_check_fail or not local_utils.has_adb_serial(serial = serial): device_to_remove.append(device) for device in device_to_remove: devices.remove(device) serials = [device["serial"] for device in devices] print "Serials still available after {0} step: {1}".format(previous_step, str(serials)) if send_mail: if send_email_type == "SSH": cts_steps.send_report(debug = True, recipients = report_recipients, subject = "{0}: {1} shards available after {2} for {3} with {4}".format(SUITE_NAME_STATICS[suite], len(serials), previous_step, build_platform, build_no), objective = "Serials: {0}".format(serials), email_sender = "SSH", host = email_machine, user = email_machine_user, passwd = email_machine_password, critical = False)() else: if send_email_type == "SSH": cts_steps.send_report(debug = True, recipients = report_recipients, subject = "{0}: {1} shards available after {2} for {3} with {4}".format(SUITE_NAME_STATICS[suite], len(serials), previous_step, build_platform, build_no), objective = "Serials: {0}".format(serials), email_sender = "SSH", host = email_machine, user = email_machine_user, passwd = email_machine_password, critical = False)() else: cts_steps.send_report(debug = True, recipients = report_recipients, subject = "{0}: {1} shards available after {2} for {3} with {4}".format(SUITE_NAME_STATICS[suite], len(serials), previous_step, build_platform, build_no), objective = "Serials: {0}".format(serials), critical = False)() if len(serials) == 0: print("This run has reached 0 devices ready for the next step. Terminating!") sys.exit(1)
email_sender=email_sender, host=email_host, user=email_user, password=email_pass, remote_path=sender_report_path, )() print "GTS run Done!" ######################################################################## ######################################################################## # PREPARE FOR NEXT RUN ######################################################################## s = device["serial"] print "Prepare device " + str(s) + " for next build." if local_utils.has_adb_serial(serial=s): adb_steps.enable_uiautomator_service(serial=s, timeout=120)() if ui_utils.is_view_displayed( serial=s, view_to_find={"textContains": "To start Android, enter your"}): ############ # workaround pin/pass bug ############ print "Workaround: To enter Android, input pin/pass on " + str(s) try: adb_steps.reboot(serial=s, command="fastboot", ip_enabled=False)() local_steps.command(command="fastboot -s " + s + " oem unlock")() time.sleep(3) my_relay = Relayed_device( relay_port=device["relay"]["tty"], power_port=device["relay"]["power_port"],
def do(self): if local_utils.has_adb_serial(serial = self.serial): adb_steps.reboot(serial = self.serial, command = "fastboot", ip_enabled = False)()
build_platform + "/" + flash_xml_file, build_no=device_prop, usb_debugging=True, version=build_version, platform=build_platform, timeout=900, parallel=True, update=update, user_signed=user_signed, blocking=False, critical=False)() print "DONE flashing devices!" print "Check serials for availability after flash" for s in serials: if not local_utils.has_adb_serial(serial=s): serials.remove(s) for d in devices["list"]: if d["serial"] == s: devices["list"].remove(d) print "Serials still available after flash: " + str(serials) + " - " + str( devices) cts_steps.send_report(debug = True, recipients = report_recipients, subject = str(len(serials)) + " shards available after flash for " + build_platform +\ " - " + cts_platform + " with " + str(device_prop), objective = "Serials: " + str(serials))() bios = None for d in devices["list"]: try:
globals().update(vars(get_args(sys.argv))) #globals().update({"version": adb_utils.get_android_version()}) PATH_TO_BUILD="/home/ccarabas/work/cts-dispatcher/repair/latest" ################################################################################ # Device has to be in fastboot # - if already in fastboot, do nothing # - if it has adb, reboot in fastboot via adb # - for any other state: # * force poweroff via relay # * boot in fastboot via relay (poweron & volume down) ################################################################################ if local_utils.has_fastboot_serial(serial): pass elif local_utils.has_adb_serial(serial): adb_steps.reboot(serial = serial, command="fastboot", ip_enabled=False)() else: ############################################################################ # device file should be made dynamic to support multiple relays ############################################################################ my_relay = Relay(port = "/dev/ttyACM0") my_relay.power_off() my_relay.enter_fastboot() my_relay.close() local_steps.wait_for_fastboot(serial = serial, timeout = 20)() local_steps.change_dir(serial = serial, new_folder=PATH_TO_BUILD)()