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='147eff45-97d7-47c0-b306-f84d9adecd9b') 89 def test_traffic_screen_OFF_2g_DL_TCP_medium_RSSI_HT_20(self): 90 91 self.iperf_power_test_func() 92 93 @test_tracker_info(uuid='5982268b-57e4-40bf-848e-fee80fabf9d7') 94 def test_traffic_screen_OFF_2g_DL_TCP_low_RSSI_HT_20(self): 95 96 self.iperf_power_test_func() 97 98 @test_tracker_info(uuid='c71a8c77-d355-4a82-b9f1-7cc8b888abd8') 99 def test_traffic_screen_OFF_5g_DL_TCP_high_RSSI_VHT_20(self): 100 101 self.iperf_power_test_func() 102 103 @test_tracker_info(uuid='307945a6-32b7-42d0-a26c-d439f1599963') 104 def test_traffic_screen_OFF_5g_DL_TCP_medium_RSSI_VHT_20(self): 105 106 self.iperf_power_test_func() 107 108 @test_tracker_info(uuid='e9a900a1-e263-45ad-bdf3-9c463f761d3c') 109 def test_traffic_screen_OFF_5g_DL_TCP_low_RSSI_VHT_20(self): 110 111 self.iperf_power_test_func() 112 113 @test_tracker_info(uuid='1d1d9a06-98e1-486e-a1db-2102708161ec') 114 def test_traffic_screen_OFF_5g_DL_TCP_high_RSSI_VHT_40(self): 115 116 self.iperf_power_test_func() 117 118 @test_tracker_info(uuid='feeaad15-6893-4d49-aaf6-bf9802780f5d') 119 def test_traffic_screen_OFF_5g_DL_TCP_medium_RSSI_VHT_40(self): 120 121 self.iperf_power_test_func() 122 123 @test_tracker_info(uuid='f378679a-1c20-43a1-bff6-a6a5482a8e3d') 124 def test_traffic_screen_OFF_5g_DL_TCP_low_RSSI_VHT_40(self): 125 126 self.iperf_power_test_func() 127 128 @test_tracker_info(uuid='6a05f133-49e5-4436-ba84-0746f04021ef') 129 def test_traffic_screen_OFF_5g_DL_TCP_high_RSSI_VHT_80(self): 130 131 self.iperf_power_test_func() 132 133 @test_tracker_info(uuid='750bf1c3-2099-4b89-97dd-18f8e72df462') 134 def test_traffic_screen_OFF_5g_DL_TCP_medium_RSSI_VHT_80(self): 135 136 self.iperf_power_test_func() 137 138 @test_tracker_info(uuid='1ea458af-1ae0-40ee-853d-ac57b51d3eda') 139 def test_traffic_screen_OFF_5g_DL_TCP_low_RSSI_VHT_80(self): 140 141 self.iperf_power_test_func() 142 143 @test_tracker_info(uuid='43d9b146-3547-4a27-9d79-c9341c32ccda') 144 def test_traffic_screen_OFF_2g_UL_TCP_high_RSSI_HT_20(self): 145 146 self.iperf_power_test_func() 147 148 @test_tracker_info(uuid='f00a868b-c8b1-4b36-8136-b39b5c2396a7') 149 def test_traffic_screen_OFF_2g_UL_TCP_medium_RSSI_HT_20(self): 150 151 self.iperf_power_test_func() 152 153 @test_tracker_info(uuid='cd0c37ac-23fe-4dd1-9130-ccb2dfa71020') 154 def test_traffic_screen_OFF_2g_UL_TCP_low_RSSI_HT_20(self): 155 156 self.iperf_power_test_func() 157 158 @test_tracker_info(uuid='f9173d39-b46d-4d80-a5a5-7966f5eed9de') 159 def test_traffic_screen_OFF_5g_UL_TCP_high_RSSI_VHT_20(self): 160 161 self.iperf_power_test_func() 162 163 @test_tracker_info(uuid='cf77e1dc-30bc-4df9-88be-408f1fddc24f') 164 def test_traffic_screen_OFF_5g_UL_TCP_medium_RSSI_VHT_20(self): 165 166 self.iperf_power_test_func() 167 168 @test_tracker_info(uuid='48f91745-22dc-47c9-ace6-c2719df651d6') 169 def test_traffic_screen_OFF_5g_UL_TCP_low_RSSI_VHT_20(self): 170 171 self.iperf_power_test_func() 172 173 @test_tracker_info(uuid='18456aa7-62f0-4560-a7dc-4d7e01f6aca5') 174 def test_traffic_screen_OFF_5g_UL_TCP_high_RSSI_VHT_40(self): 175 176 self.iperf_power_test_func() 177 178 @test_tracker_info(uuid='8ad237d7-f5e1-45e1-a4a2-a010628a4db9') 179 def test_traffic_screen_OFF_5g_UL_TCP_medium_RSSI_VHT_40(self): 180 181 self.iperf_power_test_func() 182 183 @test_tracker_info(uuid='3e29173f-b950-4a41-a7f6-6cc0731bf477') 184 def test_traffic_screen_OFF_5g_UL_TCP_low_RSSI_VHT_40(self): 185 186 self.iperf_power_test_func() 187 188 @test_tracker_info(uuid='3d4cdb21-a1b0-4011-9956-ca0b7a9f3bec') 189 def test_traffic_screen_OFF_5g_UL_TCP_high_RSSI_VHT_80(self): 190 191 self.iperf_power_test_func() 192 193 @test_tracker_info(uuid='8427d3f0-9418-4b5c-aea9-7509e5959ce6') 194 def test_traffic_screen_OFF_5g_UL_TCP_medium_RSSI_VHT_80(self): 195 196 self.iperf_power_test_func() 197 198 @test_tracker_info(uuid='5ac91734-0323-464b-b04a-c7d3d7ff8cdf') 199 def test_traffic_screen_OFF_5g_UL_TCP_low_RSSI_VHT_80(self): 200 201 self.iperf_power_test_func() 202 203 # Screen off UDP tests - only check 5g VHT 80 204 @test_tracker_info(uuid='1ab4a4e2-bce2-4ff8-be9d-f8ed2bb617cd') 205 def test_traffic_screen_OFF_5g_DL_UDP_high_RSSI_VHT_80(self): 206 207 self.iperf_power_test_func() 208 209 @test_tracker_info(uuid='a2c66d63-e93f-42aa-a021-0c6cdfdc87b8') 210 def test_traffic_screen_OFF_5g_DL_UDP_medium_RSSI_VHT_80(self): 211 212 self.iperf_power_test_func() 213 214 @test_tracker_info(uuid='68e6f92a-ae15-4e76-81e7-a7b491e181fe') 215 def test_traffic_screen_OFF_5g_DL_UDP_low_RSSI_VHT_80(self): 216 217 self.iperf_power_test_func() 218 219 @test_tracker_info(uuid='258500f4-f177-43df-82a7-a64d66e90720') 220 def test_traffic_screen_OFF_5g_UL_UDP_high_RSSI_VHT_80(self): 221 222 self.iperf_power_test_func() 223 224 @test_tracker_info(uuid='3d2d3d45-575d-4080-86f9-b32a96963032') 225 def test_traffic_screen_OFF_5g_UL_UDP_medium_RSSI_VHT_80(self): 226 227 self.iperf_power_test_func() 228 229 @test_tracker_info(uuid='a17c7d0b-58ca-47b5-9f32-0b7a3d7d3d9d') 230 def test_traffic_screen_OFF_5g_UL_UDP_low_RSSI_VHT_80(self): 231 232 self.iperf_power_test_func() 233 234 # Screen on point check 235 @test_tracker_info(uuid='c1c71639-4463-4999-8f5d-7d9153402c79') 236 def test_traffic_screen_ON_2g_DL_TCP_high_RSSI_HT_20(self): 237 238 self.iperf_power_test_func() 239 240 @test_tracker_info(uuid='40daebc4-45a2-4299-b724-e8cb917b86e8') 241 def test_traffic_screen_ON_5g_DL_TCP_high_RSSI_VHT_80(self): 242 243 self.iperf_power_test_func() 244 245 @test_tracker_info(uuid='2e286f36-1a47-4895-a0e8-a161d6a9fd9f') 246 def test_traffic_screen_ON_2g_UL_TCP_high_RSSI_HT_20(self): 247 248 self.iperf_power_test_func() 249 250 @test_tracker_info(uuid='9f6b52cb-b48a-4382-8061-3d3a511a261a') 251 def test_traffic_screen_ON_5g_UL_TCP_high_RSSI_VHT_80(self): 252 253 self.iperf_power_test_func() 254 255 @test_tracker_info(uuid='59d79274-15cf-446b-a567-655c07f8a778') 256 def test_traffic_screen_ON_2g_DL_UDP_high_RSSI_HT_20(self): 257 258 self.iperf_power_test_func() 259 260 @test_tracker_info(uuid='02891671-48cc-4186-9a95-3e02671477d0') 261 def test_traffic_screen_ON_5g_DL_UDP_high_RSSI_VHT_80(self): 262 263 self.iperf_power_test_func() 264 265 @test_tracker_info(uuid='02821540-7b08-4e4f-a1f1-b455fd4cec6e') 266 def test_traffic_screen_ON_2g_UL_UDP_high_RSSI_HT_20(self): 267 268 self.iperf_power_test_func() 269 270 @test_tracker_info(uuid='59ea06ac-3ac8-4ecc-abb1-bcde34f47358') 271 def test_traffic_screen_ON_2g_UL_UDP_medium_RSSI_HT_20(self): 272 273 self.iperf_power_test_func() 274 275 @test_tracker_info(uuid='0cbbd849-7b59-4143-95e7-92cf1fd955dc') 276 def test_traffic_screen_ON_2g_UL_UDP_low_RSSI_HT_20(self): 277 278 self.iperf_power_test_func() 279 280 @test_tracker_info(uuid='d84f11d8-41a9-4ce8-a351-ebb0379d56c1') 281 def test_traffic_screen_ON_5g_UL_UDP_high_RSSI_VHT_80(self): 282 283 self.iperf_power_test_func() 284 285 @test_tracker_info(uuid='01b6087c-b39a-441d-90e9-da659aa0db7f') 286 def test_traffic_screen_ON_5g_UL_UDP_medium_RSSI_VHT_80(self): 287 288 self.iperf_power_test_func() 289 290 @test_tracker_info(uuid='7e16dcaa-128f-4874-ab52-2f43e25e6da8') 291 def test_traffic_screen_ON_5g_UL_UDP_low_RSSI_VHT_80(self): 292 293 self.iperf_power_test_func() 294