Beispiel #1
0
 def setup_test(self):
     self.tcpdump_pid_a = start_adb_tcpdump(self.dut_a,
                                            self.test_name,
                                            mask='all')
     self.tcpdump_pid_b = start_adb_tcpdump(self.dut_b,
                                            self.test_name,
                                            mask='all')
Beispiel #2
0
    def setup_class(self):
        super().setup_class()
        self.ad = self.android_devices[0]
        req_params = [
            # A { SSID, password } dictionary. Password is optional.
            'wifi_network',
            # A [latitude, longitude] list to identify test location.
            'test_location',
            # Cold Start Criteria, a int to define the criteria.
            'cs_criteria',
            # Warm Start Criteria, a int to define the criteria.
            'ws_criteria',
            # Hot Start Criteria, a int to define the criteria.
            'hs_criteria',
            # NetworkLocationProvide Criteria, a int to define the criteria.
            'nlp_criteria',
            # A list to identify QXDM log path.
            'qdsp6m_path'
        ]
        self.unpack_userparams(req_param_names=req_params)

        # Init test types Cold Start, Warm Start and Hot Start.
        test_type = namedtuple('Type', ['command', 'criteria'])
        self.test_types = {
            'cs': test_type('Cold Start', self.cs_criteria),
            'ws': test_type('Warm Start', self.ws_criteria),
            'hs': test_type('Hot Start', self.hs_criteria)
        }
        gutils._init_device(self.ad)
        self.begin_time = utils.get_current_epoch_time()
        gutils.clear_logd_gnss_qxdm_log(self.ad)
        tutils.start_qxdm_logger(self.ad, self.begin_time)
        tutils.start_adb_tcpdump(self.ad)
Beispiel #3
0
 def setup_class(self):
     super(TelLiveStressTest, self).setup_class()
     self.dut = self.android_devices[0]
     self.single_phone_test = self.user_params.get("single_phone_test",
                                                   False)
     # supported file download methods: chrome, sl4a, curl
     self.file_download_method = self.user_params.get(
         "file_download_method", "curl")
     self.get_binder_logs = self.user_params.get("get_binder_logs", False)
     if len(self.android_devices) == 1:
         self.single_phone_test = True
     if self.single_phone_test:
         self.android_devices = self.android_devices[:1]
         self.call_server_number = self.user_params.get(
             "call_server_number", STORY_LINE)
         if self.file_download_method == "sl4a":
             # with single device, do not use sl4a file download
             # due to stability issue
             self.file_download_method = "curl"
     else:
         self.android_devices = self.android_devices[:2]
     for ad in self.android_devices:
         ad.adb.shell("setprop nfc.debug_enable 1")
         if self.user_params.get("turn_on_tcpdump", True):
             start_adb_tcpdump(ad, interface="any", mask="all")
     self.user_params["telephony_auto_rerun"] = 0
     self.phone_call_iteration = int(
         self.user_params.get("phone_call_iteration", 500))
     self.max_phone_call_duration = int(
         self.user_params.get("max_phone_call_duration", 600))
     self.min_sleep_time = int(self.user_params.get("min_sleep_time", 30))
     self.max_sleep_time = int(self.user_params.get("max_sleep_time", 60))
     self.max_run_time = int(self.user_params.get("max_run_time", 14400))
     self.max_sms_length = int(self.user_params.get("max_sms_length", 1000))
     self.max_mms_length = int(self.user_params.get("max_mms_length", 160))
     self.min_sms_length = int(self.user_params.get("min_sms_length", 1))
     self.min_mms_length = int(self.user_params.get("min_mms_length", 1))
     self.min_phone_call_duration = int(
         self.user_params.get("min_phone_call_duration", 10))
     self.crash_check_interval = int(
         self.user_params.get("crash_check_interval", 300))
     self.dut_incall = False
     self.dut_capabilities = self.dut.telephony.get("capabilities", [])
     self.dut_wfc_modes = self.dut.telephony.get("wfc_modes", [])
     self.gps_log_file = self.user_params.get("gps_log_file", None)
     return True
    def _start_tcp_dump(self, ad):
        """ Start tcpdump on the give dut

        Args:
            1. ad: dut to run tcpdump on
        """
        if self.tcpdump_pid:
            stop_adb_tcpdump(ad, self.tcpdump_pid, pull_tcpdump=False)
        self.tcpdump_pid = start_adb_tcpdump(ad, self.test_name, mask='all')
 def setup_test(self):
     self.dut.droid.wifiStartTrackingStateChange()
     self.dut.droid.wakeLockAcquireBright()
     self.dut.droid.wakeUpNow()
     wutils.reset_wifi(self.dut)
     self.dut.ed.clear_all_events()
     self.tcpdump_pid = start_adb_tcpdump(self.dut,
                                          self.test_name,
                                          mask='all')
 def data_test(self):
     failure = 0
     total_count = 0
     tcpdump_pid = None
     #file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB", "1GB"]
     file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB"]
     while time.time() < self.finishing_time:
         total_count += 1
         pull_tcpdump = False
         try:
             self.dut.log.info(dict(self.result_info))
             self.result_info["Total file download"] += 1
             selection = random.randrange(0, len(file_names))
             file_name = file_names[selection]
             (tcpdump_pid, tcpdump_file) = \
                      start_adb_tcpdump(self.dut, self.test_name, mask="all")
             if not active_file_download_test(self.log, self.dut,
                                              file_name):
                 self.result_info["%s file download failure" %
                                  file_name] += 1
                 failure += 1
                 pull_tcpdump = True
                 self._take_bug_report("%s_download_failure" %
                                       self.test_name,
                                       time.strftime("%m-%d-%Y-%H-%M-%S"))
                 self.dut.droid.goToSleepNow()
                 time.sleep(random.randrange(0, self.max_sleep_time))
         except IGNORE_EXCEPTIONS as e:
             self.log.error("Exception error %s", str(e))
             self.result_info["Exception Errors"] += 1
             if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE:
                 self.finishing_time = time.time()
                 raise
         except Exception as e:
             self.finishing_time = time.time()
             raise
         finally:
             if tcpdump_pid is not None:
                 stop_adb_tcpdump(self.dut, tcpdump_pid, tcpdump_file,
                                  pull_tcpdump)
         self.dut.log.info("File download test failure: %s/%s", failure,
                           total_count)
     if failure / total_count > 0.1:
         return "File download test failure: %s/%s" % (failure, total_count)
     else:
         return ""
 def setup_test(self):
     self.tcpdump_pid = start_adb_tcpdump(self.dut,
                                          self.test_name,
                                          mask='all')
Beispiel #8
0
 def start_qxdm_and_tcpdump_log(self):
     """Start QXDM and adb tcpdump if collect_logs is True."""
     if self.collect_logs:
         start_qxdm_logger(self.ad, get_current_epoch_time())
         start_adb_tcpdump(self.ad)
Beispiel #9
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
Beispiel #10
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