Example #1
0
 def setup_cellular_voice_calling(self):
     """Setup phone for voice general calling and make sure phone is
        attached to voice."""
     # Make sure Phone A and B are attached to voice network.
     for ad in self.ads:
         if not phone_setup_voice_general(self.log, ad):
             raise signals.TestFailure("Phone failed to setup for voice"
                                       " calling serial:%s" % ad.serial)
     self.log.debug("Finished setting up phones for voice calling")
Example #2
0
 def _test_power_active_call(self,
                             test_name,
                             test_setup_func,
                             pass_criteria=DEFAULT_POWER_PASS_CRITERIA,
                             phone_check_func_after_power_test=None,
                             *args,
                             **kwargs):
     average_current = 0
     try:
         ensure_phone_default_state(self.log, self.android_devices[0])
         ensure_phone_default_state(self.log, self.android_devices[1])
         if not phone_setup_voice_general(self.log,
                                          self.android_devices[1]):
             self.log.error("PhoneB Failed to Set Up Properly.")
             return False
         if not test_setup_func(self.android_devices[0], *args, **kwargs):
             self.log.error("DUT Failed to Set Up Properly.")
             return False
         result = self.mon.measure_power(ACTIVE_CALL_TEST_SAMPLING_RATE,
                                         ACTIVE_CALL_TEST_SAMPLE_TIME,
                                         test_name,
                                         ACTIVE_CALL_TEST_OFFSET_TIME)
         self._save_logs_for_power_test(test_name, result)
         average_current = result.average_current
         if not verify_incall_state(
                 self.log,
             [self.android_devices[0], self.android_devices[1]], True):
             self.log.error("Call drop during power test.")
             return False
         if ((phone_check_func_after_power_test is not None)
                 and (not phone_check_func_after_power_test(
                     self.log, self.android_devices[0]))):
             self.log.error(
                 "Phone is not in correct status after power test.")
             return False
         return (average_current <= pass_criteria)
     finally:
         self.android_devices[1].droid.telecomEndCall()
         self.log.info("Result: {} mA, pass criteria: {} mA".format(
             average_current, pass_criteria))
