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.base_test import BaseTestClass 19from acts_contrib.test_utils.wifi.rtt import rtt_test_utils as rutils 20from acts_contrib.test_utils.wifi.rtt.RttBaseTest import RttBaseTest 21 22 23class StressRangeApTest(RttBaseTest): 24 """Test class for stress testing of RTT ranging to Access Points""" 25 26 ############################################################################# 27 28 def test_rtt_supporting_ap_only(self): 29 """Scan for APs and perform RTT only to those which support 802.11mc. 30 31 Stress test: repeat ranging to the same AP. Verify rate of success and 32 stability of results. 33 """ 34 dut = self.android_devices[0] 35 rtt_supporting_aps = rutils.scan_with_rtt_support_constraint( 36 dut, True, repeat=10) 37 dut.log.debug("RTT Supporting APs=%s", rtt_supporting_aps) 38 39 num_iter = self.stress_test_min_iteration_count 40 41 max_peers = dut.droid.wifiRttMaxPeersInRequest() 42 asserts.assert_true( 43 len(rtt_supporting_aps) > 0, 44 "Need at least one AP which supports 802.11mc!") 45 if len(rtt_supporting_aps) > max_peers: 46 rtt_supporting_aps = rtt_supporting_aps[0:max_peers] 47 48 events = rutils.run_ranging(dut, rtt_supporting_aps, num_iter, 0, 49 self.stress_test_target_run_time_sec) 50 stats = rutils.analyze_results( 51 events, 52 self.rtt_reference_distance_mm, 53 self.rtt_reference_distance_margin_mm, 54 self.rtt_min_expected_rssi_dbm, 55 self.lci_reference, 56 self.lcr_reference, 57 summary_only=True) 58 dut.log.debug("Stats=%s", stats) 59 60 for bssid, stat in stats.items(): 61 asserts.assert_true( 62 stat['num_no_results'] == 0, 63 "Missing (timed-out) results", 64 extras=stats) 65 asserts.assert_false( 66 stat['any_lci_mismatch'], "LCI mismatch", extras=stats) 67 asserts.assert_false( 68 stat['any_lcr_mismatch'], "LCR mismatch", extras=stats) 69 asserts.assert_equal( 70 stat['num_invalid_rssi'], 0, "Invalid RSSI", extras=stats) 71 asserts.assert_true( 72 stat['num_failures'] <= 73 self.rtt_max_failure_rate_two_sided_rtt_percentage * 74 stat['num_results'] / 100, 75 "Failure rate is too high", 76 extras=stats) 77 asserts.assert_true( 78 stat['num_range_out_of_margin'] <= 79 self.rtt_max_margin_exceeded_rate_two_sided_rtt_percentage * 80 stat['num_success_results'] / 100, 81 "Results exceeding error margin rate is too high", 82 extras=stats) 83 asserts.explicit_pass("RTT test done", extras=stats) 84