def setup_and_connect(self, ap_settings):
        """Generates a hostapd config, setups up the AP with that config, then
           attempts to associate a DUT

        Args:
               ap_settings: A dictionary of hostapd constant n_capabilities.
        """
        security_profile = None
        password = None
        temp_n_capabilities = list(ap_settings['n_capabilities'])
        n_capabilities = []
        for n_capability in temp_n_capabilities:
            if n_capability in hostapd_constants.N_CAPABILITIES_MAPPING.keys():
                n_capabilities.append(n_capability)

        if ap_settings['chbw'] == 'HT20' or ap_settings['chbw'] == 'HT40+':
            if ap_settings['frequency'] == '2.4GHz':
                channel = 1
            elif ap_settings['frequency'] == '5GHz':
                channel = 36
            else:
                raise ValueError('Invalid frequence: %s' %
                                 ap_settings['frequency'])

        if ap_settings['chbw'] == 'HT40-':
            if ap_settings['frequency'] == '2.4GHz':
                channel = 11
            elif ap_settings['frequency'] == '5GHz':
                channel = 60
            else:
                raise ValueError('Invalid frequency: %s' %
                                 ap_settings['frequency'])

        if ap_settings['chbw'] == 'HT40-' or ap_settings['chbw'] == 'HT40+':
            if hostapd_config.ht40_plus_allowed(channel):
                extended_channel = hostapd_constants.N_CAPABILITY_HT40_PLUS
            elif hostapd_config.ht40_minus_allowed(channel):
                extended_channel = hostapd_constants.N_CAPABILITY_HT40_MINUS
            else:
                raise ValueError('Invalid channel: %s' % channel)
            n_capabilities.append(extended_channel)

        if ap_settings['security'] == 'wpa2':
            security_profile = Security(security_mode=SECURITY_WPA2,
                                        password=rand_ascii_str(20),
                                        wpa_cipher='CCMP',
                                        wpa2_cipher='CCMP')
            password = security_profile.password

        validate_setup_ap_and_associate(access_point=self.access_point,
                                        client=self.dut,
                                        profile_name='whirlwind',
                                        mode=hostapd_constants.MODE_11N_MIXED,
                                        channel=channel,
                                        n_capabilities=n_capabilities,
                                        ac_capabilities=[],
                                        force_wmm=True,
                                        ssid=utils.rand_ascii_str(20),
                                        security=security_profile,
                                        password=password)
    def get_open_network(self,
                         ap_count=1,
                         ssid_length_2g=hostapd_constants.AP_SSID_LENGTH_2G,
                         ssid_length_5g=hostapd_constants.AP_SSID_LENGTH_5G):
        """Generates SSIDs for a open network using a random generator.

        Args:
            ap_count: Determines if we want to use one or both the APs for
                      for configuration. If set to '2', then both APs will
                      be configured with the same configuration.
            ssid_length_2g: Int, number of characters to use for 2G SSID.
            ssid_length_5g: Int, number of characters to use for 5G SSID.
        Returns: A dict of 2G and 5G network lists for hostapd configuration.

        """
        network_dict_2g = {}
        network_dict_5g = {}
        self.user_params["open_network"] = []
        open_2g_ssid = '2g_%s' % utils.rand_ascii_str(ssid_length_2g)
        open_5g_ssid = '5g_%s' % utils.rand_ascii_str(ssid_length_5g)
        network_dict_2g = {"SSID": open_2g_ssid, "security": 'none'}
        network_dict_5g = {"SSID": open_5g_ssid, "security": 'none'}
        for ap in range(ap_count):
            self.user_params["open_network"].append({
                "2g": network_dict_2g,
                "5g": network_dict_5g
            })
        self.open_network = self.user_params["open_network"]
        return {"2g": network_dict_2g, "5g": network_dict_5g}
