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