1#!/usr/bin/env python3.4 2# 3# Copyright 2016 - 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 Pre Check In Sanity 18""" 19 20import collections 21import time 22 23from acts import signals 24from acts.test_decorators import test_tracker_info 25from acts.controllers.sl4a_lib.sl4a_types import Sl4aNetworkInfo 26from acts_contrib.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest 27from acts_contrib.test_utils.tel.tel_data_utils import wifi_tethering_setup_teardown 28from acts_contrib.test_utils.tel.tel_defines import CAPABILITY_VOLTE 29from acts_contrib.test_utils.tel.tel_defines import CAPABILITY_VT 30from acts_contrib.test_utils.tel.tel_defines import CAPABILITY_WFC 31from acts_contrib.test_utils.tel.tel_defines import CAPABILITY_OMADM 32from acts_contrib.test_utils.tel.tel_defines import MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK 33from acts_contrib.test_utils.tel.tel_defines import NETWORK_SERVICE_DATA 34from acts_contrib.test_utils.tel.tel_defines import GEN_4G 35from acts_contrib.test_utils.tel.tel_defines import RAT_FAMILY_WLAN 36from acts_contrib.test_utils.tel.tel_defines import TETHERING_MODE_WIFI 37from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_AFTER_REBOOT 38from acts_contrib.test_utils.tel.tel_defines import WAIT_TIME_AFTER_CRASH 39from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED 40from acts_contrib.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED 41from acts_contrib.test_utils.tel.tel_defines import VT_STATE_BIDIRECTIONAL 42from acts_contrib.test_utils.tel.tel_data_utils import wait_for_wifi_data_connection 43from acts_contrib.test_utils.tel.tel_message_utils import sms_send_receive_verify 44from acts_contrib.test_utils.tel.tel_message_utils import mms_send_receive_verify 45from acts_contrib.test_utils.tel.tel_ims_utils import wait_for_wfc_enabled 46from acts_contrib.test_utils.tel.tel_subscription_utils import get_slot_index_from_subid 47from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_idle_volte 48from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_voice_3g 49from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_csfb 50from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_iwlan 51from acts_contrib.test_utils.tel.tel_phone_setup_utils import phone_setup_volte 52from acts_contrib.test_utils.tel.tel_phone_setup_utils import ensure_phone_subscription 53from acts_contrib.test_utils.tel.tel_phone_setup_utils import wait_for_network_generation 54from acts_contrib.test_utils.tel.tel_phone_setup_utils import wait_for_network_rat 55from acts_contrib.test_utils.tel.tel_test_utils import get_model_name 56from acts_contrib.test_utils.tel.tel_test_utils import get_outgoing_voice_sub_id 57from acts_contrib.test_utils.tel.tel_test_utils import is_droid_in_network_generation 58from acts_contrib.test_utils.tel.tel_test_utils import is_sim_locked 59from acts_contrib.test_utils.tel.tel_test_utils import power_off_sim 60from acts_contrib.test_utils.tel.tel_test_utils import power_on_sim 61from acts_contrib.test_utils.tel.tel_test_utils import reboot_device 62from acts_contrib.test_utils.tel.tel_test_utils import trigger_modem_crash 63from acts_contrib.test_utils.tel.tel_test_utils import trigger_modem_crash_by_modem 64from acts_contrib.test_utils.tel.tel_test_utils import unlock_sim 65from acts_contrib.test_utils.tel.tel_data_utils import wait_for_cell_data_connection 66from acts_contrib.test_utils.tel.tel_test_utils import verify_internet_connection 67from acts_contrib.test_utils.tel.tel_test_utils import wait_for_state 68from acts_contrib.test_utils.tel.tel_voice_utils import call_setup_teardown 69from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_3g 70from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb 71from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan 72from acts_contrib.test_utils.tel.tel_voice_utils import is_phone_in_call_volte 73from acts_contrib.test_utils.tel.tel_video_utils import video_call_setup_teardown 74from acts_contrib.test_utils.tel.tel_video_utils import phone_setup_video 75from acts_contrib.test_utils.tel.tel_video_utils import is_phone_in_call_video_bidirectional 76 77from acts.utils import get_current_epoch_time 78from acts.utils import rand_ascii_str 79 80 81class TelLiveRebootStressTest(TelephonyBaseTest): 82 def setup_class(self): 83 TelephonyBaseTest.setup_class(self) 84 85 self.stress_test_number = int( 86 self.user_params.get("stress_test_number", 10)) 87 self.skip_reset_between_cases = False 88 89 self.dut = self.android_devices[0] 90 self.ad_reference = self.android_devices[1] if len( 91 self.android_devices) > 1 else None 92 self.dut_model = get_model_name(self.dut) 93 self.user_params["check_crash"] = False 94 self.skip_reset_between_cases = False 95 96 self.dut_subID = get_outgoing_voice_sub_id(self.dut) 97 self.dut_capabilities = self.dut.telephony["subscription"][self.dut_subID].get("capabilities", []) 98 self.dut_wfc_modes = self.dut.telephony["subscription"][self.dut_subID].get("wfc_modes", []) 99 self.default_testing_func_names = [] 100 for method in ("_check_volte", "_check_3g"): 101 func = getattr(self, method) 102 try: 103 check_result = func() 104 except Exception as e: 105 self.dut.log.error("%s failed with %s", method, e) 106 check_result = False 107 self.dut.log.info("%s is %s before tests start", method, 108 check_result) 109 if check_result: 110 self.default_testing_func_names.append(method) 111 self.dut.log.info("To be tested: %s", self.default_testing_func_names) 112 113 def teardown_test(self): 114 self._set_volte_provisioning() 115 116 def feature_validator(self, *args): 117 failed_tests = [] 118 for method in ("_check_subscription", "_check_data", 119 "_check_call_setup_teardown", "_check_sms"): 120 func = getattr(self, method) 121 if not func(): 122 self.log.error("%s failed", method) 123 failed_tests.append(method) 124 self.log.info("Wait 5s before each function check.") 125 time.sleep(5) 126 self.log.info("Wait 30s before NW mode switch.") 127 time.sleep(30) 128 for method in args: 129 func = getattr(self, method) 130 try: 131 func_result = func() 132 except Exception as e: 133 self.log.error("%s check failed with %s", method, e) 134 func_result = False 135 if not func_result: 136 self.log.error("%s failed", method) 137 failed_tests.append(method) 138 else: 139 self.log.info("%s succeeded", method) 140 if failed_tests: 141 self.log.error("%s failed", failed_tests) 142 return failed_tests 143 144 def _check_subscription(self): 145 if not ensure_phone_subscription(self.log, self.dut): 146 self.dut.log.error("Subscription check failed") 147 return False 148 else: 149 return True 150 151 def _check_volte_provisioning(self): 152 if CAPABILITY_OMADM in self.dut_capabilities: 153 if not wait_for_state(self.dut.droid.imsIsVolteProvisionedOnDevice, 154 True): 155 self.dut.log.error("VoLTE provisioning is disabled.") 156 return False 157 else: 158 self.dut.log.info("VoLTE provision is enabled") 159 return True 160 return True 161 162 def _check_volte_provisioning_disabled(self): 163 if CAPABILITY_OMADM in self.dut_capabilities: 164 if not wait_for_state(self.dut.droid.imsIsVolteProvisionedOnDevice, 165 False): 166 self.dut.log.error("VoLTE provisioning is not disabled.") 167 return False 168 else: 169 self.dut.log.info("VoLTE provision is disabled") 170 return True 171 return True 172 173 def _set_volte_provisioning(self): 174 if CAPABILITY_OMADM in self.dut_capabilities: 175 provisioned = self.dut.droid.imsIsVolteProvisionedOnDevice() 176 if provisioned: 177 self.dut.log.info("Volte is provioned") 178 return 179 self.dut.log.info("Volte is not provisioned") 180 self.dut.log.info("Set VoLTE Provisioning bit") 181 self.dut.droid.imsSetVolteProvisioning(True) 182 183 def _clear_volte_provisioning(self): 184 if CAPABILITY_OMADM in self.dut_capabilities: 185 self.dut.log.info("Clear VoLTE Provisioning bit") 186 self.dut.droid.imsSetVolteProvisioning(False) 187 if self.dut.droid.imsIsVolteProvisionedOnDevice(): 188 self.dut.log.error("VoLTE is still provisioned") 189 return False 190 else: 191 self.dut.log.info("VoLTE provisioning is disabled") 192 return True 193 194 def _check_call_setup_teardown(self): 195 if not call_setup_teardown(self.log, self.dut, self.ad_reference, 196 self.dut): 197 self.log.error("Phone call test failed.") 198 return False 199 return True 200 201 def _check_sms(self): 202 if not sms_send_receive_verify(self.log, self.dut, self.ad_reference, 203 [rand_ascii_str(180)]): 204 self.log.error("SMS send test failed") 205 return False 206 else: 207 self.log.info("SMS send test passed") 208 return True 209 210 def _check_mms(self): 211 message_array = [("Test Message", rand_ascii_str(180), None)] 212 if not mms_send_receive_verify(self.log, self.dut, self.ad_reference, 213 message_array): 214 self.log.error("MMS test sendfailed") 215 return False 216 else: 217 self.log.info("MMS send test passed") 218 return True 219 220 def _check_sms_mt(self): 221 if not sms_send_receive_verify(self.log, self.ad_reference, self.dut, 222 [rand_ascii_str(180)]): 223 self.log.error("SMS receive test failed") 224 return False 225 else: 226 self.log.info("SMS receive test passed") 227 return True 228 229 def _check_mms_mt(self): 230 message_array = [("Test Message", rand_ascii_str(180), None)] 231 if not mms_send_receive_verify(self.log, self.ad_reference, self.dut, 232 message_array): 233 self.log.error("MMS receive test failed") 234 return False 235 else: 236 self.log.info("MMS receive test passed") 237 return True 238 239 def _check_data(self): 240 if not verify_internet_connection(self.log, self.dut): 241 self.dut.log.error("Data connection is not available.") 242 return False 243 return True 244 245 def _get_list_average(self, input_list): 246 total_sum = float(sum(input_list)) 247 total_count = float(len(input_list)) 248 if input_list == []: 249 return False 250 return float(total_sum / total_count) 251 252 def _check_lte_data(self): 253 if not is_droid_in_network_generation(self.log, self.dut, GEN_4G, 254 NETWORK_SERVICE_DATA): 255 self.dut.log.error("Data is not on 4G network") 256 return False 257 if not verify_internet_connection(self.log, self.dut): 258 self.log.error("Data not available on cell.") 259 return False 260 return True 261 262 def _check_volte(self): 263 if CAPABILITY_VOLTE in self.dut_capabilities: 264 self._set_volte_provisioning() 265 if not self._check_volte_provisioning(): 266 return False 267 self.log.info("Check VoLTE") 268 if not wait_for_state(self.dut.droid.imsIsVolteProvisionedOnDevice, 269 True): 270 self.dut.log.error("VoLTE provisioning is disabled.") 271 return False 272 if not phone_setup_volte(self.log, self.dut): 273 self.log.error("Failed to setup VoLTE.") 274 return False 275 time.sleep(5) 276 if not call_setup_teardown(self.log, self.dut, self.ad_reference, 277 self.dut, is_phone_in_call_volte): 278 self.log.error("VoLTE Call Failed.") 279 return False 280 if not self._check_lte_data(): 281 return False 282 else: 283 self.dut.log.info("VoLTE is not supported") 284 return False 285 return True 286 287 def _check_csfb(self): 288 if not phone_setup_csfb(self.log, self.dut): 289 self.log.error("Failed to setup CSFB.") 290 return False 291 if not call_setup_teardown(self.log, self.dut, self.ad_reference, 292 self.dut, is_phone_in_call_csfb): 293 self.dut.log.error("CSFB Call Failed.") 294 return False 295 if not wait_for_network_generation( 296 self.log, self.dut, GEN_4G, 297 voice_or_data=NETWORK_SERVICE_DATA): 298 self.dut.log.error("Data service failed to camp to 4G") 299 return False 300 if not verify_internet_connection(self.log, self.dut): 301 self.log.error("Data not available on cell.") 302 return False 303 return True 304 305 def _check_volte_enabled(self): 306 if phone_idle_volte(self.log, self.dut): 307 self.dut.log.info("VoLTE is enabled") 308 else: 309 self.dut.log.error("VoLTE is not enabled") 310 return False 311 if not call_setup_teardown(self.log, self.dut, self.ad_reference, 312 self.dut, is_phone_in_call_volte): 313 self.log.error("VoLTE Call Failed.") 314 return False 315 if not self._check_lte_data(): 316 return False 317 return True 318 319 def _check_csfb_enabled(self): 320 if not call_setup_teardown(self.log, self.dut, self.ad_reference, 321 self.dut, is_phone_in_call_csfb): 322 self.log.error("CSFB Call Failed.") 323 return False 324 if not wait_for_network_generation( 325 self.log, self.dut, GEN_4G, 326 voice_or_data=NETWORK_SERVICE_DATA): 327 self.dut.log.error("Data service failed to camp to 4G") 328 return False 329 if not verify_internet_connection(self.log, self.dut): 330 self.log.error("Data not available on cell.") 331 return False 332 return True 333 334 def _check_vt(self): 335 if CAPABILITY_VT in self.dut_capabilities: 336 self.log.info("Check VT") 337 for ad in (self.dut, self.ad_reference): 338 if not phone_setup_video(self.log, ad): 339 ad.log.error("Failed to setup VT.") 340 return False 341 time.sleep(5) 342 if not video_call_setup_teardown( 343 self.log, 344 self.dut, 345 self.ad_reference, 346 self.dut, 347 video_state=VT_STATE_BIDIRECTIONAL, 348 verify_caller_func=is_phone_in_call_video_bidirectional, 349 verify_callee_func=is_phone_in_call_video_bidirectional): 350 self.log.error("VT Call Failed.") 351 return False 352 else: 353 return True 354 return False 355 356 def _check_vt_enabled(self): 357 if not video_call_setup_teardown( 358 self.log, 359 self.dut, 360 self.ad_reference, 361 self.dut, 362 video_state=VT_STATE_BIDIRECTIONAL, 363 verify_caller_func=is_phone_in_call_video_bidirectional, 364 verify_callee_func=is_phone_in_call_video_bidirectional): 365 self.log.error("VT Call Failed.") 366 return False 367 return True 368 369 def _check_wfc_apm(self): 370 if CAPABILITY_WFC in self.dut_capabilities: 371 self.log.info("Check WFC in APM") 372 if not phone_setup_iwlan( 373 self.log, self.dut, True, WFC_MODE_CELLULAR_PREFERRED, 374 self.wifi_network_ssid, self.wifi_network_pass): 375 self.log.error("Failed to setup WFC.") 376 return False 377 if not call_setup_teardown(self.log, self.dut, self.ad_reference, 378 self.dut, is_phone_in_call_iwlan): 379 self.log.error("WFC Call Failed.") 380 return False 381 else: 382 return True 383 return False 384 385 def _check_wfc_nonapm(self): 386 if CAPABILITY_WFC not in self.dut_capabilities and ( 387 WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes): 388 return False 389 self.log.info("Check WFC in NonAPM") 390 if not phone_setup_iwlan( 391 self.log, self.dut, False, WFC_MODE_WIFI_PREFERRED, 392 self.wifi_network_ssid, self.wifi_network_pass): 393 self.log.error("Failed to setup WFC.") 394 return False 395 if not call_setup_teardown(self.log, self.dut, self.ad_reference, 396 self.dut, is_phone_in_call_iwlan): 397 self.log.error("WFC Call Failed.") 398 return False 399 else: 400 return True 401 402 def _check_wfc_enabled(self): 403 if not wait_for_wifi_data_connection(self.log, self.dut, True): 404 self.dut.log.error("Failed to connect to WIFI") 405 return False 406 if not wait_for_wfc_enabled(self.log, self.dut): 407 self.dut.log.error("WFC is not enabled") 408 return False 409 if not wait_for_network_rat( 410 self.log, 411 self.dut, 412 RAT_FAMILY_WLAN, 413 voice_or_data=NETWORK_SERVICE_DATA): 414 ad.log.info("Data rat can not go to iwlan mode successfully") 415 return False 416 if not call_setup_teardown(self.log, self.dut, self.ad_reference, 417 self.dut, is_phone_in_call_iwlan): 418 self.log.error("WFC Call Failed.") 419 return False 420 return True 421 422 def _check_3g(self): 423 self.log.info("Check 3G data and CS call") 424 if not phone_setup_voice_3g(self.log, self.dut): 425 self.log.error("Failed to setup 3G") 426 return False 427 if not verify_internet_connection(self.log, self.dut): 428 self.log.error("Data not available on cell.") 429 return False 430 if not call_setup_teardown(self.log, self.dut, self.ad_reference, 431 self.dut, is_phone_in_call_3g): 432 self.log.error("WFC Call Failed.") 433 return False 434 if not sms_send_receive_verify(self.log, self.dut, self.ad_reference, 435 [rand_ascii_str(50)]): 436 self.log.error("SMS failed in 3G") 437 return False 438 return True 439 440 def _check_tethering(self): 441 self.log.info("Check tethering") 442 for i in range(3): 443 try: 444 if not self.dut.droid.carrierConfigIsTetheringModeAllowed( 445 TETHERING_MODE_WIFI, 446 MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK): 447 self.log.error("Tethering Entitlement check failed.") 448 if i == 2: return False 449 time.sleep(10) 450 except Exception as e: 451 if i == 2: 452 self.dut.log.error(e) 453 return False 454 time.sleep(10) 455 if not wifi_tethering_setup_teardown( 456 self.log, 457 self.dut, [self.ad_reference], 458 check_interval=5, 459 check_iteration=1): 460 self.log.error("Tethering check failed.") 461 return False 462 return True 463 464 def _check_data_roaming_status(self): 465 if not self.dut.droid.telephonyIsDataEnabled(): 466 self.log.info("Enabling Cellular Data") 467 telephonyToggleDataConnection(True) 468 else: 469 self.log.info("Cell Data is Enabled") 470 self.log.info("Waiting for cellular data to be connected") 471 if not wait_for_cell_data_connection(self.log, self.dut, state=True): 472 self.log.error("Failed to enable cell data") 473 return False 474 self.log.info("Cellular data connected, checking NetworkInfos") 475 roaming_state = self.dut.droid.telephonyCheckNetworkRoaming() 476 for network_info in self.dut.droid.connectivityNetworkGetAllInfo(): 477 sl4a_network_info = Sl4aNetworkInfo.from_dict(network_info) 478 if sl4a_network_info.isRoaming: 479 self.log.warning("We don't expect to be roaming") 480 if sl4a_network_info.isRoaming != roaming_state: 481 self.log.error( 482 "Mismatched Roaming Status Information Telephony: {}, NetworkInfo {}". 483 format(roaming_state, sl4a_network_info.isRoaming)) 484 self.log.error(network_info) 485 return False 486 return True 487 488 def _reboot_stress_test(self, *args): 489 """Reboot Reliability Test 490 491 Arguments: 492 function_name: function to be checked 493 494 Expected Results: 495 No crash happens in stress test. 496 497 Returns: 498 True is pass, False if fail. 499 """ 500 self.number_of_devices = 2 501 fail_count = collections.defaultdict(int) 502 test_result = True 503 504 for i in range(1, self.stress_test_number + 1): 505 begin_time = get_current_epoch_time() 506 test_name = "%s_iteration_%s" % (self.test_name, i) 507 log_msg = "[Test Case] %s" % test_name 508 self.log.info("%s begin", log_msg) 509 self.dut.droid.logI("%s begin" % log_msg) 510 test_msg = "Reboot Stress Test %s Iteration <%s> / <%s>" % ( 511 self.test_name, i, self.stress_test_number) 512 self.log.info(test_msg) 513 reboot_device(self.dut) 514 self.log.info("{} wait {}s for radio up.".format( 515 self.dut.serial, WAIT_TIME_AFTER_REBOOT)) 516 time.sleep(WAIT_TIME_AFTER_REBOOT) 517 failed_tests = self.feature_validator(*args) 518 for test in failed_tests: 519 fail_count[test] += 1 520 521 crash_report = self.dut.check_crash_report( 522 "%s_%s" % (self.test_name, i), 523 begin_time, 524 log_crash_report=True) 525 if crash_report: 526 fail_count["crashes"] += 1 527 if failed_tests or crash_report: 528 self.log.error("%s FAIL with %s and crashes %s", test_msg, 529 failed_tests, crash_report) 530 self._take_bug_report(test_name, begin_time) 531 else: 532 self.log.info("%s PASS", test_msg) 533 self.log.info("Total failure count: %s", dict(fail_count)) 534 self.log.info("%s end", log_msg) 535 self.dut.droid.logI("%s end" % log_msg) 536 537 for failure, count in fail_count.items(): 538 if count: 539 self.log.error("%s failure count = %s in total %s iterations", 540 failure, count, self.stress_test_number) 541 test_result = False 542 return test_result 543 544 def _crash_recovery_test(self, process, *args): 545 """Crash Recovery Test 546 547 Arguments: 548 process: the process to be killed. For example: 549 "rild", "netmgrd", "com.android.phone", "imsqmidaemon", 550 "imsdatadaemon", "ims_rtp_daemon", 551 "com.android.ims.rcsservice", "system_server", "cnd", 552 "modem" 553 554 Expected Results: 555 All Features should work as intended post crash recovery 556 557 Returns: 558 True is pass, False if fail. 559 """ 560 self.number_of_devices = 2 561 562 try: 563 self.dut.droid.logI("======== Trigger %s crash ========" % process) 564 except: 565 pass 566 if process == "modem": 567 self.user_params["check_crash"] = False 568 self.dut.log.info("======== Crash modem from kernal ========") 569 trigger_modem_crash(self.dut) 570 elif process == "modem-crash": 571 self.user_params["check_crash"] = False 572 self.dut.log.info("======== Crash modem from modem ========") 573 trigger_modem_crash_by_modem(self.dut) 574 elif process == "sim": 575 self.dut.log.info("======== Power cycle SIM slot ========") 576 self.user_params["check_crash"] = True 577 sub_id = get_outgoing_voice_sub_id(self.dut) 578 slot_index = get_slot_index_from_subid(self.dut, sub_id) 579 if not power_off_sim(self.dut, slot_index): 580 self.dut.log.warning("Fail to power off SIM") 581 raise signals.TestSkip("Power cycle SIM not working") 582 if not power_on_sim(self.dut, slot_index): 583 self.dut.log.error("Fail to power on SIM slot") 584 setattr(self.dut, "reboot_to_recover", True) 585 return False 586 else: 587 if process == "rild": 588 if int(self.dut.adb.getprop( 589 "ro.product.first_api_level")) >= 28: 590 process = "qcrild" 591 self.dut.log.info("======== Killing process <%s> ========", 592 process) 593 process_pid = self.dut.adb.shell("pidof %s" % process) 594 self.dut.log.info("Pid of %s is %s", process, process_pid) 595 if not process_pid: 596 self.dut.log.error("Process %s not running", process) 597 return False 598 if process in ("netd", "system_server"): 599 self.dut.stop_services() 600 self.dut.adb.shell("kill -9 %s" % process_pid, ignore_status=True) 601 self.dut.log.info("Wait %s sec for process %s come up.", 602 WAIT_TIME_AFTER_CRASH, process) 603 time.sleep(WAIT_TIME_AFTER_CRASH) 604 if process in ("netd", "system_server"): 605 self.dut.ensure_screen_on() 606 try: 607 self.dut.start_services() 608 except Exception as e: 609 self.dut.log.warning(e) 610 process_pid_new = self.dut.adb.shell("pidof %s" % process) 611 if process_pid == process_pid_new: 612 self.dut.log.error( 613 "Process %s has the same pid: old:%s new:%s", process, 614 process_pid, process_pid_new) 615 try: 616 self.dut.droid.logI( 617 "======== Start testing after triggering %s crash ========" % 618 process) 619 except Exception: 620 self.dut.ensure_screen_on() 621 self.dut.start_services() 622 if is_sim_locked(self.dut): 623 unlock_sim(self.dut) 624 625 if process == "ims_rtp_daemon": 626 if not self._check_wfc_enabled: 627 failed_tests = ["_check_wfc_enabled"] 628 else: 629 failed_tests = [] 630 else: 631 failed_tests = [] 632 633 begin_time = get_current_epoch_time() 634 failed_tests.extend(self.feature_validator(*args)) 635 crash_report = self.dut.check_crash_report( 636 self.test_name, begin_time, log_crash_report=True) 637 if failed_tests or crash_report: 638 if failed_tests: 639 self.dut.log.error("%s failed after %s restart", failed_tests, 640 process) 641 setattr(self.dut, "reboot_to_recover", True) 642 if crash_report: 643 self.dut.log.error("Crash %s found after %s restart", 644 crash_report, process) 645 return False 646 else: 647 return True 648 649 """ Tests Begin """ 650 651 @test_tracker_info(uuid="4d9b425b-f804-45f4-8f47-0ba3f01a426b") 652 @TelephonyBaseTest.tel_test_wrap 653 def test_reboot_stress(self): 654 """Reboot with VoLTE Test 655 656 Steps: 657 1. Reboot DUT. 658 2. Wait for DUT to camp 659 3. Verify Subscription, Call, Data, Messaging, Tethering 660 4. Check crashes. 661 5. Repeat Step 1~4 for N times. (before reboot, clear Provisioning 662 bit if provisioning is supported) 663 664 Expected Results: 665 No crash happens in stress test. 666 667 Returns: 668 True is pass, False if fail. 669 """ 670 return self._reboot_stress_test(*self.default_testing_func_names) 671 672 @test_tracker_info(uuid="8b0e2c06-02bf-40fd-a374-08860e482757") 673 @TelephonyBaseTest.tel_test_wrap 674 def test_reboot_stress_check_phone_call_only(self): 675 """Reboot with VoLTE Test 676 677 Steps: 678 1. Reboot DUT with volte enabled. 679 2. Wait for DUT to camp on LTE, Verify Data. 680 3. Check VoLTE is enabled by default, check IMS registration. 681 Wait for DUT report VoLTE enabled, make VoLTE call. 682 And verify VoLTE SMS. (if support VoLTE) 683 4. Check crashes. 684 5. Repeat Step 1~4 for N times. (before reboot, clear Provisioning 685 bit if provisioning is supported) 686 687 Expected Results: 688 No crash happens in stress test. 689 690 Returns: 691 True is pass, False if fail. 692 """ 693 if not self._check_call_setup_teardown(): 694 self.dut.log.error("Call setup test failed before reboot test") 695 return False 696 func_names = [ 697 "_check_subscription", "_check_data", "_check_call_setup_teardown" 698 ] 699 return self._reboot_stress_test(*func_names) 700 701 @test_tracker_info(uuid="39a822e5-0360-44ce-97c7-f75468eba8d7") 702 @TelephonyBaseTest.tel_test_wrap 703 def test_reboot_stress_volte_enabled(self): 704 """Reboot with VoLTE Test 705 706 Steps: 707 1. Reboot DUT with volte enabled. 708 2. Wait for DUT to camp on LTE, Verify Data. 709 3. Check VoLTE is enabled by default, check IMS registration. 710 Wait for DUT report VoLTE enabled, make VoLTE call. 711 And verify VoLTE SMS. (if support VoLTE) 712 4. Check crashes. 713 5. Repeat Step 1~4 for N times. (before reboot, clear Provisioning 714 bit if provisioning is supported) 715 716 Expected Results: 717 No crash happens in stress test. 718 719 Returns: 720 True is pass, False if fail. 721 """ 722 if CAPABILITY_VOLTE not in self.dut_capabilities: 723 raise signals.TestSkip("VOLTE is not supported") 724 if not self._check_volte(): 725 self.dut.log.error("VoLTE test failed before reboot test") 726 return False 727 func_names = ["_check_volte_enabled"] 728 if "_check_vt" in self.default_testing_func_names: 729 func_names.append("_check_vt_enabled") 730 return self._reboot_stress_test(*func_names) 731 732 @test_tracker_info(uuid="3dace255-01a6-46ba-87e0-35396d406c95") 733 @TelephonyBaseTest.tel_test_wrap 734 def test_reboot_stress_csfb(self): 735 """Reboot with VoLTE Test 736 737 Steps: 738 1. Reboot DUT with CSFB. 739 2. Wait for DUT to camp on LTE, Verify Data. 740 3. Check call in CSFB after rebooting. 741 4. Check crashes. 742 5. Repeat Step 1~4 for N times. (before reboot, clear Provisioning 743 bit if provisioning is supported) 744 745 Expected Results: 746 No crash happens in stress test. 747 748 Returns: 749 True is pass, False if fail. 750 """ 751 if not self._check_csfb(): 752 self.dut.log.error("CSFB test failed before reboot test") 753 return False 754 func_names = ["_check_csfb_enabled"] 755 return self._reboot_stress_test(*func_names) 756 757 @test_tracker_info(uuid="326f5ba4-8819-49bc-af87-6b3c07532de3") 758 @TelephonyBaseTest.tel_test_wrap 759 def test_reboot_stress_volte_provisioning_disabled(self): 760 """Reboot with VoLTE Test 761 762 Steps: 763 1. Reboot DUT with volte provisioning disabled. 764 2. Wait for DUT to camp on LTE, Verify Data. 765 3. Check VoLTE is disabled after rebooting. 766 4. Check crashes. 767 5. Repeat Step 1~4 for N times. (before reboot, clear Provisioning 768 bit if provisioning is supported) 769 770 Expected Results: 771 No crash happens in stress test. 772 773 Returns: 774 True is pass, False if fail. 775 """ 776 if CAPABILITY_OMADM not in self.dut_capabilities: 777 raise signals.TestSkip("OMADM is not supported") 778 self._clear_volte_provisioning() 779 if not self._check_csfb(): 780 self.dut.log.error("CSFB test failed before reboot test") 781 return False 782 func_names = [ 783 "_check_volte_provisioning_disabled", "_check_csfb_enabled" 784 ] 785 return self._reboot_stress_test(*func_names) 786 787 @test_tracker_info(uuid="6c243b53-379a-4cda-9848-84fcec4019bd") 788 @TelephonyBaseTest.tel_test_wrap 789 def test_reboot_stress_wfc_apm(self): 790 """Reboot with WFC in APM Test 791 792 Steps: 793 1. Reboot DUT with wfc in apm mode. 794 2. Check phone call. 795 3. Check crashes. 796 4. Repeat Step 1~4 for N times. (before reboot, clear Provisioning 797 bit if provisioning is supported) 798 799 Expected Results: 800 No crash happens in stress test. 801 802 Returns: 803 True is pass, False if fail. 804 """ 805 if CAPABILITY_WFC not in self.dut_capabilities: 806 raise signals.TestSkip("WFC is not supported") 807 if "_check_wfc_apm" not in self.default_testing_func_names: 808 raise signals.TestSkip("WFC in airplane mode is not supported") 809 func_names = ["_check_data", "_check_wfc_enabled"] 810 if "_check_vt" in self.default_testing_func_names: 811 func_names.append("_check_vt_enabled") 812 if not self._check_wfc_apm(): 813 self.dut.log.error("WFC in APM test failed before reboot test") 814 return False 815 return self._reboot_stress_test(*func_names) 816 817 @test_tracker_info(uuid="d0439c53-98fa-4303-b097-12ba2462295d") 818 @TelephonyBaseTest.tel_test_wrap 819 def test_reboot_stress_wfc_nonapm(self): 820 """Reboot with WFC in APM Test 821 822 Steps: 823 1. Reboot DUT with wfc in apm mode. 824 2. Check phone call . 825 3. Check crashes. 826 4. Repeat Step 1~4 for N times. (before reboot, clear Provisioning 827 bit if provisioning is supported) 828 829 Expected Results: 830 No crash happens in stress test. 831 832 Returns: 833 True is pass, False if fail. 834 """ 835 if CAPABILITY_WFC not in self.dut_capabilities and ( 836 WFC_MODE_WIFI_PREFERRED not in self.dut_wfc_modes): 837 raise signals.TestSkip("WFC_NONAPM is not supported") 838 if "_check_wfc_nonapm" not in self.default_testing_func_names: 839 raise signals.TestSkip("WFC in non-airplane mode is not working") 840 func_names = ["_check_wfc_enabled"] 841 if "_check_vt" in self.default_testing_func_names: 842 func_names.append("_check_vt_enabled") 843 if not self._check_wfc_nonapm(): 844 self.dut.log.error("WFC test failed before reboot test") 845 return False 846 return self._reboot_stress_test(*func_names) 847 848 @test_tracker_info(uuid="08752fac-dbdb-4d5b-91f6-4ffc3a3ac6d6") 849 @TelephonyBaseTest.tel_test_wrap 850 def test_crash_recovery_modem(self): 851 """Crash Recovery Test 852 853 Steps: 854 1. Crash modem 855 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 856 857 Expected Results: 858 No crash happens in functional test, features work fine. 859 860 Returns: 861 True is pass, False if fail. 862 """ 863 return self._crash_recovery_test("modem", 864 *self.default_testing_func_names) 865 866 @test_tracker_info(uuid="ce5f4d63-7f3d-48b7-831d-2c1d5db60733") 867 @TelephonyBaseTest.tel_test_wrap 868 def test_crash_recovery_crash_modem_from_modem(self): 869 """Crash Recovery Test 870 871 Steps: 872 1. Crash modem 873 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 874 875 Expected Results: 876 No crash happens in functional test, features work fine. 877 878 Returns: 879 True is pass, False if fail. 880 """ 881 if (not self.dut.is_apk_installed("com.google.mdstest")) or ( 882 self.dut.adb.getprop("ro.build.version.release")[0] in 883 ("8", "O", "7", "N")) or self.dut.model in ("angler", "bullhead", 884 "sailfish", "marlin"): 885 raise signals.TestSkip( 886 "com.google.mdstest not installed or supported") 887 return self._crash_recovery_test("modem-crash", 888 *self.default_testing_func_names) 889 890 @test_tracker_info(uuid="489284e8-77c9-4961-97c8-b6f1a833ff90") 891 @TelephonyBaseTest.tel_test_wrap 892 def test_crash_recovery_rild(self): 893 """Crash Recovery Test 894 895 Steps: 896 1. Crash rild 897 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 898 899 Expected Results: 900 No crash happens in functional test, features work fine. 901 902 Returns: 903 True is pass, False if fail. 904 """ 905 return self._crash_recovery_test("rild", 906 *self.default_testing_func_names) 907 908 @test_tracker_info(uuid="e1b34b2c-99e6-4966-a11c-88cedc953b47") 909 @TelephonyBaseTest.tel_test_wrap 910 def test_crash_recovery_netmgrd(self): 911 """Crash Recovery Test 912 913 Steps: 914 1. Crash netmgrd 915 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 916 917 Expected Results: 918 No crash happens in functional test, features work fine. 919 920 Returns: 921 True is pass, False if fail. 922 """ 923 return self._crash_recovery_test("netmgrd", 924 *self.default_testing_func_names) 925 926 @test_tracker_info(uuid="6d6908b7-7eca-42e3-b165-2621714f1822") 927 @TelephonyBaseTest.tel_test_wrap 928 def test_crash_recovery_qtidataservice(self): 929 """Crash Recovery Test 930 931 Steps: 932 1. Crash qtidataservice 933 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 934 935 Expected Results: 936 No crash happens in functional test, features work fine. 937 938 Returns: 939 True is pass, False if fail. 940 """ 941 if int(self.dut.adb.getprop( 942 "ro.product.first_api_level")) > 28: 943 return self._crash_recovery_test(".qtidataservices", 944 *self.default_testing_func_names) 945 946 return self._crash_recovery_test(".dataservices", 947 *self.default_testing_func_names) 948 949 @test_tracker_info(uuid="fa34f994-bc49-4444-9187-87691c94b4f4") 950 @TelephonyBaseTest.tel_test_wrap 951 def test_crash_recovery_phone(self): 952 """Crash Recovery Test 953 954 Steps: 955 1. Crash com.android.phone 956 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 957 958 Expected Results: 959 No crash happens in functional test, features work fine. 960 961 Returns: 962 True is pass, False if fail. 963 """ 964 return self._crash_recovery_test("com.android.phone", 965 *self.default_testing_func_names) 966 967 @test_tracker_info(uuid="6f5a24bb-3cf3-4362-9675-36a6be90282f") 968 @TelephonyBaseTest.tel_test_wrap 969 def test_crash_recovery_imsqmidaemon(self): 970 """Crash Recovery Test 971 972 Steps: 973 1. Crash imsqmidaemon 974 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 975 976 Expected Results: 977 No crash happens in functional test, features work fine. 978 979 Returns: 980 True is pass, False if fail. 981 """ 982 return self._crash_recovery_test("imsqmidaemon", 983 *self.default_testing_func_names) 984 985 @test_tracker_info(uuid="7a8dc971-054b-47e7-9e57-3bb7b39937d3") 986 @TelephonyBaseTest.tel_test_wrap 987 def test_crash_recovery_imsdatadaemon(self): 988 """Crash Recovery Test 989 990 Steps: 991 1. Crash imsdatadaemon 992 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 993 994 Expected Results: 995 No crash happens in functional test, features work fine. 996 997 Returns: 998 True is pass, False if fail. 999 """ 1000 return self._crash_recovery_test("imsdatadaemon", 1001 *self.default_testing_func_names) 1002 1003 @test_tracker_info(uuid="350ca58c-01f2-4a61-baff-530b8b24f1f6") 1004 @TelephonyBaseTest.tel_test_wrap 1005 def test_crash_recovery_ims_rtp_daemon(self): 1006 """Crash Recovery Test 1007 1008 Steps: 1009 1. Crash imsdatadaemon 1010 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 1011 1012 Expected Results: 1013 No crash happens in functional test, features work fine. 1014 1015 Returns: 1016 True is pass, False if fail. 1017 """ 1018 if CAPABILITY_WFC not in self.dut_capabilities: 1019 raise signals.TestSkip("WFC is not supported") 1020 if WFC_MODE_WIFI_PREFERRED in self.dut_wfc_modes: 1021 self._check_wfc_nonapm() 1022 else: 1023 self._check_wfc_apm() 1024 return self._crash_recovery_test("ims_rtp_daemon", 1025 *self.default_testing_func_names) 1026 1027 @test_tracker_info(uuid="af78f33a-2b50-4c55-a302-3701b655c557") 1028 @TelephonyBaseTest.tel_test_wrap 1029 def test_crash_recovery_ims_rcsservice(self): 1030 """Crash Recovery Test 1031 1032 Steps: 1033 1. Crash imsdatadaemon 1034 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 1035 1036 Expected Results: 1037 No crash happens in functional test, features work fine. 1038 1039 Returns: 1040 True is pass, False if fail. 1041 """ 1042 return self._crash_recovery_test("com.android.ims.rcsservice", 1043 *self.default_testing_func_names) 1044 1045 @test_tracker_info(uuid="8119aeef-84ba-415c-88ea-6eba35bd91fd") 1046 @TelephonyBaseTest.tel_test_wrap 1047 def test_crash_recovery_system_server(self): 1048 """Crash Recovery Test 1049 1050 Steps: 1051 1. Crash system_server 1052 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 1053 1054 Expected Results: 1055 No crash happens in functional test, features work fine. 1056 1057 Returns: 1058 True is pass, False if fail. 1059 """ 1060 return self._crash_recovery_test("system_server", 1061 *self.default_testing_func_names) 1062 1063 @test_tracker_info(uuid="c3891aca-9e1a-4e37-9f2f-23f12ef0a86f") 1064 @TelephonyBaseTest.tel_test_wrap 1065 def test_crash_recovery_cnd(self): 1066 """Crash Recovery Test 1067 1068 Steps: 1069 1. Crash cnd 1070 2. Post crash recovery, verify Voice, Data, SMS, VoLTE, VT 1071 1072 Expected Results: 1073 No crash happens in functional test, features work fine. 1074 1075 Returns: 1076 True is pass, False if fail. 1077 """ 1078 return self._crash_recovery_test("cnd", 1079 *self.default_testing_func_names) 1080 1081 @test_tracker_info(uuid="c1b661b9-d5cf-4a22-90a9-3fd55ddc2f3f") 1082 @TelephonyBaseTest.tel_test_wrap 1083 def test_sim_slot_power_cycle(self): 1084 """SIM slot power cycle Test 1085 1086 Steps: 1087 1. Power cycle SIM slot to simulate SIM resit 1088 2. Post power cycle SIM, verify Voice, Data, SMS, VoLTE, VT 1089 1090 Expected Results: 1091 No crash happens in functional test, features work fine. 1092 1093 Returns: 1094 True is pass, False if fail. 1095 """ 1096 if self.dut.adb.getprop("ro.build.version.release")[0] in ( 1097 "8", "O", "7", "N") or self.dut.model in ("angler", "bullhead", 1098 "marlin", 1099 "sailfish"): 1100 raise signals.TestSkip("Power off SIM is not supported") 1101 return self._crash_recovery_test("sim", 1102 *self.default_testing_func_names) 1103 1104 1105""" Tests End """ 1106