예제 #3
0
    def setup_class(self):
        super().setup_class()
        if 'dut' in self.user_params:
            if self.user_params['dut'] == 'fuchsia_devices':
                self.dut = create_wlan_device(self.fuchsia_devices[0])
            elif self.user_params['dut'] == 'android_devices':
                self.dut = create_wlan_device(self.android_devices[0])
            else:
                raise ValueError('Invalid DUT specified in config. (%s)' %
                                 self.user_params['dut'])
        else:
            # Default is an android device, just like the other tests
            self.dut = create_wlan_device(self.android_devices[0])

        self.access_point = self.access_points[0]

        # Same for both 2g and 5g
        self.ssid = utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G)
        self.password = utils.rand_ascii_str(
            hostapd_constants.AP_PASSPHRASE_LENGTH_2G)
        self.security_profile_wpa2 = Security(
            security_mode=hostapd_constants.WPA2_STRING,
            password=self.password,
            wpa2_cipher=hostapd_constants.WPA2_DEFAULT_CIPER)

        self.access_point.stop_all_aps()
 def create_softap_config(self):
     """Create a softap config with ssid and password."""
     ap_ssid = "softap_" + utils.rand_ascii_str(8)
     ap_password = utils.rand_ascii_str(8)
     self.dut.log.info("softap setup: %s %s", ap_ssid, ap_password)
     config = {wutils.WifiEnums.SSID_KEY: ap_ssid}
     config[wutils.WifiEnums.PWD_KEY] = ap_password
     return config
예제 #5
0
    def test_smoke_wfc_call_sms(self):
        ads = self.android_devices
        sms_idle_result = False
        sms_incall_result = False
        call_result = False

        self.log.info("--------start test_smoke_wfc_call_sms--------")
        for ad in [ads[0], ads[1]]:
            if not ad.droid.imsIsWfcEnabledByPlatform():
                self.log.info("WFC not supported by platform.")
                return True
        try:
            ensure_phones_default_state(self.log, ads)
            tasks = [(phone_setup_iwlan,
                      (self.log, ads[0], True, WFC_MODE_WIFI_PREFERRED,
                       self.wifi_network_ssid, self.wifi_network_pass)),
                     (phone_setup_iwlan,
                      (self.log, ads[1], True, WFC_MODE_WIFI_PREFERRED,
                       self.wifi_network_ssid, self.wifi_network_pass))]
            if not multithread_func(self.log, tasks):
                self.log.error("Phone Failed to Set Up WiFI Calling.")
                return False

            self.log.info("1. Verify SMS in idle.")
            if sms_send_receive_verify(self.log, ads[0], ads[1],
                                       [rand_ascii_str(50)]):
                sms_idle_result = True

            self.log.info("2. Setup WiFi Call.")
            if not call_setup_teardown(
                    self.log,
                    ads[0],
                    ads[1],
                    ad_hangup=None,
                    verify_caller_func=is_phone_in_call_iwlan,
                    verify_callee_func=is_phone_in_call_iwlan):
                self.log.error("Setup WiFi Call Failed.")
                self.log.info("sms_idle_result:{}".format(sms_idle_result))
                return False

            self.log.info("3. Verify SMS in call.")
            if sms_send_receive_verify(self.log, ads[0], ads[1],
                                       [rand_ascii_str(51)]):
                sms_incall_result = True

            self.log.info("4. Verify Call not drop and hangup.")
            if (is_phone_in_call_iwlan(self.log, ads[0])
                    and is_phone_in_call_iwlan(self.log, ads[1])
                    and hangup_call(self.log, ads[0])):
                call_result = True

            return (call_result and sms_idle_result and sms_incall_result)
        finally:
            self.log.info(
                "Summary for test run. Testbed:<{}>. <WFC> SMS idle: {}, "
                "SMS in call: {}, Voice Call: {}".format(
                    getattr(self, Config.ikey_testbed_name.value),
                    sms_idle_result, sms_incall_result, call_result))
예제 #6
0
 def sms_send_outgoing_texts(self, pri_dut, sec_dut):
     self.log.info("Test send sms of different sizes.")
     input("Press enter to execute this testcase...")
     msg = [rand_ascii_str(50), rand_ascii_str(1), rand_ascii_str(500)]
     if not sms_send_receive_verify(self.log, pri_dut, sec_dut, msg):
         return False
     else:
         self.log.info("Successfully sent sms. Please verify on carkit.")
     return True
