1#!/usr/bin/python3 2# 3# Copyright 2019 The Chromium OS Authors. All rights reserved. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7from __future__ import absolute_import 8from __future__ import division 9from __future__ import print_function 10 11from six.moves import zip 12import unittest 13 14import common 15 16from autotest_lib.client.common_lib.cros.network import iw_runner 17 18class IwRunnerTest(unittest.TestCase): 19 """Unit test for the IWRunner object.""" 20 21 22 class host_cmd(object): 23 """Mock host command class.""" 24 25 def __init__(self, stdout, stderr, exit_status): 26 self._stdout = stdout 27 self._stderr = stderr 28 self._exit_status = exit_status 29 30 31 @property 32 def stdout(self): 33 """Returns stdout.""" 34 return self._stdout 35 36 37 @property 38 def stderr(self): 39 """Returns stderr.""" 40 return self._stderr 41 42 43 @property 44 def exit_status(self): 45 """Returns the exit status.""" 46 return self._exit_status 47 48 49 class host(object): 50 """Mock host class.""" 51 52 def __init__(self, host_cmd): 53 self._host_cmd = IwRunnerTest.host_cmd(host_cmd, 1.0, 0) 54 55 56 def run(self, cmd, ignore_status=False): 57 """Returns the mocked output. 58 59 @param cmd: a stub input ignore 60 @param ignore_status: a stub input ignore 61 62 """ 63 return self._host_cmd 64 65 66 HT20 = str('BSS aa:aa:aa:aa:aa:aa (on wlan0)\n' 67 ' freq: 2412\n' 68 ' signal: -50.00 dBm\n' 69 ' SSID: support_ht20\n' 70 ' HT operation:\n' 71 ' * secondary channel offset: no secondary\n') 72 73 HT20_IW_BSS = iw_runner.IwBss('aa:aa:aa:aa:aa:aa', 2412, 74 'support_ht20', iw_runner.SECURITY_OPEN, 75 iw_runner.WIDTH_HT20, -50.00) 76 77 HT20_2 = str('BSS 11:11:11:11:11:11 (on wlan0)\n' 78 ' freq: 2462\n' 79 ' signal: -42.00 dBm\n' 80 ' SSID: support_ht20\n' 81 ' WPA: * Version: 1\n' 82 ' HT operation:\n' 83 ' * secondary channel offset: below\n') 84 85 HT20_2_IW_BSS = iw_runner.IwBss('11:11:11:11:11:11', 2462, 86 'support_ht20', iw_runner.SECURITY_WPA, 87 iw_runner.WIDTH_HT40_MINUS, -42.00) 88 89 HT40_ABOVE = str('BSS bb:bb:bb:bb:bb:bb (on wlan0)\n' 90 ' freq: 5180\n' 91 ' signal: -55.00 dBm\n' 92 ' SSID: support_ht40_above\n' 93 ' RSN: * Version: 1\n' 94 ' HT operation:\n' 95 ' * secondary channel offset: above\n') 96 97 HT40_ABOVE_IW_BSS = iw_runner.IwBss('bb:bb:bb:bb:bb:bb', 5180, 98 'support_ht40_above', 99 iw_runner.SECURITY_WPA2, 100 iw_runner.WIDTH_HT40_PLUS, -55.00) 101 102 HT40_BELOW = str('BSS cc:cc:cc:cc:cc:cc (on wlan0)\n' 103 ' freq: 2462\n' 104 ' signal: -44.00 dBm\n' 105 ' SSID: support_ht40_below\n' 106 ' RSN: * Version: 1\n' 107 ' WPA: * Version: 1\n' 108 ' HT operation:\n' 109 ' * secondary channel offset: below\n') 110 111 HT40_BELOW_IW_BSS = iw_runner.IwBss('cc:cc:cc:cc:cc:cc', 2462, 112 'support_ht40_below', 113 iw_runner.SECURITY_MIXED, 114 iw_runner.WIDTH_HT40_MINUS, -44.00) 115 116 NO_HT = str('BSS dd:dd:dd:dd:dd:dd (on wlan0)\n' 117 ' freq: 2412\n' 118 ' signal: -45.00 dBm\n' 119 ' SSID: no_ht_support\n') 120 121 NO_HT_IW_BSS = iw_runner.IwBss('dd:dd:dd:dd:dd:dd', 2412, 122 'no_ht_support', iw_runner.SECURITY_OPEN, 123 None, -45.00) 124 125 VHT_CAPA_20 = str('BSS ff:ff:ff:ff:ff:ff (on wlan0)\n' 126 ' freq: 2462\n' 127 ' signal: -44.00 dBm\n' 128 ' SSID: vht_capable_20\n' 129 ' HT operation:\n' 130 ' * secondary channel offset: no secondary\n' 131 ' VHT capabilities:\n' 132 ' VHT Capabilities (0x0f8369b1):\n' 133 ' Max MPDU length: 7991\n' 134 ' Supported Channel Width: neither 160 nor 80+80\n' 135 ' VHT operation:\n' 136 ' * channel width: 0 (20 or 40 MHz)\n' 137 ' * center freq segment 1: 11\n') 138 139 VHT_CAPA_20_IW_BSS = iw_runner.IwBss('ff:ff:ff:ff:ff:ff', 2462, 140 'vht_capable_20', 141 iw_runner.SECURITY_OPEN, 142 iw_runner.WIDTH_HT20, -44.00) 143 144 VHT80 = str('BSS ff:ff:ff:ff:ff:ff (on wlan0)\n' 145 ' freq: 2462\n' 146 ' signal: -44.00 dBm\n' 147 ' SSID: support_vht80\n' 148 ' HT operation:\n' 149 ' * secondary channel offset: below\n' 150 ' VHT capabilities:\n' 151 ' VHT Capabilities (0x0f8369b1):\n' 152 ' Max MPDU length: 7991\n' 153 ' Supported Channel Width: neither 160 nor 80+80\n' 154 ' VHT operation:\n' 155 ' * channel width: 1 (80 MHz)\n' 156 ' * center freq segment 1: 11\n' 157 ' * center freq segment 2: 0\n') 158 159 VHT80_IW_BSS = iw_runner.IwBss('ff:ff:ff:ff:ff:ff', 2462, 160 'support_vht80', iw_runner.SECURITY_OPEN, 161 iw_runner.WIDTH_VHT80, -44.00) 162 163 VHT160 = str('BSS 12:34:56:78:90:aa (on wlan0)\n' 164 ' freq: 5180\n' 165 ' signal: -44.00 dBm\n' 166 ' SSID: support_vht160\n' 167 ' HT operation:\n' 168 ' * secondary channel offset: below\n' 169 ' VHT capabilities:\n' 170 ' VHT Capabilities (0x0f8369b1):\n' 171 ' Max MPDU length: 7991\n' 172 ' Supported Channel Width: 160 MHz\n' 173 ' VHT operation:\n' 174 ' * channel width: 1 (80 MHz)\n' 175 ' * center freq segment 1: 42\n' 176 ' * center freq segment 2: 50\n') 177 178 VHT160_IW_BSS = iw_runner.IwBss('12:34:56:78:90:aa', 5180, 179 'support_vht160', iw_runner.SECURITY_OPEN, 180 iw_runner.WIDTH_VHT160, -44.00) 181 182 VHT80_80 = str('BSS ab:cd:ef:fe:dc:ba (on wlan0)\n' 183 ' freq: 5180\n' 184 ' signal: -44.00 dBm\n' 185 ' SSID: support_vht80_80\n' 186 ' HT operation:\n' 187 ' * secondary channel offset: below\n' 188 ' VHT operation:\n' 189 ' * channel width: 1 (80 MHz)\n' 190 ' * center freq segment 1: 42\n' 191 ' * center freq segment 2: 106\n') 192 193 VHT80_80_IW_BSS = iw_runner.IwBss('ab:cd:ef:fe:dc:ba', 5180, 194 'support_vht80_80', iw_runner.SECURITY_OPEN, 195 iw_runner.WIDTH_VHT80_80, -44.00) 196 197 HIDDEN_SSID = str('BSS ee:ee:ee:ee:ee:ee (on wlan0)\n' 198 ' freq: 2462\n' 199 ' signal: -70.00 dBm\n' 200 ' SSID: \n' 201 ' HT operation:\n' 202 ' * secondary channel offset: no secondary\n') 203 204 SCAN_TIME_OUTPUT = str('real 4.5\n' 205 'user 2.1\n' 206 'system 3.1\n') 207 208 HIDDEN_SSID_IW_BSS = iw_runner.IwBss('ee:ee:ee:ee:ee:ee', 2462, 209 None, iw_runner.SECURITY_OPEN, 210 iw_runner.WIDTH_HT20, -70.00) 211 212 STATION_LINK_INFORMATION = str( 213 'Connected to 12:34:56:ab:cd:ef (on wlan0)\n' 214 ' SSID: PMKSACaching_4m9p5_ch1\n' 215 ' freq: 5220\n' 216 ' RX: 5370 bytes (37 packets)\n' 217 ' TX: 3604 bytes (15 packets)\n' 218 ' signal: -59 dBm\n' 219 ' tx bitrate: 13.0 MBit/s MCS 1\n' 220 '\n' 221 ' bss flags: short-slot-time\n' 222 ' dtim period: 5\n' 223 ' beacon int: 100\n') 224 225 STATION_LINK_BSSID = '12:34:56:ab:cd:ef' 226 227 STATION_LINK_IFACE = 'wlan0' 228 229 STATION_LINK_FREQ = '5220' 230 231 STATION_LINK_PARSED = { 232 'SSID': 'PMKSACaching_4m9p5_ch1', 233 'freq': '5220', 234 'RX': '5370 bytes (37 packets)', 235 'TX': '3604 bytes (15 packets)', 236 'signal': '-59 dBm', 237 'tx bitrate': '13.0 MBit/s MCS 1', 238 'bss flags': 'short-slot-time', 239 'dtim period': '5', 240 'beacon int': '100' 241 } 242 243 STATION_DUMP_INFORMATION = str( 244 'Station dd:ee:ff:33:44:55 (on mesh-5000mhz)\n' 245 ' inactive time: 140 ms\n' 246 ' rx bytes: 2883498\n' 247 ' rx packets: 31981\n' 248 ' tx bytes: 1369934\n' 249 ' tx packets: 6615\n' 250 ' tx retries: 4\n' 251 ' tx failed: 0\n' 252 ' rx drop misc: 5\n' 253 ' signal: -4 dBm\n' 254 ' signal avg: -11 dBm\n' 255 ' Toffset: 81715566854 us\n' 256 ' tx bitrate: 866.7 MBit/s VHT-MCS 9 80MHz ' 257 'short GI VHT-NSS 2\n' 258 ' rx bitrate: 866.7 MBit/s VHT-MCS 9 80MHz ' 259 'short GI VHT-NSS 2\n' 260 ' mesh llid: 0\n' 261 ' mesh plid: 0\n' 262 ' mesh plink: ESTAB\n' 263 ' mesh local PS mode: ACTIVE\n' 264 ' mesh peer PS mode: ACTIVE\n' 265 ' mesh non-peer PS mode: ACTIVE\n' 266 ' authorized: yes\n' 267 ' authenticated: yes\n' 268 ' preamble: long\n' 269 ' WMM/WME: yes\n' 270 ' MFP: yes\n' 271 ' TDLS peer: no\n' 272 ' connected time: 8726 seconds\n' 273 'Station aa:bb:cc:00:11:22 (on mesh-5000mhz)\n' 274 ' inactive time: 140 ms\n' 275 ' rx bytes: 2845200\n' 276 ' rx packets: 31938\n' 277 ' tx bytes: 1309945\n' 278 ' tx packets: 6672\n' 279 ' tx retries: 0\n' 280 ' tx failed: 1\n' 281 ' signal: -21 dBm\n' 282 ' signal avg: -21 dBm\n' 283 ' tx bitrate: 866.7 MBit/s VHT-MCS 9 80MHz ' 284 'short GI VHT-NSS 2\n' 285 ' rx bitrate: 650.0 MBit/s VHT-MCS 7 80MHz ' 286 'short GI VHT-NSS 2\n' 287 ' mesh llid: 0\n' 288 ' mesh plid: 0\n' 289 ' mesh plink: ESTAB\n' 290 ' mesh local PS mode: ACTIVE\n' 291 ' mesh peer PS mode: ACTIVE\n' 292 ' mesh non-peer PS mode: ACTIVE\n' 293 ' authorized: yes\n' 294 ' authenticated: yes\n' 295 ' preamble: long\n' 296 ' WMM/WME: yes\n' 297 ' MFP: yes\n' 298 ' TDLS peer: no\n' 299 ' connected time: 8724 seconds\n' 300 'Station ff:aa:bb:aa:44:55 (on mesh-5000mhz)\n' 301 ' inactive time: 304 ms\n' 302 ' rx bytes: 18816\n' 303 ' rx packets: 75\n' 304 ' tx bytes: 5386\n' 305 ' tx packets: 21\n' 306 ' signal: -29 dBm\n' 307 ' tx bitrate: 65.0 MBit/s VHT-MCS 0 80MHz short GI VHT-NSS 2\n' 308 ' mesh llid: 0\n' 309 ' mesh plid: 0\n' 310 ' mesh plink: ESTAB\n' 311 ' mesh local PS mode: ACTIVE\n' 312 ' mesh peer PS mode: ACTIVE\n' 313 ' mesh non-peer PS mode: ACTIVE\n' 314 ' authorized: yes\n' 315 ' authenticated: yes\n' 316 ' preamble: long\n' 317 ' WMM/WME: yes\n' 318 ' MFP: yes\n' 319 ' TDLS peer: no\n' 320 ' connected time: 824 seconds\n') 321 322 STATION_DUMP_INFORMATION_PARSED = [ 323 {'mac': 'aa:bb:cc:00:11:22', 324 'rssi_str': '-21 dBm', 325 'rssi_int': -21, 326 'rx_bitrate': '650.0 MBit/s VHT-MCS 7 80MHz short GI VHT-NSS 2', 327 'rx_drops': 0, 328 'rx_drop_rate': 0.0, 329 'rx_packets': 31938, 330 'tx_bitrate': '866.7 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 2', 331 'tx_failures': 1, 332 'tx_failure_rate': 0.00014988009592326138, 333 'tx_packets': 6672, 334 'tx_retries': 0, 335 'tx_retry_rate': 0.0}, 336 {'mac': 'dd:ee:ff:33:44:55', 337 'rssi_str': '-4 dBm', 338 'rssi_int': -4, 339 'rx_bitrate': '866.7 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 2', 340 'rx_drops': 5, 341 'rx_drop_rate': 0.0001563428285544542, 342 'rx_packets': 31981, 343 'tx_bitrate': '866.7 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 2', 344 'tx_failures': 0, 345 'tx_failure_rate': 0.0, 346 'tx_packets': 6615, 347 'tx_retries': 4, 348 'tx_retry_rate': 0.0006046863189720333}, 349 {'mac': 'ff:aa:bb:aa:44:55', 350 'rssi_str': '-29 dBm', 351 'rssi_int': -29, 352 'rx_bitrate': '0', 353 'rx_drops': 0, 354 'rx_drop_rate': 0.0, 355 'rx_packets': 75, 356 'tx_bitrate': '65.0 MBit/s VHT-MCS 0 80MHz short GI VHT-NSS 2', 357 'tx_failures': 0, 358 'tx_failure_rate': 0.0, 359 'tx_retries': 0, 360 'tx_retry_rate': 0.0, 361 'tx_packets': 21}, 362 ] 363 364 STATION_DUMP_IFACE = 'mesh-5000mhz' 365 366 INFO_MESH_MODE = str( 367 'Interface wlan-2400mhz\n' 368 ' ifindex 10\n' 369 ' wdev 0x100000002\n' 370 ' addr aa:bb:cc:dd:ee:ff\n' 371 ' type mesh point\n' 372 ' wiphy 1\n' 373 ' channel 149 (5745 MHz), width: 80 MHz, center1: 5775 MHz\n') 374 375 INFO_AP_MODE = str( 376 'Interface wlan-2400mhz\n' 377 ' ifindex 8\n' 378 ' wdev 0x1\n' 379 ' addr 00:11:22:33:44:55\n' 380 ' ssid testap_170501151530_wsvx\n' 381 ' type AP\n' 382 ' wiphy 0\n' 383 ' channel 11 (2462 MHz), width: 20 MHz, center1: 2462 MHz\n') 384 385 RADIO_CONFIG_AP_MODE = {'number': 11, 'freq': 2462, 'width': 20, 386 'center1_freq': 2462} 387 388 INFO_STA_MODE = str( 389 'Interface wlan-2400mhz\n' 390 ' ifindex 9\n' 391 ' wdev 0x1\n' 392 ' addr 44:55:66:77:88:99\n' 393 ' type managed\n' 394 ' wiphy 0\n' 395 ' channel 11 (2462 MHz), width: 20 MHz, center1: 2462 MHz\n') 396 397 INFO_IFACE = 'wlan-2400mhz' 398 399 PHY_INFO_FRAGMENTATION = str( 400 'Wiphy phy1\n' 401 ' max # scan SSIDs: 20\n' 402 ' max scan IEs length: 425 bytes\n' 403 ' Fragmentation threshold: 256\n' 404 ' Retry short limit: 7\n' 405 ' Retry long limit: 4\n') 406 407 INFO_PHY = 'phy1' 408 409 PHY_FRAGMENTATION_THRESHOLD = 256 410 411 VHT_IW_INFO = str( 412 'Wiphy phy0\n' 413 ' max # scan SSIDs: 20\n' 414 ' max scan IEs length: 425 bytes\n' 415 ' max # sched scan SSIDs: 20\n' 416 ' max # match sets: 11\n' 417 ' Retry short limit: 7\n' 418 ' Retry long limit: 4\n' 419 ' Coverage class: 0 (up to 0m)\n' 420 ' Device supports RSN-IBSS.\n' 421 ' Device supports AP-side u-APSD.\n' 422 ' Device supports T-DLS.\n' 423 ' Supported Ciphers:\n' 424 ' * WEP40 (00-0f-ac:1)\n' 425 ' * WEP104 (00-0f-ac:5)\n' 426 ' * TKIP (00-0f-ac:2)\n' 427 ' * CCMP-128 (00-0f-ac:4)\n' 428 ' * CMAC (00-0f-ac:6)\n' 429 ' Available Antennas: TX 0 RX 0\n' 430 ' Supported interface modes:\n' 431 ' * IBSS\n' 432 ' * managed\n' 433 ' * AP\n' 434 ' * AP/VLAN\n' 435 ' * monitor\n' 436 ' * P2P-client\n' 437 ' * P2P-GO\n' 438 ' * P2P-device\n' 439 ' Band 1:\n' 440 ' Capabilities: 0x11ef\n' 441 ' RX LDPC\n' 442 ' HT20/HT40\n' 443 ' SM Power Save disabled\n' 444 ' RX HT20 SGI\n' 445 ' RX HT40 SGI\n' 446 ' TX STBC\n' 447 ' RX STBC 1-stream\n' 448 ' Max AMSDU length: 3839 bytes\n' 449 ' DSSS/CCK HT40\n' 450 ' Maximum RX AMPDU length 65535 bytes (exponent: 0x003)\n' 451 ' Minimum RX AMPDU time spacing: 4 usec (0x05)\n' 452 ' HT Max RX data rate: 300 Mbps\n' 453 ' HT TX/RX MCS rate indexes supported: 0-15\n' 454 ' Band 2:\n' 455 ' Capabilities: 0x11ef\n' 456 ' RX LDPC\n' 457 ' HT20/HT40\n' 458 ' SM Power Save disabled\n' 459 ' RX HT20 SGI\n' 460 ' RX HT40 SGI\n' 461 ' TX STBC\n' 462 ' RX STBC 1-stream\n' 463 ' Max AMSDU length: 3839 bytes\n' 464 ' DSSS/CCK HT40\n' 465 ' Maximum RX AMPDU length 65535 bytes (exponent: 0x003)\n' 466 ' Minimum RX AMPDU time spacing: 4 usec (0x05)\n' 467 ' HT Max RX data rate: 300 Mbps\n' 468 ' HT TX/RX MCS rate indexes supported: 0-15\n' 469 ' VHT Capabilities (0x038071b0):\n' 470 ' Max MPDU length: 3895\n' 471 ' Supported Channel Width: neither 160 nor 80+80\n' 472 ' RX LDPC\n' 473 ' short GI (80 MHz)\n' 474 ' TX STBC\n' 475 ' SU Beamformee\n') 476 477 HE_IW_INFO = str( 478 'Wiphy phy0\n' 479 ' max # scan SSIDs: 20\n' 480 ' max scan IEs length: 365 bytes\n' 481 ' max # sched scan SSIDs: 20\n' 482 ' max # match sets: 11\n' 483 ' max # scan plans: 2\n' 484 ' max scan plan interval: 65535\n' 485 ' max scan plan iterations: 254\n' 486 ' Retry short limit: 7\n' 487 ' Retry long limit: 4\n' 488 ' Coverage class: 0 (up to 0m)\n' 489 ' Device supports RSN-IBSS.\n' 490 ' Device supports AP-side u-APSD.\n' 491 ' Device supports T-DLS.\n' 492 ' Supported Ciphers:\n' 493 ' * WEP40 (00-0f-ac:1)\n' 494 ' * WEP104 (00-0f-ac:5)\n' 495 ' * TKIP (00-0f-ac:2)\n' 496 ' * CCMP-128 (00-0f-ac:4)\n' 497 ' * GCMP-128 (00-0f-ac:8)\n' 498 ' * GCMP-256 (00-0f-ac:9)\n' 499 ' * CMAC (00-0f-ac:6)\n' 500 ' * GMAC-128 (00-0f-ac:11)\n' 501 ' * GMAC-256 (00-0f-ac:12)\n' 502 ' Available Antennas: TX 0 RX 0\n' 503 ' Supported interface modes:\n' 504 ' * IBSS\n' 505 ' * managed\n' 506 ' * AP\n' 507 ' * AP/VLAN\n' 508 ' * monitor\n' 509 ' * P2P-client\n' 510 ' * P2P-GO\n' 511 ' * P2P-device\n' 512 ' Band 1:\n' 513 ' Capabilities: 0x19ef\n' 514 ' RX LDPC\n' 515 ' HT20/HT40\n' 516 ' SM Power Save disabled\n' 517 ' RX HT20 SGI\n' 518 ' RX HT40 SGI\n' 519 ' TX STBC\n' 520 ' RX STBC 1-stream\n' 521 ' Max AMSDU length: 7935 bytes\n' 522 ' DSSS/CCK HT40\n' 523 ' Maximum RX AMPDU length 65535 bytes (exponent: 0x003)\n' 524 ' Minimum RX AMPDU time spacing: 4 usec (0x05)\n' 525 ' HT Max RX data rate: 300 Mbps\n' 526 ' HT TX/RX MCS rate indexes supported: 0-15\n' 527 ' HE Iftypes: Station\n' 528 ' HE MAC Capabilities (0x780112a0abc0):\n' 529 ' +HTC HE Supported\n' 530 ' HE PHY Capabilities: (0x0e3f0200fd09800ecff200):\n' 531 ' HE40/2.4GHz\n' 532 ' HE40/HE80/5GHz\n' 533 ' HE160/5GHz\n' 534 ' Band 2:\n' 535 ' Capabilities: 0x19ef\n' 536 ' RX LDPC\n' 537 ' HT20/HT40\n' 538 ' SM Power Save disabled\n' 539 ' RX HT20 SGI\n' 540 ' RX HT40 SGI\n' 541 ' TX STBC\n' 542 ' RX STBC 1-stream\n' 543 ' Max AMSDU length: 7935 bytes\n' 544 ' DSSS/CCK HT40\n' 545 ' Maximum RX AMPDU length 65535 bytes (exponent: 0x003)\n' 546 ' Minimum RX AMPDU time spacing: 4 usec (0x05)\n' 547 ' HT Max RX data rate: 300 Mbps\n' 548 ' HT TX/RX MCS rate indexes supported: 0-15\n' 549 ' VHT Capabilities (0x039071f6):\n' 550 ' Max MPDU length: 11454\n' 551 ' Supported Channel Width: 160 MHz\n' 552 ' RX LDPC\n' 553 ' short GI (80 MHz)\n' 554 ' short GI (160/80+80 MHz)\n' 555 ' TX STBC\n' 556 ' SU Beamformee\n' 557 ' MU Beamformee\n' 558 ' VHT RX MCS set:\n' 559 ' 1 streams: MCS 0-9\n' 560 ' 2 streams: MCS 0-9\n' 561 ' 3 streams: not supported\n' 562 ' 4 streams: not supported\n' 563 ' 5 streams: not supported\n' 564 ' 6 streams: not supported\n' 565 ' 7 streams: not supported\n' 566 ' 8 streams: not supported\n' 567 ' VHT RX highest supported: 0 Mbps\n' 568 ' VHT TX MCS set:\n' 569 ' 1 streams: MCS 0-9\n' 570 ' 2 streams: MCS 0-9\n' 571 ' 3 streams: not supported\n' 572 ' 4 streams: not supported\n' 573 ' 5 streams: not supported\n' 574 ' 6 streams: not supported\n' 575 ' 7 streams: not supported\n' 576 ' 8 streams: not supported\n' 577 ' VHT TX highest supported: 0 Mbps\n' 578 ' HE Iftypes: Station\n' 579 ' HE MAC Capabilities (0x780112a0abc0):\n' 580 ' +HTC HE Supported\n' 581 ' HE PHY Capabilities: (0x0e3f0200fd09800ecff200):\n' 582 ' HE40/2.4GHz\n' 583 ' HE40/HE80/5GHz\n' 584 ' HE160/5GHz\n') 585 586 587 def verify_values(self, iw_bss_1, iw_bss_2): 588 """Checks all of the IWBss values 589 590 @param iw_bss_1: an IWBss object 591 @param iw_bss_2: an IWBss object 592 593 """ 594 595 self.assertEquals(iw_bss_1.bss, iw_bss_2.bss) 596 self.assertEquals(iw_bss_1.ssid, iw_bss_2.ssid) 597 self.assertEquals(iw_bss_1.frequency, iw_bss_2.frequency) 598 self.assertEquals(iw_bss_1.security, iw_bss_2.security) 599 self.assertEquals(iw_bss_1.width, iw_bss_2.width) 600 self.assertEquals(iw_bss_1.signal, iw_bss_2.signal) 601 602 603 def search_by_bss(self, scan_output, test_iw_bss): 604 """ 605 606 @param scan_output: the output of the scan as a string 607 @param test_iw_bss: an IWBss object 608 609 Uses the runner to search for a network by bss. 610 """ 611 host = self.host(scan_output + self.SCAN_TIME_OUTPUT) 612 runner = iw_runner.IwRunner(remote_host=host) 613 network = runner.wait_for_scan_result('wlan0', bsses=[test_iw_bss.bss]) 614 self.verify_values(test_iw_bss, network[0]) 615 616 617 def test_find_first(self): 618 """Test with the first item in the list.""" 619 scan_output = self.HT20 + self.HT40_ABOVE 620 self.search_by_bss(scan_output, self.HT20_IW_BSS) 621 622 623 def test_find_last(self): 624 """Test with the last item in the list.""" 625 scan_output = self.HT40_ABOVE + self.HT20 626 self.search_by_bss(scan_output, self.HT20_IW_BSS) 627 628 629 def test_find_middle(self): 630 """Test with the middle item in the list.""" 631 scan_output = self.HT40_ABOVE + self.HT20 + self.NO_HT 632 self.search_by_bss(scan_output, self.HT20_IW_BSS) 633 634 635 def test_ht40_above(self): 636 """Test with a HT40+ network.""" 637 scan_output = self.HT20 + self.HT40_ABOVE + self.NO_HT 638 self.search_by_bss(scan_output, self.HT40_ABOVE_IW_BSS) 639 640 641 def test_ht40_below(self): 642 """Test with a HT40- network.""" 643 scan_output = self.HT20 + self.HT40_BELOW + self.NO_HT 644 self.search_by_bss(scan_output, self.HT40_BELOW_IW_BSS) 645 646 647 def test_no_ht(self): 648 """Test with a network that doesn't have ht.""" 649 scan_output = self.HT20 + self.NO_HT + self.HT40_ABOVE 650 self.search_by_bss(scan_output, self.NO_HT_IW_BSS) 651 652 653 def test_vht_20(self): 654 """Test with a network that supports vht but is 20 MHz wide.""" 655 scan_output = self.HT20 + self.NO_HT + self.VHT_CAPA_20 656 self.search_by_bss(scan_output, self.VHT_CAPA_20_IW_BSS) 657 658 659 def test_vht80(self): 660 """Test with a VHT80 network.""" 661 scan_output = self.HT20 + self.VHT80 + self.HT40_ABOVE 662 self.search_by_bss(scan_output, self.VHT80_IW_BSS) 663 664 665 def test_vht160(self): 666 """Test with a VHT160 network.""" 667 scan_output = self.VHT160 + self.VHT80 + self.HT40_ABOVE 668 self.search_by_bss(scan_output, self.VHT160_IW_BSS) 669 670 def test_vht80_80(self): 671 """Test with a VHT80+80 network.""" 672 scan_output = self.VHT160 + self.VHT80_80 673 self.search_by_bss(scan_output, self.VHT80_80_IW_BSS) 674 675 676 def test_hidden_ssid(self): 677 """Test with a network with a hidden ssid.""" 678 scan_output = self.HT20 + self.HIDDEN_SSID + self.NO_HT 679 self.search_by_bss(scan_output, self.HIDDEN_SSID_IW_BSS) 680 681 682 def test_multiple_ssids(self): 683 """Test with multiple networks with the same ssids.""" 684 scan_output = self.HT40_ABOVE + self.HT20 + self.NO_HT + self.HT20_2 685 host = self.host(scan_output + self.SCAN_TIME_OUTPUT) 686 runner = iw_runner.IwRunner(remote_host=host) 687 networks = runner.wait_for_scan_result('wlan 0', 688 ssids=[self.HT20_2_IW_BSS.ssid]) 689 for iw_bss_1, iw_bss_2 in zip([self.HT20_IW_BSS, self.HT20_2_IW_BSS], 690 networks): 691 self.verify_values(iw_bss_1, iw_bss_2) 692 693 694 def test_station_bssid(self): 695 """Test parsing of the bssid of a station-mode link.""" 696 host = self.host(self.STATION_LINK_INFORMATION) 697 runner = iw_runner.IwRunner(remote_host=host) 698 self.assertEquals( 699 runner.get_current_bssid(self.STATION_LINK_IFACE), 700 self.STATION_LINK_BSSID) 701 702 703 def test_station_link_parsing(self): 704 """Test all link keys can be parsed from station link information.""" 705 self.assertEquals( 706 iw_runner._get_all_link_keys(self.STATION_LINK_INFORMATION), 707 self.STATION_LINK_PARSED) 708 709 710 def test_station_link_key(self): 711 """Test a link key is extracted from station link information.""" 712 host = self.host(self.STATION_LINK_INFORMATION) 713 runner = iw_runner.IwRunner(remote_host=host) 714 self.assertEquals( 715 runner.get_link_value(self.STATION_LINK_INFORMATION, 716 iw_runner.IW_LINK_KEY_FREQUENCY), 717 self.STATION_LINK_FREQ) 718 719 720 def test_station_dump(self): 721 """Test parsing of a station dump.""" 722 host = self.host(self.STATION_DUMP_INFORMATION) 723 runner = iw_runner.IwRunner(remote_host=host) 724 self.assertEquals( 725 runner.get_station_dump(self.STATION_DUMP_IFACE), 726 self.STATION_DUMP_INFORMATION_PARSED) 727 728 729 def test_operating_mode_mesh(self): 730 """Test mesh operating mode parsing.""" 731 host = self.host(self.INFO_MESH_MODE) 732 runner = iw_runner.IwRunner(remote_host=host) 733 self.assertEquals( 734 runner.get_operating_mode(self.INFO_IFACE), 735 iw_runner.DEV_MODE_MESH_POINT) 736 737 738 def test_operating_mode_ap(self): 739 """Test AP operating mode parsing.""" 740 host = self.host(self.INFO_AP_MODE) 741 runner = iw_runner.IwRunner(remote_host=host) 742 self.assertEquals( 743 runner.get_operating_mode(self.INFO_IFACE), 744 iw_runner.DEV_MODE_AP) 745 746 747 def test_operating_mode_station(self): 748 """Test STA operating mode parsing.""" 749 host = self.host(self.INFO_STA_MODE) 750 runner = iw_runner.IwRunner(remote_host=host) 751 self.assertEquals( 752 runner.get_operating_mode(self.INFO_IFACE), 753 iw_runner.DEV_MODE_STATION) 754 755 756 def test_radio_information(self): 757 """Test radio information parsing.""" 758 host = self.host(self.INFO_AP_MODE) 759 runner = iw_runner.IwRunner(remote_host=host) 760 self.assertEquals( 761 runner.get_radio_config(self.INFO_IFACE), 762 self.RADIO_CONFIG_AP_MODE) 763 764 765 def test_fragmentation_threshold(self): 766 """Test fragmentation threshold parsing.""" 767 host = self.host(self.PHY_INFO_FRAGMENTATION) 768 runner = iw_runner.IwRunner(remote_host=host) 769 self.assertEquals( 770 runner.get_fragmentation_threshold(self.INFO_PHY), 771 self.PHY_FRAGMENTATION_THRESHOLD) 772 773 774 def test_vht_supported(self): 775 """Test VHT support parsing.""" 776 host = self.host(self.VHT_IW_INFO) 777 runner = iw_runner.IwRunner(remote_host=host) 778 self.assertEquals(runner.vht_supported(), True) 779 780 781 def test_he_supported(self): 782 """Test HE support parsing.""" 783 host = self.host(self.HE_IW_INFO) 784 runner = iw_runner.IwRunner(remote_host=host) 785 self.assertEquals(runner.he_supported(), True) 786 787 788if __name__ == '__main__': 789 unittest.main() 790