Example #3
0
    def test_sms_mo_4g(self):
        """Test SMS basic function between two phone. Phones in LTE network.

        Airplane mode is off.
        Send SMS from PhoneA to PhoneB.
        Verify received message on PhoneB is correct.

        Returns:
            True if success.
            False if failed.
        """

        ads = self.android_devices
        # TODO: this is a temporary fix for this test case.
        # A better fix will be introduced once pag/539845 is merged.
        if not phone_setup_voice_general(self.log, ads[1]):
            self.log.error("Failed to setup PhoneB.")
            return False
        if not ensure_network_generation(self.log, ads[0], GEN_4G):
            self.log.error("DUT Failed to Set Up Properly.")
            return False

        return self._sms_test_mo(ads)
    def _crash_recovery_test(self, **kwargs):
        """Crash Recovery Test

        Arguments:
            check_lte_data: whether to check the LTE data.
            check_volte: whether to check Voice over LTE.
            check_vt: whether to check VT
            check_wfc: whether to check Wifi Calling.

        Expected Results:
            All Features should work as intended post crash recovery

        Returns:
            True is pass, False if fail.
        """
        CHECK_INTERVAL = 10

        toggle_airplane_mode(self.log, self.dut, False)
        phone_setup_voice_general(self.log, self.ad_reference)
        fail_count = collections.defaultdict(int)
        test_result = True
        test_method_mapping = {
            "check_provision": self._check_provision,
            "check_call_setup_teardown": self._check_call_setup_teardown,
            "check_lte_data": self._check_lte_data,
            "check_volte": self._check_volte,
            "check_vt": self._check_vt,
            "check_wfc": self._check_wfc,
            "check_3g": self._check_3g,
            "check_tethering": self._check_tethering,
            "check_data_roaming": self._check_data_roaming_status,
            "clear_provision": self._clear_provisioning
        }
        for kwarg in kwargs:
            if kwarg not in test_method_mapping:
                self.log.error("method %s is not supported" % method)

        required_methods = []
        for method in test_method_mapping.keys():
            if method in kwargs: required_methods.append(method)

        process_list = ("rild", "netmgrd", "com.android.phone", "imsqmidaemon",
                        "imsdatadaemon", "ims_rtp_daemon", "netd",
                        "com.android.ims.rcsservice", "system_server", "cnd",
                        "modem")
        for service in process_list:
            iteration_result = "pass"
            self.log.info("Crash Recover Test for Process <%s>" % service)
            self.log.info("%s kill Process %s" % (self.dut.serial, service))
            if service == "modem":
                trigger_modem_crash(self.log, self.dut)
                time.sleep(WAIT_TIME_AFTER_CRASH * 2)
            else:
                process_pid = self.dut.adb.shell("pidof %s" % service)
                self.log.info("%s is the pidof %s" % (process_pid, service))
                if not process_pid:
                    self.dut.log.error("Process %s not running" % service)
                    iteration_result = "fail"
                if service == "netd" or service == "system_server":
                    self.dut.stop_services()
                self.dut.adb.shell("kill -9 %s" % process_pid,
                                   ignore_status=True)
                self.log.info("%s wait %d sec for radio up." %
                              (self.dut.serial, WAIT_TIME_AFTER_CRASH))
                time.sleep(WAIT_TIME_AFTER_CRASH)
                if service == "netd" or service == "system_server":
                    self.dut.start_services()
                process_pid_new = self.dut.adb.shell("pidof %s" % service)
                if process_pid == process_pid_new:
                    self.log.error("kill failed old:%s new:%s" %
                                   (process_pid, process_pid_new))
            for check in required_methods:
                if not test_method_mapping[check]():
                    fail_count[check] += 1
                    iteration_result = "fail"
            self.log.info("Crash Recover Test for Process <%s> %s" %
                          (service, iteration_result))
        for failure, count in fail_count.items():
            if count:
                self.log.error("%d %s failures" % (count, failure))
                test_result = False
        return test_result
    def _reboot_stress_test(self, **kwargs):
        """Reboot Reliability Test

        Arguments:
            check_provision: whether to check provisioning after reboot.
            check_call_setup_teardown: whether to check setup and teardown a call.
            check_lte_data: whether to check the LTE data.
            check_volte: whether to check Voice over LTE.
            check_wfc: whether to check Wifi Calling.
            check_3g: whether to check 3G.
            check_tethering: whether to check Tethering.
            check_data_roaming: whether to check Data Roaming.
            clear_provision: whether to clear provisioning before reboot.

        Expected Results:
            No crash happens in stress test.

        Returns:
            True is pass, False if fail.
        """
        CHECK_INTERVAL = 10

        toggle_airplane_mode(self.log, self.dut, False)
        phone_setup_voice_general(self.log, self.ad_reference)
        fail_count = collections.defaultdict(int)
        test_result = True
        test_method_mapping = {
            "check_provision": self._check_provision,
            "check_call_setup_teardown": self._check_call_setup_teardown,
            "check_lte_data": self._check_lte_data,
            "check_volte": self._check_volte,
            "check_wfc": self._check_wfc,
            "check_3g": self._check_3g,
            "check_tethering": self._check_tethering,
            "check_data_roaming": self._check_data_roaming_status,
            "clear_provision": self._clear_provisioning
        }
        for kwarg in kwargs:
            if kwarg not in test_method_mapping:
                self.log.error("method %s is not supported" % method)

        required_methods = []
        for method in test_method_mapping.keys():
            if method in kwargs: required_methods.append(method)

        for i in range(1, self.stress_test_number + 1):
            self.log.info(
                "Reboot Stress Test {} Iteration: <{}> / <{}>".format(
                    self.test_name, i, self.stress_test_number))

            self.log.info("{} reboot!".format(self.dut.serial))
            self.dut.reboot()
            self.log.info("{} wait {}s for radio up.".format(
                self.dut.serial, WAIT_TIME_AFTER_REBOOT))
            time.sleep(WAIT_TIME_AFTER_REBOOT)
            iteration_result = "pass"
            for check in required_methods:
                if not test_method_mapping[check]():
                    fail_count[check] += 1
                    iteration_result = "fail"
            self.log.info(
                "Reboot Stress Test {} Iteration: <{}> / <{}> {}".format(
                    self.test_name, i, self.stress_test_number,
                    iteration_result))

            # TODO: Check if crash happens.

        for failure, count in fail_count.items():
            if count:
                self.log.error("{} {} failures in {} iterations".format(
                    count, failure, self.stress_test_number))
                test_result = False
        return test_result
    def test_reboot_stress_without_clear_provisioning(self):
        """Reboot Reliability Test without Clear Provisioning

        Steps:
            1. Reboot DUT.
            2. Check Provisioning bit (if support provisioning)
            3. Wait for DUT to camp on LTE, Verify Data.
            4. Enable VoLTE, check IMS registration. Wait for DUT report VoLTE
                enabled, make VoLTE call. And verify VoLTE SMS.
                (if support VoLTE)
            5. Connect WiFi, enable WiFi Calling, wait for DUT report WiFi
                Calling enabled and make a WFC call and verify SMS.
                Disconnect WiFi. (if support WFC)
            6. Wait for DUT to camp on 3G, Verify Data.
            7. Make CS call and verify SMS.
            8. Verify Tethering Entitlement Check and Verify WiFi Tethering.
            9. Check crashes.
            10. Repeat Step 1~9 for N times.

        Expected Results:
            No crash happens in stress test.

        Returns:
            True is pass, False if fail.
        """

        toggle_airplane_mode(self.log, self.dut, False)
        phone_setup_voice_general(self.log, self.ad_reference)

        for i in range(1, self.stress_test_number + 1):
            self.log.info("Reboot Stress Test Iteration: <{}> / <{}>".
                format(i, self.stress_test_number))

            self.log.info("{} reboot!".format(self.dut.serial))
            self.dut.reboot()
            self.log.info("{} wait {}s for radio up.".format(
                self.dut.serial, WAIT_TIME_AFTER_REBOOT))
            time.sleep(WAIT_TIME_AFTER_REBOOT)

            if not self._check_provisioning(self.dut):
                self.log.error("Provisioning fail.")
                return False

            if not self._check_lte_data(self.dut):
                self.log.error("LTE Data fail.")
                return False

            if not self._check_volte(self.dut, self.ad_reference):
                self.log.error("VoLTE fail.")
                return False

            if not self._check_wfc(self.dut, self.ad_reference):
                self.log.error("WFC fail.")
                return False

            if not self._check_3g(self.dut, self.ad_reference):
                self.log.error("3G fail.")
                return False

            if not self._check_tethering(self.dut, self.ad_reference):
                self.log.error("Tethering fail.")
                return False

            # TODO: Check if crash happens.

            self.log.info("Iteration: <{}> / <{}> Pass".
                format(i, self.stress_test_number))

        return True
 def _phone_setup_voice_general(self):
     return phone_setup_voice_general(self.log, self.android_devices[0])
    def _cbrs_call_sequence(
            self, ads, mo_mt, cbrs_phone_setup_func,
            verify_cbrs_initial_idle_func, verify_data_initial_func,
            verify_cbrs_in_call_state_func, verify_data_in_call_func,
            incall_cbrs_setting_check_func, verify_data_final_func,
            verify_cbrs_final_func, expected_result):
        """_cbrs_call_sequence

        Args:
            ads: list of android devices. This list should have 2 ad.
            mo_mt: indicating this call sequence is MO or MT.
                Valid input: DIRECTION_MOBILE_ORIGINATED and
                DIRECTION_MOBILE_TERMINATED.

        Returns:
            if expected_result is True,
                Return True if call sequence finish without exception.
            if expected_result is string,
                Return True if expected exception happened. Otherwise False.

        """
        class _CBRSCallSequenceException(Exception):
            pass

        if (len(ads) != 2) or (mo_mt not in [
                DIRECTION_MOBILE_ORIGINATED, DIRECTION_MOBILE_TERMINATED
        ]):
            self.log.error("Invalid parameters.")
            return False

        self.cbrs_subid, self.default_subid = get_cbrs_and_default_sub_id(
            ads[0])

        if mo_mt == DIRECTION_MOBILE_ORIGINATED:
            ad_caller = ads[0]
            ad_callee = ads[1]
            caller_number = get_phone_number(self.log, ad_caller)
            callee_number = get_phone_number(self.log, ad_callee)
            mo_operator = get_operator_name(ads[0].log, ads[0])
            mt_operator = get_operator_name(ads[1].log, ads[1])
        else:
            ad_caller = ads[1]
            ad_callee = ads[0]
            caller_number = get_phone_number(self.log, ad_caller)
            callee_number = get_phone_number(self.log, ad_callee)
            mt_operator = get_operator_name(ads[0].log, ads[0])
            mo_operator = get_operator_name(ads[1].log, ads[1])

        self.log.info("-->Begin cbrs_call_sequence: %s to %s<--",
                      caller_number, callee_number)
        self.log.info("--> %s to %s <--", mo_operator, mt_operator)

        try:
            # Setup
            if cbrs_phone_setup_func and not cbrs_phone_setup_func():
                raise _CBRSCallSequenceException("cbrs_phone_setup_func fail.")
            if not phone_setup_voice_general(self.log, ads[1]):
                raise _CBRSCallSequenceException(
                    "phone_setup_voice_general fail.")
            time.sleep(WAIT_TIME_BETWEEN_REG_AND_CALL)

            # Ensure idle status correct
            if verify_cbrs_initial_idle_func and not \
                verify_cbrs_initial_idle_func():
                raise _CBRSCallSequenceException(
                    "verify_cbrs_initial_idle_func fail.")

            # Ensure data checks are performed
            if verify_data_initial_func and not \
                verify_data_initial_func():
                raise _CBRSCallSequenceException(
                    "verify_data_initial_func fail.")

            # Make MO/MT call.
            if not initiate_call(self.log, ad_caller, callee_number):
                raise _CBRSCallSequenceException("initiate_call fail.")
            if not wait_and_answer_call(self.log, ad_callee, caller_number):
                raise _CBRSCallSequenceException("wait_and_answer_call fail.")
            time.sleep(WAIT_TIME_FOR_CBRS_DATA_SWITCH)

            # Check state, wait 30 seconds, check again.
            if (verify_cbrs_in_call_state_func
                    and not verify_cbrs_in_call_state_func()):
                raise _CBRSCallSequenceException(
                    "verify_cbrs_in_call_state_func fail.")

            if is_phone_not_in_call(self.log, ads[1]):
                raise _CBRSCallSequenceException("PhoneB not in call.")

            # Ensure data checks are performed
            if verify_data_in_call_func and not \
                verify_data_in_call_func():
                raise _CBRSCallSequenceException(
                    "verify_data_in_call_func fail.")

            time.sleep(WAIT_TIME_IN_CALL)

            if (verify_cbrs_in_call_state_func
                    and not verify_cbrs_in_call_state_func()):
                raise _CBRSCallSequenceException(
                    "verify_cbrs_in_call_state_func fail after 30 seconds.")
            if is_phone_not_in_call(self.log, ads[1]):
                raise _CBRSCallSequenceException(
                    "PhoneB not in call after 30 seconds.")

            # in call change setting and check
            if (incall_cbrs_setting_check_func
                    and not incall_cbrs_setting_check_func()):
                raise _CBRSCallSequenceException(
                    "incall_cbrs_setting_check_func fail.")

            # Hangup call
            if is_phone_in_call(self.log, ads[0]):
                if not hangup_call(self.log, ads[0]):
                    raise _CBRSCallSequenceException("hangup_call fail.")
            else:
                if incall_cbrs_setting_check_func is None:
                    raise _CBRSCallSequenceException("Unexpected call drop.")

            time.sleep(WAIT_TIME_FOR_CBRS_DATA_SWITCH)

            # Ensure data checks are performed
            if verify_data_final_func and not \
                verify_data_final_func():
                raise _CBRSCallSequenceException(
                    "verify_data_final_func fail.")

            # Ensure data checks are performed
            if verify_cbrs_final_func and not \
                verify_cbrs_final_func():
                raise _CBRSCallSequenceException(
                    "verify_cbrs_final_func fail.")

        except _CBRSCallSequenceException as e:
            if str(e) == expected_result:
                self.log.info("Expected exception: <%s>, return True.", e)
                return True
            else:
                self.log.info("Unexpected exception: <%s>, return False.", e)
                return False
        finally:
            for ad in ads:
                if ad.droid.telecomIsInCall():
                    hangup_call_by_adb(ad)
        self.log.info("cbrs_call_sequence finished, return %s",
                      expected_result is True)
        return (expected_result is True)