예제 #7
0
    def get_open_network(self,
                         mirror_ap,
                         open_network,
                         hidden=False,
                         same_ssid=False,
                         ssid_length_2g=hostapd_constants.AP_SSID_LENGTH_2G,
                         ssid_length_5g=hostapd_constants.AP_SSID_LENGTH_5G,
                         security_mode='none'):
        """Generates SSIDs for a open network using a random generator.

        Args:
            mirror_ap: Boolean, determines if both APs use the same hostapd
                       config or different configs.
            open_network: List of open networks.
            same_ssid: Boolean, determines if both bands on AP use the same
                       SSID.
            ssid_length_2g: Int, number of characters to use for 2G SSID.
            ssid_length_5g: Int, number of characters to use for 5G SSID.
            security_mode: 'none' for open and 'OWE' for WPA3 OWE.

        Returns: A dict of 2G and 5G network lists for hostapd configuration.

        """
        network_dict_2g = {}
        network_dict_5g = {}

        if same_ssid:
            open_2g_ssid = 'xg_%s' % utils.rand_ascii_str(ssid_length_2g)
            open_5g_ssid = open_2g_ssid

        else:
            open_2g_ssid = '2g_%s' % utils.rand_ascii_str(ssid_length_2g)
            open_5g_ssid = '5g_%s' % utils.rand_ascii_str(ssid_length_5g)

        network_dict_2g = {
            "SSID": open_2g_ssid,
            "security": security_mode,
            "hiddenSSID": hidden
        }

        network_dict_5g = {
            "SSID": open_5g_ssid,
            "security": security_mode,
            "hiddenSSID": hidden
        }

        ap = 0
        for ap in range(MAX_AP_COUNT):
            open_network.append({
                "2g": copy.copy(network_dict_2g),
                "5g": copy.copy(network_dict_5g)
            })
            if not mirror_ap:
                break
        return {"2g": network_dict_2g, "5g": network_dict_5g}
    def get_wpa2_network(
            self,
            ap_count=1,
            ssid_length_2g=hostapd_constants.AP_SSID_LENGTH_2G,
            ssid_length_5g=hostapd_constants.AP_SSID_LENGTH_5G,
            passphrase_length_2g=hostapd_constants.AP_PASSPHRASE_LENGTH_2G,
            passphrase_length_5g=hostapd_constants.AP_PASSPHRASE_LENGTH_5G):
        """Generates SSID and passphrase for a WPA2 network using random
           generator.

           Args:
               ap_count: Determines if we want to use one or both the APs
                         for configuration. If set to '2', then both APs will
                         be configured with the same configuration.
               ssid_length_2g: Int, number of characters to use for 2G SSID.
               ssid_length_5g: Int, number of characters to use for 5G SSID.
               passphrase_length_2g: Int, length of password for 2G network.
               passphrase_length_5g: Int, length of password for 5G network.
           Returns: A dict of 2G and 5G network lists for hostapd configuration.

        """
        network_dict_2g = {}
        network_dict_5g = {}
        ref_5g_security = hostapd_constants.WPA2_STRING
        ref_2g_security = hostapd_constants.WPA2_STRING
        self.user_params["reference_networks"] = []

        ref_2g_ssid = '2g_%s' % utils.rand_ascii_str(ssid_length_2g)
        ref_2g_passphrase = utils.rand_ascii_str(passphrase_length_2g)

        ref_5g_ssid = '5g_%s' % utils.rand_ascii_str(ssid_length_5g)
        ref_5g_passphrase = utils.rand_ascii_str(passphrase_length_5g)

        network_dict_2g = {
            "SSID": ref_2g_ssid,
            "security": ref_2g_security,
            "password": ref_2g_passphrase
        }

        network_dict_5g = {
            "SSID": ref_5g_ssid,
            "security": ref_5g_security,
            "password": ref_5g_passphrase
        }

        for ap in range(ap_count):
            self.user_params["reference_networks"].append({
                "2g":
                network_dict_2g,
                "5g":
                network_dict_5g
            })
        self.reference_networks = self.user_params["reference_networks"]
        return {"2g": network_dict_2g, "5g": network_dict_5g}
 def test_wrong_password_whirlwind_5g(self):
     self.connect_disconnect(
         {
             'profile':
             'whirlwind',
             'channel':
             self.channel_5G,
             'security':
             hostapd_security.Security(security_mode='wpa2',
                                       password=rand_ascii_str(10))
         },
         password=rand_ascii_str(20),
         negative_test=True)
 def test_soft_ap_5g_wpa2_local(self):
     self.verify_soft_ap_associate_and_pass_traffic(
         self.primary_client, {
             'ssid':
             utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G),
             'security_type':
             SECURITY_WPA2,
             'password':
             utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH),
             'connectivity_mode':
             CONNECTIVITY_MODE_LOCAL,
             'operating_band':
             OPERATING_BAND_5G
         })
 def test_soft_ap_any_wpa3_unrestricted(self):
     self.verify_soft_ap_associate_and_pass_traffic(
         self.primary_client, {
             'ssid':
             utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G),
             'security_type':
             SECURITY_WPA3,
             'password':
             utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH),
             'connectivity_mode':
             CONNECTIVITY_MODE_UNRESTRICTED,
             'operating_band':
             OPERATING_BAND_ANY
         })
 def _send_message(self, ads):
     selection = random.randrange(0, 2)
     message_type_map = {0: "SMS", 1: "MMS"}
     max_length_map = {0: self.max_sms_length, 1: self.max_mms_length}
     min_length_map = {0: self.min_sms_length, 1: self.min_mms_length}
     length = random.randrange(min_length_map[selection],
                               max_length_map[selection] + 1)
     text = rand_ascii_str(length)
     message_content_map = {0: [text], 1: [("Mms Message", text, None)]}
     message_func_map = {
         0: sms_send_receive_verify,
         1: mms_send_receive_verify
     }
     message_type = message_type_map[selection]
     self.result_info["Total %s" % message_type] += 1
     begin_time = get_current_epoch_time()
     start_qxdm_loggers(self.log, self.android_devices)
     if not message_func_map[selection](self.log, ads[0], ads[1],
                                        message_content_map[selection]):
         self.log.error("%s of length %s from %s to %s fails", message_type,
                        length, ads[0].serial, ads[1].serial)
         self.result_info["%s failure" % message_type] += 1
         if message_type == "SMS" or self.result_info["%s failure" %
                                                      message_type] == 1:
             self._take_bug_report("%s_%s_failure" % (self.test_name,
                                                      message_type),
                                   begin_time)
         return False
     else:
         self.log.info("%s of length %s from %s to %s succeed",
                       message_type_map[selection], length, ads[0].serial,
                       ads[1].serial)
         return True
