コード例 #1
0
 def _data_call_test(self, sub_id, generation):
     self.dut.log.info(dict(self.result_info))
     begin_time = get_device_epoch_time(self.dut)
     start_qxdm_loggers(self.log, self.android_devices)
     self.result_info["Network Change Request Total"] += 1
     test_name = "%s_network_change_test_iter_%s" % (
         self.test_name, self.result_info["Network Change Request Total"])
     log_msg = "[Test Case] %s" % test_name
     self.log.info("%s begin", log_msg)
     self.dut.droid.logI("%s begin" % log_msg)
     if not ensure_network_generation_for_subscription(
             self.log, self.dut, sub_id,
             generation) or not self._check_data():
         self.result_info["Network Change Failure"] += 1
         self.dut.droid.logI("%s end" % log_msg)
         self.dut.log.info("%s end", log_msg)
         try:
             self._ad_take_extra_logs(self.dut, test_name, begin_time)
             self._ad_take_bugreport(self.dut, test_name, begin_time)
         except Exception as e:
             self.log.warning(e)
         return False
     if not self._mobile_data_toggling(setup=None):
         return False
     return True
コード例 #2
0
 def _mobile_data_toggling(self, setup="volte"):
     # ModePref change to non-LTE
     begin_time = get_device_epoch_time(self.dut)
     start_qxdm_loggers(self.log, self.android_devices)
     result = True
     self.result_info["Data Toggling Request Total"] += 1
     test_name = "%s_data_toggling_iter_%s" % (
         self.test_name, self.result_info["Data Toggling Request Total"])
     log_msg = "[Test Case] %s" % test_name
     self.log.info("%s begin", log_msg)
     self.dut.droid.logI("%s begin" % log_msg)
     self.dut.adb.shell("svc data disable")
     time.sleep(WAIT_TIME_AFTER_MODE_CHANGE)
     self.dut.adb.shell("svc data enable")
     if not self._check_data():
         result = False
     elif setup == "volte" and not phone_idle_volte(self.log, self.dut):
         result = False
     self.dut.droid.logI("%s end" % log_msg)
     self.dut.log.info("%s end", log_msg)
     if not result:
         self.result_info["Data Toggling Failure"] += 1
         try:
             self._ad_take_extra_logs(self.dut, test_name, begin_time)
             self._ad_take_bugreport(self.dut, test_name, begin_time)
         except Exception as e:
             self.log.exception(e)
         return False
     else:
         self.result_info["Data Toggling Success"] += 1
         return True
コード例 #3
0
 def crash_check_test(self):
     failure = 0
     while time.time() < self.finishing_time:
         try:
             self.log.info(dict(self.result_info))
             self._update_perf_json()
             begin_time = get_device_epoch_time(self.dut)
             run_time_in_seconds = (begin_time - self.begin_time) / 1000
             test_name = "%s_crash_%s_seconds_after_start" % (
                 self.test_name, run_time_in_seconds)
             time.sleep(self.crash_check_interval)
             for ad in self.android_devices:
                 crash_report = ad.check_crash_report(
                     test_name, begin_time, log_crash_report=True)
                 if crash_report:
                     ad.log.error("Find new crash reports %s", crash_report)
                     failure += 1
                     self.result_info["Crashes"] += len(crash_report)
                     for crash in crash_report:
                         if "ramdump_modem" in crash:
                             self.result_info["Crashes-Modem"] += 1
                     try:
                         ad.take_bug_report(test_name, begin_time)
                     except Exception as e:
                         self.log.exception(e)
         except Exception as e:
             self.log.error("Exception error %s", str(e))
             self.result_info["Exception Errors"] += 1
         self.log.info("Crashes found: %s", failure)
         if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
             self.log.error("Too many exception errors, quit test")
             return False
     if failure:
         return False
     else:
         return True
