Home | History | Annotate | Download | only in live
      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 
     20 import time
     21 from acts.test_utils.tel.TelephonyBaseTest import TelephonyBaseTest
     22 from acts.test_utils.tel.tel_data_utils import wifi_tethering_setup_teardown
     23 from acts.test_utils.tel.tel_defines import AOSP_PREFIX
     24 from acts.test_utils.tel.tel_defines import CAPABILITY_VOLTE
     25 from acts.test_utils.tel.tel_defines import CAPABILITY_WFC
     26 from acts.test_utils.tel.tel_defines import CAPABILITY_OMADM
     27 from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_PROVISIONING
     28 from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK
     29 from acts.test_utils.tel.tel_defines import TETHERING_MODE_WIFI
     30 from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_REBOOT
     31 from acts.test_utils.tel.tel_defines import WAIT_TIME_ANDROID_STATE_SETTLING
     32 from acts.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL
     33 from acts.test_utils.tel.tel_defines import WAIT_TIME_IN_CALL_FOR_IMS
     34 from acts.test_utils.tel.tel_defines import WFC_MODE_CELLULAR_PREFERRED
     35 from acts.test_utils.tel.tel_defines import WFC_MODE_DISABLED
     36 from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_ONLY
     37 from acts.test_utils.tel.tel_defines import WFC_MODE_WIFI_PREFERRED
     38 from acts.test_utils.tel.tel_lookup_tables import device_capabilities
     39 from acts.test_utils.tel.tel_lookup_tables import operator_capabilities
     40 from acts.test_utils.tel.tel_test_utils import call_setup_teardown
     41 from acts.test_utils.tel.tel_test_utils import ensure_wifi_connected
     42 from acts.test_utils.tel.tel_test_utils import get_model_name
     43 from acts.test_utils.tel.tel_test_utils import get_operator_name
     44 from acts.test_utils.tel.tel_test_utils import multithread_func
     45 from acts.test_utils.tel.tel_test_utils import sms_send_receive_verify
     46 from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode
     47 from acts.test_utils.tel.tel_test_utils import verify_http_connection
     48 from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_3g
     49 from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_csfb
     50 from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_iwlan
     51 from acts.test_utils.tel.tel_voice_utils import is_phone_in_call_volte
     52 from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_3g
     53 from acts.test_utils.tel.tel_voice_utils import phone_setup_csfb
     54 from acts.test_utils.tel.tel_voice_utils import phone_setup_iwlan
     55 from acts.test_utils.tel.tel_voice_utils import \
     56     phone_setup_iwlan_cellular_preferred
     57 from acts.test_utils.tel.tel_voice_utils import phone_setup_voice_general
     58 from acts.test_utils.tel.tel_voice_utils import phone_setup_volte
     59 from acts.test_utils.tel.tel_voice_utils import phone_idle_3g
     60 from acts.test_utils.tel.tel_voice_utils import phone_idle_csfb
     61 from acts.test_utils.tel.tel_voice_utils import phone_idle_iwlan
     62 from acts.test_utils.tel.tel_voice_utils import phone_idle_volte
     63 
     64 from acts.utils import rand_ascii_str
     65 
     66 
     67 class TelLiveRebootStressTest(TelephonyBaseTest):
     68     def __init__(self, controllers):
     69         TelephonyBaseTest.__init__(self, controllers)
     70         self.tests = (
     71             "test_reboot_stress",
     72             "test_reboot_stress_without_clear_provisioning"
     73             )
     74 
     75         self.stress_test_number = int(self.user_params["stress_test_number"])
     76         self.wifi_network_ssid = self.user_params["wifi_network_ssid"]
     77 
     78         try:
     79             self.wifi_network_pass = self.user_params["wifi_network_pass"]
     80         except KeyError:
     81             self.wifi_network_pass = None
     82 
     83         self.dut = self.android_devices[0]
     84         self.ad_reference = self.android_devices[1]
     85         self.dut_model = get_model_name(self.dut)
     86         self.dut_operator = get_operator_name(self.log, self.dut)
     87 
     88     def _check_provisioning(self, ad):
     89         if (CAPABILITY_OMADM in device_capabilities[self.dut_model] and
     90                 CAPABILITY_OMADM in operator_capabilities[self.dut_operator]):
     91             self.log.info("Check Provisioning bit")
     92             if not ad.droid.imsIsVolteProvisionedOnDevice():
     93                 self.log.error("{}: VoLTE Not Provisioned on the Platform".format(
     94                     ad.serial))
     95                 return False
     96         return True
     97 
     98     def _clear_provisioning(self, ad):
     99         if (CAPABILITY_OMADM in device_capabilities[self.dut_model] and
    100                 CAPABILITY_OMADM in operator_capabilities[self.dut_operator]):
    101             self.log.info("Clear Provisioning bit")
    102             ad.droid.imsSetVolteProvisioning(False)
    103         return True
    104 
    105     def _check_lte_data(self, ad):
    106         self.log.info("Check LTE data.")
    107         if not phone_setup_csfb(self.log, ad):
    108             self.log.error("Failed to setup LTE data.")
    109             return False
    110         if not verify_http_connection(self.log, ad):
    111             self.log.error("Data not available on cell.")
    112             return False
    113         return True
    114 
    115     def _check_volte(self, ad, ad_reference):
    116         if (CAPABILITY_VOLTE in device_capabilities[self.dut_model] and
    117                 CAPABILITY_VOLTE in operator_capabilities[self.dut_operator]):
    118             self.log.info("Check VoLTE")
    119             if not phone_setup_volte(self.log, ad):
    120                 self.log.error("Failed to setup VoLTE.")
    121                 return False
    122             if not call_setup_teardown(self.log, ad, ad_reference, ad,
    123                                        is_phone_in_call_volte):
    124                 self.log.error("VoLTE Call Failed.")
    125                 return False
    126             if not sms_send_receive_verify(self.log, ad, ad_reference,
    127                                            [rand_ascii_str(50)]):
    128                 self.log.error("SMS failed")
    129                 return False
    130         return True
    131 
    132     def _check_wfc(self, ad, ad_reference):
    133         if (CAPABILITY_WFC in device_capabilities[self.dut_model] and
    134                 CAPABILITY_WFC in operator_capabilities[self.dut_operator]):
    135             self.log.info("Check WFC")
    136             if not phone_setup_iwlan(self.log, ad, True, WFC_MODE_WIFI_PREFERRED,
    137                 self.wifi_network_ssid, self.wifi_network_pass):
    138                 self.log.error("Failed to setup WFC.")
    139                 return False
    140             if not call_setup_teardown(self.log, ad, ad_reference, ad,
    141                                        is_phone_in_call_iwlan):
    142                 self.log.error("WFC Call Failed.")
    143                 return False
    144             if not sms_send_receive_verify(self.log, ad, ad_reference,
    145                                            [rand_ascii_str(50)]):
    146                 self.log.error("SMS failed")
    147                 return False
    148         return True
    149 
    150     def _check_3g(self, ad, ad_reference):
    151         self.log.info("Check 3G data and CS call")
    152         if not phone_setup_voice_3g(self.log, ad):
    153             self.log.error("Failed to setup 3G")
    154             return False
    155         if not verify_http_connection(self.log, ad):
    156             self.log.error("Data not available on cell.")
    157             return False
    158         if not call_setup_teardown(self.log, ad, ad_reference, ad,
    159                                    is_phone_in_call_3g):
    160             self.log.error("WFC Call Failed.")
    161             return False
    162         if not sms_send_receive_verify(self.log, ad, ad_reference,
    163                                        [rand_ascii_str(50)]):
    164             self.log.error("SMS failed")
    165             return False
    166         return True
    167 
    168     def _check_tethering(self, ad, ad_reference):
    169         self.log.info("Check tethering")
    170         if not ad.droid.carrierConfigIsTetheringModeAllowed(
    171             TETHERING_MODE_WIFI, MAX_WAIT_TIME_TETHERING_ENTITLEMENT_CHECK):
    172             self.log.error("Tethering Entitlement check failed.")
    173             return False
    174         if not wifi_tethering_setup_teardown(self.log, ad, [ad_reference],
    175             check_interval = 5, check_iteration = 1):
    176             self.log.error("Tethering Failed.")
    177             return False
    178         return True
    179 
    180     """ Tests Begin """
    181 
    182     @TelephonyBaseTest.tel_test_wrap
    183     def test_reboot_stress(self):
    184         """Reboot Reliability Test
    185 
    186         Steps:
    187             1. Reboot DUT.
    188             2. Check Provisioning bit (if support provisioning)
    189             3. Wait for DUT to camp on LTE, Verify Data.
    190             4. Enable VoLTE, check IMS registration. Wait for DUT report VoLTE
    191                 enabled, make VoLTE call. And verify VoLTE SMS.
    192                 (if support VoLTE)
    193             5. Connect WiFi, enable WiFi Calling, wait for DUT report WiFi
    194                 Calling enabled and make a WFC call and verify SMS.
    195                 Disconnect WiFi. (if support WFC)
    196             6. Wait for DUT to camp on 3G, Verify Data.
    197             7. Make CS call and verify SMS.
    198             8. Verify Tethering Entitlement Check and Verify WiFi Tethering.
    199             9. Check crashes.
    200             10. Repeat Step 1~9 for N times. (before reboot, clear Provisioning
    201                 bit if provisioning is supported)
    202 
    203         Expected Results:
    204             No crash happens in stress test.
    205 
    206         Returns:
    207             True is pass, False if fail.
    208         """
    209         CHECK_INTERVAL = 10
    210 
    211         toggle_airplane_mode(self.log, self.dut, False)
    212         phone_setup_voice_general(self.log, self.ad_reference)
    213 
    214         for i in range(1, self.stress_test_number + 1):
    215             self.log.info("Reboot Stress Test Iteration: <{}> / <{}>".
    216                 format(i, self.stress_test_number))
    217 
    218             self.log.info("{} reboot!".format(self.dut.serial))
    219             self.dut.reboot()
    220             self.log.info("{} wait {}s for radio up.".format(
    221                 self.dut.serial, WAIT_TIME_AFTER_REBOOT))
    222             time.sleep(WAIT_TIME_AFTER_REBOOT)
    223 
    224             elapsed_time = 0
    225             provisioned = False
    226             while(elapsed_time < MAX_WAIT_TIME_PROVISIONING):
    227                 if self._check_provisioning(self.dut):
    228                     provisioned = True
    229                     break
    230                 else:
    231                     time.sleep(CHECK_INTERVAL)
    232                     elapsed_time += CHECK_INTERVAL
    233             if not provisioned:
    234                 self.log.error("Provisioning fail.")
    235                 return False
    236 
    237             if not self._check_lte_data(self.dut):
    238                 self.log.error("LTE Data fail.")
    239                 return False
    240 
    241             if not self._check_volte(self.dut, self.ad_reference):
    242                 self.log.error("VoLTE fail.")
    243                 return False
    244 
    245             if not self._check_wfc(self.dut, self.ad_reference):
    246                 self.log.error("WFC fail.")
    247                 return False
    248 
    249             if not self._check_3g(self.dut, self.ad_reference):
    250                 self.log.error("3G fail.")
    251                 return False
    252 
    253             if not self._check_tethering(self.dut, self.ad_reference):
    254                 self.log.error("Tethering fail.")
    255                 return False
    256 
    257             self._clear_provisioning(self.dut)
    258 
    259             # TODO: Check if crash happens.
    260 
    261             self.log.info("Iteration: <{}> / <{}> Pass".
    262                 format(i, self.stress_test_number))
    263 
    264         return True
    265 
    266     @TelephonyBaseTest.tel_test_wrap
    267     def test_reboot_stress_without_clear_provisioning(self):
    268         """Reboot Reliability Test without Clear Provisioning
    269 
    270         Steps:
    271             1. Reboot DUT.
    272             2. Check Provisioning bit (if support provisioning)
    273             3. Wait for DUT to camp on LTE, Verify Data.
    274             4. Enable VoLTE, check IMS registration. Wait for DUT report VoLTE
    275                 enabled, make VoLTE call. And verify VoLTE SMS.
    276                 (if support VoLTE)
    277             5. Connect WiFi, enable WiFi Calling, wait for DUT report WiFi
    278                 Calling enabled and make a WFC call and verify SMS.
    279                 Disconnect WiFi. (if support WFC)
    280             6. Wait for DUT to camp on 3G, Verify Data.
    281             7. Make CS call and verify SMS.
    282             8. Verify Tethering Entitlement Check and Verify WiFi Tethering.
    283             9. Check crashes.
    284             10. Repeat Step 1~9 for N times.
    285 
    286         Expected Results:
    287             No crash happens in stress test.
    288 
    289         Returns:
    290             True is pass, False if fail.
    291         """
    292 
    293         toggle_airplane_mode(self.log, self.dut, False)
    294         phone_setup_voice_general(self.log, self.ad_reference)
    295 
    296         for i in range(1, self.stress_test_number + 1):
    297             self.log.info("Reboot Stress Test Iteration: <{}> / <{}>".
    298                 format(i, self.stress_test_number))
    299 
    300             self.log.info("{} reboot!".format(self.dut.serial))
    301             self.dut.reboot()
    302             self.log.info("{} wait {}s for radio up.".format(
    303                 self.dut.serial, WAIT_TIME_AFTER_REBOOT))
    304             time.sleep(WAIT_TIME_AFTER_REBOOT)
    305 
    306             if not self._check_provisioning(self.dut):
    307                 self.log.error("Provisioning fail.")
    308                 return False
    309 
    310             if not self._check_lte_data(self.dut):
    311                 self.log.error("LTE Data fail.")
    312                 return False
    313 
    314             if not self._check_volte(self.dut, self.ad_reference):
    315                 self.log.error("VoLTE fail.")
    316                 return False
    317 
    318             if not self._check_wfc(self.dut, self.ad_reference):
    319                 self.log.error("WFC fail.")
    320                 return False
    321 
    322             if not self._check_3g(self.dut, self.ad_reference):
    323                 self.log.error("3G fail.")
    324                 return False
    325 
    326             if not self._check_tethering(self.dut, self.ad_reference):
    327                 self.log.error("Tethering fail.")
    328                 return False
    329 
    330             # TODO: Check if crash happens.
    331 
    332             self.log.info("Iteration: <{}> / <{}> Pass".
    333                 format(i, self.stress_test_number))
    334 
    335         return True
    336 
    337 """ Tests End """
    338