예제 #13
0
    def stress_test(self, setup_func=None, network_check_func=None, test_sms=False):
        if setup_func and not setup_func():
            self.log.error("Test setup %s failed", setup_func.__name__)
            return False
        fail_count = collections.defaultdict(int)
        for i in range(1, self.phone_call_iteration + 1):
            msg = "Stress Call Test %s Iteration: <%s> / <%s>" % (
                self.test_name, i, self.phone_call_iteration)
            self.log.info(msg)
            iteration_result = True
            ensure_phones_idle(self.log, self.android_devices)
            if not self._setup_phone_call():
                fail_count["dialing"] += 1
                iteration_result = False
                self.log.error("%s call dialing failure.", msg)

            if network_check_func and not network_check_func(self.log,
                                                             self.caller):
                fail_count["caller_network_check"] += 1
                iteration_result = False
                self.log.error("%s network check %s failure.", msg,
                               network_check_func.__name__)

            if network_check_func and not network_check_func(self.log,
                                                             self.callee):
                fail_count["callee_network_check"] += 1
                iteration_result = False
                self.log.error("%s network check failure.", msg)

            time.sleep(self.phone_call_duration)

            if not verify_incall_state(self.log, [self.caller, self.callee],
                                       True):
                self.log.error("%s call dropped.", msg)
                iteration_result = False
                fail_count["drop"] += 1

            self._hangup_call()

            if test_sms and not sms_send_receive_verify(
                    self.log, self.caller, self.callee, [rand_ascii_str(180)]):
                fail_count["sms"] += 1

            self.log.info("%s %s" % (msg, str(iteration_result)))
            if not iteration_result:
                self._take_bug_report("%s_%s" % (self.test_name, i), self.begin_time)

            if self.sleep_time_between_test_iterations:
                self.caller.droid.goToSleepNow()
                self.callee.droid.goToSleepNow()
                time.sleep(self.sleep_time_between_test_iterations)


        test_result = True
        for failure, count in fail_count.items():
            if count:
                self.log.error("%s: %s %s failures in %s iterations".format(
                    self.test_name, count, failure, self.phone_call_iteration))
                test_result = False
        return test_result
