1#!/usr/bin/env python3.4 2# 3# Copyright 2018 - 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 17import time 18from acts.test_decorators import test_tracker_info 19from acts.test_utils.power import PowerWiFiBaseTest as PWBT 20from acts.test_utils.wifi import wifi_power_test_utils as wputils 21 22TEMP_FILE = '/sdcard/Download/tmp.log' 23 24 25class PowerWiFitrafficTest(PWBT.PowerWiFiBaseTest): 26 def iperf_power_test_func(self): 27 """Test function for iperf power measurement at different RSSI level. 28 29 """ 30 # Decode the test configs from test name 31 attrs = [ 32 'screen_status', 'band', 'traffic_direction', 'traffic_type', 33 'signal_level', 'oper_mode', 'bandwidth' 34 ] 35 indices = [3, 4, 5, 6, 7, 9, 10] 36 self.decode_test_configs(attrs, indices) 37 38 # Set attenuator to desired level 39 self.log.info('Set attenuation to desired RSSI level') 40 atten_setting = self.test_configs.band + '_' + self.test_configs.signal_level 41 self.set_attenuation(self.atten_level[atten_setting]) 42 43 # Setup AP and connect dut to the network 44 self.setup_ap_connection( 45 network=self.main_network[self.test_configs.band], 46 bandwidth=int(self.test_configs.bandwidth)) 47 # Wait for DHCP on the ethernet port and get IP as Iperf server address 48 # Time out in 60 seconds if not getting DHCP address 49 self.iperf_server_address = wputils.wait_for_dhcp( 50 self.pkt_sender.interface) 51 52 time.sleep(5) 53 if self.test_configs.screen_status == 'OFF': 54 self.dut.droid.goToSleepNow() 55 self.RSSI = wputils.get_wifi_rssi(self.dut) 56 57 # Run IPERF 58 self.setup_iperf() 59 self.iperf_server.start() 60 wputils.run_iperf_client_nonblocking( 61 self.dut, self.iperf_server_address, self.iperf_args) 62 63 self.measure_power_and_validate() 64 65 def setup_iperf(self): 66 """Setup iperf command and arguments. 67 68 """ 69 # Construct the iperf command based on the test params 70 iperf_args = '-i 1 -t {} -p {} -J'.format(self.iperf_duration, 71 self.iperf_server.port) 72 if self.test_configs.traffic_type == "UDP": 73 iperf_args = iperf_args + "-u -b 2g" 74 if self.test_configs.traffic_direction == "DL": 75 iperf_args = iperf_args + ' -R' 76 self.use_client_output = True 77 else: 78 self.use_client_output = False 79 # Parse the client side data to a file saved on the phone 80 self.iperf_args = iperf_args + ' > %s' % TEMP_FILE 81 82 # Screen off TCP test cases 83 @test_tracker_info(uuid='93f79f74-88d9-4781-bff0-8899bed1c336') 84 def test_traffic_screen_OFF_2g_DL_TCP_high_RSSI_HT_20(self): 85 86 self.iperf_power_test_func() 87 88 @test_tracker_info(uuid='5982268b-57e4-40bf-848e-fee80fabf9d7') 89 def test_traffic_screen_OFF_2g_DL_TCP_low_RSSI_HT_20(self): 90 91 self.iperf_power_test_func() 92 93 @test_tracker_info(uuid='c71a8c77-d355-4a82-b9f1-7cc8b888abd8') 94 def test_traffic_screen_OFF_5g_DL_TCP_high_RSSI_VHT_20(self): 95 96 self.iperf_power_test_func() 97 98 @test_tracker_info(uuid='e9a900a1-e263-45ad-bdf3-9c463f761d3c') 99 def test_traffic_screen_OFF_5g_DL_TCP_low_RSSI_VHT_20(self): 100 101 self.iperf_power_test_func() 102 103 @test_tracker_info(uuid='1d1d9a06-98e1-486e-a1db-2102708161ec') 104 def test_traffic_screen_OFF_5g_DL_TCP_high_RSSI_VHT_40(self): 105 106 self.iperf_power_test_func() 107 108 @test_tracker_info(uuid='f378679a-1c20-43a1-bff6-a6a5482a8e3d') 109 def test_traffic_screen_OFF_5g_DL_TCP_low_RSSI_VHT_40(self): 110 111 self.iperf_power_test_func() 112 113 @test_tracker_info(uuid='6a05f133-49e5-4436-ba84-0746f04021ef') 114 def test_traffic_screen_OFF_5g_DL_TCP_high_RSSI_VHT_80(self): 115 116 self.iperf_power_test_func() 117 118 @test_tracker_info(uuid='1ea458af-1ae0-40ee-853d-ac57b51d3eda') 119 def test_traffic_screen_OFF_5g_DL_TCP_low_RSSI_VHT_80(self): 120 121 self.iperf_power_test_func() 122 123 @test_tracker_info(uuid='43d9b146-3547-4a27-9d79-c9341c32ccda') 124 def test_traffic_screen_OFF_2g_UL_TCP_high_RSSI_HT_20(self): 125 126 self.iperf_power_test_func() 127 128 @test_tracker_info(uuid='cd0c37ac-23fe-4dd1-9130-ccb2dfa71020') 129 def test_traffic_screen_OFF_2g_UL_TCP_low_RSSI_HT_20(self): 130 131 self.iperf_power_test_func() 132 133 @test_tracker_info(uuid='f9173d39-b46d-4d80-a5a5-7966f5eed9de') 134 def test_traffic_screen_OFF_5g_UL_TCP_high_RSSI_VHT_20(self): 135 136 self.iperf_power_test_func() 137 138 @test_tracker_info(uuid='48f91745-22dc-47c9-ace6-c2719df651d6') 139 def test_traffic_screen_OFF_5g_UL_TCP_low_RSSI_VHT_20(self): 140 141 self.iperf_power_test_func() 142 143 @test_tracker_info(uuid='18456aa7-62f0-4560-a7dc-4d7e01f6aca5') 144 def test_traffic_screen_OFF_5g_UL_TCP_high_RSSI_VHT_40(self): 145 146 self.iperf_power_test_func() 147 148 @test_tracker_info(uuid='3e29173f-b950-4a41-a7f6-6cc0731bf477') 149 def test_traffic_screen_OFF_5g_UL_TCP_low_RSSI_VHT_40(self): 150 151 self.iperf_power_test_func() 152 153 @test_tracker_info(uuid='3d4cdb21-a1b0-4011-9956-ca0b7a9f3bec') 154 def test_traffic_screen_OFF_5g_UL_TCP_high_RSSI_VHT_80(self): 155 156 self.iperf_power_test_func() 157 158 @test_tracker_info(uuid='5ac91734-0323-464b-b04a-c7d3d7ff8cdf') 159 def test_traffic_screen_OFF_5g_UL_TCP_low_RSSI_VHT_80(self): 160 161 self.iperf_power_test_func() 162 163 # Screen off UDP tests - only check 5g VHT 80 164 @test_tracker_info(uuid='1ab4a4e2-bce2-4ff8-be9d-f8ed2bb617cd') 165 def test_traffic_screen_OFF_5g_DL_UDP_high_RSSI_VHT_80(self): 166 167 self.iperf_power_test_func() 168 169 @test_tracker_info(uuid='68e6f92a-ae15-4e76-81e7-a7b491e181fe') 170 def test_traffic_screen_OFF_5g_DL_UDP_low_RSSI_VHT_80(self): 171 172 self.iperf_power_test_func() 173 174 @test_tracker_info(uuid='258500f4-f177-43df-82a7-a64d66e90720') 175 def test_traffic_screen_OFF_5g_UL_UDP_high_RSSI_VHT_80(self): 176 177 self.iperf_power_test_func() 178 179 @test_tracker_info(uuid='a17c7d0b-58ca-47b5-9f32-0b7a3d7d3d9d') 180 def test_traffic_screen_OFF_5g_UL_UDP_low_RSSI_VHT_80(self): 181 182 self.iperf_power_test_func() 183