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 adb_command_process_exists(serial=None, strpro="com.google.android.setupwizard"): local_steps.command("adb -s {} reboot".format(serial))() local_steps.wait_for_adb(timeout=300, serial=serial)() time.sleep(10) adb_command = "adb shell ps | grep \"" + strpro + "\"" return_result = subprocess.Popen( adb_command, stdout=subprocess.PIPE, shell=True).stdout.readline() if return_result != "": return True return False
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())()
print "CTS run Done!" ######################################################################## ######################################################################## # PREPARE FOR NEXT RUN ######################################################################## devices = eval(open(dut_file, 'r').read()) for d in devices["list"]: s = d["serial"] print "Prepare device " + str(s) + " for next build." print "Will try to use adb connection to shutdown/put to sleep the device" if local_utils.has_adb_serial(serial=s): adb_steps.enable_uiautomator_service(serial=s, timeout=120)() if shutdown_to_charge: print str(s) + ": Shutdown device to charge" local_steps.command(command="adb -s " + str(s) + " shell reboot -p")() time.sleep(5) print str(s) + ": Shutdown - Done!" else: print str(s) + ": Put device to sleep" adb_steps.put_device_into_sleep_mode(serial=s)() print str(s) + ": Sleep - Done!" else: print str(s) + ": does not have adb connection!!!" print str(s) + ": Try to use relay to shutdown the devices" try: my_relay = Relayed_device(relay_port=d["relay"]["tty"], power_port=d["relay"]["power_port"], v_up_port=d["relay"]["v_up_port"], v_down_port=d["relay"]["v_down_port"]) my_relay.power_on()
adb_steps.connect_device(serial=args.serial, port=args.adb_server_port)() for apk in apks: # TODO: # add suite logic # add test completion logic # add DUT check # add deps check (another DUT, AP) # END # test resolution test = {} test["resolution"] = Resolution.PASS log_dir = os.path.join(RESULTS_PATH, apk + get_time_string()) local_steps.command(command='mkdir {0}'.format(log_dir), stdout_grep="", critical=False, blocking=False)() log_file = os.path.join(log_dir, apk + ".log") #dmesg_file = os.path.join(RESULTS_PATH, test['name'] + "timestamp.dmesg") #logcat_file = os.path.join(RESULTS_PATH, test['name'] + "timestamp.logcat") print "" print "============================================================" print 'Running test for apk: "{0}"'.format(apk) # create process for each test p = multiprocessing.Process(target=run_test, args=(apk, args.serial, args.adb_server_port, log_dir, log_file)) # start the process p.start()
fastboot_utils.download_file(url=fastboot_path+eb_userdebug_patch_flashfiles_zip_path, local_filename="./temp/image/eb/userdebug/"+eb_userdebug_patch_flashfiles_zip_name) if platform_name == "bxtp_abl": fastboot_utils.flash_bxt_m_fused(eb_user_patch_flashfiles_zip_name=eb_user_patch_flashfiles_zip_name, eb_userdebug_patch_flashfiles_zip_name=eb_userdebug_patch_flashfiles_zip_name, serial=serial) if platform_name == "gordon_peak": zip_name = fastboot_utils.get_zip_name(zip_path=flash_files) if zip_name == "r0_bxtp_abl": fastboot_utils.flash_bxt_m_fused(eb_user_patch_flashfiles_zip_name=eb_user_patch_flashfiles_zip_name, eb_userdebug_patch_flashfiles_zip_name=eb_userdebug_patch_flashfiles_zip_name, serial=serial) if zip_name == "gordon_peak": fastboot_utils.flash_bxt(zip_file="./temp/image/eb/userdebug/"+eb_userdebug_patch_flashfiles_zip_name, serial=serial) check_point1 = False fastboot_utils.start_minicom(serial=serial) local_steps.command("adb -s {} reboot".format(serial))() time.sleep(60) fastboot_utils.kill_minicom() file_path = "./temp/files/minicom_result.txt" return_result = open(file_path).readlines() for line in return_result: if "SB: On" in line: check_point1 = True if not check_point1: raise Exception("The test result did not achieve the desired results") fastboot_utils.flash_bxt(zip_file=flash_files, serial=serial) os.system("sudo rm -rf ./temp")
# Connect to device from testlib.base.base_utils import get_args globals().update(vars(get_args(sys.argv))) SCREENSHOT_NAME = 'check_resolution.png' ########### Preconditions ############### ######################################### adb_steps.connect_device( serial = serial, port = adb_server_port )() ############### Test #################### ######################################### media_steps.check_resolution(screenshot_name = SCREENSHOT_NAME)() ########### Postconditions ############## ######################################### local_steps.command('rm ' + SCREENSHOT_NAME) adb_steps.disconnect_device( serial = serial, local_port = adb_server_port )()
key, val = entry.split("=") args[key] = val relay_type = args["relay_type"] relay_port = args["relay_port"] power_port = args["power_port"] USB_VC_cut_port = args["USB_VC_cut"] ##### test start ##### try: relay_steps.reboot_main_os(serial=serial, relay_type=relay_type, relay_port=relay_port, power_port=power_port)() local_steps.command("adb -s {} shell reboot -p".format(serial))() # check charging local_steps.wait_for_cos(serial=serial)() ## disconnect adb relay_steps.connect_disconnect_usb(serial=serial, relay_type=relay_type, relay_port=relay_port, connect=False, USB_VC_cut_port=USB_VC_cut_port)() time.sleep(10) ## reconnect adb relay_steps.connect_disconnect_usb(serial=serial, relay_type=relay_type, relay_port=relay_port,
def check_condition(self): a = local_steps.command('file ' + self.screenshot_name)() screenshot_resolution = a[0].split(',')[1] prop_resolution = self.adb_connection.parse_cmd_output( cmd='getprop ro.sf.lcd_density_info').split('px')[0] return screenshot_resolution.strip() == prop_resolution.strip()
v_down_port=v_down_port, v_up_port=v_up_port, wait_ui=True)() ui_steps.wake_up_device(serial=serial)() ui_steps.unlock_device(serial=serial)() dessert = adb_utils.get_android_version(serial=serial) # Disable OEM unlock in developer options # ui_steps.disable_options_from_developer_options( serial=serial, developer_options=[dev_oem_option])() # Reboot into bootloader #adb_steps.reboot(command="fastboot", serial=serial)() local_steps.command( command="adb -s {0} reboot bootloader".format(serial))() local_steps.wait_for_fastboot(serial=serial, timeout=60)() # Check unlock ability (should be disabled) fastboot_steps.command(serial=serial, command=get_unlock_ability_command, stderr_grep=unlock_disabled_output, timeout=20)() # Attempt to unlock bootloader relay_steps.change_state(serial=serial, dessert=dessert, unlock_bootloader="yes", oem_unlock_enabled="no", relay_type=relay_type, relay_port=relay_port,
def do(self): command = "cat {0}".format( os.path.join(self.path_to_image, self.prop_file)) print command self.step_data = self.local_connection.parse_cmd_output( cmd=command, grep_for=self.device_prop).split("=")[1] self.set_passm("Preparing image for build {0}".format(self.step_data)) self.set_errorm("", "Preparing image for build {0}".format(self.step_data)) # delete the unzip path folder if exists if self.cts_abi: self.unzip_path = os.path.join( self.path_to_image, "{0}{1}".format(self.platform, self.cts_abi)) else: self.unzip_path = os.path.join(self.path_to_image, self.platform) if local_utils.folder_exists(path=self.unzip_path): local_steps.delete_folder(folder=self.unzip_path)() # get the archive name ls_out = self.local_connection.parse_cmd_output(cmd="ls {0}".format( self.path_to_image), grep_for=self.platform) if "zip" not in ls_out: ls_out = self.local_connection.parse_cmd_output( cmd="ls {0}".format(self.path_to_image), grep_for=self.step_data) archive_name = None for entry in ls_out.split(): if (self.user_signed and "signed.zip" in entry) or \ (not self.user_signed and "automation.zip" in entry) or \ (not self.user_signed and "signed.zip" not in entry): archive_name = entry break if archive_name is None: archive_name = [ entry for entry in ls_out.split() if ".zip" in entry ][0] print archive_name # create the unzip path folder if self.cts_abi: local_steps.create_folder(folder="{0}{1}".format( self.platform, self.cts_abi), path=self.path_to_image)() else: local_steps.create_folder(folder=self.platform, path=self.path_to_image)() # unzip the archive local_steps.unzip_archive(zip_path=os.path.join( self.path_to_image, archive_name), unzip_destination=self.unzip_path)() #repackage userdata if needed if self.repackage_userdata: local_steps.copy_file(file=os.path.join(self.path_to_image, archive_name), destination=self.fls_tool_location, with_rename=False)() if local_utils.folder_exists(path=os.path.join( self.fls_tool_location, self.repackage_build_location)): local_steps.delete_folder(folder=os.path.join( self.fls_tool_location, self.repackage_build_location))() if local_utils.folder_exists(path=os.path.join( self.fls_tool_location, self.repackage_origdata_location)): local_steps.delete_folder( folder=os.path.join(self.fls_tool_location, self.repackage_origdata_location))() local_steps.create_folder(folder=self.repackage_build_location, path=self.fls_tool_location)() local_steps.create_folder(folder=self.repackage_origdata_location, path=self.fls_tool_location)() local_steps.unzip_archive(zip_path=os.path.join( self.fls_tool_location, archive_name), unzip_destination=os.path.join( self.fls_tool_location, self.repackage_build_location))() userdata_name = self.local_connection.parse_cmd_output( cmd="ls {0}".format( os.path.join(self.fls_tool_location, self.repackage_build_location)), grep_for="userdata") if ".fls" not in userdata_name: self.set_errorm( "", "There is no userdata in the image".format(self.step_data)) else: command = "cd {0}; make_ext4fs -s -C fsconfig.txt -l {1} -a data fakedata.img {2}".format( self.fls_tool_location, self.fake_userdata_size, self.repackage_fakedata_location) local_steps.command(command=command, live_print=False, mode="sync")() command = "cd {0};./FlsTool -x {1}/{2} -o {3}".format( self.fls_tool_location, self.repackage_build_location, userdata_name, self.repackage_origdata_location) local_steps.command(command=command, live_print=False, mode="sync")() command = "cd {0};./FlsTool --extract-prg -r {1}/{2} -o {3}/prg.bin".format( self.fls_tool_location, self.repackage_build_location, userdata_name, self.repackage_origdata_location) local_steps.command(command=command, live_print=False, mode="sync")() command = "cd {0};./FlsTool --to-fls2 --prg {2}/prg.bin --psi {2}/userdata.fls_inj_PSI.bin --ebl {2}/userdata.fls_inj_EBL.bin \ --tag USERDATA -r -o {1} fakedata.img".format( self.fls_tool_location, self.new_userdata_name, self.repackage_origdata_location) local_steps.command(command=command, live_print=False, mode="sync")() local_steps.copy_file( file=os.path.join(self.fls_tool_location, self.new_userdata_name), destination=os.path.join(self.resources_folder, userdata_name), with_rename=True)() # copy resources folder local_steps.copy_folder_content(folder=self.resources_folder, destination=self.unzip_path)() # edit flash.json to flash userdata and/or remove oem/flashing lock print "Edit {0} file".format(self.flash_xml_path) if ('json' in self.flash_xml_path) and (self.edit_flash_file): js_data = None with open(self.flash_xml_path, "r") as flash_file: js_data = json.load(flash_file) # do not lock bootloader. Write userdata instead for cmd in js_data['flash']['commands']: if 'blank' in cmd['restrict'][0] and cmd[ 'tool'] == "fastboot": if cmd['args'] == "oem lock" or cmd[ 'args'] == "flashing lock": cmd[u'description'] = u'Flash userdata partition' cmd[u'args'] = u'flash userdata ${userdata}' cmd[u'timeout'] = 180000 for cmd in js_data['flash']['commands']: if 'blank' in cmd['restrict'][0] and cmd[ 'tool'] == "fastboot": if "flash oemvars" in cmd['args']: js_data['flash']['commands'].remove(cmd) break js_data['flash']['parameters']['userdata'] = { u'type': u'file', u'description': u'userdata.img', u'value': u'userdata.img', u'name': u'userdata' } if js_data is not None: with open(self.flash_xml_path, "w") as flash_file: json.dump(js_data, flash_file, sort_keys=True, indent=4)
def do(self): cmd_header = "screen -x {0} -p0 -X stuff '".format(self.screen_name) enter = "\r'" local_steps.command(command="{0}{1}{2}".format( cmd_header, self.screen_command, enter))() if not self.user_build or self.user_signed or self.update: return waiting = 0 unlock_grep = "\"oem\" \"unlock\"` command" print "{0}: Waiting unlock command".format(self.serial) while waiting < self.timeout / 8: cat_grep_cmd = "tail -n 10 {0} | grep '{1}'".format( self.screen_log, unlock_grep) stdout, stderr = self.local_connection.run_cmd( command=cat_grep_cmd) if unlock_grep in stdout: time.sleep(30) my_relay = Relayed_device( relay_port=self.device["relay"]["tty"], power_port=self.device["relay"]["power_port"], v_up_port=self.device["relay"]["v_up_port"], v_down_port=self.device["relay"]["v_down_port"]) my_relay.press_volume_up() my_relay.press_power() my_relay.close() break waiting += 2 time.sleep(2) unlock_grep = "\"oem\" \"unlock\"` failed" while waiting < 30: cat_grep_cmd = "tail -n 10 {0} | grep '{1}'".format( self.screen_log, unlock_grep) stdout, stderr = self.local_connection.run_cmd( command=cat_grep_cmd) if unlock_grep in stdout: print "{0}: Unlock command failed".format(self.serial) print "{0}: The device is not OEM enabled!!!!!".format( self.serial) sys.exit(0) waiting += 2 time.sleep(2) waiting = 0 lock_grep = "\"oem\" \"lock\"` command" print "{0}: Waiting lock command".format(self.serial) while waiting < self.timeout * 6 / 8: cat_grep_cmd = "tail -n 10 {0} | grep '{1}'".format( self.screen_log, lock_grep) stdout, stderr = self.local_connection.run_cmd( command=cat_grep_cmd) if lock_grep in stdout: time.sleep(30) my_relay = Relayed_device( relay_port=self.device["relay"]["tty"], power_port=self.device["relay"]["power_port"], v_up_port=self.device["relay"]["v_up_port"], v_down_port=self.device["relay"]["v_down_port"]) my_relay.press_volume_up() my_relay.press_power() my_relay.close() break waiting += 2 time.sleep(2)
def do(self): command = self.script + " " + self.name self.so, self.se = local_steps.command(command=command, stderr_grep=self.pass_message)()
watchdog_delay = 600 wait_for_state = None fastboot_power_off_timeout = 20 # Test start # try: device_state = local_utils.get_device_boot_state(serial=serial) if device_state == "fastboot": fastboot_steps.continue_to_adb(serial=serial)() adb_steps.wait_for_ui_processes(serial=serial)() elif device_state == "recovery": adb_steps.reboot(serial=serial)() elif device_state == "crashmode": print "adb -s {0} reboot".format(serial) local_steps.command("adb -s {0} reboot".format(serial))() local_steps.wait_for_adb(serial=serial)() adb_steps.wait_for_ui_processes(serial=serial)() else: relay_steps.reboot_main_os(serial=serial, relay_type=relay_type, relay_port=relay_port, power_port=power_port)() # Reboot the device into bootloader adb_steps.reboot(command="bootloader", serial=serial)() # Set the watchdog counter fastboot_steps.command(command="oem set-watchdog-counter-max {0}".format(watchdog_counter_max), serial=serial,
port=adb_server_port, name=DUT_NAME)() bluetooth_steps_old.bt_make_discoverable(serial=serial, port=adb_server_port, name=DUT_NAME)() bluetooth_steps_old.bt_change_device_name(serial=PAIRING_DEV, port=adb_server_port, name=PAIRING_DEV_NAME)() bluetooth_steps_old.bt_make_discoverable(serial=PAIRING_DEV, port=adb_server_port, name=PAIRING_DEV_NAME)() #push photo download_command = 'wget ' + PHOTO_URL local_steps.command(command=download_command)() adb_steps.push_file(serial=serial, local=PHOTO_NAME, remote=PHOTO_PATH + PHOTO_NAME)() adb_steps.command(serial=serial, command=REFRESH_MEDIA_COMMAND + PHOTO_PATH + PHOTO_NAME)() ############### Test #################### ######################################### ui_steps.open_picture_from_gallery(serial=serial, port=adb_server_port)() while not ui_device(serial=serial)(descriptionContains='Share with').exists: ui_steps.click_button( serial=serial, port=adb_server_port,
wait_ui = get_devices_info("adb shell getprop ro.product.device") try: relay_steps.reboot_main_os(serial=serial, relay_type=relay_type, relay_port=relay_port, power_port=power_port, wait_ui=wait_ui, timeout=300, delay_power_on=30, device_info="broxtonp")() # Reboot to main OS local_steps.command("adb -s {} reboot".format(serial))() local_steps.wait_for_adb(timeout=300, serial=serial)() if wait_ui: adb_steps.wait_for_ui_processes(serial=serial)() else: time.sleep(20) adb_steps.root_connect_device(serial=serial)() time.sleep(5) command = "adb shell ps | grep /sbin/watchdogd" r = os.popen(command) info = r.readlines() for line in info: line = line.strip("\r\n") line = line.split()
wait_ui = get_devices_info("adb shell getprop ro.product.device") try: relay_steps.reboot_main_os(serial=serial, relay_type=relay_type, relay_port=relay_port, power_port=power_port, wait_ui=wait_ui, timeout=300, delay_power_on=30, device_info="broxtonp")() adb_steps.root_connect_device(serial=serial)() time.sleep(5) local_steps.command( "adb -s {} shell \"echo c > /proc/sysrq-trigger\"".format(serial))() time.sleep(300) relay_steps.reboot_main_os(serial=serial, relay_type=relay_type, relay_port=relay_port, power_port=power_port, wait_ui=wait_ui, timeout=300, delay_power_on=30, device_info="broxtonp")() adb_steps.root_connect_device(serial=serial)() time.sleep(5) command = "adb shell cat /proc/cmdline"
step_file["step_file"] = f step_files.append(step_file) from testlib.scripts.connections.local import local_steps steps = [] for step_file in step_files: print "*****" + step_file["module"] + "." + step_file["step_file"] + "*****" module = step_file["module"].split(ROOT)[1].replace( "/", ".") + "." + step_file["step_file"].strip(".py") module_path = step_file["module"] + "/" + step_file["step_file"] module_python_path = module_path.split(ROOT)[1].replace("/", ".").strip(".py") module = importlib.import_module(module_python_path) command = "python " + ROOT + PYOBJECT_PATH + " " + module_path stdout, stderr = local_steps.command(command=command)() new_step = {} for line in stdout.split("\n"): if "_step)" in line: if new_step.has_key("class"): new_step["python_path"] = module_python_path new_class = getattr(module, new_step["class"]) new_step["doc"] = new_class.__doc__ steps.append(new_step) new_step = {} line_elems = line.split(".") new_step["category"] = line_elems[0] new_step["class"] = line_elems[1].split("(")[0] new_step["step"] = line_elems[1].split("(")[1].strip(")") if "__init__" in line: new_step["params"] = line.split("(")[1].strip(")")
def do(self): local_steps.command(command="rm -f " + self.file_name)()
# Test start # try: # Boot to main OS relay_steps.reboot_main_os(serial=serial, relay_type=relay_type, relay_port=relay_port, power_port=power_port, v_down_port=v_down_port, v_up_port=v_up_port, wait_ui=True)() # Perform adb pull command from MOS adb_steps.root_connect_device(serial=serial)() local_steps.command(command="adb -s {0} pull {1} /tmp/{2}".format(serial, pull_mos_file, mos_tmp_file))() # Boot to crashmode os.system("adb -s {} reboot crashmode > /dev/null 2>&1".format(serial)) time.sleep(15) local_steps.wait_for_crashmode(serial=serial, timeout=60)() # Perform adb pull command from crashmode local_steps.command(command="adb -s {0} pull {1} /tmp/{2}".format(serial, pull_crashmode_file, crashmode_tmp_file))() # Compare the two files. They should be the same local_steps.command(command="diff -s /tmp/{0} /tmp/{1}".format(mos_tmp_file, crashmode_tmp_file), stdout_grep="are identical")() # Run the "adb reboot" command and wait for the device to boot to main UI local_steps.command(command="adb -s {0} reboot".format(serial))()
def do(self): local_steps.command(command="touch " + self.file_name)()
######################################################################## 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"], v_up_port=device["relay"]["v_up_port"], v_down_port=device["relay"]["v_down_port"]) my_relay.press_volume_up() my_relay.press_power() my_relay.close() local_steps.command(command="fastboot -s " + s + " oem verified")() local_steps.command(command="fastboot -s " + s + " oem lock")() time.sleep(3) my_relay = Relayed_device( relay_port=device["relay"]["tty"],
def do(self): local_steps.command(command="dd if=/dev/zero of=" + self.file_name + " bs=" + str(self.size) + " count=1")()
def do(self): # Create panic adb_steps.root_connect_device(serial=self.serial)() if self.create_crash_mode == "panic": # Using local_steps to run the command because adb_steps.command() does not create kernel panic local_steps.command("adb -s {0} shell {1}".format( self.serial, self.panic_command))() # Wait for the device to disconnect local_steps.wait_until_disconnected(serial=self.serial)() if self.use_combo_button == False: print "======================wait 120s=======================" time.sleep(120) else: adb_steps.kill_process(serial=self.serial, process_name=self.watchdog_process_name, with_reboot=True, reboot_timeout=60)() # Wait for a device state if self.wait_for_state == "fastboot": # Set the pass and error messages self.set_errorm( "", "The device with serial {0} is not in fastboot".format( self.serial)) self.set_passm("The device with serial {0} is in fastboot".format( self.serial)) # If the expected state is fastboot, we need to press the volume down button after the panic is created # This will boot the device in fastboot # Create a parallel step # use_control_process=False psteps = ParallelSteps(use_control_process=False) step_id_combo = psteps.add_step( local_steps.wait_for_fastboot, serial=self.serial, timeout=self.wait_for_fastboot_timeout) self.relay.relay.on(self.relay.v_down_port) time.sleep(self.wait_for_fastboot_timeout - 10) self.relay.relay.off(self.relay.v_down_port) # Interpret the parallel step result psteps.interpret_step(step_id_combo) elif self.wait_for_state == "android": # Set the pass and error messages self.set_errorm( "", "The device with serial {0} is not in MOS".format(self.serial)) self.set_passm("The device with serial {0} is in MOS".format( self.serial)) # Wait for adb connection local_steps.wait_for_adb(serial=self.serial)() # Wait for the UI processes adb_steps.wait_for_ui_processes(serial=self.serial)() elif self.wait_for_state == "crashmode": # Set the pass and error messages self.set_errorm( "", "The device with serial {0} is not in crash mode".format( self.serial)) self.set_passm( "The device with serial {0} is in crash mode".format( self.serial)) # Wait for crashmode local_steps.wait_for_crashmode(serial=self.serial, timeout=60)()
def check_condition(self): local_steps.command(command="ls", stdout_grep=self.file_name)
# mandatory params radio_name = random.choice(radio_defaults.radio_name_values) ta = "on" pi = random.randint(20001, 99999) pty = random.choice(radio_defaults.pty_rds.keys()) if "frequency" in args.keys(): frequency = args["frequency"] else: # Select the frequency param with the lowest power from the scan results radio_path = radio.__file__ if radio_path.endswith("c"): radio_path = radio_path[:-1] # Start the scan a = local_steps.command(command=radio_path + " -s")() # Select the frequency b = re.findall("Measuring (\d+:\d+)", a[0]) c = sorted( zip([int(i.split(":")[1]) for i in b], [int(i.split(":")[0]) for i in b])) frequency = random.choice([c[0][1], c[1][1], c[2][1]]) # optional params if "pty_check" in args.keys(): pty_check = args["pty_check"] else: pty_check = False if "ta_check" in args.keys():
# 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)() local_steps.command(serial = serial, command="./flash-all.sh")() local_steps.wait_for_adb(serial = serial, timeout = 720)()