예제 #14
0
    def setup_and_connect(self, ap_settings):
        """Uses ap_settings to set up ap and then attempts to associate a DUT.

        Args:
            ap_settings: a dict containing test case settings, including
                bandwidth, security, n_capabilities, and ac_capabilities

        """
        security = ap_settings['security']
        chbw = ap_settings['chbw']
        password = None
        if security:
            password = security.password
        n_capabilities = ap_settings['n_capabilities']
        ac_capabilities = ap_settings['ac_capabilities']

        validate_setup_ap_and_associate(access_point=self.access_point,
                                        client=self.dut,
                                        profile_name='whirlwind',
                                        mode=hostapd_constants.MODE_11AC_MIXED,
                                        channel=36,
                                        n_capabilities=n_capabilities,
                                        ac_capabilities=ac_capabilities,
                                        force_wmm=True,
                                        ssid=utils.rand_ascii_str(20),
                                        security=security,
                                        vht_bandwidth=chbw,
                                        password=password)
예제 #15
0
 def _send_message(self, ads):
     selection = random.randrange(0, 2)
     message_type_map = {0: "SMS", 1: "MMS"}
     max_length_map = {0: self.max_sms_length, 1: self.max_mms_length}
     min_length_map = {0: self.min_sms_length, 1: self.min_mms_length}
     length = random.randrange(min_length_map[selection],
                               max_length_map[selection] + 1)
     text = rand_ascii_str(length)
     message_content_map = {0: [text], 1: [("Mms Message", text, None)]}
     message_func_map = {
         0: sms_send_receive_verify,
         1: mms_send_receive_verify
     }
     self.result_info["Total %s" % message_type_map[selection]] += 1
     if not message_func_map[selection](self.log, ads[0], ads[1],
                                        message_content_map[selection]):
         self.log.error("%s of length %s from %s to %s fails",
                        message_type_map[selection], length, ads[0].serial,
                        ads[1].serial)
         self.result_info["%s failure" % message_type_map[selection]] += 1
         return False
     else:
         self.log.info("%s of length %s from %s to %s succeed",
                       message_type_map[selection], length, ads[0].serial,
                       ads[1].serial)
         return True
예제 #16
0
 def _check_sms_mt(self):
     if not sms_send_receive_verify(self.log, self.ad_reference, self.dut,
                                    [rand_ascii_str(180)]):
         self.log.error("SMS receive test failed")
         return False
     else:
         self.log.info("SMS receive test passed")
         return True
예제 #17
0
    def setup_class(self):
        """ Setup devices for tethering and unpack params """

        self.hotspot_device = self.android_devices[0]
        self.tethered_devices = self.android_devices[1:]
        req_params = ("url", "open_network")
        self.unpack_userparams(req_params)
        self.network = {
            "SSID": "hotspot_%s" % utils.rand_ascii_str(6),
            "password": "******" % utils.rand_ascii_str(6)
        }
        self.new_ssid = "wifi_tethering_test2"
        self.tcpdump_pid = []

        nutils.verify_lte_data_and_tethering_supported(self.hotspot_device)
        for ad in self.tethered_devices:
            wutils.wifi_test_device_init(ad)
 def test_wrong_ssid_whirlwind_5g(self):
     self.connect_disconnect(
         {
             'profile': 'whirlwind',
             'channel': self.channel_5G,
             'security': None
         },
         ssid=rand_ascii_str(20),
         negative_test=True)
예제 #19
0
 def setup_class(self):
     super().setup_class()
     self.ssid = rand_ascii_str(10)
     self.wlan_device = create_wlan_device(self.fuchsia_devices[0])
     self.ap = self.access_points[0]
     self.num_of_iterations = int(
         self.user_params.get("beacon_loss_test_iterations",
                              self.num_of_iterations))
     self.in_use_interface = None
