• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python3.4
2#
3#   Copyright 2017 - The Android Open Source Project
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
17from acts import asserts
18from acts_contrib.test_utils.wifi import wifi_test_utils as wutils
19from acts_contrib.test_utils.wifi.rtt import rtt_const as rconsts
20from acts_contrib.test_utils.wifi.rtt import rtt_test_utils as rutils
21from acts_contrib.test_utils.wifi.rtt.RttBaseTest import RttBaseTest
22
23
24class RangeApMiscTest(RttBaseTest):
25    """Test class for RTT ranging to Access Points - miscellaneous tests which
26  do not fit into the strict IEEE 802.11mc supporting or non-supporting test
27  beds - e.g. a mixed test."""
28
29    # Number of RTT iterations
30    NUM_ITER = 10
31
32    # Time gap (in seconds) between iterations
33    TIME_BETWEEN_ITERATIONS = 0
34
35    #############################################################################
36
37    def test_rtt_mixed_80211mc_supporting_aps_wo_privilege(self):
38        """Scan for APs and perform RTT on one supporting and one non-supporting
39    IEEE 802.11mc APs with the device not having privilege access (expect
40    failures)."""
41        dut = self.android_devices[0]
42        rutils.config_privilege_override(dut, True)
43        rtt_aps = rutils.scan_with_rtt_support_constraint(dut, True)
44        non_rtt_aps = rutils.scan_with_rtt_support_constraint(dut, False)
45        mix_list = [rtt_aps[0], non_rtt_aps[0]]
46        dut.log.debug("Visible non-IEEE 802.11mc APs=%s", mix_list)
47        events = rutils.run_ranging(dut, mix_list, self.NUM_ITER,
48                                    self.TIME_BETWEEN_ITERATIONS)
49        stats = rutils.analyze_results(events, self.rtt_reference_distance_mm,
50                                       self.rtt_reference_distance_margin_mm,
51                                       self.rtt_min_expected_rssi_dbm,
52                                       self.lci_reference, self.lcr_reference)
53        dut.log.debug("Stats=%s", stats)
54
55        for bssid, stat in stats.items():
56            asserts.assert_true(
57                stat['num_no_results'] == 0,
58                "Missing (timed-out) results",
59                extras=stats)
60            if bssid == rtt_aps[0][wutils.WifiEnums.BSSID_KEY]:
61                asserts.assert_false(
62                    stat['any_lci_mismatch'], "LCI mismatch", extras=stats)
63                asserts.assert_false(
64                    stat['any_lcr_mismatch'], "LCR mismatch", extras=stats)
65                asserts.assert_equal(
66                    stat['num_invalid_rssi'], 0, "Invalid RSSI", extras=stats)
67                asserts.assert_true(
68                    stat['num_failures'] <=
69                    self.rtt_max_failure_rate_two_sided_rtt_percentage *
70                    stat['num_results'] / 100,
71                    "Failure rate is too high",
72                    extras=stats)
73                asserts.assert_true(
74                    stat['num_range_out_of_margin'] <=
75                    self.rtt_max_margin_exceeded_rate_two_sided_rtt_percentage
76                    * stat['num_success_results'] / 100,
77                    "Results exceeding error margin rate is too high",
78                    extras=stats)
79            else:
80                asserts.assert_true(
81                    stat['num_failures'] == self.NUM_ITER,
82                    "All one-sided RTT requests must fail when executed without privilege",
83                    extras=stats)
84                for code in stat['status_codes']:
85                    asserts.assert_true(
86                        code == rconsts.
87                        EVENT_CB_RANGING_STATUS_RESPONDER_DOES_NOT_SUPPORT_IEEE80211MC,
88                        "Expected non-support error code",
89                        extras=stats)
90        asserts.explicit_pass("RTT test done", extras=stats)
91