コード例 #4
0
    def _prefnetwork_mode_change(self, sub_id):
        # ModePref change to non-LTE
        begin_time = get_device_epoch_time(self.dut)
        start_qxdm_loggers(self.log, self.android_devices)
        self.result_info["Network Change Request Total"] += 1
        test_name = "%s_network_change_iter_%s" % (
            self.test_name, self.result_info["Network Change Request Total"])
        log_msg = "[Test Case] %s" % test_name
        self.log.info("%s begin", log_msg)
        self.dut.droid.logI("%s begin" % log_msg)
        network_preference_list = [
            NETWORK_MODE_TDSCDMA_GSM_WCDMA, NETWORK_MODE_WCDMA_ONLY,
            NETWORK_MODE_GLOBAL, NETWORK_MODE_CDMA, NETWORK_MODE_GSM_ONLY
        ]
        network_preference = random.choice(network_preference_list)
        set_preferred_network_mode_pref(self.log, self.dut, sub_id,
                                        network_preference)
        time.sleep(WAIT_TIME_AFTER_MODE_CHANGE)
        self.dut.log.info("Current Voice RAT is %s",
                          get_current_voice_rat(self.log, self.dut))

        # ModePref change back to with LTE
        if not phone_setup_volte(self.log, self.dut):
            self.dut.log.error("Phone failed to enable VoLTE.")
            self.result_info["VoLTE Setup Failure"] += 1
            self.dut.droid.logI("%s end" % log_msg)
            self.dut.log.info("%s end", log_msg)
            try:
                self._ad_take_extra_logs(self.dut, test_name, begin_time)
                self._ad_take_bugreport(self.dut, test_name, begin_time)
            except Exception as e:
                self.log.exception(e)
            return False
        else:
            self.result_info["VoLTE Setup Success"] += 1
            return True
 def _cbrs_default_data_switch_timing(self, ad, method, validation=False):
     result = True
     callback_key = None
     if not getattr(ad, "cbrs_droid", None):
         ad.cbrs_droid, ad.cbrs_ed = ad.get_droid()
         ad.cbrs_ed.start()
     else:
         try:
             if not ad.cbrs_droid.is_live:
                 ad.cbrs_droid, ad.cbrs_ed = ad.get_droid()
                 ad.cbrs_ed.start()
             else:
                 ad.cbrs_ed.clear_all_events()
             ad.cbrs_droid.logI("Start test_stress_cbrsdataswitch test")
         except Exception:
             ad.log.info("Create new sl4a session for CBRS")
             ad.cbrs_droid, ad.cbrs_ed = ad.get_droid()
             ad.cbrs_ed.start()
     if validation:
         ad.cbrs_droid.telephonyStartTrackingActiveDataChange()
     else:
         callback_key = ad.cbrs_droid.connectivityRegisterDefaultNetworkCallback(
         )
         ad.cbrs_droid.connectivityNetworkCallbackStartListeningForEvent(
             callback_key, NetworkCallbackAvailable)
     time.sleep(WAIT_TIME_FOR_CBRS_DATA_SWITCH)
     try:
         ad.cbrs_ed.clear_events(EventActiveDataSubIdChanged)
         ad.cbrs_ed.clear_events(EventNetworkCallback)
         initiate_time_before = get_device_epoch_time(ad)
         ad.log.debug("initiate_time_before: %d", initiate_time_before)
         if method == "api":
             ad.log.info("Setting DDS to default sub %s",
                         self.default_subid)
             ad.droid.telephonySetPreferredOpportunisticDataSubscription(
                 2147483647, validation)
         else:
             ad.log.info("Making a Voice Call to %s", STORY_LINE)
             ad.droid.telecomCallNumber(STORY_LINE, False)
         try:
             if validation:
                 events = ad.cbrs_ed.pop_events(
                     "(%s)" % (EventActiveDataSubIdChanged),
                     WAIT_TIME_FOR_CBRS_DATA_SWITCH)
                 for event in events:
                     ad.log.info("Got event %s", event["name"])
                     if event["name"] == EventActiveDataSubIdChanged:
                         if event.get("data") and \
                                 event["data"] == self.default_subid:
                             ad.log.info("%s has data switched to: %s sub",
                                         event["name"], event["data"])
                             initiate_time_after = event["time"]
                         break
             else:
                 events = ad.cbrs_ed.pop_events(
                     "(%s)" % (EventNetworkCallback),
                     WAIT_TIME_FOR_CBRS_DATA_SWITCH)
                 for event in events:
                     ad.log.info("Got event %s", event["name"])
                     if event["name"] == EventNetworkCallback:
                         if event.get("data") and event["data"].get(
                                 "networkCallbackEvent"):
                             ad.log.info(
                                 "%s %s has data switched to: %s sub",
                                 event["name"],
                                 event["data"]["networkCallbackEvent"],
                                 self.default_subid)
                             initiate_time_after = event["time"]
                         break
         except Empty:
             ad.log.error(
                 "No %s or %s event for DataSwitch received in %d seconds",
                 EventActiveDataSubIdChanged, EventNetworkCallback,
                 WAIT_TIME_FOR_CBRS_DATA_SWITCH)
             return False
         time_interval = (initiate_time_after - initiate_time_before) / 1000
         self.switch_time_dict['cbrs_default_switch'].append(time_interval)
         if time_interval > TIME_PERMITTED_FOR_CBRS_SWITCH:
             ad.log.error("Time for CBRS->Default - %.2f secs",
                          time_interval)
             result = False
         else:
             ad.log.info("Time for CBRS->Default - %.2f secs",
                         time_interval)
         time.sleep(WAIT_TIME_BETWEEN_HANDOVER)
         ad.cbrs_ed.clear_events(EventActiveDataSubIdChanged)
         ad.cbrs_ed.clear_events(EventNetworkCallback)
         hangup_time_before = get_device_epoch_time(ad)
         ad.log.debug("hangup_time_before: %d", hangup_time_before)
         if method == "api":
             ad.log.info("Setting DDS to cbrs sub %s", self.cbrs_subid)
             ad.droid.telephonySetPreferredOpportunisticDataSubscription(
                 self.cbrs_subid, validation)
         else:
             ad.log.info("Ending Call")
             ad.droid.telecomEndCall()
         try:
             if validation:
                 events = ad.cbrs_ed.pop_events(
                     "(%s)" % (EventActiveDataSubIdChanged),
                     WAIT_TIME_FOR_CBRS_DATA_SWITCH)
                 for event in events:
                     ad.log.info("Got event %s", event["name"])
                     if event["name"] == EventActiveDataSubIdChanged:
                         if event.get("data") and \
                                 event["data"] == self.cbrs_subid:
                             ad.log.info("%s has data switched to: %s sub",
                                         event["name"], event["data"])
                             hangup_time_after = event["time"]
                         break
             else:
                 events = ad.cbrs_ed.pop_events(
                     "(%s)" % (EventNetworkCallback),
                     WAIT_TIME_FOR_CBRS_DATA_SWITCH)
                 for event in events:
                     ad.log.info("Got event %s", event["name"])
                     if event["name"] == EventNetworkCallback:
                         if event.get("data") and event["data"].get(
                                 "networkCallbackEvent"):
                             ad.log.info(
                                 "%s %s has data switched to: %s sub",
                                 event["name"],
                                 event["data"]["networkCallbackEvent"],
                                 self.cbrs_subid)
                             hangup_time_after = event["time"]
                         break
         except Empty:
             ad.log.error(
                 "No %s event for DataSwitch received in %d seconds",
                 EventActiveDataSubIdChanged,
                 WAIT_TIME_FOR_CBRS_DATA_SWITCH)
             return False
         time_interval = (hangup_time_after - hangup_time_before) / 1000
         self.switch_time_dict['default_cbrs_switch'].append(time_interval)
         if time_interval > TIME_PERMITTED_FOR_CBRS_SWITCH:
             ad.log.error("Time for Default->CBRS - %.2f secs",
                          time_interval)
             result = False
         else:
             ad.log.info("Time for Default->CBRS - %.2f secs",
                         time_interval)
     except Exception as e:
         self.log.error("Exception error %s", e)
         raise
     finally:
         if validation:
             ad.cbrs_droid.telephonyStopTrackingActiveDataChange()
         elif callback_key:
             ad.cbrs_droid.connectivityNetworkCallbackStopListeningForEvent(
                 callback_key, NetworkCallbackAvailable)
     return result
    def call_setup_and_connectivity_monitor_checking(self,
                                                     setup=None,
                                                     handover=None,
                                                     triggers=[],
                                                     expected_drop_reason="",
                                                     expected_trouble=None,
                                                     expected_action=None):

        call_verification_function = None
        begin_time = get_device_epoch_time(self.dut)
        call_data_summary_before = self.parsing_call_summary()
        call_statistics_before = self.parsing_call_statistics()
        self.parsing_diagnostics()
        self.parsing_troubleshooter_database()
        bugreport_database_before = self.parsing_bugreport_database()

        if expected_drop_reason:
            expected_drop_reasons = set(expected_drop_reason.split("|"))
        else:
            expected_drop_reasons = set()
        checking_counters = ["Calls"]
        checking_reasons = []
        result = True
        if setup in ("wfc_apm", "wfc_non_apm"):
            call_verification_function = is_phone_in_call_iwlan
        elif setup == "volte":
            call_verification_function = is_phone_in_call_volte
        elif setup == "csfb":
            call_verification_function = is_phone_in_call_csfb
        elif setup == "3g":
            call_verification_function = is_phone_in_call_3g
        elif setup == "2g":
            call_verification_function = is_phone_in_call_2g
        technology = handover or setup
        if technology in ("wfc_apm", "wfc_non_apm"):
            if triggers and triggers[0] not in IGNORED_CALL_DROP_TRIGGERS:
                checking_counters.extend(
                    ["Calls_dropped", "VOWIFI", "VOWIFI_dropped"])
                checking_reasons.append("VOWIFI_failure_reason")
            elif call_data_summary_before.get("Calls_dropped", 0):
                checking_counters.append("VOWIFI")
        elif technology == "volte":
            if triggers and triggers[0] not in IGNORED_CALL_DROP_TRIGGERS:
                checking_counters.extend(
                    ["Calls_dropped", "VOLTE", "VOLTE_dropped"])
                checking_reasons.append("VOLTE_failure_reason")
            elif call_data_summary_before.get("Calls_dropped", 0):
                checking_counters.append("VOLTE")
        elif technology in ("csfb", "3g", "2g"):
            if triggers and triggers[0] not in IGNORED_CALL_DROP_TRIGGERS:
                checking_counters.extend(["Calls_dropped", "CS", "CS_dropped"])
                checking_reasons.append("CS_failure_reason")
            elif call_data_summary_before.get("Calls_dropped", 0):
                checking_counters.append("CS")

        if setup == "vt":
            if not video_call_setup_teardown(
                    self.log,
                    self.dut,
                    self.ad_reference,
                    None,
                    video_state=VT_STATE_BIDIRECTIONAL,
                    verify_caller_func=is_phone_in_call_video_bidirectional,
                    verify_callee_func=is_phone_in_call_video_bidirectional):
                raise signals.TestFailure("VT Call Failed.")
        else:
            if not call_setup_teardown(
                    self.log,
                    self.dut,
                    self.ad_reference,
                    ad_hangup=None,
                    verify_caller_func=call_verification_function,
                    wait_time_in_call=10):
                raise signals.TestFailure("Call Setup Failed.")

        for trigger in triggers:
            if self.dut.droid.telecomIsInCall():
                self.dut.log.info("Telecom is in call")
                self.dut.log.info(
                    "Voice in RAT %s",
                    self.dut.droid.telephonyGetCurrentVoiceNetworkType())
            else:
                self.dut.log.info("Not in call")
            # Trigger in-call event
            if trigger and getattr(self, trigger, None):
                trigger_func = getattr(self, trigger)
                trigger_func()
                time.sleep(MAX_WAIT_TIME_FOR_STATE_CHANGE)

        if self.dut.droid.telecomIsInCall():
            self.dut.log.info("Telecom is in call")
            self.dut.log.info(
                "Voice in RAT %s",
                self.dut.droid.telephonyGetCurrentVoiceNetworkType())
        else:
            self.dut.log.info("Not in call")

        if self.dut.droid.telecomIsInCall():
            self.dut.log.info("Telecom is in call")
            self.dut.log.info(
                "Voice in RAT %s",
                self.dut.droid.telephonyGetCurrentVoiceNetworkType())
        else:
            self.dut.log.info("Not in call")

        drop_reason = last_call_drop_reason(self.dut, begin_time)
        drop_reason = drop_reason.title()
        if drop_reason:
            expected_drop_reasons.add(drop_reason)
        for ad in (self.ad_reference, self.dut):
            try:
                if ad.droid.telecomIsInCall():
                    if triggers:
                        ad.log.info("Still in call after triggers %s",
                                    triggers)
                        result = False
                    hangup_call(self.log, ad)
                    time.sleep(MAX_WAIT_TIME_FOR_STATE_CHANGE)
            except Exception as e:
                ad.log.error(e)

        call_data_summary_after = self.parsing_call_summary()
        call_statistics_after = self.parsing_call_statistics()
        diagnostics_after = self.parsing_diagnostics()
        ts_database_after = self.parsing_troubleshooter_database()

        for counter in checking_counters:
            if call_data_summary_after.get(
                    counter,
                    0) != call_data_summary_before.get(counter, 0) + 1:
                self.dut.log.error("Counter %s did not increase", counter)
                result = False
            else:
                self.dut.log.info("Counter %s increased", counter)
            if counter == "Calls":
                if call_statistics_after.get("num_calls",
                                             0) - call_statistics_before.get(
                                                 "num_calls", 0) < 1:
                    self.dut.log.warning(
                        "call_statistics num_calls didn't increase")
                    # result = False
                else:
                    self.dut.log.info("call_statistics num_calls increased")
            if "_dropped" in counter and counter != "Calls_dropped":
                desc = counter.split("_")[0]
                if desc == "VOWIFI":
                    stat_key = "recent_wfc_fail_count"
                else:
                    stat_key = "recent_%s_fail_count" % desc.lower()
                before = call_statistics_after.get(stat_key, 0)
                after = call_statistics_after.get(stat_key, 0)
                most_failure_call_type = call_statistics_after.get(
                    "call_type_with_most_failures")
                diagnosis = diagnostics_after.get("diagnosis")
                actions = diagnostics_after.get("actions")
                if after - before < 1:
                    self.dut.log.warning("call_statistics %s didn't increase, "
                                         "before %s, after %s" %
                                         (stat_key, before, after))
                    # result = False
                else:
                    self.dut.log.info("call_statistics %s increased", stat_key)
                if most_failure_call_type != desc:
                    self.dut.log.warning(
                        "call_statistics call_type_with_most_failures "
                        "is %s, not %s", most_failure_call_type, desc)
                else:
                    self.dut.log.info(
                        "call_statistics call_type_with_most_failures is %s",
                        most_failure_call_type)
                dropped = call_data_summary_after.get("%s_dropped" % desc, 0)
                drop_percentage = call_data_summary_after.get(
                    "%s_dropped_percentage" % desc, 0)
                self.dut.log.info("%s_dropped = %s, percentage = %s", desc,
                                  dropped, drop_percentage)
                if expected_trouble and expected_trouble != diagnosis:
                    self.dut.log.warning("diagnoisis = %s, expecting %s",
                                         diagnosis, expected_trouble)
                if expected_action and expected_action != actions:
                    self.dut.log.error("actions = %s, expecting %s", actions,
                                       expected_action)
                    result = False
                if drop_percentage > CALL_TROUBLE_THRESHOLD and (
                        dropped > CONSECUTIVE_CALL_FAILS):
                    if diagnosis == "UNABLE_TO_TRIAGE":
                        self.dut.log.error(
                            "troubleshooter diagnosis is %s with %s dropped "
                            "and %s drop_percentage", diagnosis, dropped,
                            drop_percentage)
                        result = False
                    if actions == "NONE":
                        self.dut.log.error(
                            "troubleshooter failed to provide suggestion, "
                            "actions = %s", actions)
                        result = False
        if expected_drop_reasons:
            expected_drop_reason = "|".join(expected_drop_reasons)
        for reason_key in checking_reasons:
            if call_data_summary_after.get(reason_key, None):
                drop_reason = call_data_summary_after[reason_key]
                if expected_drop_reason and drop_reason not in expected_drop_reason:
                    self.dut.log.error("%s is: %s, expecting %s", reason_key,
                                       drop_reason, expected_drop_reason)
                    result = False
                else:
                    self.dut.log.info("%s is: %s as expected", reason_key,
                                      drop_reason)
            else:
                self.dut.log.error("%s is not provided in summary report",
                                   reason_key)
                result = False

        if not triggers or triggers[0] in IGNORED_CALL_DROP_TRIGGERS:
            return result
        if drop_reason in bugreport_database_before:
            self.dut.log.info("%s is in bugreport database %s before call",
                              drop_reason, bugreport_database_before)
            return result
        else:
            self.dut.log.info("%s is not in bugreport database %s before call",
                              drop_reason, bugreport_database_before)
        if drop_reason in IGNORED_CALL_DROP_REASONS:
            self.dut.log.info(
                "Call drop with reason %s will skip bugreport notification",
                drop_reason)
            return result
        else:
            self.dut.log.info(
                "Call drop %s should generate bugreport notification",
                drop_reason)
        # Parse logcat for UI notification only for the first failure
        if self.dut.search_logcat("Bugreport notification title Call Drop:",
                                  begin_time):
            self.dut.log.info(
                "Bugreport notification title Call Drop is seen in logcat")
            return result
        else:
            self.dut.log.error(
                "Bugreport notification title Call Drop is not seen in logcat")
            return False
    def _data_stall_detection_recovery(self, set_simulation_func, rat):
        try:
            [self.bts1] = set_simulation_func(self.anritsu, self.user_params,
                                              self.ad.sim_card)
            set_usim_parameters(self.anritsu, self.ad.sim_card)
            set_post_sim_params(self.anritsu, self.user_params,
                                self.ad.sim_card)

            self.anritsu.start_simulation()

            if rat == RAT_LTE:
                preferred_network_setting = NETWORK_MODE_LTE_CDMA_EVDO
                rat_family = RAT_FAMILY_LTE
            elif rat == RAT_WCDMA:
                preferred_network_setting = NETWORK_MODE_GSM_UMTS
                rat_family = RAT_FAMILY_UMTS
            elif rat == RAT_GSM:
                preferred_network_setting = NETWORK_MODE_GSM_ONLY
                rat_family = RAT_FAMILY_GSM
            elif rat == RAT_1XRTT:
                preferred_network_setting = NETWORK_MODE_CDMA
                rat_family = RAT_FAMILY_CDMA2000
            else:
                self.log.error("No valid RAT provided for Data Stall test.")
                return False

            if not ensure_network_rat(self.log,
                                      self.ad,
                                      preferred_network_setting,
                                      rat_family,
                                      toggle_apm_after_setting=True):
                self.log.error(
                    "Failed to set rat family {}, preferred network:{}".format(
                        rat_family, preferred_network_setting))
                return False

            self.anritsu.wait_for_registration_state()
            time.sleep(self.SETTLING_TIME)

            self.bts1.output_level = self.start_power_level

            cmd = ('ss -l -p -n | grep "tcp.*droid_script" | tr -s " " '
                   '| cut -d " " -f 5 | sed s/.*://g')
            sl4a_port = self.ad.adb.shell(cmd)

            if not test_data_browsing_success_using_sl4a(self.log, self.ad):
                self.ad.log.error("Browsing failed before the test, aborting!")
                return False

            begin_time = get_device_epoch_time(self.ad)
            break_internet_except_sl4a_port(self.ad, sl4a_port)

            if not test_data_browsing_failure_using_sl4a(self.log, self.ad):
                self.ad.log.error("Browsing success even after breaking " \
                                  "the internet, aborting!")
                return False

            if not check_data_stall_detection(self.ad):
                self.ad.log.error("NetworkMonitor unable to detect Data Stall")

            if not check_network_validation_fail(self.ad, begin_time):
                self.ad.log.error("Unable to detect NW validation fail")
                return False

            if not check_data_stall_recovery(self.ad, begin_time):
                self.ad.log.error("Recovery was not triggerred")
                return False

            resume_internet_with_sl4a_port(self.ad, sl4a_port)

            if not test_data_browsing_success_using_sl4a(self.log, self.ad):
                self.ad.log.error("Browsing failed after resuming internet")
                return False

            self.ad.log.info("Triggering Out of Service Sceanrio")
            self.bts1.output_level = POWER_LEVEL_OUT_OF_SERVICE
            time.sleep(30)
            begin_time = get_device_epoch_time(self.ad)

            if not test_data_browsing_failure_using_sl4a(self.log, self.ad):
                self.ad.log.error("Browsing success even in OOS, aborting!")
                return False

            if not check_network_validation_fail(self.ad, begin_time):
                self.ad.log.error("Unable to detect NW validation fail")
                return False

            if check_data_stall_recovery(self.ad, begin_time):
                self.ad.log.error("FAILURE - Data Recovery was performed")
                return False
            self.ad.log.info("SUCCESS - Data Recovery was not performed")

            self.ad.log.info("Bringing up Strong Cellular Signal")
            self.bts1.output_level = POWER_LEVEL_FULL_SERVICE
            time.sleep(30)

            if not test_data_browsing_success_using_sl4a(self.log, self.ad):
                self.ad.log.error("Browsing failed after full service")
                return False
            return True

        except AnritsuError as e:
            self.log.error("Error in connection with Anritsu Simulator: " +
                           str(e))
            return False
        except Exception as e:
            self.log.error("Exception during Data procedure: " + str(e))
            return False
        finally:
            resume_internet_with_sl4a_port(self.ad, sl4a_port)