예제 #20
0
 def _check_mms_mt(self):
     message_array = [("Test Message", rand_ascii_str(180), None)]
     if not mms_send_receive_verify(self.log, self.ad_reference, self.dut,
                                    message_array):
         self.log.error("MMS receive test failed")
         return False
     else:
         self.log.info("MMS receive test passed")
         return True
 def test_soft_ap_2g_open_unrestricted(self):
     self.verify_soft_ap_associate_and_pass_traffic(
         self.primary_client, {
             'ssid': utils.rand_ascii_str(
                 hostapd_constants.AP_SSID_LENGTH_2G),
             'security_type': SECURITY_OPEN,
             'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED,
             'operating_band': OPERATING_BAND_2G
         })
예제 #22
0
    def test_stress_softAP_startup_and_stop_5g(self):
        """Test to bring up softAP and down for N times.

        Steps:
            1. Bring up softAP on 5G.
            2. Check for softAP on teh client device.
            3. Turn ON WiFi.
            4. Verify softAP is turned down and WiFi is up.

        """
        ap_ssid = "softap_" + utils.rand_ascii_str(8)
        ap_password = utils.rand_ascii_str(8)
        self.dut.log.info("softap setup: %s %s", ap_ssid, ap_password)
        config = {wutils.WifiEnums.SSID_KEY: ap_ssid}
        config[wutils.WifiEnums.PWD_KEY] = ap_password
        # Set country code explicitly to "US".
        wutils.set_wifi_country_code(self.dut, wutils.WifiEnums.CountryCode.US)
        wutils.set_wifi_country_code(self.dut_client,
                                     wutils.WifiEnums.CountryCode.US)
        for count in range(self.stress_count):
            initial_wifi_state = self.dut.droid.wifiCheckState()
            wutils.start_wifi_tethering(self.dut, ap_ssid, ap_password,
                                        WifiEnums.WIFI_CONFIG_APBAND_5G)
            wutils.start_wifi_connection_scan_and_ensure_network_found(
                self.dut_client, ap_ssid)
            wutils.stop_wifi_tethering(self.dut)
            asserts.assert_false(self.dut.droid.wifiIsApEnabled(),
                                 "SoftAp failed to shutdown!")
            # Give some time for WiFi to come back to previous state.
            time.sleep(2)
            cur_wifi_state = self.dut.droid.wifiCheckState()
            if initial_wifi_state != cur_wifi_state:
                raise signals.TestFailure(
                    "Wifi state was %d before softAP and %d now!" %
                    (initial_wifi_state, cur_wifi_state),
                    extras={
                        "Iterations": "%d" % self.stress_count,
                        "Pass": "******" % count
                    })
        raise signals.TestPass(details="",
                               extras={
                                   "Iterations": "%d" % self.stress_count,
                                   "Pass": "******" % (count + 1)
                               })
 def setup_class(self):
     super().setup_class()
     self.ssid = rand_ascii_str(10)
     self.fd = self.fuchsia_devices[0]
     self.dut = create_wlan_device(self.fd)
     self.ap = self.access_points[0]
     self.num_of_iterations = int(
         self.user_params.get("connection_stress_test_iterations",
                              self.num_of_iterations))
     self.log.info('iterations: %d' % self.num_of_iterations)
    def create_and_save_wifi_network_config(self):
        """ Create a config with random SSID and password.

            Returns:
            A tuple with the config and networkId for the newly created and saved network.
        """
        config_ssid = self.TEST_SSID_PREFIX + utils.rand_ascii_str(8)
        config_password = utils.rand_ascii_str(8)
        self.dut.log.info("creating config: %s %s", config_ssid,
                          config_password)
        config = {wutils.WifiEnums.SSID_KEY: config_ssid}
        config[wutils.WifiEnums.PWD_KEY] = config_password

        # Now save the config.
        network_id = self.dut.droid.wifiAddNetwork(config)
        self.dut.log.info("saved config: network_id = %s", network_id)
        return {
            self.NETWORK_ID_ELEMENT: network_id,
            self.CONFIG_ELEMENT: config
        }
