blob: 7fac95017d10cbee402e1199464aebfcad4bfd29 [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
Betty Zhou4418a332018-05-15 13:11:18 -070026from acts import signals
Betty Zhou3468a8b2018-02-14 14:34:56 -080027from acts import utils
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
Betty Zhou59f18532017-05-01 15:06:11 -070030from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
Betty Zhou4418a332018-05-15 13:11:18 -070031from acts.test_utils.tel.tel_defines import CAPABILITY_VOLTE
32from acts.test_utils.tel.tel_defines import CAPABILITY_WFC
Betty Zhou1ffbc832018-05-08 19:02:56 -070033from acts.test_utils.tel.tel_defines import INCALL_UI_DISPLAY_BACKGROUND
Betty Zhou632793c2018-02-09 18:45:39 -080034from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_SMS_RECEIVE
Jaineelcd748202017-08-10 12:23:42 -070035from acts.test_utils.tel.tel_defines import NETWORK_MODE_WCDMA_ONLY
36from acts.test_utils.tel.tel_defines import NETWORK_MODE_GLOBAL
37from acts.test_utils.tel.tel_defines import NETWORK_MODE_CDMA
38from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_ONLY
39from acts.test_utils.tel.tel_defines import NETWORK_MODE_TDSCDMA_GSM_WCDMA
40from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA
41from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_MODE_CHANGE
Betty Zhou4418a332018-05-15 13:11:18 -070042from acts.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED
Betty Zhou632793c2018-02-09 18:45:39 -080043from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED
Betty Zhou4418a332018-05-15 13:11:18 -070044from acts.test_utils.tel.tel_lookup_tables import is_rat_svd_capable
Betty Zhouc86784b2018-02-28 16:42:53 -080045from acts.test_utils.tel.tel_test_utils import STORY_LINE
Betty Zhou86671922017-05-10 15:32:10 -070046from acts.test_utils.tel.tel_test_utils import active_file_download_test
Betty Zhou5e3f68a2017-12-14 15:50:47 -080047from acts.test_utils.tel.tel_test_utils import is_phone_in_call
Betty Zhou59f18532017-05-01 15:06:11 -070048from acts.test_utils.tel.tel_test_utils import call_setup_teardown
Betty Zhou59f18532017-05-01 15:06:11 -070049from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected
Betty Zhouabe4a442018-05-21 12:37:26 -070050from acts.test_utils.tel.tel_test_utils import get_device_epoch_time
Betty Zhou59f18532017-05-01 15:06:11 -070051from acts.test_utils.tel.tel_test_utils import hangup_call
Betty Zhoucbda4122018-01-16 19:15:42 -080052from acts.test_utils.tel.tel_test_utils import hangup_call_by_adb
Betty Zhou377f72b2018-01-12 19:43:26 -080053from acts.test_utils.tel.tel_test_utils import initiate_call
Betty Zhou16e8e662018-05-08 18:26:18 -070054from acts.test_utils.tel.tel_test_utils import last_call_drop_reason
Betty Zhou59f18532017-05-01 15:06:11 -070055from acts.test_utils.tel.tel_test_utils import run_multithread_func
56from acts.test_utils.tel.tel_test_utils import set_wfc_mode
57from acts.test_utils.tel.tel_test_utils import sms_send_receive_verify
Betty Zhou550fd372017-10-16 17:22:47 -070058from acts.test_utils.tel.tel_test_utils import start_qxdm_loggers
Betty Zhou2bb11682018-04-19 17:05:30 -070059from acts.test_utils.tel.tel_test_utils import start_tcpdumps
Betty Zhou59f18532017-05-01 15:06:11 -070060from acts.test_utils.tel.tel_test_utils import mms_send_receive_verify
Jaineelcd748202017-08-10 12:23:42 -070061from acts.test_utils.tel.tel_test_utils import set_preferred_network_mode_pref
Betty Zhoufe64cd82018-03-26 14:14:07 -070062from acts.test_utils.tel.tel_test_utils import verify_internet_connection
Betty Zhouf7a920a2018-05-11 19:21:30 -070063from acts.test_utils.tel.tel_test_utils import wait_for_call_id_clearing
Betty Zhoucf048542018-02-22 17:14:08 -080064from acts.test_utils.tel.tel_test_utils import wait_for_in_call_active
Betty Zhou59f18532017-05-01 15:06:11 -070065from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_3g
66from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_2g
67from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb
68from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan
69from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_volte
70from acts.test_utils.tel.tel_voice_utils import phone_setup_csfb
Betty Zhou042a56e2018-03-30 17:18:04 -070071from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan
Betty Zhou59f18532017-05-01 15:06:11 -070072from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g
73from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_2g
74from acts.test_utils.tel.tel_voice_utils import phone_setup_volte
Jaineel65ebd262017-07-20 11:40:17 -070075from acts.test_utils.tel.tel_voice_utils import phone_idle_iwlan
Jaineelcd748202017-08-10 12:23:42 -070076from acts.test_utils.tel.tel_voice_utils import get_current_voice_rat
Betty Zhou7b9dd3d2017-07-14 18:57:06 -070077from acts.utils import get_current_epoch_time
Betty Zhou59f18532017-05-01 15:06:11 -070078from acts.utils import rand_ascii_str
Betty Zhoub2d1c6d2017-07-17 11:40:27 -070079
Betty Zhoucf048542018-02-22 17:14:08 -080080EXCEPTION_TOLERANCE = 5
Betty Zhoue57ab692018-03-09 18:39:30 -080081BINDER_LOGS = ["/sys/kernel/debug/binder"]
Betty Zhou59f18532017-05-01 15:06:11 -070082
83
84class TelLiveStressTest(TelephonyBaseTest):
85 def setup_class(self):
86 super(TelLiveStressTest, self).setup_class()
87 self.dut = self.android_devices[0]
Betty Zhouc6685ad2018-02-21 18:33:38 -080088 self.single_phone_test = self.user_params.get("single_phone_test",
89 False)
Betty Zhouc133f8c2018-03-02 15:40:13 -080090 # supported file download methods: chrome, sl4a, curl
91 self.file_download_method = self.user_params.get(
Betty Zhoue57ab692018-03-09 18:39:30 -080092 "file_download_method", "curl")
Betty Zhou4bc31fc2018-03-12 18:28:50 -070093 self.get_binder_logs = self.user_params.get("get_binder_logs", False)
Betty Zhou377f72b2018-01-12 19:43:26 -080094 if len(self.android_devices) == 1:
95 self.single_phone_test = True
96 if self.single_phone_test:
97 self.android_devices = self.android_devices[:1]
98 self.call_server_number = self.user_params.get(
Betty Zhouc86784b2018-02-28 16:42:53 -080099 "call_server_number", STORY_LINE)
Betty Zhouc133f8c2018-03-02 15:40:13 -0800100 if self.file_download_method == "sl4a":
101 # with single device, do not use sl4a file download
102 # due to stability issue
Betty Zhoue57ab692018-03-09 18:39:30 -0800103 self.file_download_method = "curl"
Betty Zhou377f72b2018-01-12 19:43:26 -0800104 else:
105 self.android_devices = self.android_devices[:2]
Betty Zhoue36eb6a2018-05-22 19:08:53 -0700106 for ad in self.android_devices:
107 ad.adb.shell("setprop nfc.debug_enable 1")
Betty Zhoufd85e392018-03-27 21:15:10 -0700108 self.user_params["telephony_auto_rerun"] = 0
Betty Zhou59f18532017-05-01 15:06:11 -0700109 self.phone_call_iteration = int(
110 self.user_params.get("phone_call_iteration", 500))
111 self.max_phone_call_duration = int(
Betty Zhou93c0abb2017-11-14 19:32:17 -0800112 self.user_params.get("max_phone_call_duration", 600))
Betty Zhouf7a920a2018-05-11 19:21:30 -0700113 self.min_sleep_time = int(self.user_params.get("min_sleep_time", 30))
Betty Zhouc4dfad12018-04-11 18:36:49 -0700114 self.max_sleep_time = int(self.user_params.get("max_sleep_time", 60))
Betty Zhoucb2052e2017-10-10 17:46:55 -0700115 self.max_run_time = int(self.user_params.get("max_run_time", 14400))
Betty Zhou59f18532017-05-01 15:06:11 -0700116 self.max_sms_length = int(self.user_params.get("max_sms_length", 1000))
117 self.max_mms_length = int(self.user_params.get("max_mms_length", 160))
Betty Zhouf27f5482017-07-24 18:56:17 -0700118 self.min_sms_length = int(self.user_params.get("min_sms_length", 1))
119 self.min_mms_length = int(self.user_params.get("min_mms_length", 1))
120 self.min_phone_call_duration = int(
121 self.user_params.get("min_phone_call_duration", 10))
Betty Zhou56a54612017-05-09 18:54:45 -0700122 self.crash_check_interval = int(
123 self.user_params.get("crash_check_interval", 300))
Betty Zhou4418a332018-05-15 13:11:18 -0700124 self.dut_incall = False
125 self.dut_capabilities = self.dut.telephony.get("capabilities", [])
126 self.dut_wfc_modes = self.dut.telephony.get("wfc_modes", [])
Betty Zhou59f18532017-05-01 15:06:11 -0700127 return True
128
Betty Zhou61646502018-01-12 13:02:48 -0800129 def setup_test(self):
130 super(TelLiveStressTest, self).setup_test()
131 self.result_info = collections.defaultdict(int)
132 self._init_perf_json()
133
Betty Zhou103a9592017-10-20 18:57:16 -0700134 def on_fail(self, test_name, begin_time):
135 pass
136
Betty Zhou59f18532017-05-01 15:06:11 -0700137 def _setup_wfc(self):
138 for ad in self.android_devices:
139 if not ensure_wifi_connected(
Betty Zhou69c712b2017-05-23 19:28:23 -0700140 self.log,
Betty Zhou59f18532017-05-01 15:06:11 -0700141 ad,
142 self.wifi_network_ssid,
143 self.wifi_network_pass,
Jaineel65ebd262017-07-20 11:40:17 -0700144 retries=3):
Betty Zhou5dd53c02018-03-22 20:08:33 -0700145 ad.log.error("Bringing up Wifi connection fails.")
Betty Zhou59f18532017-05-01 15:06:11 -0700146 return False
147 ad.log.info("Phone WIFI is connected successfully.")
148 if not set_wfc_mode(self.log, ad, WFC_MODE_WIFI_PREFERRED):
149 ad.log.error("Phone failed to enable Wifi-Calling.")
150 return False
151 ad.log.info("Phone is set in Wifi-Calling successfully.")
Betty Zhou69c712b2017-05-23 19:28:23 -0700152 if not phone_idle_iwlan(self.log, ad):
Betty Zhou59f18532017-05-01 15:06:11 -0700153 ad.log.error("Phone is not in WFC enabled state.")
154 return False
155 ad.log.info("Phone is in WFC enabled state.")
156 return True
157
Betty Zhou042a56e2018-03-30 17:18:04 -0700158 def _setup_wfc_apm(self):
159 for ad in self.android_devices:
160 if not phone_setup_iwlan(
Betty Zhou4418a332018-05-15 13:11:18 -0700161 self.log, ad, True, WFC_MODE_CELLULAR_PREFERRED,
Betty Zhou042a56e2018-03-30 17:18:04 -0700162 self.wifi_network_ssid, self.wifi_network_pass):
163 ad.log.error("Failed to setup WFC.")
164 return False
165 return True
166
Betty Zhou59f18532017-05-01 15:06:11 -0700167 def _setup_lte_volte_enabled(self):
168 for ad in self.android_devices:
169 if not phone_setup_volte(self.log, ad):
170 ad.log.error("Phone failed to enable VoLTE.")
171 return False
172 ad.log.info("Phone VOLTE is enabled successfully.")
173 return True
174
175 def _setup_lte_volte_disabled(self):
176 for ad in self.android_devices:
177 if not phone_setup_csfb(self.log, ad):
178 ad.log.error("Phone failed to setup CSFB.")
179 return False
180 ad.log.info("Phone VOLTE is disabled successfully.")
181 return True
182
183 def _setup_3g(self):
184 for ad in self.android_devices:
185 if not phone_setup_voice_3g(self.log, ad):
186 ad.log.error("Phone failed to setup 3g.")
187 return False
188 ad.log.info("Phone RAT 3G is enabled successfully.")
189 return True
190
191 def _setup_2g(self):
192 for ad in self.android_devices:
193 if not phone_setup_voice_2g(self.log, ad):
194 ad.log.error("Phone failed to setup 2g.")
195 return False
196 ad.log.info("RAT 2G is enabled successfully.")
197 return True
198
Betty Zhouc6685ad2018-02-21 18:33:38 -0800199 def _send_message(self, max_wait_time=2 * MAX_WAIT_TIME_SMS_RECEIVE):
Betty Zhou377f72b2018-01-12 19:43:26 -0800200 if self.single_phone_test:
201 ads = [self.dut, self.dut]
202 else:
203 ads = self.android_devices[:]
204 random.shuffle(ads)
Betty Zhou59f18532017-05-01 15:06:11 -0700205 selection = random.randrange(0, 2)
206 message_type_map = {0: "SMS", 1: "MMS"}
207 max_length_map = {0: self.max_sms_length, 1: self.max_mms_length}
Betty Zhouf27f5482017-07-24 18:56:17 -0700208 min_length_map = {0: self.min_sms_length, 1: self.min_mms_length}
209 length = random.randrange(min_length_map[selection],
210 max_length_map[selection] + 1)
Betty Zhou59f18532017-05-01 15:06:11 -0700211 message_func_map = {
212 0: sms_send_receive_verify,
213 1: mms_send_receive_verify
214 }
Betty Zhou4418a332018-05-15 13:11:18 -0700215 rat = self.dut.adb.getprop("gsm.network.type")
216 self.dut.log.info("Network in RAT %s", rat)
217 if self.dut_incall and not is_rat_svd_capable(rat.upper()):
218 self.dut.log.info("In call data not supported, test SMS only")
219 selection = 0
Betty Zhou103a9592017-10-20 18:57:16 -0700220 message_type = message_type_map[selection]
Betty Zhoue31c27d2018-02-12 19:58:12 -0800221 the_number = self.result_info["%s Total" % message_type] + 1
Betty Zhouabe4a442018-05-21 12:37:26 -0700222 begin_time = get_device_epoch_time(self.dut)
Betty Zhou3db27a32018-04-23 14:31:25 -0700223 test_name = "%s_No_%s_%s" % (self.test_name, the_number, message_type)
Betty Zhouc3eedd72017-11-09 17:50:01 -0800224 start_qxdm_loggers(self.log, self.android_devices)
Betty Zhou3db27a32018-04-23 14:31:25 -0700225 log_msg = "[Test Case] %s" % test_name
226 self.log.info("%s begin", log_msg)
Betty Zhou377f72b2018-01-12 19:43:26 -0800227 for ad in self.android_devices:
Betty Zhou4bc31fc2018-03-12 18:28:50 -0700228 if not getattr(ad, "messaging_droid", None):
229 ad.messaging_droid, ad.messaging_ed = ad.get_droid()
230 ad.messaging_ed.start()
231 else:
Betty Zhou06219032018-01-11 12:40:49 -0800232 try:
Betty Zhou4bc31fc2018-03-12 18:28:50 -0700233 if not ad.messaging_droid.is_live:
234 ad.messaging_droid, ad.messaging_ed = ad.get_droid()
235 ad.messaging_ed.start()
236 else:
237 ad.messaging_ed.clear_all_events()
238 except Exception:
239 ad.log.info("Create new sl4a session for messaging")
240 ad.messaging_droid, ad.messaging_ed = ad.get_droid()
241 ad.messaging_ed.start()
Betty Zhoue26fe892018-04-23 15:29:53 -0700242 ad.messaging_droid.logI("%s begin" % log_msg)
Betty Zhou1095ee42018-05-07 09:53:28 -0700243 text = "%s: " % test_name
Betty Zhou38028b72017-12-20 17:54:12 -0800244 text_length = len(text)
245 if length < text_length:
246 text = text[:length]
247 else:
248 text += rand_ascii_str(length - text_length)
Betty Zhou1095ee42018-05-07 09:53:28 -0700249 message_content_map = {0: [text], 1: [(test_name, text, None)]}
Betty Zhou4c1c4b12017-12-21 17:06:13 -0800250
Betty Zhou3db27a32018-04-23 14:31:25 -0700251 result = message_func_map[selection](self.log, ads[0], ads[1],
252 message_content_map[selection],
253 max_wait_time)
254 self.log.info("%s end", log_msg)
255 for ad in self.android_devices:
Betty Zhoue26fe892018-04-23 15:29:53 -0700256 ad.messaging_droid.logI("%s end" % log_msg)
Betty Zhou3db27a32018-04-23 14:31:25 -0700257 if not result:
Betty Zhoue31c27d2018-02-12 19:58:12 -0800258 self.result_info["%s Total" % message_type] += 1
Betty Zhou82d7a722017-11-08 15:56:04 -0800259 if message_type == "SMS":
Betty Zhou8802ec62017-12-18 19:44:29 -0800260 self.log.error("%s fails", log_msg)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800261 self.result_info["%s Failure" % message_type] += 1
Betty Zhou82d7a722017-11-08 15:56:04 -0800262 else:
Betty Zhou4418a332018-05-15 13:11:18 -0700263 rat = self.dut.adb.getprop("gsm.network.type")
264 self.dut.log.info("Network in RAT %s", rat)
265 if self.dut_incall and not is_rat_svd_capable(rat.upper()):
266 self.dut.log.info(
267 "In call data not supported, MMS failure expected")
Betty Zhou377f72b2018-01-12 19:43:26 -0800268 self.result_info["Expected In-call MMS failure"] += 1
Betty Zhou82d7a722017-11-08 15:56:04 -0800269 return True
270 else:
Betty Zhou8802ec62017-12-18 19:44:29 -0800271 self.log.error("%s fails", log_msg)
Betty Zhouc133f8c2018-03-02 15:40:13 -0800272 self.result_info["MMS Failure"] += 1
Betty Zhou3db27a32018-04-23 14:31:25 -0700273 try:
274 self._take_bug_report(test_name, begin_time)
275 except Exception as e:
276 self.log.exception(e)
Betty Zhou59f18532017-05-01 15:06:11 -0700277 return False
278 else:
Betty Zhoue31c27d2018-02-12 19:58:12 -0800279 self.result_info["%s Total" % message_type] += 1
Betty Zhou8802ec62017-12-18 19:44:29 -0800280 self.log.info("%s succeed", log_msg)
Jaineel5bee17c2018-01-05 11:55:17 -0800281 self.result_info["%s Success" % message_type] += 1
Betty Zhou33c05292017-05-24 15:12:43 -0700282 return True
Betty Zhou59f18532017-05-01 15:06:11 -0700283
Betty Zhou377f72b2018-01-12 19:43:26 -0800284 def _make_phone_call(self, call_verification_func=None):
285 ads = self.android_devices[:]
286 if not self.single_phone_test:
287 random.shuffle(ads)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800288 the_number = self.result_info["Call Total"] + 1
Betty Zhou628b98e2018-01-08 15:45:25 -0800289 duration = random.randrange(self.min_phone_call_duration,
290 self.max_phone_call_duration)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800291 result = True
Betty Zhou3db27a32018-04-23 14:31:25 -0700292 test_name = "%s_No_%s_phone_call" % (self.test_name, the_number)
293 log_msg = "[Test Case] %s" % test_name
Betty Zhoub707ef22018-05-14 16:47:05 -0700294 self.log.info("%s for %s seconds begin", log_msg, duration)
Betty Zhou4bc31fc2018-03-12 18:28:50 -0700295 for ad in self.android_devices:
296 if not getattr(ad, "droid", None):
297 ad.droid, ad.ed = ad.get_droid()
298 ad.ed.start()
299 else:
300 try:
301 if not ad.droid.is_live:
302 ad.droid, ad.ed = ad.get_droid()
303 ad.ed.start()
304 else:
305 ad.ed.clear_all_events()
306 except Exception:
307 ad.log.info("Create new sl4a session for phone call")
308 ad.droid, ad.ed = ad.get_droid()
309 ad.ed.start()
Betty Zhou3db27a32018-04-23 14:31:25 -0700310 ad.droid.logI("%s begin" % log_msg)
Betty Zhouabe4a442018-05-21 12:37:26 -0700311 begin_time = get_device_epoch_time(self.dut)
Betty Zhou2bb11682018-04-19 17:05:30 -0700312 if "wfc" in self.test_name:
313 start_tcpdumps(
314 self.android_devices,
315 "%s_call_No_%s" % (self.test_name, the_number),
316 begin_time,
317 interface="wlan0",
318 mask=None)
Betty Zhou628b98e2018-01-08 15:45:25 -0800319 start_qxdm_loggers(self.log, self.android_devices, begin_time)
Betty Zhou5676e812018-03-20 16:57:58 -0700320 failure_reasons = set()
Betty Zhou4418a332018-05-15 13:11:18 -0700321 self.dut_incall = True
Betty Zhou377f72b2018-01-12 19:43:26 -0800322 if self.single_phone_test:
323 call_setup_result = initiate_call(
Betty Zhouf7a920a2018-05-11 19:21:30 -0700324 self.log,
325 self.dut,
326 self.call_server_number,
327 incall_ui_display=INCALL_UI_DISPLAY_BACKGROUND
Betty Zhou1ffbc832018-05-08 19:02:56 -0700328 ) and wait_for_in_call_active(self.dut, 60, 3)
Betty Zhou377f72b2018-01-12 19:43:26 -0800329 else:
330 call_setup_result = call_setup_teardown(
Betty Zhou74481722018-04-13 16:19:25 -0700331 self.log,
332 ads[0],
333 ads[1],
334 ad_hangup=None,
335 verify_caller_func=call_verification_func,
336 verify_callee_func=call_verification_func,
Betty Zhou1ffbc832018-05-08 19:02:56 -0700337 wait_time_in_call=0,
338 incall_ui_display=INCALL_UI_DISPLAY_BACKGROUND)
Betty Zhou377f72b2018-01-12 19:43:26 -0800339 if not call_setup_result:
Betty Zhou8802ec62017-12-18 19:44:29 -0800340 self.log.error("%s: Setup Call failed.", log_msg)
Betty Zhou5676e812018-03-20 16:57:58 -0700341 failure_reasons.add("Setup")
Betty Zhoue31c27d2018-02-12 19:58:12 -0800342 result = False
343 else:
344 elapsed_time = 0
345 check_interval = 5
346 while (elapsed_time < duration):
347 check_interval = min(check_interval, duration - elapsed_time)
348 time.sleep(check_interval)
349 elapsed_time += check_interval
Betty Zhouc6685ad2018-02-21 18:33:38 -0800350 time_message = "at <%s>/<%s> second." % (elapsed_time,
351 duration)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800352 for ad in ads:
353 if not call_verification_func(self.log, ad):
Betty Zhou88f1ec82018-04-09 18:51:31 -0700354 ad.log.warning("Call is NOT in correct %s state at %s",
355 call_verification_func.__name__,
356 time_message)
Betty Zhouc4dfad12018-04-11 18:36:49 -0700357 if call_verification_func.__name__ == "is_phone_in_call_iwlan":
Betty Zhou88f1ec82018-04-09 18:51:31 -0700358 if is_phone_in_call(self.log, ad):
Betty Zhouc4dfad12018-04-11 18:36:49 -0700359 if getattr(ad, "data_rat_state_error_count",
360 0) < 1:
361 setattr(ad, "data_rat_state_error_count",
362 1)
363 continue
Betty Zhou5676e812018-03-20 16:57:58 -0700364 failure_reasons.add("Maintenance")
Betty Zhou16e8e662018-05-08 18:26:18 -0700365 last_call_drop_reason(ad, begin_time)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800366 hangup_call(self.log, ads[0])
Betty Zhouc6685ad2018-02-21 18:33:38 -0800367 result = False
Betty Zhoue31c27d2018-02-12 19:58:12 -0800368 else:
Betty Zhouc6685ad2018-02-21 18:33:38 -0800369 ad.log.info("Call is in correct %s state at %s",
370 call_verification_func.__name__,
371 time_message)
Betty Zhoua301c202018-02-13 15:11:47 -0800372 if not result:
373 break
Betty Zhou6b91ab22017-12-21 18:16:36 -0800374 if not hangup_call(self.log, ads[0]):
Betty Zhouf7a920a2018-05-11 19:21:30 -0700375 failure_reasons.add("Teardown")
376 result = False
377 for ad in ads:
378 if not wait_for_call_id_clearing(ad,
379 []) or ad.droid.telecomIsInCall():
380 ad.log.error("Fail to hang up call")
381 failure_reasons.add("Teardown")
382 result = False
Betty Zhoue31c27d2018-02-12 19:58:12 -0800383 self.result_info["Call Total"] += 1
Betty Zhou3db27a32018-04-23 14:31:25 -0700384 for ad in self.android_devices:
385 try:
386 ad.droid.logI("%s end" % log_msg)
387 except:
388 pass
389 self.log.info("%s end", log_msg)
Betty Zhou4418a332018-05-15 13:11:18 -0700390 self.dut_incall = False
Betty Zhoua301c202018-02-13 15:11:47 -0800391 if not result:
Betty Zhou3db27a32018-04-23 14:31:25 -0700392 self.log.info("%s failed", log_msg)
Betty Zhoucc4e8442018-04-25 11:07:45 -0700393 if self.user_params.get("gps_log_file", None):
394 gps_info = job.run(
395 "tail %s" % self.user_params["gps_log_file"],
396 ignore_status=True)
Betty Zhou49744692018-04-24 11:00:38 -0700397 if gps_info.stdout:
398 self.log.info("gps log:\n%s", gps_info.stdout)
399 else:
400 self.log.warning("Fail to get gps log %s",
401 self.user_params["gps_log_file"])
Betty Zhou5676e812018-03-20 16:57:58 -0700402 for reason in failure_reasons:
403 self.result_info["Call %s Failure" % reason] += 1
Betty Zhou3468a8b2018-02-14 14:34:56 -0800404 for ad in ads:
Betty Zhouc6685ad2018-02-21 18:33:38 -0800405 log_path = os.path.join(self.log_path, test_name,
Betty Zhoue57ab692018-03-09 18:39:30 -0800406 "%s_binder_logs" % ad.serial)
Betty Zhou3468a8b2018-02-14 14:34:56 -0800407 utils.create_dir(log_path)
Betty Zhoue57ab692018-03-09 18:39:30 -0800408 ad.pull_files(BINDER_LOGS, log_path)
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700409 try:
410 self._take_bug_report(test_name, begin_time)
411 except Exception as e:
412 self.log.exception(e)
Betty Zhouf7a920a2018-05-11 19:21:30 -0700413 for ad in ads:
414 hangup_call_by_adb(ad)
Betty Zhou3468a8b2018-02-14 14:34:56 -0800415 else:
416 self.log.info("%s test succeed", log_msg)
417 self.result_info["Call Success"] += 1
Betty Zhou4bc31fc2018-03-12 18:28:50 -0700418 if self.get_binder_logs and self.result_info["Call Total"] % 50 == 0:
Betty Zhouc6685ad2018-02-21 18:33:38 -0800419 for ad in ads:
Betty Zhou3db27a32018-04-23 14:31:25 -0700420 log_path = os.path.join(self.log_path,
421 "%s_binder_logs" % test_name,
Betty Zhoue57ab692018-03-09 18:39:30 -0800422 "%s_binder_logs" % ad.serial)
Betty Zhouc6685ad2018-02-21 18:33:38 -0800423 utils.create_dir(log_path)
Betty Zhoue57ab692018-03-09 18:39:30 -0800424 ad.pull_files(BINDER_LOGS, log_path)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800425 return result
Betty Zhou59f18532017-05-01 15:06:11 -0700426
Betty Zhou103a9592017-10-20 18:57:16 -0700427 def _prefnetwork_mode_change(self, sub_id):
428 # ModePref change to non-LTE
Betty Zhouabe4a442018-05-21 12:37:26 -0700429 begin_time = get_device_epoch_time(self.dut)
Betty Zhou628b98e2018-01-08 15:45:25 -0800430 start_qxdm_loggers(self.log, self.android_devices)
Betty Zhou103a9592017-10-20 18:57:16 -0700431 network_preference_list = [
432 NETWORK_MODE_TDSCDMA_GSM_WCDMA, NETWORK_MODE_WCDMA_ONLY,
433 NETWORK_MODE_GLOBAL, NETWORK_MODE_CDMA, NETWORK_MODE_GSM_ONLY
434 ]
435 network_preference = random.choice(network_preference_list)
436 set_preferred_network_mode_pref(self.log, self.dut, sub_id,
437 network_preference)
438 time.sleep(WAIT_TIME_AFTER_MODE_CHANGE)
439 self.dut.log.info("Current Voice RAT is %s",
440 get_current_voice_rat(self.log, self.dut))
441
442 # ModePref change back to with LTE
443 set_preferred_network_mode_pref(self.log, self.dut, sub_id,
444 NETWORK_MODE_LTE_CDMA_EVDO_GSM_WCDMA)
445 time.sleep(WAIT_TIME_AFTER_MODE_CHANGE)
446 rat = get_current_voice_rat(self.log, self.dut)
447 self.dut.log.info("Current Voice RAT is %s", rat)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800448 self.result_info["RAT Change Total"] += 1
Betty Zhou103a9592017-10-20 18:57:16 -0700449 if rat != "LTE":
Betty Zhoue31c27d2018-02-12 19:58:12 -0800450 self.result_info["RAT Change Failure"] += 1
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700451 try:
452 self._take_bug_report("%s_rat_change_failure" % self.test_name,
453 begin_time)
454 except Exception as e:
455 self.log.exception(e)
Jaineelcd748202017-08-10 12:23:42 -0700456 return False
Betty Zhoue31c27d2018-02-12 19:58:12 -0800457 else:
458 self.result_info["RAT Change Success"] += 1
459 return True
Jaineelcd748202017-08-10 12:23:42 -0700460
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800461 def _get_result_message(self):
Betty Zhouc6685ad2018-02-21 18:33:38 -0800462 msg_list = [
463 "%s: %s" % (count, self.result_info[count])
464 for count in sorted(self.result_info.keys())
465 ]
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800466 return ", ".join(msg_list)
467
Betty Zhou61646502018-01-12 13:02:48 -0800468 def _write_perf_json(self):
469 json_str = json.dumps(self.perf_data, indent=4, sort_keys=True)
470 with open(self.perf_file, 'w') as f:
471 f.write(json_str)
472
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800473 def _init_perf_json(self):
Betty Zhouc6685ad2018-02-21 18:33:38 -0800474 self.perf_file = os.path.join(self.log_path, "%s_perf_data_%s.json" %
475 (self.test_name, self.begin_time))
Betty Zhou4418a332018-05-15 13:11:18 -0700476 self.perf_data = self.dut.build_info.copy()
477 self.perf_data["model"] = self.dut.model
478 self.perf_data["carrier"] = self.dut.adb.getprop(
479 "gsm.sim.operator.alpha")
Betty Zhou61646502018-01-12 13:02:48 -0800480 self._write_perf_json()
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800481
482 def _update_perf_json(self):
483 for result_key, result_value in self.result_info.items():
484 self.perf_data[result_key] = result_value
Betty Zhou61646502018-01-12 13:02:48 -0800485 self._write_perf_json()
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800486
Betty Zhou56a54612017-05-09 18:54:45 -0700487 def crash_check_test(self):
488 failure = 0
489 while time.time() < self.finishing_time:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700490 try:
Betty Zhou06219032018-01-11 12:40:49 -0800491 self.log.info(dict(self.result_info))
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800492 self._update_perf_json()
Betty Zhouabe4a442018-05-21 12:37:26 -0700493 begin_time = get_device_epoch_time(self.dut)
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700494 run_time_in_seconds = (begin_time - self.begin_time) / 1000
495 test_name = "%s_crash_%s_seconds_after_start" % (
496 self.test_name, run_time_in_seconds)
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700497 time.sleep(self.crash_check_interval)
Betty Zhouf52dee32018-01-08 13:07:42 -0800498 for ad in self.android_devices:
Betty Zhou4c1c4b12017-12-21 17:06:13 -0800499 crash_report = ad.check_crash_report(
Betty Zhou4bc31fc2018-03-12 18:28:50 -0700500 test_name, begin_time, log_crash_report=True)
Betty Zhou4c1c4b12017-12-21 17:06:13 -0800501 if crash_report:
502 ad.log.error("Find new crash reports %s", crash_report)
503 failure += 1
Betty Zhouabe4a442018-05-21 12:37:26 -0700504 self.result_info["Crashes"] += len(crash_report)
Betty Zhou27080b12018-03-01 15:06:13 -0800505 for crash in crash_report:
506 if "ramdump_modem" in crash:
507 self.result_info["Crashes-Modem"] += 1
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700508 try:
509 ad.take_bug_report(test_name, begin_time)
510 except Exception as e:
511 self.log.exception(e)
Betty Zhoucf048542018-02-22 17:14:08 -0800512 except Exception as e:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700513 self.log.error("Exception error %s", str(e))
514 self.result_info["Exception Errors"] += 1
Betty Zhou4c1c4b12017-12-21 17:06:13 -0800515 self.log.info("Crashes found: %s", failure)
Betty Zhoucf048542018-02-22 17:14:08 -0800516 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
517 self.log.error("Too many exception errors, quit test")
Betty Zhou53f1d0e2018-01-26 20:08:27 -0800518 return False
Betty Zhou8c0fc692017-07-20 18:49:19 -0700519 if failure:
Betty Zhoua1296402017-10-23 17:32:40 -0700520 return False
Betty Zhou8c0fc692017-07-20 18:49:19 -0700521 else:
Betty Zhoua1296402017-10-23 17:32:40 -0700522 return True
Betty Zhou56a54612017-05-09 18:54:45 -0700523
Betty Zhou82d7a722017-11-08 15:56:04 -0800524 def call_test(self, call_verification_func=None):
Betty Zhou59f18532017-05-01 15:06:11 -0700525 while time.time() < self.finishing_time:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700526 try:
Betty Zhou377f72b2018-01-12 19:43:26 -0800527 self._make_phone_call(call_verification_func)
Betty Zhoucf048542018-02-22 17:14:08 -0800528 except Exception as e:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700529 self.log.error("Exception error %s", str(e))
530 self.result_info["Exception Errors"] += 1
Betty Zhoucf048542018-02-22 17:14:08 -0800531 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
532 self.log.error("Too many exception errors, quit test")
Betty Zhou628b98e2018-01-08 15:45:25 -0800533 return False
Betty Zhou75cbbbe2017-11-06 14:09:20 -0800534 self.log.info("%s", dict(self.result_info))
Betty Zhoucf048542018-02-22 17:14:08 -0800535 time.sleep(
536 random.randrange(self.min_sleep_time, self.max_sleep_time))
Betty Zhouc6685ad2018-02-21 18:33:38 -0800537 if any([
538 self.result_info["Call Setup Failure"],
Betty Zhou5e3f68a2017-12-14 15:50:47 -0800539 self.result_info["Call Maintenance Failure"],
Betty Zhouc6685ad2018-02-21 18:33:38 -0800540 self.result_info["Call Teardown Failure"]
541 ]):
Betty Zhou103a9592017-10-20 18:57:16 -0700542 return False
Jaineelcd748202017-08-10 12:23:42 -0700543 else:
Betty Zhou103a9592017-10-20 18:57:16 -0700544 return True
Jaineelcd748202017-08-10 12:23:42 -0700545
Betty Zhou632793c2018-02-09 18:45:39 -0800546 def message_test(self, max_wait_time=MAX_WAIT_TIME_SMS_RECEIVE):
Betty Zhou59f18532017-05-01 15:06:11 -0700547 while time.time() < self.finishing_time:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700548 try:
Betty Zhou632793c2018-02-09 18:45:39 -0800549 self._send_message(max_wait_time=max_wait_time)
Betty Zhoucf048542018-02-22 17:14:08 -0800550 except Exception as e:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700551 self.log.error("Exception error %s", str(e))
552 self.result_info["Exception Errors"] += 1
Betty Zhou4c1c4b12017-12-21 17:06:13 -0800553 self.log.info(dict(self.result_info))
Betty Zhoucf048542018-02-22 17:14:08 -0800554 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
555 self.log.error("Too many exception errors, quit test")
Betty Zhou53f1d0e2018-01-26 20:08:27 -0800556 return False
Betty Zhoucf048542018-02-22 17:14:08 -0800557 time.sleep(
558 random.randrange(self.min_sleep_time, self.max_sleep_time))
Betty Zhoue31c27d2018-02-12 19:58:12 -0800559 if self.result_info["SMS Failure"] or (
560 self.result_info["MMS Failure"] / self.result_info["MMS Total"]
Betty Zhou75cbbbe2017-11-06 14:09:20 -0800561 > 0.3):
Betty Zhou103a9592017-10-20 18:57:16 -0700562 return False
Betty Zhou8c0fc692017-07-20 18:49:19 -0700563 else:
Betty Zhou103a9592017-10-20 18:57:16 -0700564 return True
Betty Zhou59f18532017-05-01 15:06:11 -0700565
Betty Zhou80f136a2018-04-23 16:37:36 -0700566 def _data_download(self,
567 file_names=["5MB", "10MB", "20MB", "50MB", "200MB"]):
Betty Zhou8c0fc692017-07-20 18:49:19 -0700568 #file_names = ["5MB", "10MB", "20MB", "50MB", "200MB", "512MB", "1GB"]
Betty Zhoue31c27d2018-02-12 19:58:12 -0800569 begin_time = get_current_epoch_time()
570 start_qxdm_loggers(self.log, self.android_devices)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800571 self.dut.log.info(dict(self.result_info))
572 selection = random.randrange(0, len(file_names))
573 file_name = file_names[selection]
Betty Zhoufe64cd82018-03-26 14:14:07 -0700574 self.result_info["Internet Connection Check Total"] += 1
575 if not verify_internet_connection(self.log, self.dut):
Betty Zhou4418a332018-05-15 13:11:18 -0700576 rat = self.dut.adb.getprop("gsm.network.type")
577 self.dut.log.info("Network in RAT %s", rat)
578 if self.dut_incall and not is_rat_svd_capable(rat.upper()):
Betty Zhou774ea542018-05-16 12:45:36 -0700579 self.result_info[
Betty Zhou4418a332018-05-15 13:11:18 -0700580 "Expected Incall Internet Connection Check Failure"] += 1
581 return True
582 else:
583 self.result_info["Internet Connection Check Failure"] += 1
584 test_name = "%s_internet_connection_No_%s_failure" % (
585 self.test_name,
586 self.result_info["Internet Connection Check Failure"])
587 try:
588 self._ad_take_extra_logs(self.dut, test_name, begin_time)
589 self._ad_take_bugreport(self.dut, test_name, begin_time)
590 except Exception as e:
591 self.log.exception(e)
592 return False
Betty Zhoufe64cd82018-03-26 14:14:07 -0700593 else:
594 self.result_info["Internet Connection Check Success"] += 1
595
Betty Zhoue31c27d2018-02-12 19:58:12 -0800596 self.result_info["File Download Total"] += 1
Betty Zhouc86784b2018-02-28 16:42:53 -0800597 if not active_file_download_test(
Betty Zhouc133f8c2018-03-02 15:40:13 -0800598 self.log, self.dut, file_name,
599 method=self.file_download_method):
Betty Zhou200031e2018-02-14 15:21:24 -0800600 self.result_info["File Download Failure"] += 1
601 if self.result_info["File Download Failure"] == 1:
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700602 try:
603 self._ad_take_extra_logs(
604 self.dut, "%s_file_download_failure" % self.test_name,
605 begin_time)
Betty Zhoufe64cd82018-03-26 14:14:07 -0700606 self._ad_take_bugreport(
Betty Zhouccfd8ef2018-03-19 17:52:01 -0700607 self.dut, "%s_file_download_failure" % self.test_name,
608 begin_time)
609 except Exception as e:
610 self.log.exception(e)
Betty Zhoue31c27d2018-02-12 19:58:12 -0800611 return False
612 else:
613 self.result_info["File Download Success"] += 1
Betty Zhoue31c27d2018-02-12 19:58:12 -0800614 return True
615
616 def data_test(self):
Betty Zhou59f18532017-05-01 15:06:11 -0700617 while time.time() < self.finishing_time:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700618 try:
Betty Zhoue31c27d2018-02-12 19:58:12 -0800619 self._data_download()
Betty Zhoucf048542018-02-22 17:14:08 -0800620 except Exception as e:
Betty Zhou7b9dd3d2017-07-14 18:57:06 -0700621 self.log.error("Exception error %s", str(e))
622 self.result_info["Exception Errors"] += 1
Betty Zhou75cbbbe2017-11-06 14:09:20 -0800623 self.log.info("%s", dict(self.result_info))
Betty Zhoucf048542018-02-22 17:14:08 -0800624 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
625 self.log.error("Too many exception errors, quit test")
Betty Zhou53f1d0e2018-01-26 20:08:27 -0800626 return False
Betty Zhoucf048542018-02-22 17:14:08 -0800627 time.sleep(
628 random.randrange(self.min_sleep_time, self.max_sleep_time))
Betty Zhoufe64cd82018-03-26 14:14:07 -0700629 if self.result_info["Internet Connection Check Failure"]:
Betty Zhou103a9592017-10-20 18:57:16 -0700630 return False
Betty Zhou8c0fc692017-07-20 18:49:19 -0700631 else:
Betty Zhou103a9592017-10-20 18:57:16 -0700632 return True
Betty Zhou59f18532017-05-01 15:06:11 -0700633
Betty Zhoub707ef22018-05-14 16:47:05 -0700634 def check_incall_data(self):
635 if self.single_phone_test:
Betty Zhou4418a332018-05-15 13:11:18 -0700636 if not initiate_call(
637 self.log, self.dut,
638 self.call_server_number) and wait_for_in_call_active(
639 self.dut, 60, 3):
Betty Zhoud2312bb2018-05-18 18:24:04 -0700640 raise signals.TestFailure("Unable to make phone call")
Betty Zhoub707ef22018-05-14 16:47:05 -0700641 else:
Betty Zhou4418a332018-05-15 13:11:18 -0700642 if not call_setup_teardown(
643 self.log, self.dut, self.android_devices[1],
644 ad_hangup=None):
Betty Zhoud2312bb2018-05-18 18:24:04 -0700645 raise signals.TestFailure("Unable to make phone call")
Betty Zhou4418a332018-05-15 13:11:18 -0700646 voice_rat = self.dut.droid.telephonyGetCurrentVoiceNetworkType()
647 data_rat = self.dut.droid.telephonyGetCurrentDataNetworkType()
648 self.dut.log.info("Voice in RAT %s, Data in RAT %s", voice_rat,
649 data_rat)
650 try:
Betty Zhouabe4a442018-05-21 12:37:26 -0700651 if is_rat_svd_capable(voice_rat.upper()) and is_rat_svd_capable(
652 data_rat.upper()):
Betty Zhou4418a332018-05-15 13:11:18 -0700653 self.dut.log.info("Capable for simultaneous voice and data")
654 if not verify_internet_connection(self.log, self.dut):
655 self.dut.log.error("Incall data check failed")
Betty Zhoud2312bb2018-05-18 18:24:04 -0700656 raise signals.TestFailure("Incall data check failed")
Betty Zhou4418a332018-05-15 13:11:18 -0700657 else:
658 return True
659 else:
660 self.dut.log.info(
661 "Not capable for simultaneous voice and data")
662 return False
663 finally:
664 hangup_call_by_adb(self.dut)
Betty Zhoub707ef22018-05-14 16:47:05 -0700665
Betty Zhou82d7a722017-11-08 15:56:04 -0800666 def parallel_tests(self, setup_func=None, call_verification_func=None):
Betty Zhou61646502018-01-12 13:02:48 -0800667 self.log.info(self._get_result_message())
Betty Zhou59f18532017-05-01 15:06:11 -0700668 if setup_func and not setup_func():
Betty Zhoue26fe892018-04-23 15:29:53 -0700669 msg = "%s setup %s failed" % (self.test_name, setup_func.__name__)
Betty Zhou103a9592017-10-20 18:57:16 -0700670 self.log.error(msg)
Betty Zhou2bb11682018-04-19 17:05:30 -0700671 self._take_bug_report("%s%s" % (self.test_name,
672 setup_func.__name__),
673 self.begin_time)
674 return False
Betty Zhou8802ec62017-12-18 19:44:29 -0800675 if not call_verification_func:
676 call_verification_func = is_phone_in_call
Betty Zhou59f18532017-05-01 15:06:11 -0700677 self.finishing_time = time.time() + self.max_run_time
Betty Zhou4418a332018-05-15 13:11:18 -0700678 if self.check_incall_data():
679 self.log.info(
680 "==== Start parallel voice/message/data stress test ====")
681 self.perf_data["testing method"] = "parallel"
Betty Zhoub707ef22018-05-14 16:47:05 -0700682 results = run_multithread_func(
683 self.log, [(self.call_test, [call_verification_func]),
684 (self.message_test, []), (self.data_test, []),
685 (self.crash_check_test, [])])
686 else:
Betty Zhou4418a332018-05-15 13:11:18 -0700687 self.log.info(
688 "==== Start sequential voice/message/data stress test ====")
689 self.perf_data["testing method"] = "sequential"
Betty Zhoub707ef22018-05-14 16:47:05 -0700690 results = run_multithread_func(
691 self.log, [(self.sequential_tests, [call_verification_func]),
692 (self.crash_check_test, [])])
Betty Zhou9aa68ad2018-01-12 12:39:23 -0800693 result_message = self._get_result_message()
Betty Zhou551ebb52017-10-24 12:59:24 -0700694 self.log.info(result_message)
Betty Zhoucbda4122018-01-16 19:15:42 -0800695 self._update_perf_json()
Betty Zhou53f1d0e2018-01-26 20:08:27 -0800696 self.result_detail = result_message
697 return all(results)
Betty Zhou59f18532017-05-01 15:06:11 -0700698
Betty Zhoub707ef22018-05-14 16:47:05 -0700699 def sequential_tests(self, call_verification_func):
700 funcs = [(self._make_phone_call, [call_verification_func]),
701 (self._send_message, []), (self._data_download, [["5MB"]])]
702 while time.time() < self.finishing_time:
703 selection = random.randrange(0, 3)
704 try:
705 funcs[selection][0](*funcs[selection][1])
706 except Exception as e:
707 self.log.error("Exception error %s", str(e))
708 self.result_info["Exception Errors"] += 1
709 self.log.info("%s", dict(self.result_info))
710 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
711 self.log.error("Too many exception errors, quit test")
712 return False
713 time.sleep(
714 random.randrange(self.min_sleep_time, self.max_sleep_time))
715 if any([
716 self.result_info["Call Setup Failure"],
717 self.result_info["Call Maintenance Failure"],
718 self.result_info["Call Teardown Failure"],
719 self.result_info["SMS Failure"],
720 self.result_info["MMS Failure"],
721 self.result_info["Internet Connection Check Failure"]
722 ]):
723 return False
724 return True
725
Betty Zhoue31c27d2018-02-12 19:58:12 -0800726 def volte_modechange_volte_test(self):
727 sub_id = self.dut.droid.subscriptionGetDefaultSubId()
728 while time.time() < self.finishing_time:
729 try:
730 run_multithread_func(
731 self.log,
Betty Zhou80f136a2018-04-23 16:37:36 -0700732 [(self._data_download, [["5MB"]]),
Betty Zhoue31c27d2018-02-12 19:58:12 -0800733 (self._make_phone_call, [is_phone_in_call_volte]),
734 (self._send_message, [])])
735 self._prefnetwork_mode_change(sub_id)
Betty Zhoucf048542018-02-22 17:14:08 -0800736 except Exception as e:
Betty Zhoue31c27d2018-02-12 19:58:12 -0800737 self.log.error("Exception error %s", str(e))
738 self.result_info["Exception Errors"] += 1
Betty Zhoue31c27d2018-02-12 19:58:12 -0800739 self.log.info(dict(self.result_info))
Betty Zhoucf048542018-02-22 17:14:08 -0800740 if self.result_info["Exception Errors"] >= EXCEPTION_TOLERANCE:
741 self.log.error("Too many exception errors, quit test")
Betty Zhoue31c27d2018-02-12 19:58:12 -0800742 return False
Betty Zhouc6685ad2018-02-21 18:33:38 -0800743 if self.result_info["Call Failure"] or self.result_info["RAT Change Failure"] or self.result_info["SMS Failure"]:
Betty Zhoue31c27d2018-02-12 19:58:12 -0800744 return False
745 else:
746 return True
Betty Zhou61646502018-01-12 13:02:48 -0800747
Betty Zhou632793c2018-02-09 18:45:39 -0800748 def parallel_with_network_change_tests(self, setup_func=None):
Jaineelcd748202017-08-10 12:23:42 -0700749 if setup_func and not setup_func():
750 self.log.error("Test setup %s failed", setup_func.__name__)
751 return False
Jaineelcd748202017-08-10 12:23:42 -0700752 self.finishing_time = time.time() + self.max_run_time
Jaineel664316b2017-12-04 15:16:48 -0800753 results = run_multithread_func(self.log,
754 [(self.volte_modechange_volte_test, []),
755 (self.crash_check_test, [])])
Betty Zhoue31c27d2018-02-12 19:58:12 -0800756 result_message = self._get_result_message()
Betty Zhou61646502018-01-12 13:02:48 -0800757 self.log.info(result_message)
Betty Zhoucbda4122018-01-16 19:15:42 -0800758 self._update_perf_json()
Betty Zhou53f1d0e2018-01-26 20:08:27 -0800759 self.result_detail = result_message
760 return all(results)
Jaineelcd748202017-08-10 12:23:42 -0700761
Betty Zhou59f18532017-05-01 15:06:11 -0700762 """ Tests Begin """
763
Betty Zhoucf456cf2017-05-10 19:15:09 -0700764 @test_tracker_info(uuid="d035e5b9-476a-4e3d-b4e9-6fd86c51a68d")
Betty Zhou59f18532017-05-01 15:06:11 -0700765 @TelephonyBaseTest.tel_test_wrap
766 def test_default_parallel_stress(self):
767 """ Default state stress test"""
768 return self.parallel_tests()
769
Betty Zhoucf456cf2017-05-10 19:15:09 -0700770 @test_tracker_info(uuid="c21e1f17-3282-4f0b-b527-19f048798098")
Betty Zhou59f18532017-05-01 15:06:11 -0700771 @TelephonyBaseTest.tel_test_wrap
Betty Zhoucf456cf2017-05-10 19:15:09 -0700772 def test_lte_volte_parallel_stress(self):
Betty Zhou59f18532017-05-01 15:06:11 -0700773 """ VoLTE on stress test"""
Betty Zhou4418a332018-05-15 13:11:18 -0700774 if CAPABILITY_VOLTE not in self.dut_capabilities:
775 raise signals.TestSkipClass("VoLTE is not supported")
Betty Zhou82d7a722017-11-08 15:56:04 -0800776 return self.parallel_tests(
777 setup_func=self._setup_lte_volte_enabled,
778 call_verification_func=is_phone_in_call_volte)
Betty Zhou59f18532017-05-01 15:06:11 -0700779
Betty Zhoucf456cf2017-05-10 19:15:09 -0700780 @test_tracker_info(uuid="a317c23a-41e0-4ef8-af67-661451cfefcf")
Betty Zhou59f18532017-05-01 15:06:11 -0700781 @TelephonyBaseTest.tel_test_wrap
Betty Zhoucf456cf2017-05-10 19:15:09 -0700782 def test_csfb_parallel_stress(self):
Betty Zhou59f18532017-05-01 15:06:11 -0700783 """ LTE non-VoLTE stress test"""
Betty Zhou82d7a722017-11-08 15:56:04 -0800784 return self.parallel_tests(
785 setup_func=self._setup_lte_volte_disabled,
786 call_verification_func=is_phone_in_call_csfb)
Betty Zhou59f18532017-05-01 15:06:11 -0700787
Betty Zhoucf456cf2017-05-10 19:15:09 -0700788 @test_tracker_info(uuid="fdb791bf-c414-4333-9fa3-cc18c9b3b234")
Betty Zhou59f18532017-05-01 15:06:11 -0700789 @TelephonyBaseTest.tel_test_wrap
Betty Zhoucf456cf2017-05-10 19:15:09 -0700790 def test_wfc_parallel_stress(self):
Betty Zhou042a56e2018-03-30 17:18:04 -0700791 """ Wifi calling APM mode off stress test"""
Betty Zhou4418a332018-05-15 13:11:18 -0700792 if CAPABILITY_WFC not in self.dut_capabilities:
793 raise signals.TestSkipClass("WFC is not supported")
794 if WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes:
795 raise signals.TestSkip("WFC_MODE_WIFI_PREFERRED is not supported")
Betty Zhou82d7a722017-11-08 15:56:04 -0800796 return self.parallel_tests(
797 setup_func=self._setup_wfc,
798 call_verification_func=is_phone_in_call_iwlan)
Betty Zhou59f18532017-05-01 15:06:11 -0700799
Betty Zhou042a56e2018-03-30 17:18:04 -0700800 @test_tracker_info(uuid="e334c1b3-4378-49bb-bf57-1573fa1b23fa")
801 @TelephonyBaseTest.tel_test_wrap
802 def test_wfc_apm_parallel_stress(self):
803 """ Wifi calling in APM mode on stress test"""
Betty Zhou4418a332018-05-15 13:11:18 -0700804 if CAPABILITY_WFC not in self.dut_capabilities:
805 raise signals.TestSkipClass("WFC is not supported")
Betty Zhou042a56e2018-03-30 17:18:04 -0700806 return self.parallel_tests(
807 setup_func=self._setup_wfc_apm,
808 call_verification_func=is_phone_in_call_iwlan)
809
Betty Zhoucf456cf2017-05-10 19:15:09 -0700810 @test_tracker_info(uuid="4566eef6-55de-4ac8-87ee-58f2ef41a3e8")
Betty Zhou59f18532017-05-01 15:06:11 -0700811 @TelephonyBaseTest.tel_test_wrap
Betty Zhoucf456cf2017-05-10 19:15:09 -0700812 def test_3g_parallel_stress(self):
Betty Zhou59f18532017-05-01 15:06:11 -0700813 """ 3G stress test"""
Betty Zhou82d7a722017-11-08 15:56:04 -0800814 return self.parallel_tests(
815 setup_func=self._setup_3g,
816 call_verification_func=is_phone_in_call_3g)
Betty Zhou59f18532017-05-01 15:06:11 -0700817
Betty Zhoucf456cf2017-05-10 19:15:09 -0700818 @test_tracker_info(uuid="f34f1a31-3948-4675-8698-372a83b8088d")
Betty Zhou59f18532017-05-01 15:06:11 -0700819 @TelephonyBaseTest.tel_test_wrap
Betty Zhou4418a332018-05-15 13:11:18 -0700820 def test_2g_parallel_stress(self):
Betty Zhou59f18532017-05-01 15:06:11 -0700821 """ 2G call stress test"""
Betty Zhou82d7a722017-11-08 15:56:04 -0800822 return self.parallel_tests(
823 setup_func=self._setup_2g,
824 call_verification_func=is_phone_in_call_2g)
Betty Zhou59f18532017-05-01 15:06:11 -0700825
Jaineelcd748202017-08-10 12:23:42 -0700826 @test_tracker_info(uuid="af580fca-fea6-4ca5-b981-b8c710302d37")
827 @TelephonyBaseTest.tel_test_wrap
828 def test_volte_modeprefchange_parallel_stress(self):
829 """ VoLTE Mode Pref call stress test"""
Betty Zhou4418a332018-05-15 13:11:18 -0700830 if CAPABILITY_VOLTE not in self.dut_capabilities:
831 raise signals.TestSkipClass("VoLTE is not supported")
Betty Zhou632793c2018-02-09 18:45:39 -0800832 return self.parallel_with_network_change_tests(
Jaineelcd748202017-08-10 12:23:42 -0700833 setup_func=self._setup_lte_volte_enabled)
834
Betty Zhou59f18532017-05-01 15:06:11 -0700835 """ Tests End """