| """Tests for report.""" |
| |
| import os |
| |
| import report |
| from wvtest import * # pylint: disable=wildcard-import |
| |
| |
| @wvtest |
| def LoadExternalData(): |
| print |
| report.LoadNRates() |
| WVPASS(report.nrates) |
| |
| idx = (0, 20, 800) |
| print 'Testing MCS rate in file', idx |
| WVPASSEQ(report.nrates[idx], 6.5 ) |
| |
| idx = (25, 40, 400) |
| print 'Testing computed MCS rate', idx |
| WVPASSEQ(report.nrates[idx], 120 ) |
| |
| print |
| report.LoadChannels() |
| WVPASS(report.channels) |
| |
| ch = 5 |
| print 'Testing 2.4GHz channel', ch |
| WVPASSEQ(report.channels[ch], 2432) |
| |
| ch = 149 |
| print 'Testing 5GHz channel', ch |
| WVPASSEQ(report.channels[ch], 5745) |
| |
| |
| @wvtest |
| def TVBoxReport(): |
| rpt = 'testdata/wifi-1424739295.41-0010' |
| print 'Checking IP address' |
| with open(os.path.join(rpt, 'ipaddr')) as ip: |
| addrmap = report.ParseIpAddr(ip.read()) |
| WVPASSEQ(addrmap.get('lo'), '127.0.0.1/32') |
| WVPASSEQ(addrmap.get('wcli0'), '192.168.1.222/24') |
| |
| print 'Checking for link information' |
| with open(os.path.join(rpt, 'iwlink')) as iw: |
| data = report.ParseIwLink(iw.read()) |
| WVPASSEQ(data.get('SSID'), 'GSAFNS1441P0208_TestWifi') |
| WVPASSEQ(data.get('BSSID'), 'f4:f5:e8:80:f3:d0') |
| |
| line = report.ReportLine(rpt) |
| print ('Checking report. Implemented measures: steps, channel, width, rssi, ' |
| 'TCP performance, UDP performance') |
| print line |
| |
| (steps, ch, width, rssi, _, _, _, _, _, |
| tcperf, tcpbw, udperf, udpbw) = line |
| |
| WVPASSEQ(steps, 10) |
| WVPASSEQ(ch, 5745) |
| WVPASSEQ(width, 80) |
| WVPASSEQ(rssi, -39) |
| WVPASSEQ(tcperf, 92.1) |
| WVPASSEQ(tcpbw, 'Mbits/sec') |
| WVPASSEQ(udperf, 91.2) |
| WVPASSEQ(udpbw, 'Mbits/sec') |
| |
| |
| @wvtest |
| def MacbookReport(): |
| rpt = 'testdata/wifi-1424744066.47-0010' |
| line = report.ReportLine(rpt) |
| |
| print ('Checking report. Implemented measures: steps, channel, width, rssi, ' |
| 'noise, devices on channel, off channel, MCS, PHY rate, ' |
| 'TCP performance, UDP performance.') |
| print line |
| |
| (steps, ch, width, rssi, noise, shared, conflict, |
| mcs, phy, tcperf, tcpbw, udperf, udpbw) = line |
| |
| WVPASSEQ(steps, 10) |
| WVPASSEQ(ch, 5755) |
| WVPASSEQ(width, 40) |
| WVPASSEQ(rssi, -29) |
| WVPASSEQ(noise, -90) |
| WVPASSEQ(shared, 17) |
| WVPASSEQ(conflict, 10) |
| WVPASSEQ(mcs, 21) |
| WVPASS(abs(phy - 340.9) < 0.1) |
| WVPASSEQ(tcperf, 196.0) |
| WVPASSEQ(tcpbw, 'Mbits/sec') |
| WVPASSEQ(udperf, 260.0) |
| WVPASSEQ(udpbw, 'Mbits/sec') |
| |
| |
| @wvtest |
| def ReportWithHyphensInPath(): |
| rpt = 'testdata/this-failed-before/wifi-1425669615.33-0010' |
| try: |
| _ = report.ReportLine(rpt) |
| except ValueError: |
| WVFAIL('Failed to read report directory with hyphens in path.') |
| return |
| |
| WVPASS('Report with hypens in path read successfully.') |
| |