예제 #25
0
    def _sms_test(self, ads):
        """Test SMS between two phones.

        Returns:
            True if success.
            False if failed.
        """

        sms_params = [(ads[0], ads[1])]
        message_arrays = [[rand_ascii_str(50)], [rand_ascii_str(160)],
                          [rand_ascii_str(180)]]

        for outer_param in sms_params:
            outer_param = (self.log, ) + outer_param
            for message_array in message_arrays:
                inner_param = outer_param + (message_array, )
                if not sms_send_receive_verify(*inner_param):
                    return False

        return True
 def message_test(self):
     failure = 0
     total_count = 0
     message_type_map = {0: "SMS", 1: "MMS"}
     max_length_map = {0: self.max_sms_length, 1: self.max_mms_length}
     min_length_map = {0: self.min_sms_length, 1: self.min_mms_length}
     message_func_map = {
         0: sms_send_receive_verify,
         1: mms_send_receive_verify
     }
     while time.time() < self.finishing_time:
         try:
             self.dut.log.info(dict(self.result_info))
             total_count += 1
             selection = random.randrange(0, 2)
             message_type = message_type_map[selection]
             self.result_info["Total %s" % message_type] += 1
             length = random.randrange(min_length_map[selection],
                                       max_length_map[selection] + 1)
             text = rand_ascii_str(length)
             message_content_map = {
                 0: [text],
                 1: [("Mms Message", text, None)]
             }
             if not message_func_map[selection](
                     self.log, self.dut, self.dut,
                     message_content_map[selection]):
                 self.log.error("%s of length %s from self to self fails",
                                message_type, length)
                 self.result_info["%s failure" % message_type] += 1
                 #self._take_bug_report("%s_messaging_failure" % self.test_name,
                 #                      time.strftime("%m-%d-%Y-%H-%M-%S"))
                 failure += 1
             else:
                 self.dut.log.info(
                     "%s of length %s from self to self succeed",
                     message_type, length)
             self.dut.droid.goToSleepNow()
             time.sleep(random.randrange(0, self.max_sleep_time))
         except IGNORE_EXCEPTIONS as e:
             self.log.error("Exception error %s", str(e))
             self.result_info["Exception Errors"] += 1
             if self.result_info["Exception Errors"] > EXCEPTION_TOLERANCE:
                 self.finishing_time = time.time()
                 raise
         except Exception as e:
             self.finishing_time = time.time()
             raise
         self.dut.log.info("Messaging test failure: %s/%s", failure,
                           total_count)
     if failure / total_count > 0.1:
         return "Messaging test failure: %s/%s" % (failure, total_count)
     else:
         return ""
    def test_mt_sms_multipart_gsm(self):
        """ Test MT SMS(more than 160 charcters) functionality on GSM

        Make Sure Phone is in GSM mode
        Send a SMS from Anritsu
        Verify Phone receives the SMS

        Returns:
            True if pass; False if fail
        """
        return self._setup_sms(set_system_model_gsm, RAT_GSM, self.phoneNumber,
                               rand_ascii_str(MULTI_PART_LEN),
                               DIRECTION_MOBILE_TERMINATED)
예제 #28
0
 def sms_receive_multiple(self, pri_dut, sec_dut):
     text_count = 10
     self.log.info(
         "Test sending {} sms messages to phone.".format(text_count))
     input("Press enter to execute this testcase...")
     for _ in range(text_count):
         msg = [rand_ascii_str(50)]
         if not sms_send_receive_verify(self.log, sec_dut, pri_dut, msg):
             return False
         else:
             self.log.info(
                 "Successfully sent sms. Please verify on carkit.")
     return True
    def test_mo_sms_singlepart_gsm(self):
        """ Test MO SMS(less than 160 charcters) functionality on GSM

        Make Sure Phone is in GSM mode
        Send a SMS from Phone
        Verify Anritsu receives the SMS

        Returns:
            True if pass; False if fail
        """
        return self._setup_sms(set_system_model_gsm, RAT_GSM, self.phoneNumber,
                               rand_ascii_str(SINGLE_PART_LEN),
                               DIRECTION_MOBILE_ORIGINATED)
예제 #30
0
    def setup_class(self):
        super().setup_class()

        self.ssid = rand_ascii_str(10)
        self.fd = self.fuchsia_devices[0]
        self.wlan_device = create_wlan_device(self.fd)
        self.ap = self.access_points[0]
        setup_ap_and_associate(access_point=self.ap,
                               client=self.wlan_device,
                               profile_name='whirlwind',
                               channel=hostapd_constants.AP_DEFAULT_CHANNEL_2G,
                               ssid=self.ssid,
                               setup_bridge=True)