blob: 99478ffc0455757c559cf3d93fb8584a43eaba9c [file] [log] [blame]
Betty Zhou59f18532017-05-01 15:06:11 -07001#!/usr/bin/env python3.4
2#
3# Copyright 2017 - Google
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16"""
17 Test Script for Telephony Stress Call Test
18"""
19
20import collections
Betty Zhou9aa68ad2018-01-12 12:39:23 -080021import json
22import os
Betty Zhou59f18532017-05-01 15:06:11 -070023import random
24import time
Betty Zhou53f1d0e2018-01-26 20:08:27 -080025
Xianyuan Jia04e15322019-05-20 11:22:00 -070026from acts import context
Betty Zhou4418a332018-05-15 13:11:18 -070027from acts import signals
Betty Zhou49744692018-04-24 11:00:38 -070028from acts.libs.proc import job
Betty Zhoucf456cf2017-05-10 19:15:09 -070029from acts.test_decorators import test_tracker_info
Xianyuan Jia24299b72020-10-21 13:52:47 -070030from acts_contrib.test_utils.tel.loggers.telephony_metric_logger import TelephonyMetricLogger
Ashutosh Rajmani Singhe31addf2021-02-11 13:54:25 -080031from acts_contrib.test_utils.tel.loggers.telephony_stress_metric_logger import TelephonyStressMetricLogger
Xianyuan Jia24299b72020-10-21 13:52:47 -070032from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
33from acts_contrib.test_utils.tel.tel_defines import CAPABILITY_VOLTE
34from acts_contrib.test_utils.tel.tel_defines import CAPABILITY_WFC
35from acts_contrib.test_utils.tel.tel_defines import GEN_3G
36from acts_contrib.test_utils.tel.tel_defines import GEN_4G
Pratik Shethdb52e652021-03-17 15:08:27 -070037from acts_contrib.test_utils.tel.tel_defines import GOOGLE_CBRS_CARRIER_ID
38from acts_contrib.test_utils.tel.tel_defines import GOOGLE_FI_CARRIER_ID
Xianyuan Jia24299b72020-10-21 13:52:47 -070039from acts_contrib.test_utils.tel.tel_defines import INCALL_UI_DISPLAY_BACKGROUND
40from acts_contrib.test_utils.tel.tel_defines import MAX_WAIT_TIME_SMS_RECEIVE
41from acts_contrib.test_utils.tel.tel_defines import NETWORK_MODE_WCDMA_ONLY
42from acts_contrib.test_utils.tel.tel_defines import NETWORK_MODE_GLOBAL
43from acts_contrib.test_utils.tel.tel_defines import NETWORK_MODE_CDMA
44from acts_contrib.test_utils.tel.tel_defines import NETWORK_MODE_GSM_ONLY
45from acts_contrib.test_utils.tel.tel_defines import NETWORK_MODE_TDSCDMA_GSM_WCDMA
46from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_AFTER_MODE_CHANGE
47from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED
48from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED
49from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_CHANGE_MESSAGE_SUB_ID
50from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_CHANGE_VOICE_SUB_ID
51from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_FOR_CBRS_DATA_SWITCH
52from acts_contrib.test_utils.tel.tel_defines import CARRIER_SING
53from acts_contrib.test_utils.tel.tel_lookup_tables import is_rat_svd_capable
54from acts_contrib.test_utils.tel.tel_test_utils import STORY_LINE
55from acts_contrib.test_utils.tel.tel_test_utils import active_file_download_test
Ashutosh Rajmani Singha54c01e2021-02-01 21:56:25 -080056from acts_contrib.test_utils.tel.tel_test_utils import configure_sdm_logs
Xianyuan Jia24299b72020-10-21 13:52:47 -070057from acts_contrib.test_utils.tel.tel_test_utils import is_phone_in_call
58from acts_contrib.test_utils.tel.tel_test_utils import call_setup_teardown
59from acts_contrib.test_utils.tel.tel_test_utils import ensure_network_generation_for_subscription
60from acts_contrib.test_utils.tel.tel_test_utils import ensure_wifi_connected
61from acts_contrib.test_utils.tel.tel_test_utils import extract_test_log
62from acts_contrib.test_utils.tel.tel_test_utils import force_connectivity_metrics_upload
63from acts_contrib.test_utils.tel.tel_test_utils import get_device_epoch_time
64from acts_contrib.test_utils.tel.tel_test_utils import get_telephony_signal_strength
65from acts_contrib.test_utils.tel.tel_test_utils import hangup_call
66from acts_contrib.test_utils.tel.tel_test_utils import hangup_call_by_adb
67from acts_contrib.test_utils.tel.tel_test_utils import initiate_call
68from acts_contrib.test_utils.tel.tel_test_utils import last_call_drop_reason
69from acts_contrib.test_utils.tel.tel_test_utils import run_multithread_func
70from acts_contrib.test_utils.tel.tel_test_utils import set_wfc_mode
71from acts_contrib.test_utils.tel.tel_test_utils import sms_send_receive_verify
72from acts_contrib.test_utils.tel.tel_test_utils import start_qxdm_loggers
73from acts_contrib.test_utils.tel.tel_test_utils import start_sdm_loggers
74from acts_contrib.test_utils.tel.tel_test_utils import start_adb_tcpdump
75from acts_contrib.test_utils.tel.tel_test_utils import synchronize_device_time
76from acts_contrib.test_utils.tel.tel_test_utils import mms_send_receive_verify
77from acts_contrib.test_utils.tel.tel_test_utils import set_preferred_network_mode_pref
78from acts_contrib.test_utils.tel.tel_test_utils import verify_internet_connection
79from acts_contrib.test_utils.tel.tel_test_utils import verify_internet_connection_by_ping
80from acts_contrib.test_utils.tel.tel_test_utils import verify_http_connection
81from acts_contrib.test_utils.tel.tel_test_utils import wait_for_call_id_clearing
82from acts_contrib.test_utils.tel.tel_test_utils import wait_for_data_connection
83from acts_contrib.test_utils.tel.tel_test_utils import wait_for_in_call_active
84from acts_contrib.test_utils.tel.tel_test_utils import is_current_data_on_cbrs
Pratik Sheth68e4eba2021-03-23 17:10:13 -070085from acts_contrib.test_utils.tel.tel_test_utils import check_voice_network_type
Xianyuan Jia24299b72020-10-21 13:52:47 -070086from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_3g
87from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_2g
88from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb
89from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan
90from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_volte
91from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_csfb
92from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_iwlan
93from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_voice_3g
94from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_voice_2g
95from acts_contrib.test_utils.tel.tel_voice_utils import phone_setup_volte
96from acts_contrib.test_utils.tel.tel_voice_utils import phone_idle_iwlan
97from acts_contrib.test_utils.tel.tel_voice_utils import phone_idle_volte
98from acts_contrib.test_utils.tel.tel_voice_utils import get_current_voice_rat
99from acts_contrib.test_utils.tel.tel_subscription_utils import get_subid_from_slot_index
100from acts_contrib.test_utils.tel.tel_subscription_utils import get_operatorname_from_slot_index
101from acts_contrib.test_utils.tel.tel_subscription_utils import get_carrierid_from_slot_index
102from acts_contrib.test_utils.tel.tel_subscription_utils import get_isopportunistic_from_slot_index
103from acts_contrib.test_utils.tel.tel_subscription_utils import set_subid_for_data
104from acts_contrib.test_utils.tel.tel_subscription_utils import set_subid_for_message
105from acts_contrib.test_utils.tel.tel_subscription_utils import set_subid_for_outgoing_call
Pratik Shethdb52e652021-03-17 15:08:27 -0700106from acts_contrib.test_utils.tel.tel_subscription_utils import set_always_allow_mms_data
Pratik Shethffd15372021-04-29 15:03:47 -0700107from acts_contrib.test_utils.tel.tel_5g_utils import provision_device_for_5g
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700108from acts.utils import get_current_epoch_time
Betty Zhou59f18532017-05-01 15:06:11 -0700109from acts.utils import rand_ascii_str
Betty Zhoub2d1c6d2017-07-17 11:40:27 -0700110
Betty Zhoucf048542018-02-22 17:14:08 -0800111EXCEPTION_TOLERANCE = 5
Betty Zhoue57ab692018-03-09 18:39:30 -0800112BINDER_LOGS = ["/sys/kernel/debug/binder"]
Jaineel33a11932020-07-31 17:37:03 -0700113DEFAULT_FILE_DOWNLOADS = ["1MB", "5MB", "10MB", "20MB", "50MB"]
Ashutosh Rajmani Singhe31addf2021-02-11 13:54:25 -0800114RESULTS_LIST = {-2: "UNAVAILABLE_NETWORK_TYPE",
115 -1: "CALL_SETUP_FAILURE",
116 0: "SUCCESS",
117 1: "INITIATE_FAILED",
118 2: "NO_RING_EVENT_OR_ANSWER_FAILED",
119 3: "NO_CALL_ID_FOUND",
120 4: "CALL_STATE_NOT_ACTIVE_DURING_ESTABLISHMENT",
121 5: "AUDIO_STATE_NOT_INCALL_DURING_ESTABLISHMENT",
122 6: "AUDIO_STATE_NOT_INCALL_AFTER_CONNECTED",
123 7: "CALL_DROP_OR_WRONG_STATE_DURING_ESTABLISHMENT",
124 8: "CALL_DROP_OR_WRONG_STATE_AFTER_CONNECTED",
125 9: "CALL_HANGUP_FAIL",
126 10: "CALL_ID_CLEANUP_FAIL"}
Betty Zhou59f18532017-05-01 15:06:11 -0700127
128
129class TelLiveStressTest(TelephonyBaseTest):
130 def setup_class(self):
131 super(TelLiveStressTest, self).setup_class()
132 self.dut = self.android_devices[0]
Betty Zhouc6685ad2018-02-21 18:33:38 -0800133 self.single_phone_test = self.user_params.get("single_phone_test",
134 False)
Betty Zhouc133f8c2018-03-02 15:40:13 -0800135 # supported file download methods: chrome, sl4a, curl
136 self.file_download_method = self.user_params.get(
Betty Zhoue57ab692018-03-09 18:39:30 -0800137 "file_download_method", "curl")
Betty Zhou4bc31fc2018-03-12 18:28:50 -0700138 self.get_binder_logs = self.user_params.get("get_binder_logs", False)
Betty Zhou377f72b2018-01-12 19:43:26 -0800139 if len(self.android_devices) == 1:
140 self.single_phone_test = True
141 if self.single_phone_test:
142 self.android_devices = self.android_devices[:1]
143 self.call_server_number = self.user_params.get(
Betty Zhouc86784b2018-02-28 16:42:53 -0800144 "call_server_number", STORY_LINE)
Betty Zhouc133f8c2018-03-02 15:40:13 -0800145 if self.file_download_method == "sl4a":
146 # with single device, do not use sl4a file download
147 # due to stability issue
Betty Zhoue57ab692018-03-09 18:39:30 -0800148 self.file_download_method = "curl"
Betty Zhou377f72b2018-01-12 19:43:26 -0800149 else:
150 self.android_devices = self.android_devices[:2]
Sarah Boechat2be72ce2019-09-27 12:21:27 -0700151 self.sdm_log = self.user_params.get("sdm_log", False)
Betty Zhoue36eb6a2018-05-22 19:08:53 -0700152 for ad in self.android_devices:
Sarah Boechat2be72ce2019-09-27 12:21:27 -0700153 setattr(ad, "sdm_log", self.sdm_log)
Ashutosh Rajmani Singha54c01e2021-02-01 21:56:25 -0800154 configure_sdm_logs(ad)
Betty Zhoue36eb6a2018-05-22 19:08:53 -0700155 ad.adb.shell("setprop nfc.debug_enable 1")
Jaineela987bff2019-05-14 17:11:48 -0700156 if self.user_params.get("turn_on_tcpdump", False):
Betty Zhou89a71032018-06-08 18:05:25 -0700157 start_adb_tcpdump(ad, interface="any", mask="all")
Betty Zhoufd85e392018-03-27 21:15:10 -0700158 self.user_params["telephony_auto_rerun"] = 0
Betty Zhou59f18532017-05-01 15:06:11 -0700159 self.phone_call_iteration = int(
160 self.user_params.get("phone_call_iteration", 500))
161 self.max_phone_call_duration = int(
Betty Zhou93c0abb2017-11-14 19:32:17 -0800162 self.user_params.get("max_phone_call_duration", 600))
Betty Zhouf7a920a2018-05-11 19:21:30 -0700163 self.min_sleep_time = int(self.user_params.get("min_sleep_time", 30))
Betty Zhouc4dfad12018-04-11 18:36:49 -0700164 self.max_sleep_time = int(self.user_params.get("max_sleep_time", 60))
Betty Zhoucb2052e2017-10-10 17:46:55 -0700165 self.max_run_time = int(self.user_params.get("max_run_time", 14400))
Betty Zhou59f18532017-05-01 15:06:11 -0700166 self.max_sms_length = int(self.user_params.get("max_sms_length", 1000))
167 self.max_mms_length = int(self.user_params.get("max_mms_length", 160))
Betty Zhouf27f5482017-07-24 18:56:17 -0700168 self.min_sms_length = int(self.user_params.get("min_sms_length", 1))
169 self.min_mms_length = int(self.user_params.get("min_mms_length", 1))
170 self.min_phone_call_duration = int(
171 self.user_params.get("min_phone_call_duration", 10))
Betty Zhou56a54612017-05-09 18:54:45 -0700172 self.crash_check_interval = int(
173 self.user_params.get("crash_check_interval", 300))
Jaineel15879c92019-06-03 17:08:13 -0700174 self.cbrs_check_interval = int(
175 self.user_params.get("cbrs_check_interval", 100))
Betty Zhou4418a332018-05-15 13:11:18 -0700176 self.dut_incall = False
Jaineelf76b37b2019-01-15 16:08:22 -0800177 self.dsds_esim = self.user_params.get("dsds_esim", False)
Jaineel15879c92019-06-03 17:08:13 -0700178 self.cbrs_esim = self.user_params.get("cbrs_esim", False)
Mark De Ruyter177197d2018-11-09 20:20:04 -0800179 telephony_info = getattr(self.dut, "telephony", {})
180 self.dut_capabilities = telephony_info.get("capabilities", [])
181 self.dut_wfc_modes = telephony_info.get("wfc_modes", [])
Betty Zhoue204f462018-06-08 18:36:01 -0700182 self.gps_log_file = self.user_params.get("gps_log_file", None)
Jaineel33a11932020-07-31 17:37:03 -0700183 self.file_name_list = self.user_params.get("file_downloads", DEFAULT_FILE_DOWNLOADS)
Ashutosh Rajmani Singh1401e8b2020-08-13 20:41:54 -0700184 self.tel_logger = TelephonyMetricLogger.for_test_case()
Ashutosh Rajmani Singhe31addf2021-02-11 13:54:25 -0800185 self.tel_logger = TelephonyStressMetricLogger.for_test_case()
186 self.result_collection = {"UNAVAILABLE_NETWORK_TYPE" : 0,
187 "CALL_SETUP_FAILURE" : 0,
188 "SUCCESS" : 0,
189 "INITIATE_FAILED" : 0,
190 "NO_RING_EVENT_OR_ANSWER_FAILED" : 0,
191 "NO_CALL_ID_FOUND" : 0,
192 "CALL_STATE_NOT_ACTIVE_DURING_ESTABLISHMENT" : 0,
193 "AUDIO_STATE_NOT_INCALL_DURING_ESTABLISHMENT" : 0,
194 "AUDIO_STATE_NOT_INCALL_AFTER_CONNECTED" : 0,
195 "CALL_DROP_OR_WRONG_STATE_DURING_ESTABLISHMENT" : 0,
196 "CALL_DROP_OR_WRONG_STATE_AFTER_CONNECTED": 0,
197 "CALL_HANGUP_FAIL": 0,
198 "CALL_ID_CLEANUP_FAIL": 0 }
Pratik Sheth68e4eba2021-03-23 17:10:13 -0700199 self.call_stats_check = self.user_params.get("call_stats_check", False)
Pratik Shethffd15372021-04-29 15:03:47 -0700200 self.nsa_5g_for_stress = self.user_params.get("nsa_5g_for_stress", False)
Betty Zhou59f18532017-05-01 15:06:11 -0700201 return True
202
Betty Zhou61646502018-01-12 13:02:48 -0800203 def setup_test(self):
204 super(TelLiveStressTest, self).setup_test()
205 self.result_info = collections.defaultdict(int)
206 self._init_perf_json()
Betty Zhou5ee8e042018-06-05 20:34:12 -0700207 self.internet_connection_check_method = verify_internet_connection
Betty Zhou61646502018-01-12 13:02:48 -0800208
Betty Zhou103a9592017-10-20 18:57:16 -0700209 def on_fail(self, test_name, begin_time):
210 pass
211
Xianyuan Jia04e15322019-05-20 11:22:00 -0700212 def _take_bug_report(self, test_name, begin_time):
213 if self._skip_bug_report(test_name):
214 return
215 src_dir = context.get_current_context().get_full_output_path()
216 dst_dir = os.path.join(self.log_path, test_name)
217
218 # Extract test_run_info.txt, test_run_debug.txt
219 for file_name in ("test_run_info.txt", "test_run_debug.txt"):
220 extract_test_log(self.log, os.path.join(src_dir, file_name),
221 os.path.join(dst_dir,
222 "%s_%s" % (test_name, file_name)),
223 "\[Test Case\] %s " % test_name)
224 super()._take_bug_report(test_name, begin_time)
225
226 def _ad_take_extra_logs(self, ad, test_name, begin_time):
227 src_file = os.path.join(ad.device_log_path,
228 'adblog_%s_debug.txt' % ad.serial)
229 dst_file = os.path.join(ad.device_log_path, test_name,
230 "%s_%s.logcat" % (ad.serial, test_name))
231 extract_test_log(self.log, src_file, dst_file, test_name)
232 return super()._ad_take_extra_logs(ad, test_name, begin_time)
233
Betty Zhou59f18532017-05-01 15:06:11 -0700234 def _setup_wfc(self):
235 for ad in self.android_devices:
236 if not ensure_wifi_connected(
Betty Zhou69c712b2017-05-23 19:28:23 -0700237 self.log,
Betty Zhou59f18532017-05-01 15:06:11 -0700238 ad,
239 self.wifi_network_ssid,
240 self.wifi_network_pass,
Jaineel65ebd262017-07-20 11:40:17 -0700241 retries=3):
Betty Zhou5dd53c02018-03-22 20:08:33 -0700242 ad.log.error("Bringing up Wifi connection fails.")
Betty Zhou59f18532017-05-01 15:06:11 -0700243 return False
244 ad.log.info("Phone WIFI is connected successfully.")
245 if not set_wfc_mode(self.log, ad, WFC_MODE_WIFI_PREFERRED):
246 ad.log.error("Phone failed to enable Wifi-Calling.")
247 return False
248 ad.log.info("Phone is set in Wifi-Calling successfully.")
Betty Zhou69c712b2017-05-23 19:28:23 -0700249 if not phone_idle_iwlan(self.log, ad):
Betty Zhou59f18532017-05-01 15:06:11 -0700250 ad.log.error("Phone is not in WFC enabled state.")
251 return False
252 ad.log.info("Phone is in WFC enabled state.")
253 return True
254
Betty Zhou042a56e2018-03-30 17:18:04 -0700255 def _setup_wfc_apm(self):
256 for ad in self.android_devices:
257 if not phone_setup_iwlan(
Betty Zhou4418a332018-05-15 13:11:18 -0700258 self.log, ad, True, WFC_MODE_CELLULAR_PREFERRED,
Betty Zhou042a56e2018-03-30 17:18:04 -0700259 self.wifi_network_ssid, self.wifi_network_pass):
260 ad.log.error("Failed to setup WFC.")
261 return False
262 return True
263
Betty Zhou59f18532017-05-01 15:06:11 -0700264 def _setup_lte_volte_enabled(self):
265 for ad in self.android_devices:
266 if not phone_setup_volte(self.log, ad):
267 ad.log.error("Phone failed to enable VoLTE.")
268 return False
269 ad.log.info("Phone VOLTE is enabled successfully.")
Pratik Shethffd15372021-04-29 15:03:47 -0700270 # TODO: b/186865335 Move 5G methods to NR directory
271 if self.nsa_5g_for_stress:
272 if not provision_device_for_5g(self.log, ad):
273 ad.log.error("Phone failed to attach 5G NSA.")
274 return False
275 ad.log.info("Phone 5G NSA VOLTE is enabled successfully.")
Betty Zhou59f18532017-05-01 15:06:11 -0700276 return True
277
278 def _setup_lte_volte_disabled(self):
279 for ad in self.android_devices:
280 if not phone_setup_csfb(self.log, ad):
281 ad.log.error("Phone failed to setup CSFB.")
282 return False
283 ad.log.info("Phone VOLTE is disabled successfully.")
284 return True
285
286 def _setup_3g(self):
287 for ad in self.android_devices:
288 if not phone_setup_voice_3g(self.log, ad):
289 ad.log.error("Phone failed to setup 3g.")
290 return False
291 ad.log.info("Phone RAT 3G is enabled successfully.")
292 return True
293
294 def _setup_2g(self):
295 for ad in self.android_devices:
296 if not phone_setup_voice_2g(self.log, ad):
297 ad.log.error("Phone failed to setup 2g.")
298 return False
299 ad.log.info("RAT 2G is enabled successfully.")
300 return True
301
Jaineel43096f92019-10-21 15:18:24 -0700302 def _get_network_rat(self, slot_id):
303 rat = self.dut.adb.getprop("gsm.network.type")
304 if "," in rat:
305 if self.dsds_esim:
306 rat = rat.split(',')[slot_id]
307 else:
308 (rat1, rat2) = rat.split(',')
309 if rat1 == "Unknown":
310 rat = rat2
311 else:
312 rat = rat1
313 return rat
314
Betty Zhouc6685ad2018-02-21 18:33:38 -0800315 def _send_message(self, max_wait_time=2 * MAX_WAIT_TIME_SMS_RECEIVE):
Jaineeld19c60f2019-01-18 11:25:42 -0800316 slot_id_rx = None
Betty Zhou377f72b2018-01-12 19:43:26 -0800317 if self.single_phone_test:
318 ads = [self.dut, self.dut]
319 else:
320 ads = self.android_devices[:]
321 random.shuffle(ads)
Jaineelf76b37b2019-01-15 16:08:22 -0800322 slot_id = random.randint(0,1)
323 if self.dsds_esim:
324 sub_id = get_subid_from_slot_index(self.log, ads[0], slot_id)
325 ads[0].log.info("Message - MO - slot_Id %d", slot_id)
326 set_subid_for_message(ads[0], sub_id)
Jaineelf9f40232019-04-02 17:42:25 -0700327 time.sleep(WAIT_TIME_CHANGE_MESSAGE_SUB_ID)
Jaineelf76b37b2019-01-15 16:08:22 -0800328 slot_id_rx = random.randint(0,1)
329 ads[1].log.info("Message - MT - slot_id %d", slot_id_rx)
Betty Zhou59f18532017-05-01 15:06:11 -0700330 selection = random.randrange(0, 2)
331 message_type_map = {0: "SMS", 1: "MMS"}
332 max_length_map = {0: self.max_sms_length, 1: self.max_mms_length}
Betty Zhouf27f5482017-07-24 18:56:17 -0700333 min_length_map = {0: self.min_sms_length, 1: self.min_mms_length}
334 length = random.randrange(min_length_map[selection],
335 max_length_map[selection] + 1)
Betty Zhou59f18532017-05-01 15:06:11 -0700336 message_func_map = {
337 0: sms_send_receive_verify,
338 1: mms_send_receive_verify
339 }
Jaineelc55ca592019-10-25 10:26:33 -0700340 rat = self._get_network_rat(slot_id)
341 self.dut.log.info("Network in RAT %s", rat)
Betty Zhou4418a332018-05-15 13:11:18 -0700342 if self.dut_incall and not is_rat_svd_capable(rat.upper()):
343 self.dut.log.info("In call data not supported, test SMS only")
344 selection = 0
Betty Zhou103a9592017-10-20 18:57:16 -0700345 message_type = message_type_map[selection]
Betty Zhoue31c27d2018-02-12 19:58:12 -0800346 the_number = self.result_info["%s Total" % message_type] + 1
Betty Zhouabe4a442018-05-21 12:37:26 -0700347 begin_time = get_device_epoch_time(self.dut)
Betty Zhou3db27a32018-04-23 14:31:25 -0700348 test_name = "%s_No_%s_%s" % (self.test_name, the_number, message_type)
Jaineel72d2c242019-07-23 12:00:07 -0700349 if self.sdm_log:
350 start_sdm_loggers(self.log, self.android_devices)
351 else:
352 start_qxdm_loggers(self.log, self.android_devices)
Betty Zhou3db27a32018-04-23 14:31:25 -0700353 log_msg = "[Test Case] %s" % test_name
354 self.log.info("%s begin", log_msg)
Betty Zhou377f72b2018-01-12 19:43:26 -0800355 for ad in self.android_devices:
Jaineela987bff2019-05-14 17:11:48 -0700356 if self.user_params.get("turn_on_tcpdump", False):
Betty Zhou749fabd2018-06-08 17:09:39 -0700357 start_adb_tcpdump(ad, interface="any", mask="all")
Betty Zhou4bc31fc2018-03-12 18:28:50 -0700358 if not getattr(ad, "messaging_droid", None):
359 ad.messaging_droid, ad.messaging_ed = ad.get_droid()
360 ad.messaging_ed.start()
361 else:
Betty Zhou06219032018-01-11 12:40:49 -0800362 try:
Betty Zhou4bc31fc2018-03-12 18:28:50 -0700363 if not ad.messaging_droid.is_live:
364 ad.messaging_droid, ad.messaging_ed = ad.get_droid()
365 ad.messaging_ed.start()
366 else:
367 ad.messaging_ed.clear_all_events()
368 except Exception:
369 ad.log.info("Create new sl4a session for messaging")
370 ad.messaging_droid, ad.messaging_ed = ad.get_droid()
371 ad.messaging_ed.start()
Betty Zhouc9a4d0c2018-06-18 16:26:07 -0700372 ad.messaging_droid.logI("[BEGIN]%s" % log_msg)
Betty Zhou749fabd2018-06-08 17:09:39 -0700373
Jaineel19a12c52019-03-11 13:25:36 -0700374 text = "%s:" % test_name
Betty Zhou38028b72017-12-20 17:54:12 -0800375 text_length = len(text)
376 if length < text_length:
377 text = text[:length]
378 else:
379 text += rand_ascii_str(length - text_length)
Betty Zhou1095ee42018-05-07 09:53:28 -0700380 message_content_map = {0: [text], 1: [(test_name, text, None)]}
Betty Zhou4c1c4b12017-12-21 17:06:13 -0800381
Betty Zhou3db27a32018-04-23 14:31:25 -0700382 result = message_func_map[selection](self.log, ads[0], ads[1],
383 message_content_map[selection],
Jaineelf76b37b2019-01-15 16:08:22 -0800384 max_wait_time,
385 slot_id_rx=slot_id_rx)
Betty Zhou3db27a32018-04-23 14:31:25 -0700386 self.log.info("%s end", log_msg)
387 for ad in self.android_devices:
Betty Zhouc9a4d0c2018-06-18 16:26:07 -0700388 ad.messaging_droid.logI("[END]%s" % log_msg)
Betty Zhou3db27a32018-04-23 14:31:25 -0700389 if not result:
Betty Zhoue31c27d2018-02-12 19:58:12 -0800390 self.result_info["%s Total" % message_type] += 1
Betty Zhou82d7a722017-11-08 15:56:04 -0800391 if message_type == "SMS":
Betty Zhou8802ec62017-12-18 19:44:29 -0800392 self.log.error("%s fails", log_msg)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800393 self.result_info["%s Failure" % message_type] += 1
Betty Zhou82d7a722017-11-08 15:56:04 -0800394 else:
Jaineelc55ca592019-10-25 10:26:33 -0700395 rat = self._get_network_rat(slot_id)
396 self.dut.log.info("Network in RAT %s", rat)
Betty Zhou4418a332018-05-15 13:11:18 -0700397 if self.dut_incall and not is_rat_svd_capable(rat.upper()):
398 self.dut.log.info(
399 "In call data not supported, MMS failure expected")
Betty Zhou377f72b2018-01-12 19:43:26 -0800400 self.result_info["Expected In-call MMS failure"] += 1
Betty Zhou82d7a722017-11-08 15:56:04 -0800401 return True
402 else:
Betty Zhou8802ec62017-12-18 19:44:29 -0800403 self.log.error("%s fails", log_msg)
Betty Zhouc133f8c2018-03-02 15:40:13 -0800404 self.result_info["MMS Failure"] += 1
Betty Zhou3db27a32018-04-23 14:31:25 -0700405 try:
406 self._take_bug_report(test_name, begin_time)
407 except Exception as e:
408 self.log.exception(e)
Betty Zhou59f18532017-05-01 15:06:11 -0700409 return False
410 else:
Betty Zhoue31c27d2018-02-12 19:58:12 -0800411 self.result_info["%s Total" % message_type] += 1
Betty Zhou8802ec62017-12-18 19:44:29 -0800412 self.log.info("%s succeed", log_msg)
Jaineel5bee17c2018-01-05 11:55:17 -0800413 self.result_info["%s Success" % message_type] += 1
Betty Zhou33c05292017-05-24 15:12:43 -0700414 return True
Betty Zhou59f18532017-05-01 15:06:11 -0700415
Ashutosh Rajmani Singh84512902020-08-18 00:47:50 -0700416 def _make_phone_call(self, call_verification_func=None, voice_stress_only = False):
Betty Zhou377f72b2018-01-12 19:43:26 -0800417 ads = self.android_devices[:]
Jaineeld19c60f2019-01-18 11:25:42 -0800418 slot_id_callee = None
Ashutosh Rajmani Singh84512902020-08-18 00:47:50 -0700419 if not voice_stress_only:
420 if not self.single_phone_test:
421 random.shuffle(ads)
Jaineelf76b37b2019-01-15 16:08:22 -0800422 if self.dsds_esim:
423 slot_id = random.randint(0,1)
424 sub_id = get_subid_from_slot_index(self.log, ads[0], slot_id)
425 ads[0].log.info("Voice - MO - slot_Id %d", slot_id)
426 set_subid_for_outgoing_call(ads[0], sub_id)
Jaineelf9f40232019-04-02 17:42:25 -0700427 time.sleep(WAIT_TIME_CHANGE_VOICE_SUB_ID)
Jaineelf76b37b2019-01-15 16:08:22 -0800428 slot_id_callee = random.randint(0,1)
429 ads[1].log.info("Voice - MT - slot_id %d", slot_id_callee)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800430 the_number = self.result_info["Call Total"] + 1
Ashutosh Rajmani Singh84512902020-08-18 00:47:50 -0700431 if voice_stress_only:
432 duration = 30
433 else:
434 duration = random.randrange(self.min_phone_call_duration,
Betty Zhou628b98e2018-01-08 15:45:25 -0800435 self.max_phone_call_duration)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800436 result = True
Betty Zhou3db27a32018-04-23 14:31:25 -0700437 test_name = "%s_No_%s_phone_call" % (self.test_name, the_number)
438 log_msg = "[Test Case] %s" % test_name
Betty Zhoub707ef22018-05-14 16:47:05 -0700439 self.log.info("%s for %s seconds begin", log_msg, duration)
Pratik Sheth68e4eba2021-03-23 17:10:13 -0700440
441 if self.call_stats_check:
442 voice_type_init = check_voice_network_type(ads, voice_init=True)
443 else:
444 voice_type_init = None
445
Betty Zhou5ee8e042018-06-05 20:34:12 -0700446 begin_time = get_device_epoch_time(ads[0])
Betty Zhou4bc31fc2018-03-12 18:28:50 -0700447 for ad in self.android_devices:
Jaineela987bff2019-05-14 17:11:48 -0700448 if self.user_params.get("turn_on_tcpdump", False):
Betty Zhou749fabd2018-06-08 17:09:39 -0700449 start_adb_tcpdump(ad, interface="any", mask="all")
Betty Zhou4bc31fc2018-03-12 18:28:50 -0700450 if not getattr(ad, "droid", None):
451 ad.droid, ad.ed = ad.get_droid()
452 ad.ed.start()
453 else:
454 try:
455 if not ad.droid.is_live:
456 ad.droid, ad.ed = ad.get_droid()
457 ad.ed.start()
458 else:
459 ad.ed.clear_all_events()
460 except Exception:
461 ad.log.info("Create new sl4a session for phone call")
462 ad.droid, ad.ed = ad.get_droid()
463 ad.ed.start()
Betty Zhouc9a4d0c2018-06-18 16:26:07 -0700464 ad.droid.logI("[BEGIN]%s" % log_msg)
Jaineel72d2c242019-07-23 12:00:07 -0700465 if self.sdm_log:
Jaineel080f1ec2019-08-02 15:01:18 -0700466 for ad in ads:
467 ad.adb.shell("i2cset -fy 3 64 6 1 b", ignore_status=True)
468 ad.adb.shell("i2cset -fy 3 65 6 1 b", ignore_status=True)
Jaineel72d2c242019-07-23 12:00:07 -0700469 start_sdm_loggers(self.log, self.android_devices)
470 else:
471 start_qxdm_loggers(self.log, self.android_devices)
Jaineelce9c7302019-06-21 15:05:48 -0700472 if self.cbrs_esim:
473 self._cbrs_data_check_test(begin_time, expected_cbrs=True,
474 test_time="before")
Betty Zhou5676e812018-03-20 16:57:58 -0700475 failure_reasons = set()
Betty Zhou4418a332018-05-15 13:11:18 -0700476 self.dut_incall = True
Betty Zhou377f72b2018-01-12 19:43:26 -0800477 if self.single_phone_test:
478 call_setup_result = initiate_call(
Betty Zhouf7a920a2018-05-11 19:21:30 -0700479 self.log,
480 self.dut,
481 self.call_server_number,
Pratik Sheth68e4eba2021-03-23 17:10:13 -0700482 incall_ui_display=INCALL_UI_DISPLAY_BACKGROUND,
483 call_stats_check=self.call_stats_check,
Pratik Sheth232f7952021-04-08 12:17:30 -0700484 voice_type_init=voice_type_init,
Pratik Shethffd15372021-04-29 15:03:47 -0700485 result_info = self.result_info,
486 nsa_5g_for_stress=self.nsa_5g_for_stress
Betty Zhou1ffbc832018-05-08 19:02:56 -0700487 ) and wait_for_in_call_active(self.dut, 60, 3)
Betty Zhou377f72b2018-01-12 19:43:26 -0800488 else:
489 call_setup_result = call_setup_teardown(
Betty Zhou74481722018-04-13 16:19:25 -0700490 self.log,
491 ads[0],
492 ads[1],
493 ad_hangup=None,
494 verify_caller_func=call_verification_func,
495 verify_callee_func=call_verification_func,
Betty Zhou1ffbc832018-05-08 19:02:56 -0700496 wait_time_in_call=0,
Jaineelf76b37b2019-01-15 16:08:22 -0800497 incall_ui_display=INCALL_UI_DISPLAY_BACKGROUND,
Pratik Sheth68e4eba2021-03-23 17:10:13 -0700498 slot_id_callee=slot_id_callee,
499 call_stats_check=self.call_stats_check,
Pratik Sheth232f7952021-04-08 12:17:30 -0700500 voice_type_init=voice_type_init,
Pratik Shethffd15372021-04-29 15:03:47 -0700501 result_info = self.result_info,
502 nsa_5g_for_stress=self.nsa_5g_for_stress)
Ashutosh Rajmani Singhe31addf2021-02-11 13:54:25 -0800503 self.result_collection[RESULTS_LIST[call_setup_result.result_value]] += 1
Ashutosh Rajmani Singh1401e8b2020-08-13 20:41:54 -0700504
Betty Zhou377f72b2018-01-12 19:43:26 -0800505 if not call_setup_result:
Betty Zhou9ffafce2018-06-15 18:56:10 -0700506 get_telephony_signal_strength(ads[0])
Jaineelc95ca432018-07-09 16:42:29 -0700507 if not self.single_phone_test:
508 get_telephony_signal_strength(ads[1])
Betty Zhou00ac4bd2018-05-29 16:23:44 -0700509 call_logs = ads[0].search_logcat(
510 "ActivityManager: START u0 {act=android.intent.action.CALL",
511 begin_time)
512 messaging_logs = ads[0].search_logcat(
513 "com.google.android.apps.messaging/.ui.conversation.ConversationActivity",
514 begin_time)
515 if call_logs and messaging_logs:
Betty Zhoud2ddfa02018-07-05 13:11:23 -0700516 if (messaging_logs[-1]["datetime_obj"] -
517 call_logs[-1]["datetime_obj"]).seconds < 5:
Betty Zhou00ac4bd2018-05-29 16:23:44 -0700518 ads[0].log.info(
519 "Call setup failure due to simultaneous activities")
520 self.result_info[
521 "Call Setup Failure With Simultaneous Activity"] += 1
522 return True
Betty Zhou8802ec62017-12-18 19:44:29 -0800523 self.log.error("%s: Setup Call failed.", log_msg)
Betty Zhou5676e812018-03-20 16:57:58 -0700524 failure_reasons.add("Setup")
Betty Zhoue31c27d2018-02-12 19:58:12 -0800525 result = False
526 else:
527 elapsed_time = 0
528 check_interval = 5
Jaineel080f1ec2019-08-02 15:01:18 -0700529 if self.sdm_log:
530 for ad in ads:
531 ad.adb.shell("i2cset -fy 3 64 6 1 b", ignore_status=True)
532 ad.adb.shell("i2cset -fy 3 65 6 1 b", ignore_status=True)
Jaineelce9c7302019-06-21 15:05:48 -0700533 if self.cbrs_esim:
Jaineele82830a2019-07-03 16:08:04 -0700534 time.sleep(5)
Jaineelce9c7302019-06-21 15:05:48 -0700535 self._cbrs_data_check_test(begin_time, expected_cbrs=False,
536 test_time="during")
Betty Zhoue31c27d2018-02-12 19:58:12 -0800537 while (elapsed_time < duration):
538 check_interval = min(check_interval, duration - elapsed_time)
539 time.sleep(check_interval)
540 elapsed_time += check_interval
Betty Zhouc6685ad2018-02-21 18:33:38 -0800541 time_message = "at <%s>/<%s> second." % (elapsed_time,
542 duration)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800543 for ad in ads:
Betty Zhou9ffafce2018-06-15 18:56:10 -0700544 get_telephony_signal_strength(ad)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800545 if not call_verification_func(self.log, ad):
Betty Zhou88f1ec82018-04-09 18:51:31 -0700546 ad.log.warning("Call is NOT in correct %s state at %s",
547 call_verification_func.__name__,
548 time_message)
Betty Zhouc4dfad12018-04-11 18:36:49 -0700549 if call_verification_func.__name__ == "is_phone_in_call_iwlan":
Betty Zhou88f1ec82018-04-09 18:51:31 -0700550 if is_phone_in_call(self.log, ad):
Betty Zhouc4dfad12018-04-11 18:36:49 -0700551 if getattr(ad, "data_rat_state_error_count",
552 0) < 1:
553 setattr(ad, "data_rat_state_error_count",
554 1)
555 continue
Betty Zhou5676e812018-03-20 16:57:58 -0700556 failure_reasons.add("Maintenance")
Betty Zhou16e8e662018-05-08 18:26:18 -0700557 last_call_drop_reason(ad, begin_time)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800558 hangup_call(self.log, ads[0])
Betty Zhouc6685ad2018-02-21 18:33:38 -0800559 result = False
Betty Zhoue31c27d2018-02-12 19:58:12 -0800560 else:
Betty Zhouc6685ad2018-02-21 18:33:38 -0800561 ad.log.info("Call is in correct %s state at %s",
562 call_verification_func.__name__,
563 time_message)
Betty Zhoua301c202018-02-13 15:11:47 -0800564 if not result:
565 break
Betty Zhou6b91ab22017-12-21 18:16:36 -0800566 if not hangup_call(self.log, ads[0]):
Betty Zhouf7a920a2018-05-11 19:21:30 -0700567 failure_reasons.add("Teardown")
568 result = False
569 for ad in ads:
570 if not wait_for_call_id_clearing(ad,
571 []) or ad.droid.telecomIsInCall():
572 ad.log.error("Fail to hang up call")
573 failure_reasons.add("Teardown")
574 result = False
Betty Zhoue31c27d2018-02-12 19:58:12 -0800575 self.result_info["Call Total"] += 1
Betty Zhou3db27a32018-04-23 14:31:25 -0700576 for ad in self.android_devices:
577 try:
Betty Zhouc9a4d0c2018-06-18 16:26:07 -0700578 ad.droid.logI("[END]%s" % log_msg)
Betty Zhou3db27a32018-04-23 14:31:25 -0700579 except:
580 pass
581 self.log.info("%s end", log_msg)
Betty Zhou4418a332018-05-15 13:11:18 -0700582 self.dut_incall = False
Jaineelce9c7302019-06-21 15:05:48 -0700583 if self.cbrs_esim:
Jaineel5acbf8c2019-09-17 14:15:06 -0700584 time.sleep(30)
Jaineelce9c7302019-06-21 15:05:48 -0700585 self._cbrs_data_check_test(begin_time, expected_cbrs=True,
586 test_time="after")
Betty Zhoua301c202018-02-13 15:11:47 -0800587 if not result:
Betty Zhou3db27a32018-04-23 14:31:25 -0700588 self.log.info("%s failed", log_msg)
Betty Zhoue204f462018-06-08 18:36:01 -0700589 if self.gps_log_file:
Betty Zhoucc4e8442018-04-25 11:07:45 -0700590 gps_info = job.run(
Betty Zhoue204f462018-06-08 18:36:01 -0700591 "tail %s" % self.gps_log_file, ignore_status=True)
Betty Zhou49744692018-04-24 11:00:38 -0700592 if gps_info.stdout:
Betty Zhou95b25f52018-06-12 17:39:23 -0700593 gps_log_path = os.path.join(self.log_path, test_name)
Mark De Ruyter72f8df92020-02-12 13:44:49 -0800594 os.makedirs(gps_log_path, exist_ok=True)
Betty Zhoue204f462018-06-08 18:36:01 -0700595 job.run(
Betty Zhou95b25f52018-06-12 17:39:23 -0700596 "tail %s > %s" %
597 (self.gps_log_file,
598 os.path.join(gps_log_path, "gps_logs.txt")),
Betty Zhoue204f462018-06-08 18:36:01 -0700599 ignore_status=True)
Betty Zhou49744692018-04-24 11:00:38 -0700600 self.log.info("gps log:\n%s", gps_info.stdout)
601 else:
602 self.log.warning("Fail to get gps log %s",
603 self.user_params["gps_log_file"])
Betty Zhou5676e812018-03-20 16:57:58 -0700604 for reason in failure_reasons:
605 self.result_info["Call %s Failure" % reason] += 1
Betty Zhou3468a8b2018-02-14 14:34:56 -0800606 for ad in ads:
Betty Zhouc6685ad2018-02-21 18:33:38 -0800607 log_path = os.path.join(self.log_path, test_name,
Betty Zhoue57ab692018-03-09 18:39:30 -0800608 "%s_binder_logs" % ad.serial)
Mark De Ruyter72f8df92020-02-12 13:44:49 -0800609 os.makedirs(log_path, exist_ok=True)
Betty Zhoue57ab692018-03-09 18:39:30 -0800610 ad.pull_files(BINDER_LOGS, log_path)
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700611 try:
612 self._take_bug_report(test_name, begin_time)
613 except Exception as e:
614 self.log.exception(e)
Betty Zhouf7a920a2018-05-11 19:21:30 -0700615 for ad in ads:
Betty Zhoudd610552018-05-31 14:18:03 -0700616 if ad.droid.telecomIsInCall():
617 hangup_call_by_adb(ad)
Betty Zhou3468a8b2018-02-14 14:34:56 -0800618 else:
619 self.log.info("%s test succeed", log_msg)
620 self.result_info["Call Success"] += 1
Betty Zhou9a0840d2018-05-24 18:01:00 -0700621 if self.result_info["Call Total"] % 50 == 0:
Betty Zhouc6685ad2018-02-21 18:33:38 -0800622 for ad in ads:
Betty Zhou9a0840d2018-05-24 18:01:00 -0700623 synchronize_device_time(ad)
Betty Zhou9ffafce2018-06-15 18:56:10 -0700624 force_connectivity_metrics_upload(ad)
Betty Zhou9a0840d2018-05-24 18:01:00 -0700625 if self.get_binder_logs:
Xianyuan Jia1b7bb2a2019-05-10 10:54:07 -0700626 log_path = os.path.join(self.log_path, test_name,
Betty Zhou9a0840d2018-05-24 18:01:00 -0700627 "%s_binder_logs" % ad.serial)
Mark De Ruyter72f8df92020-02-12 13:44:49 -0800628 os.makedirs(log_path, exist_ok=True)
Betty Zhou9a0840d2018-05-24 18:01:00 -0700629 ad.pull_files(BINDER_LOGS, log_path)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800630 return result
Betty Zhou59f18532017-05-01 15:06:11 -0700631
Betty Zhou103a9592017-10-20 18:57:16 -0700632 def _prefnetwork_mode_change(self, sub_id):
633 # ModePref change to non-LTE
Betty Zhouabe4a442018-05-21 12:37:26 -0700634 begin_time = get_device_epoch_time(self.dut)
Jaineel72d2c242019-07-23 12:00:07 -0700635 if self.sdm_log:
636 start_sdm_loggers(self.log, self.android_devices)
637 else:
638 start_qxdm_loggers(self.log, self.android_devices)
Betty Zhou732c23b2018-05-25 20:05:11 -0700639 self.result_info["Network Change Request Total"] += 1
640 test_name = "%s_network_change_iter_%s" % (
641 self.test_name, self.result_info["Network Change Request Total"])
642 log_msg = "[Test Case] %s" % test_name
643 self.log.info("%s begin", log_msg)
Betty Zhouc9a4d0c2018-06-18 16:26:07 -0700644 self.dut.droid.logI("[BEGIN]%s" % log_msg)
Betty Zhou103a9592017-10-20 18:57:16 -0700645 network_preference_list = [
646 NETWORK_MODE_TDSCDMA_GSM_WCDMA, NETWORK_MODE_WCDMA_ONLY,
647 NETWORK_MODE_GLOBAL, NETWORK_MODE_CDMA, NETWORK_MODE_GSM_ONLY
648 ]
649 network_preference = random.choice(network_preference_list)
650 set_preferred_network_mode_pref(self.log, self.dut, sub_id,
651 network_preference)
652 time.sleep(WAIT_TIME_AFTER_MODE_CHANGE)
653 self.dut.log.info("Current Voice RAT is %s",
654 get_current_voice_rat(self.log, self.dut))
655
656 # ModePref change back to with LTE
Betty Zhou732c23b2018-05-25 20:05:11 -0700657 if not phone_setup_volte(self.log, self.dut):
658 self.dut.log.error("Phone failed to enable VoLTE.")
659 self.result_info["VoLTE Setup Failure"] += 1
660 self.dut.droid.logI("%s end" % log_msg)
Betty Zhouc9a4d0c2018-06-18 16:26:07 -0700661 self.dut.log.info("[END]%s", log_msg)
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700662 try:
Betty Zhou732c23b2018-05-25 20:05:11 -0700663 self._ad_take_extra_logs(self.dut, test_name, begin_time)
664 self._ad_take_bugreport(self.dut, test_name, begin_time)
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700665 except Exception as e:
666 self.log.exception(e)
Jaineelcd748202017-08-10 12:23:42 -0700667 return False
Betty Zhoue31c27d2018-02-12 19:58:12 -0800668 else:
Betty Zhou732c23b2018-05-25 20:05:11 -0700669 self.result_info["VoLTE Setup Success"] += 1
670 return True
671
672 def _mobile_data_toggling(self, setup="volte"):
673 # ModePref change to non-LTE
674 begin_time = get_device_epoch_time(self.dut)
Jaineel72d2c242019-07-23 12:00:07 -0700675 if self.sdm_log:
676 start_sdm_loggers(self.log, self.android_devices)
677 else:
678 start_qxdm_loggers(self.log, self.android_devices)
Betty Zhou732c23b2018-05-25 20:05:11 -0700679 result = True
680 self.result_info["Data Toggling Request Total"] += 1
681 test_name = "%s_data_toggling_iter_%s" % (
682 self.test_name, self.result_info["Data Toggling Request Total"])
683 log_msg = "[Test Case] %s" % test_name
684 self.log.info("%s begin", log_msg)
Betty Zhouc9a4d0c2018-06-18 16:26:07 -0700685 self.dut.droid.logI("[BEGIN]%s" % log_msg)
Betty Zhouca028012018-05-31 17:29:01 -0700686 self.dut.adb.shell("svc data disable")
Betty Zhou732c23b2018-05-25 20:05:11 -0700687 time.sleep(WAIT_TIME_AFTER_MODE_CHANGE)
Betty Zhouca028012018-05-31 17:29:01 -0700688 self.dut.adb.shell("svc data enable")
Betty Zhou732c23b2018-05-25 20:05:11 -0700689 if not self._check_data():
690 result = False
691 elif setup == "volte" and not phone_idle_volte(self.log, self.dut):
692 result = False
693 self.dut.droid.logI("%s end" % log_msg)
Betty Zhouc9a4d0c2018-06-18 16:26:07 -0700694 self.dut.log.info("[END]%s", log_msg)
Betty Zhou732c23b2018-05-25 20:05:11 -0700695 if not result:
696 self.result_info["Data Toggling Failure"] += 1
697 try:
698 self._ad_take_extra_logs(self.dut, test_name, begin_time)
699 self._ad_take_bugreport(self.dut, test_name, begin_time)
700 except Exception as e:
701 self.log.exception(e)
702 return False
703 else:
704 self.result_info["Data Toggling Success"] += 1
Betty Zhoue31c27d2018-02-12 19:58:12 -0800705 return True
Jaineelcd748202017-08-10 12:23:42 -0700706
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800707 def _get_result_message(self):
Betty Zhouc6685ad2018-02-21 18:33:38 -0800708 msg_list = [
709 "%s: %s" % (count, self.result_info[count])
710 for count in sorted(self.result_info.keys())
711 ]
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800712 return ", ".join(msg_list)
713
Betty Zhou61646502018-01-12 13:02:48 -0800714 def _write_perf_json(self):
715 json_str = json.dumps(self.perf_data, indent=4, sort_keys=True)
716 with open(self.perf_file, 'w') as f:
717 f.write(json_str)
718
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800719 def _init_perf_json(self):
Betty Zhouc6685ad2018-02-21 18:33:38 -0800720 self.perf_file = os.path.join(self.log_path, "%s_perf_data_%s.json" %
721 (self.test_name, self.begin_time))
Betty Zhou4418a332018-05-15 13:11:18 -0700722 self.perf_data = self.dut.build_info.copy()
Betty Zhou732c23b2018-05-25 20:05:11 -0700723 self.perf_data["build_fingerprint"] = self.dut.adb.getprop(
724 "ro.build.fingerprint")
Betty Zhou4418a332018-05-15 13:11:18 -0700725 self.perf_data["model"] = self.dut.model
726 self.perf_data["carrier"] = self.dut.adb.getprop(
727 "gsm.sim.operator.alpha")
Betty Zhou61646502018-01-12 13:02:48 -0800728 self._write_perf_json()
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800729
730 def _update_perf_json(self):
731 for result_key, result_value in self.result_info.items():
732 self.perf_data[result_key] = result_value
Betty Zhou61646502018-01-12 13:02:48 -0800733 self._write_perf_json()
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800734
Betty Zhou56a54612017-05-09 18:54:45 -0700735 def crash_check_test(self):
736 failure = 0
737 while time.time() < self.finishing_time:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700738 try:
Betty Zhou06219032018-01-11 12:40:49 -0800739 self.log.info(dict(self.result_info))
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800740 self._update_perf_json()
Betty Zhouabe4a442018-05-21 12:37:26 -0700741 begin_time = get_device_epoch_time(self.dut)
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700742 run_time_in_seconds = (begin_time - self.begin_time) / 1000
743 test_name = "%s_crash_%s_seconds_after_start" % (
744 self.test_name, run_time_in_seconds)
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700745 time.sleep(self.crash_check_interval)
Betty Zhouf52dee32018-01-08 13:07:42 -0800746 for ad in self.android_devices:
Betty Zhou4c1c4b12017-12-21 17:06:13 -0800747 crash_report = ad.check_crash_report(
Betty Zhou4bc31fc2018-03-12 18:28:50 -0700748 test_name, begin_time, log_crash_report=True)
Betty Zhou4c1c4b12017-12-21 17:06:13 -0800749 if crash_report:
750 ad.log.error("Find new crash reports %s", crash_report)
751 failure += 1
Betty Zhouabe4a442018-05-21 12:37:26 -0700752 self.result_info["Crashes"] += len(crash_report)
Betty Zhou27080b12018-03-01 15:06:13 -0800753 for crash in crash_report:
754 if "ramdump_modem" in crash:
755 self.result_info["Crashes-Modem"] += 1
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700756 try:
757 ad.take_bug_report(test_name, begin_time)
758 except Exception as e:
759 self.log.exception(e)
Betty Zhoucf048542018-02-22 17:14:08 -0800760 except Exception as e:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700761 self.log.error("Exception error %s", str(e))
762 self.result_info["Exception Errors"] += 1
Betty Zhou4c1c4b12017-12-21 17:06:13 -0800763 self.log.info("Crashes found: %s", failure)
Betty Zhoucf048542018-02-22 17:14:08 -0800764 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
765 self.log.error("Too many exception errors, quit test")
Betty Zhou53f1d0e2018-01-26 20:08:27 -0800766 return False
Betty Zhou8c0fc692017-07-20 18:49:19 -0700767 if failure:
Betty Zhoua1296402017-10-23 17:32:40 -0700768 return False
Betty Zhou8c0fc692017-07-20 18:49:19 -0700769 else:
Betty Zhoua1296402017-10-23 17:32:40 -0700770 return True
Betty Zhou56a54612017-05-09 18:54:45 -0700771
Jaineelce9c7302019-06-21 15:05:48 -0700772 def _cbrs_data_check_test(self, begin_time, expected_cbrs=True,
773 test_time="before"):
774 cbrs_fail_count = 0
775 the_number = self.result_info["CBRS Total"] + 1
776 test_name = "%s_cbrs_%s_call_No_%s" % (self.test_name,
777 test_time, the_number)
Jaineel15879c92019-06-03 17:08:13 -0700778 for ad in self.android_devices:
Jaineelce9c7302019-06-21 15:05:48 -0700779 current_state = is_current_data_on_cbrs(ad, ad.cbrs)
780 if current_state == expected_cbrs:
781 self.result_info["CBRS-Check-Pass"] += 1
782 else:
783 self.result_info["CBRS-Check-Fail"] += 1
784 cbrs_fail_count += 1
785 try:
786 self._ad_take_extra_logs(ad, test_name, begin_time)
787 self._ad_take_bugreport(ad, test_name, begin_time)
788 except Exception as e:
789 self.log.warning(e)
790 if cbrs_fail_count > 0:
791 ad.log.error("Found %d checks failed, expected cbrs %s",
792 cbrs_fail_count, expected_cbrs)
793 cbrs_fail_count += 1
Jaineel5acbf8c2019-09-17 14:15:06 -0700794 self.result_info["CBRS Total"] += 1
Jaineelce9c7302019-06-21 15:05:48 -0700795 return True
Jaineel15879c92019-06-03 17:08:13 -0700796
Betty Zhou82d7a722017-11-08 15:56:04 -0800797 def call_test(self, call_verification_func=None):
Betty Zhou59f18532017-05-01 15:06:11 -0700798 while time.time() < self.finishing_time:
Jaineel6db9de42019-01-14 11:47:41 -0800799 time.sleep(
800 random.randrange(self.min_sleep_time, self.max_sleep_time))
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700801 try:
Betty Zhou377f72b2018-01-12 19:43:26 -0800802 self._make_phone_call(call_verification_func)
Betty Zhoucf048542018-02-22 17:14:08 -0800803 except Exception as e:
Betty Zhou03bd3f92018-06-06 17:37:56 -0700804 self.log.exception("Exception error %s", str(e))
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700805 self.result_info["Exception Errors"] += 1
Betty Zhoucf048542018-02-22 17:14:08 -0800806 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
807 self.log.error("Too many exception errors, quit test")
Betty Zhou628b98e2018-01-08 15:45:25 -0800808 return False
Betty Zhou75cbbbe2017-11-06 14:09:20 -0800809 self.log.info("%s", dict(self.result_info))
Ashutosh Rajmani Singhe31addf2021-02-11 13:54:25 -0800810 self.tel_logger.set_result(self.result_collection)
Betty Zhouc6685ad2018-02-21 18:33:38 -0800811 if any([
812 self.result_info["Call Setup Failure"],
Betty Zhou5e3f68a2017-12-14 15:50:47 -0800813 self.result_info["Call Maintenance Failure"],
Betty Zhouc6685ad2018-02-21 18:33:38 -0800814 self.result_info["Call Teardown Failure"]
815 ]):
Betty Zhou103a9592017-10-20 18:57:16 -0700816 return False
Jaineelcd748202017-08-10 12:23:42 -0700817 else:
Betty Zhou103a9592017-10-20 18:57:16 -0700818 return True
Jaineelcd748202017-08-10 12:23:42 -0700819
Betty Zhou632793c2018-02-09 18:45:39 -0800820 def message_test(self, max_wait_time=MAX_WAIT_TIME_SMS_RECEIVE):
Betty Zhou59f18532017-05-01 15:06:11 -0700821 while time.time() < self.finishing_time:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700822 try:
Betty Zhou632793c2018-02-09 18:45:39 -0800823 self._send_message(max_wait_time=max_wait_time)
Betty Zhoucf048542018-02-22 17:14:08 -0800824 except Exception as e:
Betty Zhou03bd3f92018-06-06 17:37:56 -0700825 self.log.exception("Exception error %s", str(e))
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700826 self.result_info["Exception Errors"] += 1
Betty Zhou4c1c4b12017-12-21 17:06:13 -0800827 self.log.info(dict(self.result_info))
Betty Zhoucf048542018-02-22 17:14:08 -0800828 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
829 self.log.error("Too many exception errors, quit test")
Betty Zhou53f1d0e2018-01-26 20:08:27 -0800830 return False
Betty Zhoucf048542018-02-22 17:14:08 -0800831 time.sleep(
832 random.randrange(self.min_sleep_time, self.max_sleep_time))
Betty Zhoue31c27d2018-02-12 19:58:12 -0800833 if self.result_info["SMS Failure"] or (
834 self.result_info["MMS Failure"] / self.result_info["MMS Total"]
Betty Zhou75cbbbe2017-11-06 14:09:20 -0800835 > 0.3):
Betty Zhou103a9592017-10-20 18:57:16 -0700836 return False
Betty Zhou8c0fc692017-07-20 18:49:19 -0700837 else:
Betty Zhou103a9592017-10-20 18:57:16 -0700838 return True
Betty Zhou59f18532017-05-01 15:06:11 -0700839
Jaineel33a11932020-07-31 17:37:03 -0700840 def _data_download(self, file_names=[]):
Betty Zhoue31c27d2018-02-12 19:58:12 -0800841 begin_time = get_current_epoch_time()
Jaineelf76b37b2019-01-15 16:08:22 -0800842 slot_id = random.randint(0,1)
843 if self.dsds_esim:
844 sub_id = get_subid_from_slot_index(self.log, self.dut, slot_id)
845 self.dut.log.info("Data - slot_Id %d", slot_id)
846 set_subid_for_data(self.dut, sub_id)
Jaineel65c5a982019-02-22 15:55:47 -0800847 self.dut.droid.telephonyToggleDataConnection(True)
Jaineel72d2c242019-07-23 12:00:07 -0700848 if self.sdm_log:
849 start_sdm_loggers(self.log, self.android_devices)
850 else:
851 start_qxdm_loggers(self.log, self.android_devices)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800852 self.dut.log.info(dict(self.result_info))
853 selection = random.randrange(0, len(file_names))
854 file_name = file_names[selection]
Betty Zhoufe64cd82018-03-26 14:14:07 -0700855 self.result_info["Internet Connection Check Total"] += 1
Jaineel15879c92019-06-03 17:08:13 -0700856
Jaineelc55ca592019-10-25 10:26:33 -0700857 rat = self._get_network_rat(slot_id)
Betty Zhou5ee8e042018-06-05 20:34:12 -0700858 if not self.internet_connection_check_method(self.log, self.dut):
Jaineelc55ca592019-10-25 10:26:33 -0700859 self.dut.log.info("Network in RAT %s", rat)
Betty Zhou4418a332018-05-15 13:11:18 -0700860 if self.dut_incall and not is_rat_svd_capable(rat.upper()):
Betty Zhou774ea542018-05-16 12:45:36 -0700861 self.result_info[
Betty Zhou4418a332018-05-15 13:11:18 -0700862 "Expected Incall Internet Connection Check Failure"] += 1
863 return True
864 else:
865 self.result_info["Internet Connection Check Failure"] += 1
866 test_name = "%s_internet_connection_No_%s_failure" % (
867 self.test_name,
868 self.result_info["Internet Connection Check Failure"])
869 try:
870 self._ad_take_extra_logs(self.dut, test_name, begin_time)
871 self._ad_take_bugreport(self.dut, test_name, begin_time)
872 except Exception as e:
873 self.log.exception(e)
874 return False
Betty Zhoufe64cd82018-03-26 14:14:07 -0700875 else:
876 self.result_info["Internet Connection Check Success"] += 1
877
Betty Zhoue31c27d2018-02-12 19:58:12 -0800878 self.result_info["File Download Total"] += 1
Ashutosh Rajmani Singha5c5b922020-12-08 23:25:33 -0800879 self.result_info["Data Download Total"] += int(file_name[:-2])
Betty Zhouc86784b2018-02-28 16:42:53 -0800880 if not active_file_download_test(
Betty Zhouc133f8c2018-03-02 15:40:13 -0800881 self.log, self.dut, file_name,
882 method=self.file_download_method):
Betty Zhou200031e2018-02-14 15:21:24 -0800883 self.result_info["File Download Failure"] += 1
Ashutosh Rajmani Singha5c5b922020-12-08 23:25:33 -0800884 self.result_info["Data Failure Total"] += int(file_name[:-2])
Betty Zhou200031e2018-02-14 15:21:24 -0800885 if self.result_info["File Download Failure"] == 1:
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700886 try:
887 self._ad_take_extra_logs(
888 self.dut, "%s_file_download_failure" % self.test_name,
889 begin_time)
Betty Zhoufe64cd82018-03-26 14:14:07 -0700890 self._ad_take_bugreport(
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700891 self.dut, "%s_file_download_failure" % self.test_name,
892 begin_time)
893 except Exception as e:
894 self.log.exception(e)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800895 return False
896 else:
897 self.result_info["File Download Success"] += 1
Ashutosh Rajmani Singha5c5b922020-12-08 23:25:33 -0800898 self.result_info["Data Success Total"] += int(file_name[:-2])
Betty Zhoue31c27d2018-02-12 19:58:12 -0800899 return True
900
901 def data_test(self):
Betty Zhou59f18532017-05-01 15:06:11 -0700902 while time.time() < self.finishing_time:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700903 try:
Jaineel33a11932020-07-31 17:37:03 -0700904 self._data_download(self.file_name_list)
Betty Zhoucf048542018-02-22 17:14:08 -0800905 except Exception as e:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700906 self.log.error("Exception error %s", str(e))
907 self.result_info["Exception Errors"] += 1
Betty Zhou75cbbbe2017-11-06 14:09:20 -0800908 self.log.info("%s", dict(self.result_info))
Betty Zhoucf048542018-02-22 17:14:08 -0800909 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
910 self.log.error("Too many exception errors, quit test")
Betty Zhou53f1d0e2018-01-26 20:08:27 -0800911 return False
Betty Zhoucf048542018-02-22 17:14:08 -0800912 time.sleep(
913 random.randrange(self.min_sleep_time, self.max_sleep_time))
Betty Zhoufe64cd82018-03-26 14:14:07 -0700914 if self.result_info["Internet Connection Check Failure"]:
Betty Zhou103a9592017-10-20 18:57:16 -0700915 return False
Betty Zhou8c0fc692017-07-20 18:49:19 -0700916 else:
Betty Zhou103a9592017-10-20 18:57:16 -0700917 return True
Betty Zhou59f18532017-05-01 15:06:11 -0700918
Betty Zhou969b17a2018-05-23 18:56:37 -0700919 def _check_data(self):
920 self.result_info["Data Connection Check Total"] += 1
921 if not wait_for_data_connection(self.log, self.dut, True):
922 self.result_info["Data Connection Setup Failure"] += 1
923 return False
Betty Zhou5ee8e042018-06-05 20:34:12 -0700924 if not self.internet_connection_check_method(self.log, self.dut):
Betty Zhou969b17a2018-05-23 18:56:37 -0700925 rat = self.dut.adb.getprop("gsm.network.type")
926 self.dut.log.info("Network in RAT %s", rat)
927 self.result_info["Internet Connection Check Failure"] += 1
928 return False
929 return True
930
931 def _data_call_test(self, sub_id, generation):
932 self.dut.log.info(dict(self.result_info))
933 begin_time = get_device_epoch_time(self.dut)
Jaineel72d2c242019-07-23 12:00:07 -0700934 if self.sdm_log:
935 start_sdm_loggers(self.log, self.android_devices)
936 else:
937 start_qxdm_loggers(self.log, self.android_devices)
Betty Zhou9a0840d2018-05-24 18:01:00 -0700938 self.result_info["Network Change Request Total"] += 1
Betty Zhou732c23b2018-05-25 20:05:11 -0700939 test_name = "%s_network_change_test_iter_%s" % (
Betty Zhou9a0840d2018-05-24 18:01:00 -0700940 self.test_name, self.result_info["Network Change Request Total"])
Betty Zhou969b17a2018-05-23 18:56:37 -0700941 log_msg = "[Test Case] %s" % test_name
Betty Zhou732c23b2018-05-25 20:05:11 -0700942 self.log.info("%s begin", log_msg)
Betty Zhouc9a4d0c2018-06-18 16:26:07 -0700943 self.dut.droid.logI("[BEGIN]%s" % log_msg)
Betty Zhou969b17a2018-05-23 18:56:37 -0700944 if not ensure_network_generation_for_subscription(
Betty Zhou732c23b2018-05-25 20:05:11 -0700945 self.log, self.dut, sub_id,
946 generation) or not self._check_data():
Betty Zhou969b17a2018-05-23 18:56:37 -0700947 self.result_info["Network Change Failure"] += 1
Betty Zhou969b17a2018-05-23 18:56:37 -0700948 self.dut.droid.logI("%s end" % log_msg)
Betty Zhouc9a4d0c2018-06-18 16:26:07 -0700949 self.dut.log.info("[END]%s", log_msg)
Betty Zhou969b17a2018-05-23 18:56:37 -0700950 try:
Betty Zhou732c23b2018-05-25 20:05:11 -0700951 self._ad_take_extra_logs(self.dut, test_name, begin_time)
952 self._ad_take_bugreport(self.dut, test_name, begin_time)
Betty Zhou969b17a2018-05-23 18:56:37 -0700953 except Exception as e:
954 self.log.warning(e)
955 return False
Betty Zhou732c23b2018-05-25 20:05:11 -0700956 if not self._mobile_data_toggling(setup=None):
957 return False
958 return True
Betty Zhou969b17a2018-05-23 18:56:37 -0700959
960 def data_call_stress_test(self):
961 result = True
962 sub_id = self.dut.droid.subscriptionGetDefaultSubId()
963 while time.time() < self.finishing_time:
964 for generation in (GEN_4G, GEN_3G):
965 try:
966 if not self._data_call_test(sub_id, generation):
967 result = False
968 except Exception as e:
969 self.log.error("Exception error %s", str(e))
970 self.result_info["Exception Errors"] += 1
971 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
972 self.log.error("Too many exception errors, quit test")
973 return False
974 return result
975
Betty Zhoub707ef22018-05-14 16:47:05 -0700976 def check_incall_data(self):
Betty Zhou1cd4ebe2018-06-08 19:02:52 -0700977 if verify_internet_connection_by_ping(self.log, self.dut):
978 self.internet_connection_check_method = verify_internet_connection_by_ping
979 elif verify_http_connection(self.log, self.dut):
980 self.internet_connection_check_method = verify_http_connection
981 else:
982 self.dut.log.error("Data test failed")
983 raise signals.TestFailure("Data check failed")
Betty Zhoub707ef22018-05-14 16:47:05 -0700984 if self.single_phone_test:
Betty Zhou4418a332018-05-15 13:11:18 -0700985 if not initiate_call(
986 self.log, self.dut,
987 self.call_server_number) and wait_for_in_call_active(
988 self.dut, 60, 3):
Betty Zhou00ac4bd2018-05-29 16:23:44 -0700989 self._take_bug_report(self.test_name, self.begin_time)
Betty Zhoud2312bb2018-05-18 18:24:04 -0700990 raise signals.TestFailure("Unable to make phone call")
Betty Zhoub707ef22018-05-14 16:47:05 -0700991 else:
Betty Zhou4418a332018-05-15 13:11:18 -0700992 if not call_setup_teardown(
993 self.log, self.dut, self.android_devices[1],
994 ad_hangup=None):
Betty Zhou00ac4bd2018-05-29 16:23:44 -0700995 self._take_bug_report(self.test_name, self.begin_time)
Betty Zhoud2312bb2018-05-18 18:24:04 -0700996 raise signals.TestFailure("Unable to make phone call")
Betty Zhou4418a332018-05-15 13:11:18 -0700997 voice_rat = self.dut.droid.telephonyGetCurrentVoiceNetworkType()
998 data_rat = self.dut.droid.telephonyGetCurrentDataNetworkType()
999 self.dut.log.info("Voice in RAT %s, Data in RAT %s", voice_rat,
1000 data_rat)
1001 try:
Betty Zhouc9a4d0c2018-06-18 16:26:07 -07001002 if "wfc" in self.test_name or is_rat_svd_capable(
1003 voice_rat.upper()) and is_rat_svd_capable(
1004 data_rat.upper()):
Betty Zhou4418a332018-05-15 13:11:18 -07001005 self.dut.log.info("Capable for simultaneous voice and data")
Betty Zhou5ee8e042018-06-05 20:34:12 -07001006
1007 if not self.internet_connection_check_method(
1008 self.log, self.dut):
Betty Zhou4418a332018-05-15 13:11:18 -07001009 self.dut.log.error("Incall data check failed")
Betty Zhoud2312bb2018-05-18 18:24:04 -07001010 raise signals.TestFailure("Incall data check failed")
Betty Zhou4418a332018-05-15 13:11:18 -07001011 else:
1012 return True
1013 else:
1014 self.dut.log.info(
1015 "Not capable for simultaneous voice and data")
1016 return False
Betty Zhoudd610552018-05-31 14:18:03 -07001017 hangup_call(self.log, self.dut)
Betty Zhou4418a332018-05-15 13:11:18 -07001018 finally:
Betty Zhoudd610552018-05-31 14:18:03 -07001019 for ad in self.android_devices:
1020 if ad.droid.telecomIsInCall():
1021 hangup_call(self.log, ad)
Betty Zhoub707ef22018-05-14 16:47:05 -07001022
Betty Zhou82d7a722017-11-08 15:56:04 -08001023 def parallel_tests(self, setup_func=None, call_verification_func=None):
Betty Zhou61646502018-01-12 13:02:48 -08001024 self.log.info(self._get_result_message())
Betty Zhou59f18532017-05-01 15:06:11 -07001025 if setup_func and not setup_func():
Betty Zhoue26fe892018-04-23 15:29:53 -07001026 msg = "%s setup %s failed" % (self.test_name, setup_func.__name__)
Betty Zhou103a9592017-10-20 18:57:16 -07001027 self.log.error(msg)
Betty Zhou2bb11682018-04-19 17:05:30 -07001028 self._take_bug_report("%s%s" % (self.test_name,
1029 setup_func.__name__),
1030 self.begin_time)
1031 return False
Betty Zhou8802ec62017-12-18 19:44:29 -08001032 if not call_verification_func:
1033 call_verification_func = is_phone_in_call
Betty Zhou59f18532017-05-01 15:06:11 -07001034 self.finishing_time = time.time() + self.max_run_time
Jaineele5550872019-12-20 13:47:18 -08001035 # CBRS setup
Jaineelce9c7302019-06-21 15:05:48 -07001036 if self.cbrs_esim:
1037 cbrs_sub_count = 0
1038 for ad in self.android_devices:
1039 if not getattr(ad, 'cbrs', {}):
1040 setattr(ad, 'cbrs', None)
1041 for i in range(0, 2):
1042 sub_id = get_subid_from_slot_index(ad.log, ad, i)
1043 operator = get_operatorname_from_slot_index(ad, i)
Jaineelc9ea2f32019-08-21 13:48:16 -07001044 carrier_id = get_carrierid_from_slot_index(ad, i)
Jaineel24052672020-04-16 20:37:36 -07001045 is_opportunistic = get_isopportunistic_from_slot_index(ad, i)
Jaineelc9ea2f32019-08-21 13:48:16 -07001046 ad.log.info("Slot %d - Sub %s - %s - %d", i, sub_id, operator, carrier_id)
Pratik Shethdb52e652021-03-17 15:08:27 -07001047 if carrier_id == GOOGLE_CBRS_CARRIER_ID or (carrier_id == GOOGLE_FI_CARRIER_ID and is_opportunistic):
Jaineelce9c7302019-06-21 15:05:48 -07001048 ad.cbrs = sub_id
1049 cbrs_sub_count += 1
1050 if cbrs_sub_count != 2:
1051 self.log.error("Expecting - 2 CBRS subs, found - %d", cbrs_sub_count)
1052 raise signals.TestAbortClass("Cannot find all expected CBRS subs")
Jaineele5550872019-12-20 13:47:18 -08001053 # DSDS setup
1054 if self.dsds_esim:
1055 for ad in self.android_devices:
1056 for i in range(0, 2):
1057 sub_id = get_subid_from_slot_index(ad.log, ad, i)
Pratik Shethdb52e652021-03-17 15:08:27 -07001058 set_always_allow_mms_data(ad, sub_id)
Jaineele5550872019-12-20 13:47:18 -08001059 operator = get_operatorname_from_slot_index(ad, i)
1060 ad.log.info("Slot %d - Sub %s - %s", i, sub_id, operator)
1061 # Actual test trigger
Jaineelf76b37b2019-01-15 16:08:22 -08001062 if not self.dsds_esim and self.check_incall_data():
Betty Zhou4418a332018-05-15 13:11:18 -07001063 self.log.info(
1064 "==== Start parallel voice/message/data stress test ====")
1065 self.perf_data["testing method"] = "parallel"
Jaineelce9c7302019-06-21 15:05:48 -07001066 results = run_multithread_func(
1067 self.log, [(self.call_test, [call_verification_func]),
1068 (self.message_test, []), (self.data_test, []),
1069 (self.crash_check_test, [])])
Betty Zhoub707ef22018-05-14 16:47:05 -07001070 else:
Betty Zhou4418a332018-05-15 13:11:18 -07001071 self.log.info(
1072 "==== Start sequential voice/message/data stress test ====")
1073 self.perf_data["testing method"] = "sequential"
Betty Zhoub707ef22018-05-14 16:47:05 -07001074 results = run_multithread_func(
1075 self.log, [(self.sequential_tests, [call_verification_func]),
1076 (self.crash_check_test, [])])
Betty Zhou9aa68ad2018-01-12 12:39:23 -08001077 result_message = self._get_result_message()
Betty Zhou551ebb52017-10-24 12:59:24 -07001078 self.log.info(result_message)
Betty Zhoucbda4122018-01-16 19:15:42 -08001079 self._update_perf_json()
Betty Zhou53f1d0e2018-01-26 20:08:27 -08001080 self.result_detail = result_message
1081 return all(results)
Betty Zhou59f18532017-05-01 15:06:11 -07001082
Betty Zhoub707ef22018-05-14 16:47:05 -07001083 def sequential_tests(self, call_verification_func):
1084 funcs = [(self._make_phone_call, [call_verification_func]),
1085 (self._send_message, []), (self._data_download, [["5MB"]])]
1086 while time.time() < self.finishing_time:
1087 selection = random.randrange(0, 3)
1088 try:
1089 funcs[selection][0](*funcs[selection][1])
1090 except Exception as e:
1091 self.log.error("Exception error %s", str(e))
1092 self.result_info["Exception Errors"] += 1
1093 self.log.info("%s", dict(self.result_info))
1094 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
1095 self.log.error("Too many exception errors, quit test")
1096 return False
1097 time.sleep(
1098 random.randrange(self.min_sleep_time, self.max_sleep_time))
1099 if any([
1100 self.result_info["Call Setup Failure"],
1101 self.result_info["Call Maintenance Failure"],
1102 self.result_info["Call Teardown Failure"],
1103 self.result_info["SMS Failure"],
1104 self.result_info["MMS Failure"],
1105 self.result_info["Internet Connection Check Failure"]
1106 ]):
1107 return False
1108 return True
1109
Betty Zhoue31c27d2018-02-12 19:58:12 -08001110 def volte_modechange_volte_test(self):
1111 sub_id = self.dut.droid.subscriptionGetDefaultSubId()
Betty Zhou732c23b2018-05-25 20:05:11 -07001112 result = True
Betty Zhoue31c27d2018-02-12 19:58:12 -08001113 while time.time() < self.finishing_time:
1114 try:
Betty Zhou732c23b2018-05-25 20:05:11 -07001115 if self._prefnetwork_mode_change(sub_id):
1116 run_multithread_func(
1117 self.log,
1118 [(self._data_download, [["5MB"]]),
1119 (self._make_phone_call, [is_phone_in_call_volte]),
1120 (self._send_message, [])])
1121 else:
1122 result = False
1123 if self._mobile_data_toggling():
1124 run_multithread_func(
1125 self.log,
1126 [(self._data_download, [["5MB"]]),
1127 (self._make_phone_call, [is_phone_in_call_volte]),
1128 (self._send_message, [])])
1129 else:
1130 result = False
Betty Zhoucf048542018-02-22 17:14:08 -08001131 except Exception as e:
Betty Zhoue31c27d2018-02-12 19:58:12 -08001132 self.log.error("Exception error %s", str(e))
1133 self.result_info["Exception Errors"] += 1
Betty Zhoue31c27d2018-02-12 19:58:12 -08001134 self.log.info(dict(self.result_info))
Betty Zhoucf048542018-02-22 17:14:08 -08001135 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
1136 self.log.error("Too many exception errors, quit test")
Betty Zhoue31c27d2018-02-12 19:58:12 -08001137 return False
Betty Zhou732c23b2018-05-25 20:05:11 -07001138 return result
Betty Zhou61646502018-01-12 13:02:48 -08001139
Betty Zhou632793c2018-02-09 18:45:39 -08001140 def parallel_with_network_change_tests(self, setup_func=None):
Jaineelcd748202017-08-10 12:23:42 -07001141 if setup_func and not setup_func():
1142 self.log.error("Test setup %s failed", setup_func.__name__)
1143 return False
Jaineelcd748202017-08-10 12:23:42 -07001144 self.finishing_time = time.time() + self.max_run_time
Jaineel664316b2017-12-04 15:16:48 -08001145 results = run_multithread_func(self.log,
1146 [(self.volte_modechange_volte_test, []),
1147 (self.crash_check_test, [])])
Betty Zhoue31c27d2018-02-12 19:58:12 -08001148 result_message = self._get_result_message()
Betty Zhou61646502018-01-12 13:02:48 -08001149 self.log.info(result_message)
Betty Zhoucbda4122018-01-16 19:15:42 -08001150 self._update_perf_json()
Betty Zhou53f1d0e2018-01-26 20:08:27 -08001151 self.result_detail = result_message
1152 return all(results)
Jaineelcd748202017-08-10 12:23:42 -07001153
Ashutosh Rajmani Singhd716bdc2019-07-26 15:07:48 -07001154 def connect_to_wifi(self):
1155 for ad in self.android_devices:
1156 if not ensure_wifi_connected(
1157 self.log,
1158 ad,
1159 self.wifi_network_ssid,
1160 self.wifi_network_pass,
1161 retries=3):
1162 ad.log.error("Bringing up Wifi connection fails.")
1163 return False
1164 ad.log.info("Phone WIFI is connected successfully.")
1165 return True
1166
Ashutosh Rajmani Singh72a83472020-08-02 23:40:40 -07001167 def performance_tests(self, setup_func=None, call_verification_func=None):
1168 self.log.info(self._get_result_message())
1169 if setup_func and not setup_func():
1170 msg = "%s setup %s failed" % (self.test_name, setup_func.__name__)
1171 self.log.error(msg)
1172 self._take_bug_report("%s%s" % (self.test_name,
1173 setup_func.__name__),
1174 self.begin_time)
1175 return False
1176 if not call_verification_func:
1177 call_verification_func = is_phone_in_call
1178 self.finishing_time = time.time() + self.max_run_time
1179
1180 self.log.info(
1181 "==== Start voice stress test ====")
1182 self.perf_data["testing method"] = "parallel"
Ashutosh Rajmani Singh84512902020-08-18 00:47:50 -07001183 results = self.call_performance_test(call_verification_func)
Ashutosh Rajmani Singh72a83472020-08-02 23:40:40 -07001184
1185 result_message = self._get_result_message()
1186 self.log.info(result_message)
1187 self._update_perf_json()
1188 self.result_detail = result_message
1189 total_call = self.result_info["Call Total"]
1190 success_call = self.result_info["Call Success Total"]
1191 call_fail = total_call - success_call
1192 if call_fail != 0:
1193 call_fail_rate = ( call_fail / total_call ) * 100
1194 else:
1195 call_fail_rate = 0
1196 call_success_rate = (success_call / total_call) * 100
1197
1198 self.log.info("Call Success Rate is %s", call_success_rate)
1199 self.log.info("Call Drop Rate is %s", call_success_rate)
1200
Ashutosh Rajmani Singh71348fe2020-08-28 11:16:30 -07001201 return results
Ashutosh Rajmani Singh72a83472020-08-02 23:40:40 -07001202
1203 def _update_initiate_call_fail_count(self):
1204 self.result_info["Call Initiate Fail"] += 1
1205
1206 def call_performance_test(self, call_verification_func=None):
Ashutosh Rajmani Singh84512902020-08-18 00:47:50 -07001207 count = 0
1208 while count < self.phone_call_iteration:
1209 time.sleep(15)
1210 count += 1
Ashutosh Rajmani Singh72a83472020-08-02 23:40:40 -07001211 try:
Ashutosh Rajmani Singh84512902020-08-18 00:47:50 -07001212 self._make_phone_call(call_verification_func, True)
Ashutosh Rajmani Singh72a83472020-08-02 23:40:40 -07001213 except Exception as e:
1214 self.log.exception("Exception error %s", str(e))
1215 self.result_info["Exception Errors"] += 1
1216 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
1217 self.log.error("Too many exception errors, quit test")
1218 return False
1219 self.log.info("%s", dict(self.result_info))
Ashutosh Rajmani Singh84512902020-08-18 00:47:50 -07001220 self.result_info["Call Success Total"] += 1
Ashutosh Rajmani Singh72a83472020-08-02 23:40:40 -07001221 if any([
1222 self.result_info["Call Setup Failure"],
1223 self.result_info["Call Maintenance Failure"],
1224 self.result_info["Call Teardown Failure"]
1225 ]):
1226 return False
1227 else:
Ashutosh Rajmani Singh72a83472020-08-02 23:40:40 -07001228 return True
1229
Betty Zhou59f18532017-05-01 15:06:11 -07001230 """ Tests Begin """
1231
Betty Zhoucf456cf2017-05-10 19:15:09 -07001232 @test_tracker_info(uuid="d035e5b9-476a-4e3d-b4e9-6fd86c51a68d")
Betty Zhou59f18532017-05-01 15:06:11 -07001233 @TelephonyBaseTest.tel_test_wrap
1234 def test_default_parallel_stress(self):
1235 """ Default state stress test"""
1236 return self.parallel_tests()
1237
Ashutosh Rajmani Singhd716bdc2019-07-26 15:07:48 -07001238 @test_tracker_info(uuid="798a3c34-db75-4bcf-b8ef-e1116414a7fe")
1239 @TelephonyBaseTest.tel_test_wrap
1240 def test_default_parallel_stress_with_wifi(self):
1241 """ Default state stress test with Wifi enabled."""
1242 if self.connect_to_wifi():
1243 return self.parallel_tests()
1244
Betty Zhoucf456cf2017-05-10 19:15:09 -07001245 @test_tracker_info(uuid="c21e1f17-3282-4f0b-b527-19f048798098")
Betty Zhou59f18532017-05-01 15:06:11 -07001246 @TelephonyBaseTest.tel_test_wrap
Betty Zhoucf456cf2017-05-10 19:15:09 -07001247 def test_lte_volte_parallel_stress(self):
Betty Zhou59f18532017-05-01 15:06:11 -07001248 """ VoLTE on stress test"""
Betty Zhou82d7a722017-11-08 15:56:04 -08001249 return self.parallel_tests(
1250 setup_func=self._setup_lte_volte_enabled,
1251 call_verification_func=is_phone_in_call_volte)
Betty Zhou59f18532017-05-01 15:06:11 -07001252
Betty Zhoucf456cf2017-05-10 19:15:09 -07001253 @test_tracker_info(uuid="a317c23a-41e0-4ef8-af67-661451cfefcf")
Betty Zhou59f18532017-05-01 15:06:11 -07001254 @TelephonyBaseTest.tel_test_wrap
Betty Zhoucf456cf2017-05-10 19:15:09 -07001255 def test_csfb_parallel_stress(self):
Betty Zhou59f18532017-05-01 15:06:11 -07001256 """ LTE non-VoLTE stress test"""
Betty Zhou82d7a722017-11-08 15:56:04 -08001257 return self.parallel_tests(
1258 setup_func=self._setup_lte_volte_disabled,
1259 call_verification_func=is_phone_in_call_csfb)
Betty Zhou59f18532017-05-01 15:06:11 -07001260
Betty Zhoucf456cf2017-05-10 19:15:09 -07001261 @test_tracker_info(uuid="fdb791bf-c414-4333-9fa3-cc18c9b3b234")
Betty Zhou59f18532017-05-01 15:06:11 -07001262 @TelephonyBaseTest.tel_test_wrap
Betty Zhoucf456cf2017-05-10 19:15:09 -07001263 def test_wfc_parallel_stress(self):
Betty Zhou042a56e2018-03-30 17:18:04 -07001264 """ Wifi calling APM mode off stress test"""
Betty Zhou4418a332018-05-15 13:11:18 -07001265 if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes:
1266 raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported")
Betty Zhou82d7a722017-11-08 15:56:04 -08001267 return self.parallel_tests(
1268 setup_func=self._setup_wfc,
1269 call_verification_func=is_phone_in_call_iwlan)
Betty Zhou59f18532017-05-01 15:06:11 -07001270
Betty Zhou042a56e2018-03-30 17:18:04 -07001271 @test_tracker_info(uuid="e334c1b3-4378-49bb-bf57-1573fa1b23fa")
1272 @TelephonyBaseTest.tel_test_wrap
1273 def test_wfc_apm_parallel_stress(self):
1274 """ Wifi calling in APM mode on stress test"""
1275 return self.parallel_tests(
1276 setup_func=self._setup_wfc_apm,
1277 call_verification_func=is_phone_in_call_iwlan)
1278
Betty Zhoucf456cf2017-05-10 19:15:09 -07001279 @test_tracker_info(uuid="4566eef6-55de-4ac8-87ee-58f2ef41a3e8")
Betty Zhou59f18532017-05-01 15:06:11 -07001280 @TelephonyBaseTest.tel_test_wrap
Betty Zhoucf456cf2017-05-10 19:15:09 -07001281 def test_3g_parallel_stress(self):
Betty Zhou59f18532017-05-01 15:06:11 -07001282 """ 3G stress test"""
Betty Zhou82d7a722017-11-08 15:56:04 -08001283 return self.parallel_tests(
1284 setup_func=self._setup_3g,
1285 call_verification_func=is_phone_in_call_3g)
Betty Zhou59f18532017-05-01 15:06:11 -07001286
Betty Zhoucf456cf2017-05-10 19:15:09 -07001287 @test_tracker_info(uuid="f34f1a31-3948-4675-8698-372a83b8088d")
Betty Zhou59f18532017-05-01 15:06:11 -07001288 @TelephonyBaseTest.tel_test_wrap
Betty Zhou4418a332018-05-15 13:11:18 -07001289 def test_2g_parallel_stress(self):
Betty Zhou59f18532017-05-01 15:06:11 -07001290 """ 2G call stress test"""
Betty Zhou82d7a722017-11-08 15:56:04 -08001291 return self.parallel_tests(
1292 setup_func=self._setup_2g,
1293 call_verification_func=is_phone_in_call_2g)
Betty Zhou59f18532017-05-01 15:06:11 -07001294
Jaineelcd748202017-08-10 12:23:42 -07001295 @test_tracker_info(uuid="af580fca-fea6-4ca5-b981-b8c710302d37")
1296 @TelephonyBaseTest.tel_test_wrap
1297 def test_volte_modeprefchange_parallel_stress(self):
1298 """ VoLTE Mode Pref call stress test"""
Betty Zhou632793c2018-02-09 18:45:39 -08001299 return self.parallel_with_network_change_tests(
Jaineelcd748202017-08-10 12:23:42 -07001300 setup_func=self._setup_lte_volte_enabled)
1301
Betty Zhou969b17a2018-05-23 18:56:37 -07001302 @test_tracker_info(uuid="10e34247-5fd3-4f87-81bf-3c17a6b71ab2")
1303 @TelephonyBaseTest.tel_test_wrap
1304 def test_data_call_stress(self):
1305 """ Default state stress test"""
1306 self.finishing_time = time.time() + self.max_run_time
1307 results = run_multithread_func(self.log,
1308 [(self.data_call_stress_test, []),
1309 (self.crash_check_test, [])])
1310 result_message = self._get_result_message()
1311 self.log.info(result_message)
1312 self._update_perf_json()
1313 self.result_detail = result_message
1314 return all(results)
1315
Ashutosh Rajmani Singh72a83472020-08-02 23:40:40 -07001316 @test_tracker_info(uuid="4212d0e0-fb87-47e5-ba48-9df9a4a6bb9b")
1317 @TelephonyBaseTest.tel_test_wrap
1318 def test_voice_performance_stress(self):
1319 """ Vocie Performance stress test"""
1320 return self.performance_tests()
1321
Betty Zhou59f18532017-05-01 15:06:11 -07001322 """ Tests End """