コード例 #8
0
 def _make_phone_call(self, call_verification_func=None):
     ads = self.android_devices[:]
     if not self.single_phone_test:
         random.shuffle(ads)
     the_number = self.result_info["Call Total"] + 1
     duration = random.randrange(self.min_phone_call_duration,
                                 self.max_phone_call_duration)
     result = True
     test_name = "%s_No_%s_phone_call" % (self.test_name, the_number)
     log_msg = "[Test Case] %s" % test_name
     self.log.info("%s for %s seconds begin", log_msg, duration)
     begin_time = get_device_epoch_time(ads[0])
     for ad in self.android_devices:
         if self.user_params.get("turn_on_tcpdump", True):
             start_adb_tcpdump(ad, interface="any", mask="all")
         if not getattr(ad, "droid", None):
             ad.droid, ad.ed = ad.get_droid()
             ad.ed.start()
         else:
             try:
                 if not ad.droid.is_live:
                     ad.droid, ad.ed = ad.get_droid()
                     ad.ed.start()
                 else:
                     ad.ed.clear_all_events()
             except Exception:
                 ad.log.info("Create new sl4a session for phone call")
                 ad.droid, ad.ed = ad.get_droid()
                 ad.ed.start()
         ad.droid.logI("%s begin" % log_msg)
     start_qxdm_loggers(self.log, self.android_devices, begin_time)
     failure_reasons = set()
     self.dut_incall = True
     if self.single_phone_test:
         call_setup_result = initiate_call(
             self.log,
             self.dut,
             self.call_server_number,
             incall_ui_display=INCALL_UI_DISPLAY_BACKGROUND
         ) and wait_for_in_call_active(self.dut, 60, 3)
     else:
         call_setup_result = call_setup_teardown(
             self.log,
             ads[0],
             ads[1],
             ad_hangup=None,
             verify_caller_func=call_verification_func,
             verify_callee_func=call_verification_func,
             wait_time_in_call=0,
             incall_ui_display=INCALL_UI_DISPLAY_BACKGROUND)
     if not call_setup_result:
         call_logs = ads[0].search_logcat(
             "ActivityManager: START u0 {act=android.intent.action.CALL",
             begin_time)
         messaging_logs = ads[0].search_logcat(
             "com.google.android.apps.messaging/.ui.conversation.ConversationActivity",
             begin_time)
         if call_logs and messaging_logs:
             if messaging_logs[-1]["datetime_obj"] - call_logs[-1]["datetime_obj"] < 5:
                 ads[0].log.info(
                     "Call setup failure due to simultaneous activities")
                 self.result_info[
                     "Call Setup Failure With Simultaneous Activity"] += 1
                 return True
         self.log.error("%s: Setup Call failed.", log_msg)
         failure_reasons.add("Setup")
         result = False
     else:
         elapsed_time = 0
         check_interval = 5
         while (elapsed_time < duration):
             check_interval = min(check_interval, duration - elapsed_time)
             time.sleep(check_interval)
             elapsed_time += check_interval
             time_message = "at <%s>/<%s> second." % (elapsed_time,
                                                      duration)
             for ad in ads:
                 if not call_verification_func(self.log, ad):
                     ad.log.warning("Call is NOT in correct %s state at %s",
                                    call_verification_func.__name__,
                                    time_message)
                     if call_verification_func.__name__ == "is_phone_in_call_iwlan":
                         if is_phone_in_call(self.log, ad):
                             if getattr(ad, "data_rat_state_error_count",
                                        0) < 1:
                                 setattr(ad, "data_rat_state_error_count",
                                         1)
                                 continue
                     failure_reasons.add("Maintenance")
                     last_call_drop_reason(ad, begin_time)
                     hangup_call(self.log, ads[0])
                     result = False
                 else:
                     ad.log.info("Call is in correct %s state at %s",
                                 call_verification_func.__name__,
                                 time_message)
             if not result:
                 break
     if not hangup_call(self.log, ads[0]):
         failure_reasons.add("Teardown")
         result = False
     for ad in ads:
         if not wait_for_call_id_clearing(ad,
                                          []) or ad.droid.telecomIsInCall():
             ad.log.error("Fail to hang up call")
             failure_reasons.add("Teardown")
             result = False
     self.result_info["Call Total"] += 1
     for ad in self.android_devices:
         try:
             ad.droid.logI("%s end" % log_msg)
         except:
             pass
     self.log.info("%s end", log_msg)
     self.dut_incall = False
     if not result:
         self.log.info("%s failed", log_msg)
         if self.gps_log_file:
             gps_info = job.run(
                 "tail %s" % self.gps_log_file, ignore_status=True)
             if gps_info.stdout:
                 gps_log_path = os.path.join(self.log_path, test_name,
                                             "gps_logs.txt")
                 utils.create_dir(gps_log_path)
                 job.run(
                     "tail %s > %s" % (self.gps_log_file, gps_log_path),
                     ignore_status=True)
                 self.log.info("gps log:\n%s", gps_info.stdout)
             else:
                 self.log.warning("Fail to get gps log %s",
                                  self.user_params["gps_log_file"])
         for reason in failure_reasons:
             self.result_info["Call %s Failure" % reason] += 1
         for ad in ads:
             log_path = os.path.join(self.log_path, test_name,
                                     "%s_binder_logs" % ad.serial)
             utils.create_dir(log_path)
             ad.pull_files(BINDER_LOGS, log_path)
         try:
             self._take_bug_report(test_name, begin_time)
         except Exception as e:
             self.log.exception(e)
         for ad in ads:
             if ad.droid.telecomIsInCall():
                 hangup_call_by_adb(ad)
     else:
         self.log.info("%s test succeed", log_msg)
         self.result_info["Call Success"] += 1
         if self.result_info["Call Total"] % 50 == 0:
             for ad in ads:
                 synchronize_device_time(ad)
                 if not check_is_wifi_connected(self.log, ad,
                                                self.wifi_network_ssid):
                     ensure_wifi_connected(self.log, ad,
                                           self.wifi_network_ssid,
                                           self.wifi_network_pass)
                     force_connectivity_metrics_upload(ad)
                     time.sleep(300)
                     wifi_toggle_state(self.log, ad, False)
                 if self.get_binder_logs:
                     log_path = os.path.join(self.log_path,
                                             "%s_binder_logs" % test_name,
                                             "%s_binder_logs" % ad.serial)
                     utils.create_dir(log_path)
                     ad.pull_files(BINDER_LOGS, log_path)
     return result
