def run_test(self): UseCaseBase.run_test(self) #manifest_instance = for manifest_instance in self._manifest_filename: result_file = execute_test_group(manifest_instance, self._result_filename) result, output = self.extract_results(result_file) self._device.get_logger().info( "Move GFX results into ACS result, as zipfile %s" % (os.path.basename(self.acs_gfx_results))) if not os.path.isdir(self.original_results_gfx_location): self._device.get_logger().warning( "%s directory does not exist, cannot copy GFX results" % (self.original_results_gfx_location, )) else: # zip results self.zip_results() return result, output
def run_test(self): """ the heart of your test. measurement should be done in this function. No test clean should be on it except if it is need by the test steps. """ UseCaseBase.run_test(self) # temperature settings if self.tc_module is not None and self.tc_module.is_default_test(): self.tc_module.adjust_temp_according_to_current_value() # implementation for B2B continuous # Do before_runtest without a try, if it can't be done then the DUT must be KO self.run_test_start() result = Global.FAILURE result_msg = "" import traceback try: result, result_msg = self.run_test_body() # the warning is known and left here to remember it except Exception as ee: _, exc_tb = sys.exc_info()[1:] self._logger.error("Error happen in RUN TEST BODY : %s" % str(ee)) self._logger.error(str(traceback.format_tb(exc_tb))) self._logger.error( "Trying to execute RUN TEST STOP before finishing test") result_msg = str(ee) finally: # in any case do a cleaning try: self.run_test_stop() # the warning is known and left here to remember it except Exception as e: _, exc_tb = sys.exc_info()[1:] self._logger.error("Exception during RUN TEST BODY: %s" % str(e)) self._logger.error(str(traceback.format_tb(exc_tb))) return result, result_msg
def run_test(self): """ Execute the test """ # Call inherited run_test method UseCaseBase.run_test(self) # Initialize some local variables registration_message = "IMS registration failure." verdict = Global.FAILURE in_service_status = ImsRegistrationStatus.in_service() # Proceed with the proper execution of the test. if "REGISTER" == self._ims_reg_operation: # Sleep during registration timeout + IMS registration timeout self._logger.info("Waiting %d seconds for IMS registration..." % \ self._ims_registration_timeout) # Check the registration status from DUT as returned by the API self._networking_api.check_ims_registration_before_timeout( self._ims_registration_timeout) # Log the latest IMS registration status registration_status = self._get_registration_status() self._logger.info("Registration status: %s (%d)" % ( str(registration_status), registration_status.as_int())) # Compute the verdict if registration_status == in_service_status: verdict = Global.SUCCESS registration_message = "IMS registration success." # Check IMS registration after registration OFF/ON procedures if self._deregistration_method: self._logger.info("Check IMS registration during registration OFF/ON procedures") (verdict, registration_message) = \ self._check_registration_off_on() # Return the test result return (verdict, registration_message)
def run_test(self): UseCaseBase.run_test(self) unlock_command = "adb shell input keyevent 82" result = Global.FAILURE output = "Error in executing Monkey tool" for application in self._app_list: self._logger.info( "Installing application: {0}".format(application)) self._app_api.install_device_app(self._app_list[application]) wait_time = (int(self._nr_events) * int(self._time_btw) + 10000) / 1000 self._device.run_cmd(unlock_command, self._wait_btwn_cmd) cmd = "adb shell monkey -p " + application + " --throttle " + self._time_btw + \ " --ignore-crashes " + "--ignore-timeouts " + "--ignore-security-exceptions " + \ " -v " + self._nr_events + " --kill-process-after-error" self._logger.info("") self._logger.info( "Starting monkey for {0} seconds".format(wait_time)) monkey_status, monkey_output = self._device.run_cmd(cmd, wait_time) monkey_output_list = monkey_output.split("\n") test_successful = False if "// Monkey finished" in monkey_output_list[-1]: test_successful = True self._tc_report.add_result(application, self._tc_report.verdict.PASS, monkey_output_list[0], self.get_name(), self.tc_order) if not test_successful: self._tc_report.add_result(application, self._tc_report.verdict.FAIL, monkey_output_list[-1], self.get_name(), self.tc_order) if test_successful: result = Global.SUCCESS output = "Monkey finished" else: result = Global.FAILURE output = "Monkey failed on some tests, please see detailed report for result" self._app_api.uninstall_device_app(application, timeout=100) return result, output
def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test(self) verdict = Global.SUCCESS msg = "No errors" # Take pictures in burst mode pictures_uri = self.__camera_api.take_picture(self.__save_directory, self.__pictures_number) time.sleep(self._wait_btwn_cmd) # Check the number of pictures taken if len(pictures_uri.split(",")) != self.__pictures_number: verdict = Global.FAILURE msg = "Number of pictures taken is not as expected. expected %s, obtained : %s" \ % (str(self.__pictures_number), str(len(pictures_uri.split(",")))) return verdict, msg # Download pictures taken from DUT local_pictures_uri = [] for picture_uri in pictures_uri.split(","): local_pictures_uri.append(self.__camera_api.download_media_file(picture_uri, self.__save_folder)) # Check if pictures are corrupted corrupted = False pictures_corrupted = 0 for picture in local_pictures_uri: if Imagecheck.check_image_corrupt(picture): corrupted = True pictures_corrupted += 1 if corrupted: verdict = Global.FAILURE msg = " %s pictures are corrupted" % str(pictures_corrupted) return (verdict, msg)
def run_test(self): """ Execute the test. """ # Call inherited method UseCaseBase.run_test(self) error_occured = False output_message = "" # Log the current network preference preferred_rat = self._networking_api.get_preferred_network_type() log_message = "Current network preference is %s ." % preferred_rat self._logger.debug(log_message) try: self._modem_api.check_rat_with_pref_network(self._preferred_nw_type, self._registration_timeout) except DeviceException as de: if self._fail_on_error: self._logger.error(de.get_error_message()) raise de else: error_occured = True output_message = de.get_error_message() self._logger.warning(output_message) if not error_occured: nw_type = self._modem_api.get_network_type() if self._expected_nw_type == nw_type: output_message = "The DUT is camped on network %s as expected with network preference %s" \ % (str(nw_type), self._preferred_nw_type) else: output_message = "The DUT is camped on network %s instead of expected %s but compatible with network type preference %s" \ % (str(nw_type), self._expected_nw_type, self._preferred_nw_type) self._logger.info(output_message) # Return the verdict return Global.SUCCESS, output_message
def run_test(self): """ Runs the test. """ # Call inherited run_test method which will ensure IMS registration # Ugly temporary solution before implementing something # better using test steps. if self._perform_ims_registration: LiveLteImsReg.run_test(self) else: UseCaseBase.run_test(self) # Check registration for secondary DUT self._check_registration_second_dut() # Release any previous call (Robustness) self._logger.info("Releasing any ongoing calls") self._voice_call_api.release() self._voice_call_api2.release() # Return the test result return (Global.SUCCESS, "No error.")
def run_test(self): """ Execute the test """ UseCaseBase.run_test(self) # Disable flight mode self._networking_api.set_flight_mode("off") # Release any previous call (Robustness) self._voicecall_api.release() # Make the call; wait for state ACTIVE to be reached for 2 seconds; # release the call and after that check that the DUT is in idle state # Repeat this several times (20) for i in range(1, self._number_of_calls): self._voicecall_api.dial(self._numtocall) self._voicecall_api.wait_for_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE, 2) self._voicecall_api.release() self._voicecall_api.check_state( self._uecmd_types.VOICE_CALL_STATE.NOCALL) # Make the call; and wait for 10 seconds self._voicecall_api.dial(self._numtocall) self._logger.info("Wait for call duration: " + str(self._callduration) + "s...") time.sleep(self._callduration) #Check that the phone is in ACTIVE state self._voicecall_api.check_state( self._uecmd_types.VOICE_CALL_STATE.ACTIVE) # Release the call and check that the phone is in idle stat self._voicecall_api.release() self._voicecall_api.check_state( self._uecmd_types.VOICE_CALL_STATE.NOCALL) return Global.SUCCESS, "No errors"
def run_test(self): """ Run the test """ UseCaseBase.run_test(self) self.__skip_wizard() self.__disable_lockscreen() self.__disable_verify_application() self.__disable_vending_app() self.__set_screen_timeout() self.__set_display_brightness() self.__configure_launcher() self.__disable_wifi_scan_always_enabled() self.__disable_google_voice_hotword() self.__close_welcome_screen() self.__close_video_popup() self.__turn_off_location() if self.__reboot_mandatory: self._device.reboot(wait_settledown_duration=True) return Global.SUCCESS, "No error"
def run_test(self): """ Performs the three tests on SIM: 1/ SIM PIN check (nominal scenario) 2/ Lock the SIM PIN 3/ Unlock it with SIM PUK """ # Run the inherited 'run_test' method UseCaseBase.run_test(self) # 1/ SIM PIN check - enter the pin when sim is locked (nominal scenario) self._logger.info("Step 1: do SIM PIN check......") is_enabled = self.sim_card_api.get_sim_lock_state() sim_state = self.sim_card_api.get_sim_state() if is_enabled and sim_state == self.sim_card_api.POSSIBLE_SIM_STATES["SIM_STATE_PIN_REQUIRED"]: self._logger.info("sim pin is enabled, dut will not ask for the pin to register until next shutdown, actually we do not need to supply pin to regitere to network without shutdown") (status, output) = self.do_sim_pin_check() self._logger.info("success: sim pin is enabled properly !!") # Stop on first failure to void device's sim brick if status != Global.SUCCESS: return status, output # 2/ block the SIM PIN: self._logger.info("Step 2: block SIM PIN test by entering wrong pin 3 times...") (status, output) = self.do_block_sim_pin() sim_state = self.sim_card_api.get_sim_state() if sim_state == self.sim_card_api.POSSIBLE_SIM_STATES["SIM_STATE_PUK_REQUIRED"]: self._logger.info("sim pin is blocked after entering wrong pin %d times" % self.sim_card_api.MAX_PIN_ATTEMPT) if status != Global.SUCCESS: return status, output # 3/ Unblock it with SIM PUK self._logger.info("Step 3: Unlock SIM PIN with PUK ...") (status, output) = self.do_unblock_sim_puk() # test has been successful return status, output
def run_test(self): """ Execute the test """ # Call UseCase base run function UseCaseBase.run_test(self) time.sleep(self._wait_btwn_cmd) self._logger.info("Ringer profile checking...") self._ringer_profile_api.set_silent_vibrate(self._target_silent_mode, self._target_vibra_mode) result = self._ringer_profile_api.get_silent_vibrate() if result == self._target_silent_mode + "+" + self._target_vibra_mode: self._logger.info("Ringer profile check succeeded") testResult = "Target ringer profile check succeeded, silent mode: %s, vibra mode: %s" % \ (self._target_silent_mode, self._target_vibra_mode) else: self._logger.info("Ringer profile check failed") testResult = "Target ringer profile check failed" return Global.SUCCESS, testResult
def run_test(self): """ Execute the test """ # Run UC base run_test UseCaseBase.run_test(self) # Initialize the return code and message of the test return_code = Global.FAILURE return_message = "An error occurred." # Check the state of the phone as returned by adb # We do not want to use the 'get_state' method # of the device as it adds some post processing # on the state value (_exit_status, output) = internal_shell_exec("adb get-state", 5) # pylint: disable=W0212 state = output.strip() self._logger.debug("Initial phone state '%s'" % state) if state not in ("unknown", "bootloader"): message = "Unexpected phone state: %s. expected 'unknown' or 'bootloader'." % state self._logger.error(message) raise DeviceException(DeviceException.PROHIBITIVE_BEHAVIOR, message) # Restart the phone in MOS rebooted = self._device.reboot(mode="MOS", transition_timeout=self._boot_timeout) if rebooted: return_code = Global.SUCCESS return_message = "Board rebooted successfully." else: return_code = Global.FAILURE return_message = "An error occurred when rebooting the board." # Return the verdict and the message return return_code, return_message
def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test(self) verdict = Global.SUCCESS msg = "No errors" # Start video record video_uri = self.__camera_api.record_video(self.__record_duration, self.__save_directory, 0) time.sleep(self._wait_btwn_cmd) # Get video from DUT to host local_video_uri = self.__camera_api.download_media_file(video_uri, self.__save_folder) # Get video's brightness local_video_brightness = VideoCheck.check_video_brightness(local_video_uri) # Set camera flash mode to torch self.__camera_api.set_flash_mode('torch') time.sleep(self._wait_btwn_cmd) # Start video record with flash mode video_with_flash_uri = self.__camera_api.record_video(self.__record_duration, self.__save_directory, 0) time.sleep(self._wait_btwn_cmd) # Get video from DUT to host local_video_with_flash_uri = self.__camera_api.download_media_file(video_with_flash_uri, self.__save_folder) # Get video with flash mode torch's brightness local_video_with_flash_brightness = VideoCheck.check_video_brightness(local_video_with_flash_uri) if local_video_with_flash_brightness <= local_video_brightness: verdict = Global.FAILURE msg = "Flash mode was not set during video record" return (verdict, msg)
def run_test(self): """ Execute the test """ # Run UC base run_test UseCaseBase.run_test(self) # Launch the test scenario main command for performing the test (response, output) = self._device.run_cmd(str(self._cmd_str), self._test_timeout, force_execution=True) # Check if the configuration commands is successful or not if self._check_adb_response(str(self._expected_result), output): return_code = Global.SUCCESS return_msg = "The adb command was successfully executed" else: return_code = Global.FAILURE return_msg = "The test case scenario has not the expected response; The command FAILED" self._logger.error(return_msg) # Return the verdict return return_code, return_msg
def run_test(self): """ UC Execution, execute your test here """ UseCaseBase.run_test(self) unlock_command = "adb shell input keyevent 82" self._device.run_cmd(unlock_command, self._timeout) if "uiautomator " in self._process_name: # Starting ui automator test, update the cmd line # TODO: see if we shall not create another UC am_command = "adb shell {0} {1}".format(self._process_name, self._am_extra) else: # Std instrumentation testing am_command = "adb shell am instrument {0} -w {1}".format( self._am_extra, self._process_name) # Execute the command if re.search("\\\u\d{4}", am_command): am_command = am_command.decode('unicode-escape') result, output = self._device.run_cmd(am_command, self._timeout) if result == 0 and "OK (1 test)" in output: output = "" elif result == 0 and ('FAILURES!!!' not in output and "OK (" in output): output = "" elif output.strip() == "": result, output = Global.FAILURE, "Am command has no output" else: result = Global.FAILURE # save the result (for retrieving artifacts only on failure) self._run_test_result = result return result, output
def run_test(self): """ Execute the test """ # Call UseCase base Run function. UseCaseBase.run_test(self) msg = "" for icon in self.__icon_dict: verdict = self._multimedia_api.check_screen(self.__icon_dict[icon], "id") time.sleep(self._wait_btwn_cmd) if not verdict: msg += "Doesn't match " + str(icon) + " in UI," if len(msg) > 0: verdict = Global.FAILURE else: verdict = Global.SUCCESS msg = "No errors" return verdict, msg
def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test(self) verdict = Global.SUCCESS msg = "No errors" # Check barometer return output, x, y, z = self.__sensor_api.check_sensor_info( "barometer", "data", "reserve") time.sleep(self._wait_btwn_cmd) barometer_value = x + y + z if barometer_value < self.__expected_value - self.__flexibility or\ barometer_value > self.__expected_value + self.__flexibility: verdict = Global.FAILURE msg = "barometer value does not mach the expected one, value : %s, expected : %s +- %s"\ % (str(barometer_value), str(self.__expected_value), str(self.__flexibility)) return (verdict, msg)
def run_test(self): """ Execute the test """ # Call UseCaseBase Set Up UseCaseBase.run_test(self) # Click to Widi to start scan self._ui_api.run_operation_set("widi_scan") # Retrieve Widi Scan Result widi_devices_list = self._networking_api.widi_scan_devices() if not widi_devices_list: return Global.FAILURE, "No available devices found !" else: for device in widi_devices_list: self._logger.info("WiDi Device found: " + str(device.name) + " in " + device.adapter + " adapter") # Return the result return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test(self) # Set volume using VOLUME parameter time.sleep(self._wait_btwn_cmd) self._system_api.adjust_specified_stream_volume("Media", self._multimedia_volume) # Launch the audio file using FILENAME parameter time.sleep(self._wait_btwn_cmd) self._audio_api.play(self._audio_filename, loop=False) self.get_logger().info("Wait for %.1f second(s) before stopping audio playback" % self._audio_duration) time.sleep(self._audio_duration) # Stop the audio file self._audio_api.stop() return Global.SUCCESS, "No errors"
def run_test(self): UseCaseBase.run_test(self) unlock_command = "adb shell input keyevent 82" self._device.run_cmd(unlock_command, self._wait_btwn_cmd) result = Global.FAILURE output = "Error in executing Monkey tool" cmd = "adb shell monkey" if self._pakage_name: cmd += " -p " + self._pakage_name cmd += " --throttle " + \ self._time_btw + " -v " + self._nr_events + " --kill-process-after-error" if self._ignore_crashes == True: cmd += " --ignore-crashes " if self._ignore_timeouts == True: cmd += " --ignore-timeouts " if self._ignore_security_exceptions == True: cmd += " --ignore-security-exceptions " monkey_status, monkey_output = self._device.run_cmd(cmd, self._timeout) monkey_output_list = monkey_output.split("\n") for line in monkey_output_list: if "// Monkey finished" in line: result = Global.SUCCESS output = "Monkey finished" return result, output + monkey_output_list[0]
def run_test(self): """ Execute the test """ # Call UseCase base Run function. UseCaseBase.run_test(self) #set display orientation self._logger.info("Force screen orientation.") self._display_api.set_display_orientation(self._force_orientation) time.sleep(self._wait_btwn_cmd) self._logger.info("Check if unlock icon is correctly display.") self._screenshot_path = self._image_api.take_screenshot_and_pull_on_host(self._image_filename, os.getcwd()) self._screenshot_state = True template = self._dic_image[self._unlock_icon] matching, x, y = Imagecheck.match_template_in_image(self._screenshot_path, template) if matching: #try to unlock phone with swipe self._logger.debug("Trying to unlock the phone with swipe.") self._phonesystem_api.unlock_phone_with_swipe(x,y,self._swipe_timeout) #Now verify if DUT is unlock if not self._system_api.check_Activity("Keyguard"): verdict = Global.SUCCESS msg = "No errors" else: verdict = Global.FAILURE msg = "Device is always lock, unlock fail." else: verdict = Global.FAILURE msg = "Doesn't match unlock icon." return verdict, msg
def run_test(self): """ Execute the test """ UseCaseBase.run_test(self) for cur_band in ["auto", "5GHz", "2.4GHz"]: # Set the new band self._networking_api.set_wifi_frequency_band( cur_band, False, self._dut_wlan_iface) sleep(self._wait_btwn_cmd) # Check the new band res_band = self._networking_api.get_wifi_frequency_band() # Compare it to the ID the device gave. if res_band == cur_band: msg = "Got band %s - OK" % res_band self._logger.info(msg) else: msg = "Got band %s instead of %s" % (res_band, cur_band) self._logger.error(msg) raise DeviceException(DeviceException.OPERATION_FAILED, msg) return Global.SUCCESS, "No error"
def run_test(self): """ Execute the CTS test Compute result based on CTS xml result output :rtype: tuple :return: ACS verdict and msg output """ UseCaseBase.run_test(self) full_path = self._artifact_manager.get_artifact( artifact_name=self._cts_path, transfer_timeout=self._timeout) if not full_path: verdict = Global.FAILURE msg = "Path not correct: %s" % full_path else: self._extract(full_path) fileName, fileExtension = os.path.splitext(full_path) (verdict, error_msg) = self._install_cts_apks(fileName) if verdict == Global.SUCCESS: (verdict, error_msg) = self._push_cts_medias() return verdict, error_msg
def run_test(self): """ Execute the test """ UseCaseBase.run_test(self) # Initialize the CWS feature states self._init_cws_features() # Enable flight mode self._networking_api.set_flight_mode(1) time.sleep(self._wait_btwn_cmd) # Check all tested features are turned OFF self._check_all_off() # Disable flight mode self._networking_api.set_flight_mode(0) time.sleep(self._wait_btwn_cmd) # Check all tested feature state after flight mode back OFF self._check_all_features_after_apm_cycle() return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the test """ # Run UC base run_test UseCaseBase.run_test(self) # Create the shell command cmd = "adb shell mmgr-test -f -t %s" % (str(self._test_number)) # Run the shell command (return_code, output) = self._device.run_cmd(cmd, self._test_timeout, force_execution=True) # Check the error code on the stdout. output = output.translate(None, '\r\n') matcher = re.search("%s" % self._expected_result, output) if matcher is not None: return_code = Global.SUCCESS return_msg = "mmgr-test success. Found expected result: %s." % ( str(self._expected_result)) else: return_code = Global.FAILURE return_msg = "mmgr-test test failed. Expected result was %s." % ( str(self._expected_result)) self._logger.error(return_msg) # Wait until the modem is up before going any further in the campaign self._logger.debug("Waiting for the modem to be up") # The modem takes up to 10 secs to be declared UP time.sleep(15) # Return the verdict of the flash return return_code, return_msg
def run_test(self): ''' Execute test case ''' UseCaseBase.run_test(self) self._setup() result = self.runner.run(self.suite) ret = [] if result.wasSuccessful(): ret = Global.SUCCESS, "SUCCESS" else: if result.errors: ret = Global.FAILURE, result.errors[0][1] elif result.failures: ret = Global.FAILURE, result.failures[0][1] elif result.skipped: ret = Global.BLOCKED, result.skipped[0][1] else: ret = Global.BLOCKED, "unknown reason" self._logger.error(ret[1]) self._tear_down(ret[0] != Global.SUCCESS) return ret
def run_test(self): """ Execute the test """ # Call UseCase base run_test function UseCaseBase.run_test(self) if self._switch_mode == "airplane": # Switch on according to the mode chosen self.phoneonoff_util.switch_on(self._switch_mode) elif self._switch_mode in ("hardshutdown", "softshutdown"): # Reboot according to the mode chosen self.phoneonoff_util.reboot(self._switch_mode) else: self._logger.info("No actions required to do a switch On/Off") # save initial time init_time = time.time() # Check registration state is connected using # registrationTimeout from Device_Catalog.xml self._logger.info("Check network registration status is %s on DUT" % self._wanted_reg_state) self._modem_api.check_cdk_state_bfor_timeout( self._wanted_reg_state, self._registration_timeout) # time needed to reach registered state reg_time = time.time() - init_time self._logger.info("DUT registered in less than %3.2f seconds!", reg_time) # Adapt attachment procedure to CIRCUIT or PACKET if self._cell_service != "GSM": if self._pdp_activation: # Set the APN time.sleep(self._wait_btwn_cmd) self._logger.info("Setting APN " + str(self._apn) + "...") self._networking_api.set_apn(self._ssid, self._apn) # Activate PDP context time.sleep(self._wait_btwn_cmd) self._logger.info("Active PDP Context...") self._networking_api.activate_pdp_context(self._ssid, check=False) # Check Data Connection State => PDP_ACTIVE before timeout RegUtil.check_dut_data_connection_state_before_timeout( "PDP_ACTIVE", self._ns_cell_2g, self._networking_api, self._logger, self._registration_timeout, flightmode_cycle=False, blocking=False) else: # Check Data Connection State => ATTACHED before timeout RegUtil.check_dut_data_connection_state_before_timeout( "ATTACHED", self._ns_cell_2g, self._networking_api, self._logger, self._registration_timeout, flightmode_cycle=False, blocking=False) # time needed to reach attach state after registration attach_time = time.time() - init_time self._logger.info("DUT attached in less than %3.2f seconds!", attach_time) # Get RAT from Equipment network_type = self._ns_data_2g.get_network_type() # Check that DUT is registered on the good RAT self._modem_api.check_network_type_before_timeout( network_type, self._registration_timeout) if self._switch_mode == "airplane": # Switch off according to the switch mode chosen self.phoneonoff_util.switch_off(self._switch_mode) # Check that DUT is no longer camped on Network self._modem_api.check_cdk_no_registration_bfor_timeout( self._registration_timeout) return Global.SUCCESS, "No errors"
def run_test(self): """ Execute the CTS test Compute result based on CTS xml result output :rtype: tuple :return: ACS verdict and msg output """ UseCaseBase.run_test(self) verdict = Global.SUCCESS tc_verdict = Verdict.BLOCKED failcount = 0 msg = "" live_report = LiveReporting.instance() self._work_dir = tempfile.mkdtemp(prefix='ITS_') outfile = file(os.path.join(self._work_dir, 'stdout.txt'), 'w') errfile = file(os.path.join(self._work_dir, 'stderr.txt'), 'w') ''' tc_order = 2 for cam in self.camids: for s in self._scenes: for t in self._tests[s]: live_report.send_create_tc_info(t[0:-3], 'bla', tc_order) tc_order += 1 ''' for cam in self.camids: camoption = 'camera=' + str(cam) outdir = os.path.join(self._work_dir, str(cam)) os.mkdir(outdir) for s in self._scenes: self._logger.debug('Running ITS test for ' + s + ' ' + camoption) for t in self._tests[s]: live_report.send_start_tc_info('cam' + str(cam) + ' ' + t[0:-3], iteration=True) cmd = [ 'python', os.path.join(self.testroot, s, t), camoption ] result = subprocess.call(cmd, stdout=outfile, stderr=errfile, cwd=outdir) debug_str = 'ITS: ' if result == 0: debug_str += ' PASS ' tc_verdict = Verdict.PASS elif result == 1: debug_str += ' FAIL ' tc_verdict = Verdict.FAIL failcount += 1 elif result == 101: debug_str += ' SKIP ' tc_verdict = Verdict.INVALID else: debug_str += ' UNKNOWN ' tc_verdict = Verdict.INCONCLUSIVE self._logger.debug(debug_str + t[0:-3]) live_report.send_stop_tc_info(verdict=tc_verdict, execution_nb=1, success_counter=1, max_attempt=1, acceptance_nb=1, tc_comments="", iteration=1) if failcount > 0: verdict = Global.FAILURE msg = 'ITS ' + str(failcount) + ' tests failed' return verdict, msg
def run_test(self): """ Steps checking that we can ENABLE SIM lock feature: - enable SIM lock system with given PIN parameter - check that SIM lock system is enabled - if user want to check feature after reboot: - reboot the device - check that device is unregistered on any cell (device PIN locked) - supply PIN in order to unlock device - check that SIM lock system feature is still enabled - check that device is "registered" (or on going to be registered) on a cell Steps checking that we can CHANGE PIN code: - Change PIN code - Check that SIM lock system is still enabled - Change PIN back to default one (living device in original state) Steps checking that we can DISABLE SIM lock feature: - disable SIM lock system with given PIN parameter - check that SIM lock system is disabled - if user want to check feature after reboot: - reboot the device - check that SIM lock system is still disabled - check that device is "registered" (or on going to be registered) on a cell """ # Run the inherited 'run_test' method UseCaseBase.run_test(self) # Enable SIM lock system self.sim_card_api.enable_sim_lock_system(self.__current_pin) # Check that SIM lock system is enabled is_enabled = self.sim_card_api.get_sim_lock_state() if not is_enabled: return Global.FAILURE, "Enabling SIM lock system has failed" # SIM lock system enabled self.__current_pin_code = self.__current_pin if self.__check_after_reboot: self.get_logger().info( "Checking that SIM lock is still enabled after a reboot") # Reboot the device self._device.reboot(wait_settledown_duration=True) # Check that the device state is unregistered self.__modem_api.check_cdk_state_bfor_timeout( "unregistered", self._device.get_uecmd_timeout()) # Unlock SIM self.sim_card_api.supply_pin(self.__current_pin) # Check that SIM lock system is still enabled self._logger.info("Check that SIM lock system is still enabled") is_enabled = self.sim_card_api.get_sim_lock_state() if not is_enabled: return (Global.FAILURE, "SIM lock System is not "\ "persistent after a device reboot") # Check that the device is able to camp on a cell self.__modem_api.check_cdk_state_bfor_timeout( ["searching", "registered", "roaming"], self._device.get_uecmd_timeout()) # Change PIN code from default (current) to new PIN self.sim_card_api.change_sim_pin(self.__current_pin, self.__new_pin) # If something goes wrong, we know at this point # that we should use NEW_PIN in tear_down # for disabling PIN lock system self.__current_pin_code = self.__new_pin # Check that SIM lock system is still enabled is_enabled = self.sim_card_api.get_sim_lock_state() if not is_enabled: return (Global.FAILURE, "SIM lock system should be still"\ " enabled after having PIN changed") # Change PIN code from new to default PIN (keep device to its initial # PIN after usecase, and without enabling again the SIM lock system) self.sim_card_api.change_sim_pin(self.__new_pin, self.__current_pin) # If something goes wrong, we know at this point # that we should use CURRENT_PIN in tear_down # for disabling PIN lock system self.__current_pin_code = self.__current_pin # Disable SIM lock system self.sim_card_api.disable_sim_lock_system(self.__current_pin) # Check that SIM lock system is disabled is_enabled = self.sim_card_api.get_sim_lock_state() if is_enabled: return Global.FAILURE, "Disabling SIM lock system has failed" if self.__check_after_reboot: self.get_logger().info( "Checking that SIM lock is still disabled after a reboot") # Reboot the device self._device.reboot(wait_settledown_duration=True) # Check that the device is able to camp on a cell self.__modem_api.check_cdk_state_bfor_timeout( ["searching", "registered", "roaming"], self._device.get_uecmd_timeout()) # Check that SIM lock system is still disabled self._logger.info("Check that SIM lock system is still disabled") is_enabled = self.sim_card_api.get_sim_lock_state() if is_enabled: return (Global.FAILURE, "SIM lock System is not "\ "persistent after a device reboot") # test has been successful return Global.SUCCESS, "No error"
def run_test(self): """ Steps checking that we can ENABLE SIM lock feature: - enable SIM lock system with given PIN parameter - check that SIM lock system is enabled - if user want to check feature after reboot: - reboot the device - check that device is unregistered on any cell (device PIN locked) - supply PIN in order to unlock device - check that SIM lock system feature is still enabled - check that device is "registered" (or on going to be registered) on a cell Steps checking that we can CHANGE PIN code: - Change PIN code - Check that SIM lock system is still enabled - Change PIN back to default one (living device in original state) Steps checking that we can DISABLE SIM lock feature: - disable SIM lock system with given PIN parameter - check that SIM lock system is disabled - if user want to check feature after reboot: - reboot the device - check that SIM lock system is still disabled - check that device is "registered" (or on going to be registered) on a cell """ # Run the inherited 'run_test' method UseCaseBase.run_test(self) # 1. Enable SIM lock system when we know the correct pin, as I have set sim back to default pin), and Check that SIM lock system is enabled try_left = self.sim_card_api.enable_sim_lock_system(self.__default_pin) is_enabled = self.sim_card_api.get_sim_lock_state() if not is_enabled and try_left != self.sim_card_api.MAX_PIN_ATTEMPT: return Global.FAILURE, "Enabling SIM lock system has failed" self._logger.info("SIM is lock properly with default pin") # make this false, as tablet would not check pin until shutdown, and we have no connection to shutdown on dut after shutdown, so it could not be implemented for automation # for reboot code below is not verified if it works """ if self.__check_after_reboot : self.get_logger().info( "Checking that SIM lock is still enabled after a reboot") # Reboot the device self._device.reboot(wait_settledown_duration=True) # Check that the device state is unregistered self.__modem_api.check_cdk_state_bfor_timeout("unregistered", self._device.get_uecmd_timeout()) # Unlock SIM self.sim_card_api.supply_pin(self.__current_pin) # Check that SIM lock system is still enabled self._logger.info("Check that SIM lock system is still enabled") is_enabled = self.sim_card_api.get_sim_lock_state() if not is_enabled: return (Global.FAILURE, "SIM lock System is not "\ "persistent after a device reboot") # if self.__check_after_reboot = true, we need to add code to provide an available network to check ["searching", "registered", "roaming"] # Check that the device is able to camp on a cell self.__modem_api.check_cdk_state_bfor_timeout( ["searching", "registered", "roaming"], self._device.get_uecmd_timeout()) """ # 2. Change PIN code from default (current) to new PIN, no need to check if the current pin is correct, as I have already know the pin is default pin self._logger.info( "changing the sim pin from 4 digit default pin to 8 digits pin") try_left = self.sim_card_api.change_sim_pin(self.__default_pin, self.__new_pin) if try_left == self.sim_card_api.MAX_PIN_ATTEMPT: self._logger.info( "pin changed sucessfully with 8 digits new pin %s, the pin trying counter is %s" % (self.__new_pin, try_left)) # Check that SIM lock system is still enabled after change the pin is_enabled = self.sim_card_api.get_sim_lock_state() if not is_enabled: return ( Global.FAILURE, "failure: SIM lock system should not be disabled after having PIN changed to new pin" ) else: self._logger.info( "after SIM pin changed properly by using new pin %s, now we are removing the lock, as it is still locked after having PIN changed" % self.__new_pin) try_left = self.sim_card_api.disable_sim_lock_system( self.__new_pin) # Check that SIM lock system is disabled is_enabled = self.sim_card_api.get_sim_lock_state() if is_enabled and try_left != self.sim_card_api.MAX_PIN_ATTEMPT: return (Global.FAILURE, "SIM lock could not be disabled with new pin") else: # sim was disabled properly # testing pin trying counter entering wrong pin once to reduce the remaining counter, by enable the pin with wrong pin self._logger.info( "using the new pin %s to unlock the sim is successful, and Changing pin function works properly" % self.__new_pin) # 3. testing pin entering counter, by entering wrong pin to see the counter changes. self._logger.info( "after SIM pin is removed successfully with new pin, now we are testing pin enter counter via entering wrong pin" ) bad_pin = str( randrange(10000)).zfill(((len(str(self.__new_pin)) - 3) % 5) + 4) try_left = self.sim_card_api.enable_sim_lock_system(bad_pin) is_enabled = self.sim_card_api.get_sim_lock_state() if try_left == self.sim_card_api.MAX_PIN_ATTEMPT - 1 and not is_enabled: self._logger.info( "entered a wrong pin %s, and pin enter remaining counter is %d" % (bad_pin, try_left)) else: return ( Global.FAILURE, "entered a wrong pin the %s, and pin enter remaining counter is %d" % (bad_pin, try_left)) # 4. test if the pin goes back to MAX_PIN_ATTEMP before via entering a right pin try_left = self.sim_card_api.enable_sim_lock_system(self.__new_pin) is_enabled = self.sim_card_api.get_sim_lock_state() if try_left == self.sim_card_api.MAX_PIN_ATTEMPT and is_enabled: self._logger.info( "success: entered a right pin %s, and pin enter remaining counter is sent back to %d (%d is MAX_PIN_ATTEMP)" % (self.__default_pin, try_left, self.sim_card_api.MAX_PIN_ATTEMPT)) else: return ( Global.FAILURE, "failure: entered a right pin the %s, and pin enter remaining counter is %d" % (self.__default_pin, try_left)) # 5. testing puk counter. We only try one wrong puk code, as we do not want to reach max trying for puk if is_enabled: self._logger.info( "to test puk trying counter, it using a wrong pin until pin is blocked to test the puk re-try counter" ) sim_state = self.sim_card_api.get_sim_state() try_left == self.sim_card_api.MAX_PIN_ATTEMPT try_times = 1 while sim_state != self.sim_card_api.POSSIBLE_SIM_STATES[ "SIM_STATE_PUK_REQUIRED"]: bad_pin = str(randrange(10000)).zfill(( (len(str(self.__new_pin)) - 3) % 5) + 4) try_left = self.sim_card_api.disable_sim_lock_system(bad_pin) sim_state = self.sim_card_api.get_sim_state() self._logger.info( "pin trying counter is %s after entered the wrong pin at the trying #%d" % (try_left, try_times)) try_times = try_times + 1 if try_left == 10 and sim_state == self.sim_card_api.POSSIBLE_SIM_STATES[ "SIM_STATE_PUK_REQUIRED"]: self._logger.info( "pin MAX_PIN_ATTEMPT has reached, and sim is blocked and puk try counter is %d" % try_left) self._logger.info( "testing puk counter via entering puk code wrong once") bad_puk = str(int(self.__puk_code) + int(self.__puk_code)) try_lef = self.sim_card_api.supply_puk(bad_puk, self.__default_pin) sim_state = self.sim_card_api.get_sim_state() try_times = 1 if sim_state == self.sim_card_api.POSSIBLE_SIM_STATES[ "SIM_STATE_PUK_REQUIRED"]: self._logger.info( "current sim_state is %s, and puk remaining counter is %d at the #%d try_times" % (self.sim_card_api.state_list[sim_state], try_left, try_times)) # unblock the sim with right puk and default pin try_left = self.sim_card_api.supply_puk( self.__puk_code, self.__default_pin) sim_state = self.sim_card_api.get_sim_state() if try_left == 3 and sim_state == self.sim_card_api.POSSIBLE_SIM_STATES[ "SIM_STATE_PIN_REQUIRED"]: self._logger.info( "current sim_state is %s, and puk remaining counter is %d after unblock the sim pin" % (self.sim_card_api.state_list[sim_state], try_left)) else: self._logger.info( "current sim_state is %s, and puk remaining counter is %d after unblock the sim pin" % (self.sim_card_api.state_list[sim_state], try_left)) return Global.FAILURE, "Unable to unblock SIM after entering %d times" % self.sim_card_api.MAX_PIN_ATTEMPT else: self._logger.info("Unable to block sim after %d tries" % self.sim_card_api.MAX_PIN_ATTEMPT) return Global.FAILURE, "Unable to block device SIM after %d tries" % self.sim_card_api.MAX_PIN_ATTEMPT """ if self.__check_after_reboot: self.get_logger().info("Checking that SIM lock is still disabled after a reboot") # Reboot the device self._device.reboot(wait_settledown_duration=True) # if self.__check_after_reboot = true, we need to add code to provide an available network to check ["searching", "registered", "roaming"] # Check that the device is able to camp on a cell self.__modem_api.check_cdk_state_bfor_timeout( ["searching", "registered", "roaming"], self._device.get_uecmd_timeout()) # Check that SIM lock system is still disabled self._logger.info("Check that SIM lock system is still disabled") is_enabled = self.sim_card_api.get_sim_lock_state() if is_enabled: return (Global.FAILURE, "SIM lock System is not "\ "persistent after a device reboot") """ # test has been successful return Global.SUCCESS, "No error"