コード例 #9
0
    def _send_message(self, max_wait_time=2 * MAX_WAIT_TIME_SMS_RECEIVE):
        if self.single_phone_test:
            ads = [self.dut, self.dut]
        else:
            ads = self.android_devices[:]
            random.shuffle(ads)
        selection = random.randrange(0, 2)
        message_type_map = {0: "SMS", 1: "MMS"}
        max_length_map = {0: self.max_sms_length, 1: self.max_mms_length}
        min_length_map = {0: self.min_sms_length, 1: self.min_mms_length}
        length = random.randrange(min_length_map[selection],
                                  max_length_map[selection] + 1)
        message_func_map = {
            0: sms_send_receive_verify,
            1: mms_send_receive_verify
        }
        rat = self.dut.adb.getprop("gsm.network.type")
        self.dut.log.info("Network in RAT %s", rat)
        if self.dut_incall and not is_rat_svd_capable(rat.upper()):
            self.dut.log.info("In call data not supported, test SMS only")
            selection = 0
        message_type = message_type_map[selection]
        the_number = self.result_info["%s Total" % message_type] + 1
        begin_time = get_device_epoch_time(self.dut)
        test_name = "%s_No_%s_%s" % (self.test_name, the_number, message_type)
        start_qxdm_loggers(self.log, self.android_devices)
        log_msg = "[Test Case] %s" % test_name
        self.log.info("%s begin", log_msg)
        for ad in self.android_devices:
            if self.user_params.get("turn_on_tcpdump", True):
                start_adb_tcpdump(ad, interface="any", mask="all")
            if not getattr(ad, "messaging_droid", None):
                ad.messaging_droid, ad.messaging_ed = ad.get_droid()
                ad.messaging_ed.start()
            else:
                try:
                    if not ad.messaging_droid.is_live:
                        ad.messaging_droid, ad.messaging_ed = ad.get_droid()
                        ad.messaging_ed.start()
                    else:
                        ad.messaging_ed.clear_all_events()
                except Exception:
                    ad.log.info("Create new sl4a session for messaging")
                    ad.messaging_droid, ad.messaging_ed = ad.get_droid()
                    ad.messaging_ed.start()
            ad.messaging_droid.logI("%s begin" % log_msg)

        text = "%s: " % test_name
        text_length = len(text)
        if length < text_length:
            text = text[:length]
        else:
            text += rand_ascii_str(length - text_length)
        message_content_map = {0: [text], 1: [(test_name, text, None)]}

        result = message_func_map[selection](self.log, ads[0], ads[1],
                                             message_content_map[selection],
                                             max_wait_time)
        self.log.info("%s end", log_msg)
        for ad in self.android_devices:
            ad.messaging_droid.logI("%s end" % log_msg)
        if not result:
            self.result_info["%s Total" % message_type] += 1
            if message_type == "SMS":
                self.log.error("%s fails", log_msg)
                self.result_info["%s Failure" % message_type] += 1
            else:
                rat = self.dut.adb.getprop("gsm.network.type")
                self.dut.log.info("Network in RAT %s", rat)
                if self.dut_incall and not is_rat_svd_capable(rat.upper()):
                    self.dut.log.info(
                        "In call data not supported, MMS failure expected")
                    self.result_info["Expected In-call MMS failure"] += 1
                    return True
                else:
                    self.log.error("%s fails", log_msg)
                    self.result_info["MMS Failure"] += 1
            try:
                self._take_bug_report(test_name, begin_time)
            except Exception as e:
                self.log.exception(e)
            return False
        else:
            self.result_info["%s Total" % message_type] += 1
            self.log.info("%s succeed", log_msg)
            self.result_info["%s Success" % message_type] += 1
            return True